#205 Window widget: panel + title 4.x-dev

Thu, 26 Nov 2020 07:22:31 +0200

author
cemkalyoncu
date
Thu, 26 Nov 2020 07:22:31 +0200
branch
4.x-dev
changeset 1500
e626149880fd
parent 1499
6c10d104a254
child 1501
5d263312e69a

#205 Window widget: panel + title

Source/Gorgon/Widgets/Generator.cpp file | annotate | diff | comparison | revisions
Source/Gorgon/Widgets/Generator.h file | annotate | diff | comparison | revisions
Source/Gorgon/Widgets/Registry.h file | annotate | diff | comparison | revisions
Source/Gorgon/Widgets/Window.cpp file | annotate | diff | comparison | revisions
Source/Gorgon/Widgets/Window.h file | annotate | diff | comparison | revisions
Source/Gorgon/Widgets/dir.cmake file | annotate | diff | comparison | revisions
Testing/Source/Manual/UI_Generate.cpp file | annotate | diff | comparison | revisions
--- a/Source/Gorgon/Widgets/Generator.cpp	Wed Nov 25 07:27:53 2020 +0200
+++ b/Source/Gorgon/Widgets/Generator.cpp	Thu Nov 26 07:22:31 2020 +0200
@@ -1907,4 +1907,10 @@
         
     }
     
+    
+    UI::Template SimpleGenerator::Window() {
+        auto tmp = makepanel(0, true);
+        tmp.SetSize({300, 200});
+        return tmp;
+    }
 }}
--- a/Source/Gorgon/Widgets/Generator.h	Wed Nov 25 07:27:53 2020 +0200
+++ b/Source/Gorgon/Widgets/Generator.h	Thu Nov 26 07:22:31 2020 +0200
@@ -70,6 +70,8 @@
         
         virtual UI::Template Dropdown() = 0;
         
+        virtual UI::Template Window() = 0;
+        
     protected:
         
         virtual UI::Template &generate(Gorgon::Widgets::Registry::TemplateType type) override {
@@ -116,6 +118,8 @@
                 return *new UI::Template(Listbox());
             case Dropdown_Regular:
                 return *new UI::Template(Dropdown());
+            case Window_Regular:
+                return *new UI::Template(Window());
             default:
                 return *new UI::Template();
             }
@@ -194,6 +198,8 @@
         
         virtual UI::Template Dropdown() override;
         
+        virtual UI::Template Window() override;
+        
 
         virtual int GetSpacing() const override {
             return Spacing;
--- a/Source/Gorgon/Widgets/Registry.h	Wed Nov 25 07:27:53 2020 +0200
+++ b/Source/Gorgon/Widgets/Registry.h	Thu Nov 26 07:22:31 2020 +0200
@@ -36,6 +36,9 @@
             Panel_Bottom,
             Panel_Right,
             
+            
+            Window_Regular,
+            
             Progress_Regular,
             
             Layerbox_Regular,
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Source/Gorgon/Widgets/Window.cpp	Thu Nov 26 07:22:31 2020 +0200
@@ -0,0 +1,21 @@
+#include "Window.h"
+
+
+namespace Gorgon { namespace Widgets {
+   
+    Window::Window(const UI::Template &temp, const std::string &title) : 
+        Panel(temp),
+        Title(this),
+        title(title)
+    {
+        EnableScroll(false, false);
+        stack.SetData(UI::ComponentTemplate::Title, title);
+    }
+    
+    void Window::SetTitle(const std::string &value) {
+        title = value;
+        stack.SetData(UI::ComponentTemplate::Title, title);
+    }
+
+    
+} }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Source/Gorgon/Widgets/Window.h	Thu Nov 26 07:22:31 2020 +0200
@@ -0,0 +1,41 @@
+#pragma once
+
+#include "Panel.h"
+
+namespace Gorgon { namespace Widgets {
+    
+    /**
+     * This class will create in system window that can be placed anywhere
+     * including panels. Once created, window will automatically place itself
+     * into the active OS window. It supports title, if enabled, self movement 
+     * and resizing.
+     */
+    class Window : public Panel {
+    public:
+        
+        Window(const Panel &) = delete;
+        
+        explicit Window(const UI::Template &temp, const std::string &title = "");
+        
+        explicit Window(Registry::TemplateType type) : Window(Registry::Active()[type], "") { }
+
+        explicit Window(const std::string &title = "", Registry::TemplateType type = Registry::Window_Regular) : Window(Registry::Active()[type], title) { }
+        
+        
+        /// Sets the window title to the given string. Title placement is controlled by
+        /// the template and might not be visible.
+        void SetTitle(const std::string &value);
+        
+        /// Returns the window title. Title placement is controlled by the template and 
+        /// might not be visible.
+        std::string GetTitle() const {
+            return title;
+        }
+        
+        TextualProperty<Window, std::string, &Window::GetTitle, &Window::SetTitle> Title;
+
+    private:
+        std::string title;
+    };
+    
+} }
--- a/Source/Gorgon/Widgets/dir.cmake	Wed Nov 25 07:27:53 2020 +0200
+++ b/Source/Gorgon/Widgets/dir.cmake	Thu Nov 26 07:22:31 2020 +0200
@@ -42,4 +42,6 @@
 	Slider.h
 	Scrollbar.h
 	
+	Window.h
+	Window.cpp
 )
--- a/Testing/Source/Manual/UI_Generate.cpp	Wed Nov 25 07:27:53 2020 +0200
+++ b/Testing/Source/Manual/UI_Generate.cpp	Thu Nov 26 07:22:31 2020 +0200
@@ -22,6 +22,7 @@
 #include <Gorgon/Graphics/BlankImage.h>
 #include <Gorgon/Graphics/TintedObject.h>
 #include <Gorgon/Widgets/Dropdown.h>
+#include <Gorgon/Widgets/Window.h>
 
 enum DaysOfWeek {
     Monday,
@@ -101,7 +102,7 @@
     generator.Activate();*/
 
     Widgets::Panel blank/*(Gorgon::Widgets::Registry::Panel_Blank)*/;
-    blank.Move(5, 200);
+    blank.Move(5, 210);
     blank.SetHeight(300);
     Gorgon::Widgets::Button btn("Save Âj",Gorgon::Widgets::Registry::Button_Regular);
     Gorgon::Widgets::Button icnbtn("+", Gorgon::Widgets::Registry::Button_Icon);
@@ -293,6 +294,9 @@
         << scroll1 << scroll2
         << sizef
     ;
+    
+    Widgets::Window wind;
+    app.wind.Add(wind);
 
     /*Widgets::Progressor<std::string, StringDiv, StringVal, Gorgon::TextualProperty> bar2;
     bar2.Maximum = "Hello world";

mercurial