add a level of indirection to themes
This commit is contained in:
parent
b20b243b48
commit
60ba709c2f
15 changed files with 96 additions and 17 deletions
|
@ -27,7 +27,7 @@
|
||||||
|
|
||||||
#include "FbTk/GContext.hh"
|
#include "FbTk/GContext.hh"
|
||||||
|
|
||||||
class ButtonTheme: public ToolTheme {
|
class ButtonTheme: public ToolTheme, public FbTk::ThemeProxy<ButtonTheme> {
|
||||||
public:
|
public:
|
||||||
ButtonTheme(int screen_num,
|
ButtonTheme(int screen_num,
|
||||||
const std::string &name, const std::string &alt_name,
|
const std::string &name, const std::string &alt_name,
|
||||||
|
@ -43,6 +43,12 @@ public:
|
||||||
int scale() const { return *m_scale; } // scale factor for inside objects
|
int scale() const { return *m_scale; } // scale factor for inside objects
|
||||||
const std::string &name() { return m_name; }
|
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:
|
private:
|
||||||
FbTk::ThemeItem<FbTk::Color> m_pic_color;
|
FbTk::ThemeItem<FbTk::Color> m_pic_color;
|
||||||
FbTk::ThemeItem<FbTk::Texture> m_pressed_texture;
|
FbTk::ThemeItem<FbTk::Texture> m_pressed_texture;
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
|
|
||||||
namespace FbTk {
|
namespace FbTk {
|
||||||
|
|
||||||
class MenuTheme:public Theme {
|
class MenuTheme: public Theme, public ThemeProxy<MenuTheme> {
|
||||||
public:
|
public:
|
||||||
//!! TODO
|
//!! TODO
|
||||||
// this isn't actually used with a theme item
|
// this isn't actually used with a theme item
|
||||||
|
@ -140,6 +140,12 @@ public:
|
||||||
m_hl_selected_pixmap->pixmap().dontFree();
|
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:
|
private:
|
||||||
ThemeItem<Color> t_text, f_text, h_text, d_text, u_text;
|
ThemeItem<Color> t_text, f_text, h_text, d_text, u_text;
|
||||||
ThemeItem<Texture> title, frame, hilite;
|
ThemeItem<Texture> title, frame, hilite;
|
||||||
|
|
|
@ -38,10 +38,10 @@ TextTheme::TextTheme(Theme &theme,
|
||||||
// set default values
|
// set default values
|
||||||
m_text_color->setFromString("white", theme.screenNum());
|
m_text_color->setFromString("white", theme.screenNum());
|
||||||
|
|
||||||
update();
|
updateTextColor();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextTheme::update() {
|
void TextTheme::updateTextColor() {
|
||||||
m_text_gc.setForeground(*m_text_color);
|
m_text_gc.setForeground(*m_text_color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ public:
|
||||||
TextTheme(Theme &theme, const std::string &name, const std::string &altname);
|
TextTheme(Theme &theme, const std::string &name, const std::string &altname);
|
||||||
virtual ~TextTheme() { }
|
virtual ~TextTheme() { }
|
||||||
|
|
||||||
void update();
|
void updateTextColor();
|
||||||
|
|
||||||
Font &font() { return *m_font; }
|
Font &font() { return *m_font; }
|
||||||
const Font &font() const { return *m_font; }
|
const Font &font() const { return *m_font; }
|
||||||
|
|
|
@ -118,6 +118,18 @@ private:
|
||||||
FbTk::Subject m_reconfig_sig;
|
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
|
/// Singleton theme manager
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -32,7 +32,8 @@
|
||||||
|
|
||||||
#include "IconbarTheme.hh"
|
#include "IconbarTheme.hh"
|
||||||
|
|
||||||
class FbWinFrameTheme: public FbTk::Theme {
|
class FbWinFrameTheme: public FbTk::Theme,
|
||||||
|
public FbTk::ThemeProxy<FbWinFrameTheme> {
|
||||||
public:
|
public:
|
||||||
explicit FbWinFrameTheme(int screen_num);
|
explicit FbWinFrameTheme(int screen_num);
|
||||||
~FbWinFrameTheme();
|
~FbWinFrameTheme();
|
||||||
|
@ -93,6 +94,12 @@ public:
|
||||||
|
|
||||||
IconbarTheme &iconbarTheme() { return m_iconbar_theme; }
|
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:
|
private:
|
||||||
FbTk::ThemeItem<FbTk::Texture> m_title_focus, m_title_unfocus;
|
FbTk::ThemeItem<FbTk::Texture> m_title_focus, m_title_unfocus;
|
||||||
FbTk::ThemeItem<FbTk::Texture> m_handle_focus, m_handle_unfocus;
|
FbTk::ThemeItem<FbTk::Texture> m_handle_focus, m_handle_unfocus;
|
||||||
|
|
|
@ -58,8 +58,8 @@ IconbarTheme::~IconbarTheme() {
|
||||||
|
|
||||||
|
|
||||||
void IconbarTheme::reconfigTheme() {
|
void IconbarTheme::reconfigTheme() {
|
||||||
m_focused_text.update();
|
m_focused_text.updateTextColor();
|
||||||
m_unfocused_text.update();
|
m_unfocused_text.updateTextColor();
|
||||||
}
|
}
|
||||||
|
|
||||||
// fallback resources
|
// fallback resources
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
#include "FbTk/Texture.hh"
|
#include "FbTk/Texture.hh"
|
||||||
#include "FbTk/TextTheme.hh"
|
#include "FbTk/TextTheme.hh"
|
||||||
|
|
||||||
class IconbarTheme:public FbTk::Theme {
|
class IconbarTheme: public FbTk::Theme, public FbTk::ThemeProxy<IconbarTheme> {
|
||||||
public:
|
public:
|
||||||
IconbarTheme(int screen_num, const std::string &name, const std::string &altname);
|
IconbarTheme(int screen_num, const std::string &name, const std::string &altname);
|
||||||
virtual ~IconbarTheme();
|
virtual ~IconbarTheme();
|
||||||
|
@ -47,6 +47,12 @@ public:
|
||||||
const FbTk::Texture &unfocusedTexture() const { return *m_unfocused_texture; }
|
const FbTk::Texture &unfocusedTexture() const { return *m_unfocused_texture; }
|
||||||
const FbTk::Texture &emptyTexture() const { return *m_empty_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:
|
private:
|
||||||
FbTk::ThemeItem<FbTk::Texture> m_focused_texture, m_unfocused_texture, m_empty_texture;
|
FbTk::ThemeItem<FbTk::Texture> m_focused_texture, m_unfocused_texture, m_empty_texture;
|
||||||
FbTk::BorderTheme m_focused_border, m_unfocused_border, m_border;
|
FbTk::BorderTheme m_focused_border, m_unfocused_border, m_border;
|
||||||
|
|
|
@ -34,7 +34,7 @@ class ImageControl;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Contains border color, border size, bevel width and opGC for objects like geometry window in BScreen
|
/// 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:
|
public:
|
||||||
/// constructor
|
/// constructor
|
||||||
/// @param resmanager resource manager for finding specific resources
|
/// @param resmanager resource manager for finding specific resources
|
||||||
|
@ -54,6 +54,12 @@ public:
|
||||||
m_opgc.setLineAttributes(width, line_style, cap_style, 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:
|
private:
|
||||||
BackgroundItem *m_background;///< background image/texture
|
BackgroundItem *m_background;///< background image/texture
|
||||||
FbTk::GContext m_opgc;
|
FbTk::GContext m_opgc;
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
#include "FbTk/Texture.hh"
|
#include "FbTk/Texture.hh"
|
||||||
#include "FbTk/Color.hh"
|
#include "FbTk/Color.hh"
|
||||||
|
|
||||||
class SlitTheme:public FbTk::Theme {
|
class SlitTheme: public FbTk::Theme, public FbTk::ThemeProxy<SlitTheme> {
|
||||||
public:
|
public:
|
||||||
explicit SlitTheme(int screen_num);
|
explicit SlitTheme(int screen_num);
|
||||||
|
|
||||||
|
@ -37,6 +37,13 @@ public:
|
||||||
const FbTk::Color &borderColor() const { return *m_border_color; }
|
const FbTk::Color &borderColor() const { return *m_border_color; }
|
||||||
int borderWidth() const { return *m_border_width; }
|
int borderWidth() const { return *m_border_width; }
|
||||||
int bevelWidth() const { return *m_bevel_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:
|
private:
|
||||||
FbTk::ThemeItem<FbTk::Texture> m_texture;
|
FbTk::ThemeItem<FbTk::Texture> m_texture;
|
||||||
FbTk::ThemeItem<int> m_border_width, m_bevel_width;
|
FbTk::ThemeItem<int> m_border_width, m_bevel_width;
|
||||||
|
|
|
@ -38,7 +38,7 @@ ToolTheme::~ToolTheme() {
|
||||||
|
|
||||||
void ToolTheme::reconfigTheme() {
|
void ToolTheme::reconfigTheme() {
|
||||||
// update text theme
|
// update text theme
|
||||||
update();
|
updateTextColor();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ToolTheme::fallback(FbTk::ThemeItem_base &item) {
|
bool ToolTheme::fallback(FbTk::ThemeItem_base &item) {
|
||||||
|
|
|
@ -29,7 +29,8 @@
|
||||||
#include "FbTk/Texture.hh"
|
#include "FbTk/Texture.hh"
|
||||||
|
|
||||||
/// Handles toolbar item theme for text and texture
|
/// 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:
|
public:
|
||||||
ToolTheme(int screen_num, const std::string &name, const std::string &altname);
|
ToolTheme(int screen_num, const std::string &name, const std::string &altname);
|
||||||
virtual ~ToolTheme();
|
virtual ~ToolTheme();
|
||||||
|
@ -43,6 +44,12 @@ public:
|
||||||
unsigned char alpha() const { return m_alpha; }
|
unsigned char alpha() const { return m_alpha; }
|
||||||
void setAlpha(unsigned char alpha) { m_alpha = 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:
|
protected:
|
||||||
FbTk::ThemeItem<FbTk::Texture> &textureTheme() { return m_texture; }
|
FbTk::ThemeItem<FbTk::Texture> &textureTheme() { return m_texture; }
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
#include "FbTk/BorderTheme.hh"
|
#include "FbTk/BorderTheme.hh"
|
||||||
|
|
||||||
/// toolbar theme class container
|
/// toolbar theme class container
|
||||||
class ToolbarTheme: public FbTk::Theme {
|
class ToolbarTheme: public FbTk::Theme, public FbTk::ThemeProxy<ToolbarTheme> {
|
||||||
public:
|
public:
|
||||||
explicit ToolbarTheme(int screen_num);
|
explicit ToolbarTheme(int screen_num);
|
||||||
virtual ~ToolbarTheme();
|
virtual ~ToolbarTheme();
|
||||||
|
@ -43,6 +43,13 @@ public:
|
||||||
bool shape() const { return *m_shape; }
|
bool shape() const { return *m_shape; }
|
||||||
int height() const { return *m_height; }
|
int height() const { return *m_height; }
|
||||||
int buttonSize() const { return *m_button_size; }
|
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:
|
private:
|
||||||
FbTk::ThemeItem<FbTk::Texture> m_toolbar;
|
FbTk::ThemeItem<FbTk::Texture> m_toolbar;
|
||||||
FbTk::BorderTheme m_border;
|
FbTk::BorderTheme m_border;
|
||||||
|
|
|
@ -27,7 +27,8 @@
|
||||||
|
|
||||||
class FbWinFrameTheme;
|
class FbWinFrameTheme;
|
||||||
|
|
||||||
class WinButtonTheme: public FbTk::Theme {
|
class WinButtonTheme: public FbTk::Theme,
|
||||||
|
public FbTk::ThemeProxy<WinButtonTheme> {
|
||||||
public:
|
public:
|
||||||
WinButtonTheme(int screen_num, FbWinFrameTheme &frame_theme);
|
WinButtonTheme(int screen_num, FbWinFrameTheme &frame_theme);
|
||||||
~WinButtonTheme();
|
~WinButtonTheme();
|
||||||
|
@ -84,6 +85,12 @@ public:
|
||||||
FbTk::PixmapWithMask &titleUnfocusPixmap() { return *m_title_unfocus_pm; }
|
FbTk::PixmapWithMask &titleUnfocusPixmap() { return *m_title_unfocus_pm; }
|
||||||
const FbTk::PixmapWithMask &titleUnfocusPixmap() const { 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:
|
private:
|
||||||
|
|
||||||
FbTk::ThemeItem<FbTk::PixmapWithMask> m_close_pm, m_close_unfocus_pm, m_close_pressed_pm;
|
FbTk::ThemeItem<FbTk::PixmapWithMask> m_close_pm, m_close_unfocus_pm, m_close_pressed_pm;
|
||||||
|
|
|
@ -25,7 +25,8 @@
|
||||||
|
|
||||||
#include "ToolTheme.hh"
|
#include "ToolTheme.hh"
|
||||||
|
|
||||||
class WorkspaceNameTheme:public ToolTheme {
|
class WorkspaceNameTheme: public ToolTheme,
|
||||||
|
public FbTk::ThemeProxy<WorkspaceNameTheme> {
|
||||||
public:
|
public:
|
||||||
WorkspaceNameTheme(int screen_num,
|
WorkspaceNameTheme(int screen_num,
|
||||||
const std::string &name,
|
const std::string &name,
|
||||||
|
@ -44,6 +45,13 @@ public:
|
||||||
|
|
||||||
return ToolTheme::fallback(item);
|
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
|
#endif // WORKSPACENAMETHEME_HH
|
||||||
|
|
Loading…
Reference in a new issue