File: TextureControl.h

package info (click to toggle)
mygui 3.2.2%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 36,224 kB
  • sloc: cpp: 118,031; ansic: 30,202; xml: 15,544; cs: 12,602; tcl: 776; python: 417; makefile: 34
file content (113 lines) | stat: -rw-r--r-- 2,809 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
/*!
	@file
	@author		Albert Semenov
	@date		08/2010
*/

#ifndef _989b726c_13e5_4bc9_853d_4630f7b925dc_
#define _989b726c_13e5_4bc9_853d_4630f7b925dc_

#include "Control.h"
#include "SelectorControl.h"
#include "Dialog.h"

namespace tools
{

	class MYGUI_EXPORT_DLL TextureControl :
		public Control
	{
	public:
		TextureControl();
		virtual ~TextureControl();

		void setTextureValue(const MyGUI::UString& _value);

		void setTextureRegion(const MyGUI::IntCoord& _value);
		void resetTextureRegion();
		const MyGUI::IntCoord& getTextureRegion() const;

	protected:
		virtual void OnInitialise(Control* _parent, MyGUI::Widget* _place, const std::string& _layoutName);

		const MyGUI::IntSize& getTextureSize() const;

		template<typename T>
		void addSelectorControl(T * & _control)
		{
			_control = new T();
			_control->Initialise(this, mTexture, "");
			registerSelectorControl(_control);
		}

		void addSelectorControl(SelectorControl* _control)
		{
			_control->Initialise(this, mTexture, "");
			registerSelectorControl(_control);
		}

		void removeSelectorControl(SelectorControl* _control);

		void setColour(MyGUI::Colour _value);
		MyGUI::Colour getColour() const;

		void setScale(double _value);
		double getScale() const;

		virtual void onChangeScale();

		virtual void onMouseMove();
		virtual void onMouseWheel(int _rel);
		virtual void onMouseButtonPressed(const MyGUI::IntPoint& _point);
		virtual void onMouseButtonReleased(const MyGUI::IntPoint& _point);
		virtual void onMouseButtonClick(const MyGUI::IntPoint& _point);
		virtual void onMouseDrag(const MyGUI::IntPoint& _point);

		bool getSelectorsCapture();

		void saveMouseRelative();
		void loadMouseRelative();

	private:
		void notifyChangePosition();
		void notifyMouseButtonPressed(MyGUI::Widget* _sender, int _left, int _top, MyGUI::MouseButton _id);
		void notifyMouseButtonReleased(MyGUI::Widget* _sender, int _left, int _top, MyGUI::MouseButton _id);
		void notifyMouseDrag(MyGUI::Widget* _sender, int _left, int _top, MyGUI::MouseButton _id);
		void notifyMouseMove(MyGUI::Widget* _sender, int _left, int _top);
		void notifyMouseWheel(MyGUI::Widget* _sender, int _rel);

		void updateTexture();
		void updateCoord();

		void updateScale();

		void updateRegionCoord();
		void updateColours();

		void registerSelectorControl(SelectorControl* _control);

		MyGUI::IntPoint getMousePosition();

	private:
		MyGUI::ScrollView* mView;
		MyGUI::ImageBox* mTexture;
		MyGUI::Widget* mBackground;

		double mScaleValue;
		MyGUI::IntSize mTextureSize;
		MyGUI::IntCoord mTextureRegion;
		MyGUI::Colour mCurrentColour;

		std::vector<SelectorControl*> mSelectors;

		MyGUI::IntPoint mRightMouseClick;
		MyGUI::IntPoint mViewOffset;
		bool mMouseCapture;

		MyGUI::FloatPoint mMouseRelative;
		bool mMouseLeftPressed;
	};

}

#endif