create a lot of GUI source code files.

This commit is contained in:
hyzboy 2020-10-14 22:05:24 +08:00
parent 111f1f8951
commit 2f98b1d08c
12 changed files with 172 additions and 4 deletions

2
CMCore

@ -1 +1 @@
Subproject commit aa7e9a7effd6c830d52cb0ca043348ee6ffa6224
Subproject commit 0c045fb8b1ce2588876c433fbd72e457bd23d2df

@ -1 +1 @@
Subproject commit be71d3b818736b746e8a9ef3b9fa8b9ab15ed5ab
Subproject commit 7bceaf2f9c5fbe1630e3a8b0e78eac5f4846f22e

21
inc/hgl/gui/Panel.h Normal file
View File

@ -0,0 +1,21 @@
#ifndef HGL_GUI_PANEL_INCLUDE
#define HGL_GUI_PANEL_INCLUDE
#include<hgl/gui/Widget.h>
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

28
inc/hgl/gui/ThemeEngine.h Normal file
View File

@ -0,0 +1,28 @@
#ifndef HGL_GUI_THEME_ENGINE_INCLUDE
#define HGL_GUI_THEME_ENGINE_INCLUDE
#include<hgl/type/RectScope.h>
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

View File

@ -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

View File

@ -2,3 +2,4 @@
add_subdirectory(RenderDevice)
add_subdirectory(SceneGraph)
#add_subdirectory(Tools)
add_subdirectory(GUI)

13
src/GUI/CMakeLists.txt Normal file
View File

@ -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})

View File

@ -0,0 +1,12 @@
#include"DefaultThemeEngine.h"
namespace hgl
{
namespace gui
{
ThemeEngine *CreateDefaultThemeEngine()
{
}
}//namespace gui
}//namespace hgl

View File

@ -0,0 +1,23 @@
#pragma once
#include<hgl/gui/ThemeEngine.h>
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

12
src/GUI/Panel.cpp Normal file
View File

@ -0,0 +1,12 @@
#include<hgl/gui/Panel.h>
#include<hgl/gui/GUIRenderEngine.h>
namespace hgl
{
namespace gui
{
void Panel::Draw()
{
}
}//namespace gui
}//namespace hgl

27
src/GUI/ThemeEngine.cpp Normal file
View File

@ -0,0 +1,27 @@
#include<hgl/gui/ThemeEngine.h>
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

24
src/GUI/Widget.cpp Normal file
View File

@ -0,0 +1,24 @@
#include<hgl/gui/Widget.h>
#include<hgl/gui/ThemeEngine.h>
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