all repos — fluxbox @ f2599d87f61ac4d2028698195024e082ed6f513a

custom fork of the fluxbox windowmanager

add a special fallback for toolbar button style
rathnor rathnor
commit

f2599d87f61ac4d2028698195024e082ed6f513a

parent

6ce5a31ea8bb6dbf6f64260c62d9af153e9d7f30

4 files changed, 43 insertions(+), 6 deletions(-)

jump to
M ChangeLogChangeLog

@@ -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
M src/ButtonTheme.ccsrc/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 @@ if (item.name().find(".borderColor") != std::string::npos) {

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; }
M src/ButtonTheme.hhsrc/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 @@

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
M src/ToolFactory.ccsrc/ToolFactory.cc

@@ -19,7 +19,7 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING

// 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 @@ };

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") {