From c6ba7a44739403fafb1ff1f3b1456684ae023cf8 Mon Sep 17 00:00:00 2001 From: Antoine Chavasse Date: Sun, 8 Jul 2007 03:22:27 +0200 Subject: [PATCH] gui: moar refactoring work. --- gui/Container_i.h | 2 +- gui/HGroup_i.h | 2 +- gui/VGroup_i.h | 2 +- gui/Widget_i.h | 2 +- gui/game/CMakeLists.txt | 8 +++---- gui/game/Container.h | 28 ++++++++++++++++++++++++ gui/game/ContainerWidget.h | 27 ----------------------- gui/game/EventHandler.h | 2 +- gui/game/HGroup.cpp | 4 ++-- gui/game/HGroup.h | 13 ++++++----- gui/game/SimpleContainer.cpp | 8 +++---- gui/game/SimpleContainer.h | 14 ++++++------ gui/game/Theme.h | 52 ++++++++++++++++++++++---------------------- gui/game/VGroup.cpp | 4 ++-- gui/game/VGroup.h | 13 ++++++----- gui/game/Widget.cpp | 6 ++--- gui/game/Widget.h | 19 ++++++++-------- gui/game/events.aih | 2 ++ gui/game/game.aidl | 13 ++++++----- gui/game/layout.aih | 8 +++---- gui/game/theming.aih | 8 +++---- gui/gui.aidl | 2 +- 22 files changed, 123 insertions(+), 116 deletions(-) create mode 100644 gui/game/Container.h delete mode 100644 gui/game/ContainerWidget.h rewrite gui/game/Theme.h (60%) diff --git a/gui/Container_i.h b/gui/Container_i.h index 34b0d05..ed28f8e 100644 --- a/gui/Container_i.h +++ b/gui/Container_i.h @@ -6,7 +6,7 @@ namespace awful { namespace gui { - class Container_i : public Widget_i + class Container_i : virtual public Widget_i { public: }; diff --git a/gui/HGroup_i.h b/gui/HGroup_i.h index 5e726ee..8688e24 100644 --- a/gui/HGroup_i.h +++ b/gui/HGroup_i.h @@ -6,7 +6,7 @@ namespace awful { namespace gui { - class HGroup_i : public Container_i + class HGroup_i : virtual public Container_i { public: }; diff --git a/gui/VGroup_i.h b/gui/VGroup_i.h index d17fafc..05d4a67 100644 --- a/gui/VGroup_i.h +++ b/gui/VGroup_i.h @@ -6,7 +6,7 @@ namespace awful { namespace gui { - class VGroup_i : public Container_i + class VGroup_i : virtual public Container_i { public: }; diff --git a/gui/Widget_i.h b/gui/Widget_i.h index c067859..91498de 100644 --- a/gui/Widget_i.h +++ b/gui/Widget_i.h @@ -5,7 +5,7 @@ namespace awful { namespace gui { - class Widget_i : public RefCounted + class Widget_i : virtual public RefCounted { public: }; diff --git a/gui/game/CMakeLists.txt b/gui/game/CMakeLists.txt index 1adf018..dcca4f2 100644 --- a/gui/game/CMakeLists.txt +++ b/gui/game/CMakeLists.txt @@ -12,13 +12,13 @@ AIC( game.aidl awful::gui::game ) # events.aih layout.aih theming.aih ) add_library( awguigame Factory.cpp EventManager.cpp -# Widget.cpp -# SimpleContainer.cpp + Widget.cpp + SimpleContainer.cpp # Window.cpp # Button.cpp # Draggable.cpp -# HGroup.cpp -# VGroup.cpp + HGroup.cpp + VGroup.cpp # BoringTheme.cpp # BoringTheme/ButtonDecorator.cpp # BoringTheme/WindowDecorator.cpp diff --git a/gui/game/Container.h b/gui/game/Container.h new file mode 100644 index 0000000..e239105 --- /dev/null +++ b/gui/game/Container.h @@ -0,0 +1,28 @@ +#ifndef AWFUL_GUI_GAME_CONTAINER_H_ +#define AWFUL_GUI_GAME_CONTAINER_H_ + +#include "core/core.h" +#include "Widget.h" +#include "gui/Container_i.h" +#include + +namespace awful { namespace gui { namespace game +{ + class Container : virtual public Container_i, public Widget + { + public: + Container( Pointer< Theme > pTheme_ ) : + Widget( pTheme_ ) + { + } + + Container( Pointer< Container > pParent_ ) : + Widget( pParent_ ) + { + } + + virtual void addChild( Pointer< Widget > pChild_ ) = 0; + }; +}}} + +#endif diff --git a/gui/game/ContainerWidget.h b/gui/game/ContainerWidget.h deleted file mode 100644 index 94651fc..0000000 --- a/gui/game/ContainerWidget.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef AWFUL_GUI_CONTAINERWIDGET_H_ -#define AWFUL_GUI_CONTAINERWIDGET_H_ - -#include "Widget.h" -#include "core/core.h" -#include - -namespace awful { namespace gui -{ - class ContainerWidget : public Widget - { - public: - ContainerWidget( Pointer< Theme > pTheme_ ) : - Widget( pTheme_ ) - { - } - - ContainerWidget( Pointer< ContainerWidget > pParent_ ) : - Widget( pParent_ ) - { - } - - virtual void addChild( Pointer< Widget > pChild_ ) = 0; - }; -}} - -#endif diff --git a/gui/game/EventHandler.h b/gui/game/EventHandler.h index 02a9a23..3ba30b1 100644 --- a/gui/game/EventHandler.h +++ b/gui/game/EventHandler.h @@ -6,7 +6,7 @@ namespace awful { namespace gui { namespace game { - class EventHandler : public RefCounted + class EventHandler : virtual public RefCounted { public: EventHandler() : m_bWantMouseMotion( false ) {} diff --git a/gui/game/HGroup.cpp b/gui/game/HGroup.cpp index 0ee4346..7cc6956 100644 --- a/gui/game/HGroup.cpp +++ b/gui/game/HGroup.cpp @@ -3,9 +3,9 @@ #include using namespace awful; -using namespace awful::gui; +using namespace awful::gui::game; -HGroup::HGroup( ContainerWidget* pParent_ ) : +HGroup::HGroup( Container* pParent_ ) : SimpleContainer( pParent_ ), m_Spacing( 2.f ) { diff --git a/gui/game/HGroup.h b/gui/game/HGroup.h index 3e6238b..583bf61 100644 --- a/gui/game/HGroup.h +++ b/gui/game/HGroup.h @@ -1,15 +1,16 @@ -#ifndef AWFUL_GUI_HGROUP_H_ -#define AWFUL_GUI_HGROUP_H_ +#ifndef AWFUL_GUI_GAME_HGROUP_H_ +#define AWFUL_GUI_GAME_HGROUP_H_ #include "SimpleContainer.h" +#include "gui/HGroup_i.h" #include "core/core.h" -namespace awful { namespace gui +namespace awful { namespace gui { namespace game { - class HGroup : public SimpleContainer + class HGroup : public HGroup_i, public SimpleContainer { public: - HGroup( ContainerWidget* pParent_ ); + HGroup( Container* pParent_ ); virtual void calcMinMax(); virtual void layout(); @@ -20,6 +21,6 @@ namespace awful { namespace gui private: float m_Spacing; }; -}} +}}} #endif diff --git a/gui/game/SimpleContainer.cpp b/gui/game/SimpleContainer.cpp index 52d958e..101adf4 100644 --- a/gui/game/SimpleContainer.cpp +++ b/gui/game/SimpleContainer.cpp @@ -3,16 +3,16 @@ #include "scenegraph/Group.h" using namespace awful; -using namespace awful::gui; +using namespace awful::gui::game; SimpleContainer::SimpleContainer( Pointer< Theme > pTheme_ ) : - ContainerWidget( pTheme_ ) + Container( pTheme_ ) { setWantMouseMotion( true ); } -SimpleContainer::SimpleContainer( ContainerWidget* pParent_ ) : - ContainerWidget( pParent_ ) +SimpleContainer::SimpleContainer( Container* pParent_ ) : + Container( pParent_ ) { setWantMouseMotion( true ); } diff --git a/gui/game/SimpleContainer.h b/gui/game/SimpleContainer.h index 71b5d4f..01f4b1b 100644 --- a/gui/game/SimpleContainer.h +++ b/gui/game/SimpleContainer.h @@ -1,17 +1,17 @@ -#ifndef AWFUL_GUI_SIMPLECONTAINER_H_ -#define AWFUL_GUI_SIMPLECONTAINER_H_ +#ifndef AWFUL_GUI_GAME_SIMPLECONTAINER_H_ +#define AWFUL_GUI_GAME_SIMPLECONTAINER_H_ -#include "ContainerWidget.h" +#include "Container.h" #include "core/core.h" #include -namespace awful { namespace gui +namespace awful { namespace gui { namespace game { - class SimpleContainer : public ContainerWidget + class SimpleContainer : public Container { public: SimpleContainer( Pointer< Theme > pTheme_ ); - SimpleContainer( ContainerWidget* pParent_ ); + SimpleContainer( Container* pParent_ ); virtual void buildSceneGraph(); virtual void mouseEnter( const math::Vector2f& pos ); @@ -34,6 +34,6 @@ namespace awful { namespace gui private: Pointer< Widget > m_pMouseFocusWidget; }; -}} +}}} #endif diff --git a/gui/game/Theme.h b/gui/game/Theme.h dissimilarity index 60% index 72e0679..4f50fe3 100644 --- a/gui/game/Theme.h +++ b/gui/game/Theme.h @@ -1,26 +1,26 @@ -#ifndef AWFUL_GUI_THEME_H_ -#define AWFUL_GUI_THEME_H_ - -#include "ButtonDecorator.h" -#include "WindowDecorator.h" -#include "core/core.h" -#include - -namespace awful { namespace gui -{ - class Button; - class ButtonDecorator; - - class Window; - class WindowDecorator; - - class Theme : public RefCounted - { - public: - virtual ~Theme() {} - virtual Pointer< ButtonDecorator > newButtonDecorator( Button* pButton_ ) = 0; - virtual Pointer< WindowDecorator > newWindowDecorator( Window* pWindow_ ) = 0; - }; -}} - -#endif +#ifndef AWFUL_GUI_GAME_THEME_H_ +#define AWFUL_GUI_GAME_THEME_H_ + +//#include "ButtonDecorator.h" +//#include "WindowDecorator.h" +#include "core/core.h" +#include + +namespace awful { namespace gui { namespace game +{ + class Button; + class ButtonDecorator; + + class Window; + class WindowDecorator; + + class Theme : public RefCounted + { + public: + virtual ~Theme() {} + // virtual Pointer< ButtonDecorator > newButtonDecorator( Button* pButton_ ) = 0; + // virtual Pointer< WindowDecorator > newWindowDecorator( Window* pWindow_ ) = 0; + }; +}}} + +#endif diff --git a/gui/game/VGroup.cpp b/gui/game/VGroup.cpp index 95fa5e1..819426b 100644 --- a/gui/game/VGroup.cpp +++ b/gui/game/VGroup.cpp @@ -3,9 +3,9 @@ #include using namespace awful; -using namespace awful::gui; +using namespace awful::gui::game; -VGroup::VGroup( ContainerWidget* pParent_ ) : +VGroup::VGroup( Container* pParent_ ) : SimpleContainer( pParent_ ), m_Spacing( 2.f ) { diff --git a/gui/game/VGroup.h b/gui/game/VGroup.h index 43e6580..1aebbcc 100644 --- a/gui/game/VGroup.h +++ b/gui/game/VGroup.h @@ -1,15 +1,16 @@ -#ifndef AWFUL_GUI_VGROUP_H_ -#define AWFUL_GUI_VGROUP_H_ +#ifndef AWFUL_GUI_GAME_VGROUP_H_ +#define AWFUL_GUI_GAME_VGROUP_H_ #include "SimpleContainer.h" +#include "gui/VGroup_i.h" #include "core/core.h" -namespace awful { namespace gui +namespace awful { namespace gui { namespace game { - class VGroup : public SimpleContainer + class VGroup : public VGroup_i, public SimpleContainer { public: - VGroup( ContainerWidget* pParent_ ); + VGroup( Container* pParent_ ); virtual void calcMinMax(); virtual void layout(); @@ -20,6 +21,6 @@ namespace awful { namespace gui private: float m_Spacing; }; -}} +}}} #endif diff --git a/gui/game/Widget.cpp b/gui/game/Widget.cpp index af2e1ca..7617aa9 100644 --- a/gui/game/Widget.cpp +++ b/gui/game/Widget.cpp @@ -1,9 +1,9 @@ #include "Widget.h" -#include "ContainerWidget.h" +#include "Container.h" #include "Theme.h" using namespace awful; -using namespace awful::gui; +using namespace awful::gui::game; Widget::Widget( Pointer< Theme > pTheme_ ) { @@ -14,7 +14,7 @@ Widget::Widget( Pointer< Theme > pTheme_ ) m_Theme = pTheme_; } -Widget::Widget( ContainerWidget* pParent_ ) : +Widget::Widget( Container* pParent_ ) : Widget( pParent_->getTheme() ) { m_pParent = pParent_; diff --git a/gui/game/Widget.h b/gui/game/Widget.h index 29da5f4..0facb74 100644 --- a/gui/game/Widget.h +++ b/gui/game/Widget.h @@ -1,24 +1,25 @@ -#ifndef AWFUL_GUI_WIDGET_H_ -#define AWFUL_GUI_WIDGET_H_ +#ifndef AWFUL_GUI_GAME_WIDGET_H_ +#define AWFUL_GUI_GAME_WIDGET_H_ +#include "core/core.h" +#include "gui/Widget_i.h" #include "EventHandler.h" #include "math/Rectf.h" #include "math/Vector2f.h" #include "scenegraph/Renderable.h" #include "scenegraph/Frame.h" -#include "core/core.h" #include -namespace awful { namespace gui +namespace awful { namespace gui { namespace game { - class ContainerWidget; + class Container; class Theme; - class Widget : public EventHandler + class Widget : virtual public Widget_i, public EventHandler { public: Widget( Pointer< Theme > pTheme_ ); - Widget( ContainerWidget* pParent_ ); + Widget( Container* pParent_ ); virtual void buildSceneGraph() {} virtual void calcMinMax() {} @@ -62,11 +63,11 @@ namespace awful { namespace gui math::Vector2f m_AbsPos; Pointer< Theme > m_Theme; - ContainerWidget* m_pParent; + Container* m_pParent; Pointer< scenegraph::Renderable > m_pRenderable; Pointer< scenegraph::Frame > m_pFrame; }; -}} +}}} #endif diff --git a/gui/game/events.aih b/gui/game/events.aih index 23ff77e..7633e98 100644 --- a/gui/game/events.aih +++ b/gui/game/events.aih @@ -1,5 +1,7 @@ namespace awful { namespace gui { namespace game { + [ genericpointer=false ] + // This singleton is the thing through which all events will pass. // It will either send them to the root gui widget, or to any other widget that has asked to // exclusively catch the events. diff --git a/gui/game/game.aidl b/gui/game/game.aidl index 589388a..25489ba 100644 --- a/gui/game/game.aidl +++ b/gui/game/game.aidl @@ -2,10 +2,11 @@ #include "../../scenegraph/scenegraph.aidl" #include "events.aih" //#include "layout.aih" -//#include "theming.aih" +#include "theming.aih" namespace awful { namespace gui { namespace game { + [ genericpointer=false ] class Factory : Factory_i { static Pointer< Factory > GetInstance(); @@ -17,10 +18,10 @@ namespace awful { namespace gui { namespace game // later. // The rendering is called through a signal, as will be event notifications. This way // it will be trivial to implement custom widgets in lua. -/* class Widget : EventHandler + class Widget : Widget_i, EventHandler { Widget( Pointer< Theme > pTheme ); - Widget( Pointer< ContainerWidget > pParent ); + Widget( Pointer< Container > pParent ); virtual void buildSceneGraph(); virtual void calcMinMax(); @@ -45,15 +46,15 @@ namespace awful { namespace gui { namespace game math::Vector2f MaxSize; Pointer< scenegraph::Renderable > pRenderable; Pointer< scenegraph::Frame > pFrame; - };*/ + }; // Base class for all widgets capable of containing other widgets. -/* class ContainerWidget : Widget + class Container : Container_i, Widget { }; // A simple, non layouting container. Useful as the root object of the gui to act as a window container. - class SimpleContainer : ContainerWidget +/* class SimpleContainer : ContainerWidget { SimpleContainer( Pointer< Theme > pTheme ); SimpleContainer( Pointer< ContainerWidget > pParent ); diff --git a/gui/game/layout.aih b/gui/game/layout.aih index 52c767a..60bdb8b 100644 --- a/gui/game/layout.aih +++ b/gui/game/layout.aih @@ -1,14 +1,14 @@ -namespace awful { namespace gui +namespace awful { namespace gui { namespace game { - class HGroup : SimpleContainer + class HGroup : HGroup_i, SimpleContainer { HGroup( Pointer< ContainerWidget > pParent ); float Spacing; }; - class VGroup : SimpleContainer + class VGroup : HGroup_i, SimpleContainer { VGroup( Pointer< ContainerWidget > pParent ); float Spacing; }; -}} +}}} diff --git a/gui/game/theming.aih b/gui/game/theming.aih index 8bc2713..32b12f6 100644 --- a/gui/game/theming.aih +++ b/gui/game/theming.aih @@ -1,4 +1,4 @@ -namespace awful { namespace gui +namespace awful { namespace gui { namespace game { // There is a decorator class for each widget type. // the decorator is responsible for layouting and rendering the widget. @@ -15,8 +15,8 @@ namespace awful { namespace gui }; // A simple and functional but boring and ugly theme - class BoringTheme : Theme + /*class BoringTheme : Theme { BoringTheme( Pointer< scenegraph::Font > pFont ); - }; -}} + };*/ +}}} diff --git a/gui/gui.aidl b/gui/gui.aidl index d52cb5d..ab6eb17 100644 --- a/gui/gui.aidl +++ b/gui/gui.aidl @@ -21,7 +21,7 @@ // Only the game implementation will be available from within the game application. namespace awful { namespace gui { - [ abstract=true ] + [ abstract=true genericpointer=false ] class Factory_i { virtual Pointer< Window_i > newWindow( Pointer< Container_i > pParent ); -- 2.11.4.GIT