From f6cf9dc1b85f576f70b79f477951eae023e674a3 Mon Sep 17 00:00:00 2001 From: hyzboy Date: Tue, 3 Nov 2020 22:29:32 +0800 Subject: [PATCH] update GUI codes.(WIP) --- inc/hgl/gui/Layout.h | 2 +- inc/hgl/gui/ThemeEngine.h | 2 ++ inc/hgl/gui/Widget.h | 5 +++++ src/GUI/DefaultThemeEngine.cpp | 7 +++++++ src/GUI/DefaultThemeEngine.h | 17 ++++++++++++++--- src/GUI/DefaultThemeForm.cpp | 2 +- src/GUI/ThemeEngine.cpp | 15 ++++++++++----- src/RenderDevice/VKRenderableInstance.cpp | 2 +- 8 files changed, 41 insertions(+), 11 deletions(-) diff --git a/inc/hgl/gui/Layout.h b/inc/hgl/gui/Layout.h index db973ceb..bad9a50f 100644 --- a/inc/hgl/gui/Layout.h +++ b/inc/hgl/gui/Layout.h @@ -36,7 +36,7 @@ namespace hgl class VBoxLayout:public LayoutBase { public: - };//class VBoxLayout:public LayoutBase + };//class VBoxLayout:public LayoutBase /** * 水平分布布局器 diff --git a/inc/hgl/gui/ThemeEngine.h b/inc/hgl/gui/ThemeEngine.h index 24b2afab..a609cada 100644 --- a/inc/hgl/gui/ThemeEngine.h +++ b/inc/hgl/gui/ThemeEngine.h @@ -29,6 +29,8 @@ namespace hgl virtual ThemeForm *CreateForm(Form *,RenderTarget *,RenderCommand *)=0; + virtual bool Render(ThemeForm *); + public: ThemeEngine(GPUDevice *dev){device=dev;} diff --git a/inc/hgl/gui/Widget.h b/inc/hgl/gui/Widget.h index bd9a7c38..56110e6e 100644 --- a/inc/hgl/gui/Widget.h +++ b/inc/hgl/gui/Widget.h @@ -37,6 +37,11 @@ namespace hgl RectScope2f position; ///<所在位置 + public: + + Widget * GetParent (){return parent_widget;} + ThemeEngine * GetThemeEngine (){return theme_engine;} + public: const bool IsVisible ()const{return visible;} diff --git a/src/GUI/DefaultThemeEngine.cpp b/src/GUI/DefaultThemeEngine.cpp index 5a23e242..2a0bdc38 100644 --- a/src/GUI/DefaultThemeEngine.cpp +++ b/src/GUI/DefaultThemeEngine.cpp @@ -22,5 +22,12 @@ namespace hgl { return(new DefaultThemeForm(f,rt,rc)); } + + void DefaultThemeEngine::DrawPanel(RenderCommand *rc,const RectScope2f &rs) + { + if(!rc)return; + + + } }//namespace gui }//namespace hgl diff --git a/src/GUI/DefaultThemeEngine.h b/src/GUI/DefaultThemeEngine.h index 2b58c68b..50c29f6b 100644 --- a/src/GUI/DefaultThemeEngine.h +++ b/src/GUI/DefaultThemeEngine.h @@ -2,6 +2,7 @@ #include #include +#include #include #include"DefaultThemeForm.h" @@ -14,10 +15,16 @@ namespace hgl class Form; ///<窗体 /** - * 缺省GUI主题引擎 - */ + * 缺省GUI主题引擎 + */ class DefaultThemeEngine:public ThemeEngine { + struct + { + Material *material; + Pipeline *pieline; + }panel; + public: using ThemeEngine::ThemeEngine; @@ -25,8 +32,12 @@ namespace hgl bool Init() override; void Clear() override; - + ThemeForm *CreateForm(Form *,RenderTarget *,RenderCommand *) override; + + public: + + void DrawPanel(RenderCommand *,const RectScope2f &); };//class DefaultThemeEngine:public ThemeEngine }//namespace gui }//namespace hgl diff --git a/src/GUI/DefaultThemeForm.cpp b/src/GUI/DefaultThemeForm.cpp index c60f522b..adeefb49 100644 --- a/src/GUI/DefaultThemeForm.cpp +++ b/src/GUI/DefaultThemeForm.cpp @@ -11,7 +11,7 @@ namespace hgl if(!cmd_buf->BeginRenderPass()) return(false); - + cmd_buf->EndRenderPass(); return(true); diff --git a/src/GUI/ThemeEngine.cpp b/src/GUI/ThemeEngine.cpp index 55ca3546..6454284c 100644 --- a/src/GUI/ThemeEngine.cpp +++ b/src/GUI/ThemeEngine.cpp @@ -106,6 +106,15 @@ namespace hgl return(true); } + bool ThemeEngine::Render(ThemeForm *tf) + { + tf->BeginRender(); + + tf->Render(); + + tf->EndRender(); + } + bool ThemeEngine::Render(Form *f) { if(!f)return(false); @@ -119,11 +128,7 @@ namespace hgl if(!form_list.Get(f,tf)) return(false); - tf->BeginRender(); - - tf->Render(); - - tf->EndRender(); + return Render(tf); } }//namespace gui }//namespace hgl \ No newline at end of file diff --git a/src/RenderDevice/VKRenderableInstance.cpp b/src/RenderDevice/VKRenderableInstance.cpp index bac2f0f6..ba229d89 100644 --- a/src/RenderDevice/VKRenderableInstance.cpp +++ b/src/RenderDevice/VKRenderableInstance.cpp @@ -68,4 +68,4 @@ RenderableInstance *CreateRenderableInstance(Renderable *r,MaterialInstance *mi, buffer_size.Discard(); return ri; } -VK_NAMESPACE_END \ No newline at end of file +VK_NAMESPACE_END