diff --git a/extra/testTheme.txt b/extra/testTheme.txt index 9b0c7be..07512c8 100644 --- a/extra/testTheme.txt +++ b/extra/testTheme.txt @@ -21,11 +21,15 @@ window.backgroundColor = Color(rgba(120, 120, 120, 255)) (panel) { backgroundColor = Color(#AAAAAAFF) - borderColor = Color(#00FF00FF) + borderColor = Color(#000000FF) borderRadius = 8 borderWidth = 4 showBorder = true padding = Rect(15, 15, 15, 15) + showTitle = true + titleColor = Color(#000000FF) + titlebarType = "full" + titleHeight = 30 } (@testLabel label) { diff --git a/other/TODO.txt b/other/TODO.txt index 3bf1c68..9832f32 100644 --- a/other/TODO.txt +++ b/other/TODO.txt @@ -4,10 +4,13 @@ ***implement file theme loading ***Implemenmt MouseDragged callback ***Add scissoring to only draw inside the bounds of containers +***Implement Drag And Drop +***Implement a way to determine on what widget (in the hierarchy chain) and event must stop Add theme caching Implement mouse scroll callback -Implement a way to determine on what widget (in the hierarchy chain) and event must stop Implement margin for widgets +Implement const in stylesheet +Implement color constants in stylesheet Implement following widgets: diff --git a/src/ogfx/gui/widgets/Containers.cpp b/src/ogfx/gui/widgets/Containers.cpp index 5f729c9..f1aa202 100644 --- a/src/ogfx/gui/widgets/Containers.cpp +++ b/src/ogfx/gui/widgets/Containers.cpp @@ -45,6 +45,10 @@ namespace ogfx m_borderWidth = getThemeValue(theme, "panel.borderWidth", 2); m_showBorder = getThemeValue(theme, "panel.showBorder", true); m_borderColor = getThemeValue(theme, "panel.borderColor", ostd::Colors::Black); + m_titleColor = getThemeValue(theme, "panel.titleColor", ostd::Colors::Black); + m_showTitle = getThemeValue(theme, "panel.showTitle", false); + m_titleHeight = getThemeValue(theme, "panel.titleHeight", 30); + m_titleType = getThemeValue(theme, "panel.titleHeight", "text"); setPadding(getThemeValue(theme, "panel.padding", { 15, 15, 15, 15 })); } @@ -54,7 +58,6 @@ namespace ogfx gfx.outlinedRoundRect({ getGlobalPosition(), getSize() }, getBackgroundColor(), m_borderColor, m_borderRadius, m_borderWidth); else gfx.fillRoundRect({ getGlobalPosition(), getSize() }, getBackgroundColor(), m_borderRadius); - gfx.drawRect(getGlobalContentBounds(), ostd::Colors::Aquamarine, 6); } } } diff --git a/src/ogfx/gui/widgets/Containers.hpp b/src/ogfx/gui/widgets/Containers.hpp index de68bbe..3835710 100644 --- a/src/ogfx/gui/widgets/Containers.hpp +++ b/src/ogfx/gui/widgets/Containers.hpp @@ -40,7 +40,10 @@ namespace ogfx private: ostd::Color m_backgroundColor { 150, 150, 150 }; - + ostd::Color m_titleColor { 0, 0, 0 }; + bool m_showTitle { false }; + ostd::String m_titleType = "full"; + float m_titleHeight { 30 }; }; } } diff --git a/src/ogfx/gui/widgets/Widget.hpp b/src/ogfx/gui/widgets/Widget.hpp index e79d80f..32ffaaf 100644 --- a/src/ogfx/gui/widgets/Widget.hpp +++ b/src/ogfx/gui/widgets/Widget.hpp @@ -43,11 +43,11 @@ namespace ogfx public: Widget(const ostd::Rectangle& bounds, WindowCore& window); bool addChild(Widget& child); - ostd::Vec2 getGlobalPosition(void) const; - ostd::Vec2 getGlobalContentPosition(void) const; - ostd::Rectangle getGlobalBounds(void) const; - ostd::Rectangle getContentBounds(void) const; - ostd::Rectangle getGlobalContentBounds(void) const; + virtual ostd::Vec2 getGlobalPosition(void) const; + virtual ostd::Vec2 getGlobalContentPosition(void) const; + virtual ostd::Rectangle getGlobalBounds(void) const; + virtual ostd::Rectangle getContentBounds(void) const; + virtual ostd::Rectangle getGlobalContentBounds(void) const; using ostd::Rectangle::contains; bool contains(ostd::Vec2 p, bool includeBounds = false) const override; void enable(bool enable = true); diff --git a/src/test/GuiTest.cpp b/src/test/GuiTest.cpp index b14f683..5ad4fcd 100644 --- a/src/test/GuiTest.cpp +++ b/src/test/GuiTest.cpp @@ -36,14 +36,16 @@ class Window : public ogfx::gui::Window pos = { event.mouse->position_x, event.mouse->position_y }; }); m_panel1.setMouseDraggedCallback([&](const ogfx::gui::Event& event) -> void { + if (m_panel1.getPressedMouseButton() == ogfx::MouseEventData::eButton::None) + return; ostd::Vec2 pos2 { event.mouse->position_x, event.mouse->position_y }; m_panel1.addPos(pos2 - pos); pos = pos2; }); - m_panel2.setSize(300, 140); - m_panel2.setPosition(130, 200); + m_panel2.setSize(600, 400); + m_panel2.setPosition(170, 200); m_panel2.setMousePressedCallback([&](const ogfx::gui::Event& event) -> void { ogfx::gui::Widget::setDragAndDropData(m_label3); setCursor(eCursor::Move); @@ -58,7 +60,7 @@ class Window : public ogfx::gui::Window std::cout << "PRESS!\n"; }); addWidget(m_label1); - addWidget(m_panel1); + m_panel2.addChild(m_panel1); addWidget(m_panel2); m_label2.setPosition(0, 0); @@ -66,7 +68,7 @@ class Window : public ogfx::gui::Window m_label2.connectSignal(ostd::BuiltinSignals::FileDragAndDropped); m_label2.addThemeID("testLabel"); m_label2.addThemeID("testLabel2"); - m_label2.setSignalCallback([&](ostd::Signal& signal){ + m_label2.setSignalCallback([&](ostd::Signal& signal) -> void { if (signal.ID == ostd::BuiltinSignals::FileDragAndDropped) { auto& data = (ogfx::DropEventData&)signal.userData; @@ -95,6 +97,8 @@ class Window : public ogfx::gui::Window m_panel1.addChild(m_label3); setTheme(m_theme); + + std::cout << m_theme.get("panel.titlebarType", "", {}, {}) << " \n"; } inline void onSignal(ostd::Signal& signal) override