From f2599d87f61ac4d2028698195024e082ed6f513a Mon Sep 17 00:00:00 2001 From: rathnor <rathnor> Date: Fri, 27 Aug 2004 14:14:42 +0000 Subject: add a special fallback for toolbar button style --- ChangeLog | 3 +++ src/ButtonTheme.cc | 32 +++++++++++++++++++++++++++++--- src/ButtonTheme.hh | 9 ++++++++- src/ToolFactory.cc | 5 +++-- 4 files changed, 43 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1b84dbb..6627169 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ (Format: Year/Month/Day) Changes for 0.9.10: +*04/08/27: + * Improve fallback if toolbar button style item missing (Simon) + ButtonTheme.hh/cc ToolFactory.cc *04/08/26: * Tiny unification (Mathias) - theme.cfg and style.cfg allowed diff --git a/src/ButtonTheme.cc b/src/ButtonTheme.cc index abd8c24..f3bed1f 100644 --- a/src/ButtonTheme.cc +++ b/src/ButtonTheme.cc @@ -4,12 +4,16 @@ //!! TODO: still missing *.pressed.picColor ButtonTheme::ButtonTheme(int screen_num, const std::string &name, - const std::string &alt_name): + const std::string &alt_name, + const std::string &extra_fallback, + const std::string &extra_fallback_alt): ToolTheme(screen_num, name, alt_name), m_pic_color(*this, name + ".picColor", alt_name + ".PicColor"), m_pressed_texture(*this, name + ".pressed", alt_name + ".Pressed"), m_gc(RootWindow(FbTk::App::instance()->display(), screen_num)), - m_scale(*this, name + ".scale", alt_name + ".Scale") { + m_scale(*this, name + ".scale", alt_name + ".Scale"), + m_name(name), + m_fallbackname(extra_fallback), m_altfallbackname(extra_fallback_alt) { } @@ -24,9 +28,31 @@ bool ButtonTheme::fallback(FbTk::ThemeItem_base &item) { return FbTk::ThemeManager::instance().loadItem(item, "borderColor", "BorderColor"); } */ - if (item.name().find(".pressed") != std::string::npos) { + if (item.name() == name()) { + // default to the toolbar label style + return FbTk::ThemeManager::instance().loadItem(item, + m_fallbackname, + m_altfallbackname); + + } else if (item.name().find(".picColor") != std::string::npos) { + // if we've fallen back to alternate name, and it doesn't have a picColor, + // try its text color instead + return FbTk::ThemeManager::instance().loadItem(item, + m_fallbackname + ".picColor", + m_altfallbackname + ".picColor") || + FbTk::ThemeManager::instance().loadItem(item, + m_fallbackname + ".textColor", + m_altfallbackname + ".TextColor"); + } else if (item.name().find(".pressed") != std::string::npos) { // copy texture *m_pressed_texture = texture(); + // invert the bevel if it has one! + unsigned long type = m_pressed_texture->type(); + unsigned long bevels = (FbTk::Texture::SUNKEN | FbTk::Texture::RAISED); + if ((type & bevels) != 0) { + type ^= bevels; + m_pressed_texture->setType(type); + } return true; } diff --git a/src/ButtonTheme.hh b/src/ButtonTheme.hh index 0df252c..cba4282 100644 --- a/src/ButtonTheme.hh +++ b/src/ButtonTheme.hh @@ -8,7 +8,9 @@ class ButtonTheme: public ToolTheme { public: ButtonTheme(int screen_num, - const std::string &name, const std::string &alt_name); + const std::string &name, const std::string &alt_name, + const std::string &extra_fallback, + const std::string &extra_fallback_alt); virtual ~ButtonTheme() { } bool fallback(FbTk::ThemeItem_base &item); @@ -17,11 +19,16 @@ public: inline const FbTk::Texture &pressed() const { return *m_pressed_texture; } inline GC gc() const { return m_gc.gc(); } inline int scale() const { return *m_scale; } // scale factor for inside objects + inline const std::string &name() { return m_name; } + private: FbTk::ThemeItem<FbTk::Color> m_pic_color; FbTk::ThemeItem<FbTk::Texture> m_pressed_texture; FbTk::GContext m_gc; FbTk::ThemeItem<int> m_scale; + const std::string m_name; + const std::string m_fallbackname; + const std::string m_altfallbackname; }; #endif // BUTTONTHEME_HH diff --git a/src/ToolFactory.cc b/src/ToolFactory.cc index 011eb39..a2d6c2b 100644 --- a/src/ToolFactory.cc +++ b/src/ToolFactory.cc @@ -19,7 +19,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: ToolFactory.cc,v 1.5 2004/08/25 17:16:40 rathnor Exp $ +// $Id: ToolFactory.cc,v 1.6 2004/08/27 14:14:42 rathnor Exp $ #include "ToolFactory.hh" @@ -75,7 +75,8 @@ private: ToolFactory::ToolFactory(BScreen &screen):m_screen(screen), m_clock_theme(screen.screenNumber(), "toolbar.clock", "Toolbar.Clock"), - m_button_theme(new ButtonTheme(screen.screenNumber(), "toolbar.button", "Toolbar.Button")), + m_button_theme(new ButtonTheme(screen.screenNumber(), "toolbar.button", "Toolbar.Button", + "toolbar.workspace", "Toolbar.Workspace")), m_workspace_theme(new WorkspaceNameTheme(screen.screenNumber(), "toolbar.workspace", "Toolbar.Workspace")), m_iconbar_theme(screen.screenNumber(), "toolbar.iconbar", "Toolbar.Iconbar") { -- cgit v0.11.2