MyGUI  3.2.0
MyGUI_PolygonalSkin.h
Go to the documentation of this file.
00001 
00006 /*
00007     This file is part of MyGUI.
00008 
00009     MyGUI is free software: you can redistribute it and/or modify
00010     it under the terms of the GNU Lesser General Public License as published by
00011     the Free Software Foundation, either version 3 of the License, or
00012     (at your option) any later version.
00013 
00014     MyGUI is distributed in the hope that it will be useful,
00015     but WITHOUT ANY WARRANTY; without even the implied warranty of
00016     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017     GNU Lesser General Public License for more details.
00018 
00019     You should have received a copy of the GNU Lesser General Public License
00020     along with MyGUI.  If not, see <http://www.gnu.org/licenses/>.
00021 */
00022 #ifndef __MYGUI_POLYGONAL_SKIN_H__
00023 #define __MYGUI_POLYGONAL_SKIN_H__
00024 
00025 #include "MyGUI_Prerequest.h"
00026 #include "MyGUI_Types.h"
00027 #include "MyGUI_ISubWidgetRect.h"
00028 #include "MyGUI_RenderFormat.h"
00029 
00030 namespace MyGUI
00031 {
00032 
00033     class MYGUI_EXPORT PolygonalSkin :
00034         public ISubWidgetRect
00035     {
00036         MYGUI_RTTI_DERIVED( PolygonalSkin )
00037 
00038     public:
00039         PolygonalSkin();
00040         virtual ~PolygonalSkin();
00041 
00043         void setPoints(const std::vector<FloatPoint>& _points);
00044 
00046         void setWidth(float _width);
00047 
00048         virtual void setAlpha(float _alpha);
00049 
00050         virtual void setVisible(bool _visible);
00051 
00052         virtual void setStateData(IStateInfo* _data);
00053 
00054         virtual void createDrawItem(ITexture* _texture, ILayerNode* _node);
00055         virtual void destroyDrawItem();
00056 
00057         // метод для отрисовки себя
00058         virtual void doRender();
00059 
00060     /*internal:*/
00061         virtual void _updateView();
00062         virtual void _correctView();
00063 
00064         virtual void _setAlign(const IntSize& _oldsize);
00065 
00066         virtual void _setUVSet(const FloatRect& _rect);
00067         virtual void _setColour(const Colour& _value);
00068 
00069     protected:
00070         void _rebuildGeometry();
00071         FloatPoint _getPerpendicular(const FloatPoint& _point1, const FloatPoint& _point2);
00072         // line from center of p1-p2 line to p3
00073         FloatPoint _getMiddleLine(const FloatPoint& _point1, const FloatPoint& _point2, const FloatPoint& _point3);
00074 
00075     private:
00076         bool mGeometryOutdated;
00077 
00078         float mLineWidth;
00079         std::vector<FloatPoint> mLinePoints;
00080         float mLineLength;
00081 
00082         std::vector<FloatPoint> mResultVerticiesPos;
00083         std::vector<FloatPoint> mResultVerticiesUV;
00084 
00085         size_t mVertexCount;
00086 
00087         bool mEmptyView;
00088 
00089         VertexColourType mVertexFormat;
00090         uint32 mCurrentColour;
00091 
00092         FloatRect mCurrentTexture;
00093         IntCoord mCurrentCoord;
00094 
00095         ILayerNode* mNode;
00096         RenderItem* mRenderItem;
00097     };
00098 
00099 } // namespace MyGUI
00100 
00101 #endif // __MYGUI_POLYGONAL_SKIN_H__