1 /*
2  * This source file is part of MyGUI. For the latest info, see http://mygui.info/
3  * Distributed under the MIT License
4  * (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT)
5  */
6 
7 #ifndef MYGUI_ROTATING_SKIN_H_
8 #define MYGUI_ROTATING_SKIN_H_
9 
10 #include "MyGUI_Prerequest.h"
11 #include "MyGUI_Types.h"
12 #include "MyGUI_ISubWidgetRect.h"
13 #include "MyGUI_RenderFormat.h"
14 
15 namespace MyGUI
16 {
17 
18 	class MYGUI_EXPORT RotatingSkin :
19 		public ISubWidgetRect
20 	{
21 		MYGUI_RTTI_DERIVED( RotatingSkin )
22 
23 	public:
24 		RotatingSkin();
25 
26 		/** Set angle of rotation in radians */
27 		void setAngle(float _angle);
28 		/** Get angle of rotation in radians */
29 		float getAngle() const;
30 
31 		/** Set center of rotation
32 			@param _center Center point.
33 		*/
34 		void setCenter(const IntPoint& _center);
35 		/** Get center of rotation */
36 		IntPoint getCenter(bool _local = true) const;
37 
38 		void setAlpha(float _alpha) override;
39 
40 		void setVisible(bool _visible) override;
41 
42 		void setStateData(IStateInfo* _data) override;
43 
44 		void createDrawItem(ITexture* _texture, ILayerNode* _node) override;
45 		void destroyDrawItem() override;
46 
47 		// метод для отрисовки себя
48 		void doRender() override;
49 
50 		/*internal:*/
51 		void _updateView() override;
52 		void _correctView() override;
53 
54 		void _setAlign(const IntSize& _oldsize) override;
55 
56 		void _setUVSet(const FloatRect& _rect) override;
57 		void _setColour(const Colour& _value) override;
58 
59 	protected:
60 		void _rebuildGeometry();
61 
62 	private:
63 		bool mGeometryOutdated;
64 
65 		float mAngle;
66 		IntPoint mCenterPos;
67 
68 		enum {RECT_VERTICIES_COUNT = 4, GEOMETRY_VERTICIES_TOTAL_COUNT = 8};
69 		FloatPoint mResultVerticiesPos[GEOMETRY_VERTICIES_TOTAL_COUNT];
70 		FloatPoint mResultVerticiesUV[GEOMETRY_VERTICIES_TOTAL_COUNT];
71 
72 		bool mEmptyView;
73 
74 		VertexColourType mVertexFormat;
75 		uint32 mCurrentColour;
76 
77 		FloatRect mCurrentTexture;
78 		IntCoord mCurrentCoord;
79 
80 		ILayerNode* mNode;
81 		RenderItem* mRenderItem;
82 	};
83 
84 } // namespace MyGUI
85 
86 #endif // MYGUI_ROTATING_SKIN_H_
87