ULRE/inc/hgl/gui/Widget.h

72 lines
2.3 KiB
C
Raw Normal View History

2020-10-14 21:05:30 +08:00
#ifndef HGL_GUI_WIDGET_INCLUDE
#define HGL_GUI_WIDGET_INCLUDE
#include<hgl/type/RectScope.h>
#include<hgl/math/Vector.h>
namespace hgl
{
namespace gui
{
2020-10-14 22:05:24 +08:00
class ThemeEngine;
2020-10-14 21:05:30 +08:00
enum Alignment
{
None =0x00,
Left =0x01,
Top =0x02,
Right =0x04,
Bottom =0x08,
Center =0x10,
HCenter =0x20,
VCenter =0x40
};//enum Alignment
/**
* GUI组件的基类
*/
class Widget
{
private:
Widget *parent_widget;
2020-10-14 22:05:24 +08:00
ThemeEngine *theme_engine;
2020-10-14 21:05:30 +08:00
bool visible; ///<控件是否可看见
bool recv_event; ///<控件是否接收事件
uint8 align_bits; ///<对齐位属性(注:不可见依然影响排版)
RectScope2f position; ///<所在位置
2020-11-03 22:29:32 +08:00
public:
Widget * GetParent (){return parent_widget;}
ThemeEngine * GetThemeEngine (){return theme_engine;}
2020-10-14 21:05:30 +08:00
public:
const bool IsVisible ()const{return visible;}
const bool IsRecvEvent ()const{return recv_event;}
const uint8 GetAlign ()const{return align_bits;}
const RectScope2f & GetPosition ()const{return position;}
const Vector2f GetOffset ()const{return position.GetLeftTop();}
const Vector2f GetSize ()const{return position.GetSize();}
void SetVisible (const bool);
void SetRecvEvent(const bool);
void SetAlign (const uint8);
2020-10-14 22:05:24 +08:00
void SetPosition (const RectScope2i &);
2020-10-14 21:05:30 +08:00
void SetSize (const Vector2f &);
2020-10-26 21:51:51 +08:00
public: //事件
virtual void OnResize(uint,uint);
2020-10-14 21:05:30 +08:00
public:
Widget(Widget *parent=nullptr,ThemeEngine *te=nullptr);
virtual ~Widget()=default;
2020-10-14 21:05:30 +08:00
};//class Widget
}//namespace gui
}//namespace hgl
#endif//HGL_GUI_WIDGET_INCLUDE