diff --git a/CMCore b/CMCore index aa7e9a7e..0c045fb8 160000 --- a/CMCore +++ b/CMCore @@ -1 +1 @@ -Subproject commit aa7e9a7effd6c830d52cb0ca043348ee6ffa6224 +Subproject commit 0c045fb8b1ce2588876c433fbd72e457bd23d2df diff --git a/CMPlatform b/CMPlatform index be71d3b8..7bceaf2f 160000 --- a/CMPlatform +++ b/CMPlatform @@ -1 +1 @@ -Subproject commit be71d3b818736b746e8a9ef3b9fa8b9ab15ed5ab +Subproject commit 7bceaf2f9c5fbe1630e3a8b0e78eac5f4846f22e diff --git a/inc/hgl/gui/Panel.h b/inc/hgl/gui/Panel.h new file mode 100644 index 00000000..db279d06 --- /dev/null +++ b/inc/hgl/gui/Panel.h @@ -0,0 +1,21 @@ +#ifndef HGL_GUI_PANEL_INCLUDE +#define HGL_GUI_PANEL_INCLUDE + +#include +namespace hgl +{ + namespace gui + { + class Panel:public Widget + { + public: + + Panel(Widget *p):Widget(p){} + + virtual ~Panel()=default; + + void Draw() override; + };//class Panel:public Widget + }//namespace gui +}//namespace hgl +#endif//HGL_GUI_PANEL_INCLUDE diff --git a/inc/hgl/gui/ThemeEngine.h b/inc/hgl/gui/ThemeEngine.h new file mode 100644 index 00000000..0b8f460a --- /dev/null +++ b/inc/hgl/gui/ThemeEngine.h @@ -0,0 +1,28 @@ +#ifndef HGL_GUI_THEME_ENGINE_INCLUDE +#define HGL_GUI_THEME_ENGINE_INCLUDE + +#include +namespace hgl +{ + namespace gui + { + class Widget; + + class ThemeEngine + { + public: + + virtual bool Init()=0; + virtual void Clear()=0; + + virtual void DrawFrame(const Widget *)=0; + //virtual void DrawButton(const Widget *)=0; + //virtual void DrawCheckBox(const Widget *)=0; + //virtual void DrawRadioBox(const Widget *)=0; + };//class ThemeEngine + +// ThemeEngine *CreateThemeEngine(); + ThemeEngine *GetDefaultThemeEngine(); ///<获取缺省主题引擎 + }//namespace gui +}//namespace hgl +#endif//HGL_GUI_THEME_ENGINE_INCLUDE \ No newline at end of file diff --git a/inc/hgl/gui/Widget.h b/inc/hgl/gui/Widget.h index a2b49420..e434aff3 100644 --- a/inc/hgl/gui/Widget.h +++ b/inc/hgl/gui/Widget.h @@ -7,6 +7,8 @@ namespace hgl { namespace gui { + class ThemeEngine; + enum Alignment { None =0x00, @@ -27,6 +29,7 @@ namespace hgl private: Widget *parent_widget; + ThemeEngine *theme_engine; bool visible; ///<控件是否可看见 bool recv_event; ///<控件是否接收事件 @@ -46,14 +49,16 @@ namespace hgl void SetVisible (const bool); void SetRecvEvent(const bool); void SetAlign (const uint8); - void SetPosition (const Rectscope2i &); + void SetPosition (const RectScope2i &); void SetSize (const Vector2f &); public: - Widget(Widget *parent=nullptr) + Widget(Widget *parent=nullptr,ThemeEngine *te=nullptr) { parent_widget=parent; + theme_engine=te; + //默认值 visible=false; //不显示 recv_event=false; //不接收事件 @@ -61,6 +66,8 @@ namespace hgl position.Clear(); } virtual ~Widget(); + + virtual void Draw(){} };//class Widget }//namespace gui }//namespace hgl diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 92567e2a..f46c123a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -2,3 +2,4 @@ add_subdirectory(RenderDevice) add_subdirectory(SceneGraph) #add_subdirectory(Tools) +add_subdirectory(GUI) \ No newline at end of file diff --git a/src/GUI/CMakeLists.txt b/src/GUI/CMakeLists.txt new file mode 100644 index 00000000..a0c4f707 --- /dev/null +++ b/src/GUI/CMakeLists.txt @@ -0,0 +1,13 @@ +file(GLOB GUI_HEADER ${ROOT_INCLUDE_PATH}/hgl/gui/*.*) + +set(GUI_SOURCE Widget.cpp + Panel.cpp + ThemeEngine.cpp + DefaultThemeEngine.h + DefaultThemeEngine.cpp) + +SOURCE_GROUP("Header Files" FILES ${GUI_HEADER}) +SOURCE_GROUP("Source Files" FILES ${GUI_SOURCE}) + +add_cm_library(ULRE.GUI "ULRE" ${GUI_HEADER} + ${GUI_SOURCE}) diff --git a/src/GUI/DefaultThemeEngine.cpp b/src/GUI/DefaultThemeEngine.cpp new file mode 100644 index 00000000..055343be --- /dev/null +++ b/src/GUI/DefaultThemeEngine.cpp @@ -0,0 +1,12 @@ +#include"DefaultThemeEngine.h" + +namespace hgl +{ + namespace gui + { + ThemeEngine *CreateDefaultThemeEngine() + { + + } + }//namespace gui +}//namespace hgl \ No newline at end of file diff --git a/src/GUI/DefaultThemeEngine.h b/src/GUI/DefaultThemeEngine.h new file mode 100644 index 00000000..34df7c0a --- /dev/null +++ b/src/GUI/DefaultThemeEngine.h @@ -0,0 +1,23 @@ +#pragma once + +#include + +namespace hgl +{ + namespace gui + { + /** + * 缺省GUI主题引擎 + */ + class DefaultThemeEngine:public ThemeEngine + { + public: + + bool Init() override; + void Clear() override; + + void DrawFrame(const RectScope2f &) override; + + };//class DefaultThemeEngine:public ThemeEngine + }//namespace gui +}//namespace hgl \ No newline at end of file diff --git a/src/GUI/Panel.cpp b/src/GUI/Panel.cpp new file mode 100644 index 00000000..cb8aa675 --- /dev/null +++ b/src/GUI/Panel.cpp @@ -0,0 +1,12 @@ +#include +#include + +namespace hgl +{ + namespace gui + { + void Panel::Draw() + { + } + }//namespace gui +}//namespace hgl \ No newline at end of file diff --git a/src/GUI/ThemeEngine.cpp b/src/GUI/ThemeEngine.cpp new file mode 100644 index 00000000..d1eac4c3 --- /dev/null +++ b/src/GUI/ThemeEngine.cpp @@ -0,0 +1,27 @@ +#include + +namespace hgl +{ + namespace gui + { + namespace + { + ThemeEngine *default_theme_engine=nullptr; + }//namespace + + ThemeEngine *CreateDefaultThemeEngine(); + + ThemeEngine *GetDefaultThemeEngine() + { + if(!default_theme_engine) + default_theme_engine=CreateDefaultThemeEngine(); + + return default_theme_engine; + } + + ThemeEngine *CreateThemeEngine() + { + return GetDefaultThemeEngine(); + } + }//namespace gui +}//namespace hgl \ No newline at end of file diff --git a/src/GUI/Widget.cpp b/src/GUI/Widget.cpp new file mode 100644 index 00000000..5bce9ec0 --- /dev/null +++ b/src/GUI/Widget.cpp @@ -0,0 +1,24 @@ +#include +#include + +namespace hgl +{ + namespace gui + { + Widget::Widget(Widget *parent=nullptr,ThemeEngine *te=nullptr) + { + parent_widget=parent; + + if(te) + theme_engine=te; + else + theme_engine=GetDefaultThemeEngine(); + + //默认值 + visible=false; //不显示 + recv_event=false; //不接收事件 + align_bits=0; //不对齐 + position.Clear(); + } + }//namespace gui +}//namespace hgl \ No newline at end of file