all repos — fluxbox @ 60ba709c2f47cc2c7b877aef1b0f297b097853e5

custom fork of the fluxbox windowmanager

add a level of indirection to themes
Mark Tiefenbruck mark@fluxbox.org
commit

60ba709c2f47cc2c7b877aef1b0f297b097853e5

parent

b20b243b48683d209f8134b46c6dcea4df94b6cc

M src/ButtonTheme.hhsrc/ButtonTheme.hh

@@ -27,7 +27,7 @@ #include "ToolTheme.hh"

#include "FbTk/GContext.hh" -class ButtonTheme: public ToolTheme { +class ButtonTheme: public ToolTheme, public FbTk::ThemeProxy<ButtonTheme> { public: ButtonTheme(int screen_num, const std::string &name, const std::string &alt_name,

@@ -42,6 +42,12 @@ const FbTk::Texture &pressed() const { return *m_pressed_texture; }

GC gc() const { return m_gc.gc(); } int scale() const { return *m_scale; } // scale factor for inside objects const std::string &name() { return m_name; } + + virtual FbTk::Subject &reconfigSig() { return FbTk::Theme::reconfigSig(); } + virtual const FbTk::Subject &reconfigSig() const { return FbTk::Theme::reconfigSig(); } + + virtual ButtonTheme *operator ->() { return this; } + virtual const ButtonTheme *operator ->() const { return this; } private: FbTk::ThemeItem<FbTk::Color> m_pic_color;
M src/FbTk/MenuTheme.hhsrc/FbTk/MenuTheme.hh

@@ -33,7 +33,7 @@ #include "GContext.hh"

namespace FbTk { -class MenuTheme:public Theme { +class MenuTheme: public Theme, public ThemeProxy<MenuTheme> { public: //!! TODO // this isn't actually used with a theme item

@@ -139,6 +139,12 @@ m_hl_selected_pixmap->pixmap() = pm;

if (is_imagecached) m_hl_selected_pixmap->pixmap().dontFree(); } + + virtual Subject &reconfigSig() { return Theme::reconfigSig(); } + virtual const Subject &reconfigSig() const { return Theme::reconfigSig(); } + + virtual MenuTheme *operator ->() { return this; } + virtual const MenuTheme *operator ->() const { return this; } private: ThemeItem<Color> t_text, f_text, h_text, d_text, u_text;
M src/FbTk/TextTheme.ccsrc/FbTk/TextTheme.cc

@@ -38,10 +38,10 @@ *m_justify = LEFT;

// set default values m_text_color->setFromString("white", theme.screenNum()); - update(); + updateTextColor(); } -void TextTheme::update() { +void TextTheme::updateTextColor() { m_text_gc.setForeground(*m_text_color); }
M src/FbTk/TextTheme.hhsrc/FbTk/TextTheme.hh

@@ -36,7 +36,7 @@ public:

TextTheme(Theme &theme, const std::string &name, const std::string &altname); virtual ~TextTheme() { } - void update(); + void updateTextColor(); Font &font() { return *m_font; } const Font &font() const { return *m_font; }
M src/FbTk/Theme.hhsrc/FbTk/Theme.hh

@@ -118,6 +118,18 @@ ItemList m_themeitems;

FbTk::Subject m_reconfig_sig; }; +/// Proxy interface for themes, so they can be substituted dynamically +template <class BaseTheme> +class ThemeProxy { +public: + virtual ~ThemeProxy() { } + + virtual Subject &reconfigSig() = 0; + virtual const Subject &reconfigSig() const = 0; + + virtual BaseTheme *operator ->() = 0; + virtual const BaseTheme *operator ->() const = 0; +}; /// Singleton theme manager /**
M src/FbWinFrameTheme.hhsrc/FbWinFrameTheme.hh

@@ -32,7 +32,8 @@ #include "FbTk/Shape.hh"

#include "IconbarTheme.hh" -class FbWinFrameTheme: public FbTk::Theme { +class FbWinFrameTheme: public FbTk::Theme, + public FbTk::ThemeProxy<FbWinFrameTheme> { public: explicit FbWinFrameTheme(int screen_num); ~FbWinFrameTheme();

@@ -92,6 +93,12 @@ void setFocusedAlpha(unsigned char alpha) { m_focused_alpha = alpha; }

void setUnfocusedAlpha(unsigned char alpha) { m_unfocused_alpha = alpha; } IconbarTheme &iconbarTheme() { return m_iconbar_theme; } + + virtual FbTk::Subject &reconfigSig() { return FbTk::Theme::reconfigSig(); } + virtual const FbTk::Subject &reconfigSig() const { return FbTk::Theme::reconfigSig(); } + + virtual FbWinFrameTheme *operator ->() { return this; } + virtual const FbWinFrameTheme *operator ->() const { return this; } private: FbTk::ThemeItem<FbTk::Texture> m_title_focus, m_title_unfocus;
M src/IconbarTheme.ccsrc/IconbarTheme.cc

@@ -58,8 +58,8 @@ }

void IconbarTheme::reconfigTheme() { - m_focused_text.update(); - m_unfocused_text.update(); + m_focused_text.updateTextColor(); + m_unfocused_text.updateTextColor(); } // fallback resources
M src/IconbarTheme.hhsrc/IconbarTheme.hh

@@ -28,7 +28,7 @@ #include "FbTk/BorderTheme.hh"

#include "FbTk/Texture.hh" #include "FbTk/TextTheme.hh" -class IconbarTheme:public FbTk::Theme { +class IconbarTheme: public FbTk::Theme, public FbTk::ThemeProxy<IconbarTheme> { public: IconbarTheme(int screen_num, const std::string &name, const std::string &altname); virtual ~IconbarTheme();

@@ -46,6 +46,12 @@

const FbTk::Texture &focusedTexture() const { return *m_focused_texture; } const FbTk::Texture &unfocusedTexture() const { return *m_unfocused_texture; } const FbTk::Texture &emptyTexture() const { return *m_empty_texture; } + + virtual FbTk::Subject &reconfigSig() { return FbTk::Theme::reconfigSig(); } + virtual const FbTk::Subject &reconfigSig() const { return FbTk::Theme::reconfigSig(); } + + virtual IconbarTheme *operator ->() { return this; } + virtual const IconbarTheme *operator ->() const { return this; } private: FbTk::ThemeItem<FbTk::Texture> m_focused_texture, m_unfocused_texture, m_empty_texture;
M src/RootTheme.hhsrc/RootTheme.hh

@@ -34,7 +34,7 @@ class ImageControl;

} /// Contains border color, border size, bevel width and opGC for objects like geometry window in BScreen -class RootTheme: public FbTk::Theme { +class RootTheme: public FbTk::Theme, public FbTk::ThemeProxy<RootTheme> { public: /// constructor /// @param resmanager resource manager for finding specific resources

@@ -53,7 +53,13 @@ int cap_style,

int join_style) { m_opgc.setLineAttributes(width, line_style, cap_style, join_style); } - + + virtual FbTk::Subject &reconfigSig() { return FbTk::Theme::reconfigSig(); } + virtual const FbTk::Subject &reconfigSig() const { return FbTk::Theme::reconfigSig(); } + + virtual RootTheme *operator ->() { return this; } + virtual const RootTheme *operator ->() const { return this; } + private: BackgroundItem *m_background;///< background image/texture FbTk::GContext m_opgc;
M src/SlitTheme.hhsrc/SlitTheme.hh

@@ -26,7 +26,7 @@ #include "FbTk/Theme.hh"

#include "FbTk/Texture.hh" #include "FbTk/Color.hh" -class SlitTheme:public FbTk::Theme { +class SlitTheme: public FbTk::Theme, public FbTk::ThemeProxy<SlitTheme> { public: explicit SlitTheme(int screen_num);

@@ -37,6 +37,13 @@ const FbTk::Texture &texture() const { return *m_texture; }

const FbTk::Color &borderColor() const { return *m_border_color; } int borderWidth() const { return *m_border_width; } int bevelWidth() const { return *m_bevel_width; } + + virtual FbTk::Subject &reconfigSig() { return FbTk::Theme::reconfigSig(); } + virtual const FbTk::Subject &reconfigSig() const { return FbTk::Theme::reconfigSig(); } + + virtual SlitTheme *operator ->() { return this; } + virtual const SlitTheme *operator ->() const { return this; } + private: FbTk::ThemeItem<FbTk::Texture> m_texture; FbTk::ThemeItem<int> m_border_width, m_bevel_width;
M src/ToolTheme.ccsrc/ToolTheme.cc

@@ -38,7 +38,7 @@ }

void ToolTheme::reconfigTheme() { // update text theme - update(); + updateTextColor(); } bool ToolTheme::fallback(FbTk::ThemeItem_base &item) {
M src/ToolTheme.hhsrc/ToolTheme.hh

@@ -29,7 +29,8 @@ #include "FbTk/BorderTheme.hh"

#include "FbTk/Texture.hh" /// Handles toolbar item theme for text and texture -class ToolTheme: public FbTk::Theme, public FbTk::TextTheme { +class ToolTheme: public FbTk::Theme, public FbTk::TextTheme, + public FbTk::ThemeProxy<ToolTheme> { public: ToolTheme(int screen_num, const std::string &name, const std::string &altname); virtual ~ToolTheme();

@@ -42,6 +43,12 @@ const FbTk::Texture &texture() const { return *m_texture; }

const FbTk::BorderTheme &border() const { return m_border; } unsigned char alpha() const { return m_alpha; } void setAlpha(unsigned char alpha) { m_alpha = alpha; } + + virtual FbTk::Subject &reconfigSig() { return FbTk::Theme::reconfigSig(); } + virtual const FbTk::Subject &reconfigSig() const { return FbTk::Theme::reconfigSig(); } + + virtual ToolTheme *operator ->() { return this; } + virtual const ToolTheme *operator ->() const { return this; } protected: FbTk::ThemeItem<FbTk::Texture> &textureTheme() { return m_texture; }
M src/ToolbarTheme.hhsrc/ToolbarTheme.hh

@@ -27,7 +27,7 @@ #include "FbTk/Texture.hh"

#include "FbTk/BorderTheme.hh" /// toolbar theme class container -class ToolbarTheme: public FbTk::Theme { +class ToolbarTheme: public FbTk::Theme, public FbTk::ThemeProxy<ToolbarTheme> { public: explicit ToolbarTheme(int screen_num); virtual ~ToolbarTheme();

@@ -43,6 +43,13 @@ int bevelWidth() const { return *m_bevel_width; }

bool shape() const { return *m_shape; } int height() const { return *m_height; } int buttonSize() const { return *m_button_size; } + + virtual FbTk::Subject &reconfigSig() { return FbTk::Theme::reconfigSig(); } + virtual const FbTk::Subject &reconfigSig() const { return FbTk::Theme::reconfigSig(); } + + virtual ToolbarTheme *operator ->() { return this; } + virtual const ToolbarTheme *operator ->() const { return this; } + private: FbTk::ThemeItem<FbTk::Texture> m_toolbar; FbTk::BorderTheme m_border;
M src/WinButtonTheme.hhsrc/WinButtonTheme.hh

@@ -27,7 +27,8 @@ #include "FbTk/PixmapWithMask.hh"

class FbWinFrameTheme; -class WinButtonTheme: public FbTk::Theme { +class WinButtonTheme: public FbTk::Theme, + public FbTk::ThemeProxy<WinButtonTheme> { public: WinButtonTheme(int screen_num, FbWinFrameTheme &frame_theme); ~WinButtonTheme();

@@ -83,6 +84,12 @@ FbTk::PixmapWithMask &titleFocusPixmap() { return *m_title_focus_pm; }

const FbTk::PixmapWithMask &titleFocusPixmap() const { return *m_title_focus_pm; } FbTk::PixmapWithMask &titleUnfocusPixmap() { return *m_title_unfocus_pm; } const FbTk::PixmapWithMask &titleUnfocusPixmap() const { return *m_title_unfocus_pm; } + + virtual FbTk::Subject &reconfigSig() { return FbTk::Theme::reconfigSig(); } + virtual const FbTk::Subject &reconfigSig() const { return FbTk::Theme::reconfigSig(); } + + virtual WinButtonTheme *operator ->() { return this; } + virtual const WinButtonTheme *operator ->() const { return this; } private:
M src/WorkspaceNameTheme.hhsrc/WorkspaceNameTheme.hh

@@ -25,7 +25,8 @@ #define WORKSPACENAMETHEME_HH

#include "ToolTheme.hh" -class WorkspaceNameTheme:public ToolTheme { +class WorkspaceNameTheme: public ToolTheme, + public FbTk::ThemeProxy<WorkspaceNameTheme> { public: WorkspaceNameTheme(int screen_num, const std::string &name,

@@ -44,6 +45,13 @@ }

return ToolTheme::fallback(item); } + + virtual FbTk::Subject &reconfigSig() { return FbTk::Theme::reconfigSig(); } + virtual const FbTk::Subject &reconfigSig() const { return FbTk::Theme::reconfigSig(); } + + virtual WorkspaceNameTheme *operator ->() { return this; } + virtual const WorkspaceNameTheme *operator ->() const { return this; } + }; #endif // WORKSPACENAMETHEME_HH