From d4a871785130ab0d6533bef4f1ec55c4cfd3b8df Mon Sep 17 00:00:00 2001 From: rathnor Date: Mon, 26 Apr 2004 15:04:37 +0000 Subject: toolbar themeing fixes --- ChangeLog | 6 ++++++ src/FbTk/MenuTheme.cc | 6 +++--- src/FbTk/Text.cc | 4 ++-- src/FbTk/Theme.cc | 10 ++++------ src/FbTk/Theme.hh | 8 +++++--- src/FbTk/ThemeItems.hh | 26 ++++++++++++++------------ src/IconbarTheme.cc | 28 ++++++++++------------------ src/IconbarTool.cc | 8 +++++--- src/MenuTheme.cc | 4 ++-- src/SlitTheme.cc | 12 ++++-------- src/Toolbar.cc | 35 +++++++++++++++++++++++++++++------ src/ToolbarTheme.cc | 4 ++-- src/WorkspaceNameTheme.hh | 13 ++++--------- 13 files changed, 90 insertions(+), 74 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6707032..96ee3b7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,10 @@ (Format: Year/Month/Day) +Changes for 0.9.10: +*04/04/27: + * Fix up several toolbar theme items and alignments (Simon) + - big improvement in look/compatibility of older styles + Toolbar.cc Theme.hh/cc ThemeItems.hh ToolbarTheme.cc MenuTheme.cc Text.cc + IconbarTheme.cc SlitTheme.cc WorkspaceNameTheme.hh IconbarTool.cc Changes for 0.9.9: *04/04/22: * New Command: Deiconify diff --git a/src/FbTk/MenuTheme.cc b/src/FbTk/MenuTheme.cc index 605246a..95d15d1 100644 --- a/src/FbTk/MenuTheme.cc +++ b/src/FbTk/MenuTheme.cc @@ -19,7 +19,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: MenuTheme.cc,v 1.14 2004/01/08 22:07:58 fluxgen Exp $ +// $Id: MenuTheme.cc,v 1.15 2004/04/26 15:04:37 rathnor Exp $ #include "MenuTheme.hh" @@ -136,7 +136,7 @@ void ThemeItem::setFromString(const char *str) { } template <> -void ThemeItem::load() { +void ThemeItem::load(const std::string *name, const std::string *altname) { // do nothing, we don't have anything extra to load } @@ -151,7 +151,7 @@ void ThemeItem::setFromString(const char *str) { } template <> -void ThemeItem::load() { +void ThemeItem::load(const std::string *name, const std::string *altname) { } diff --git a/src/FbTk/Text.cc b/src/FbTk/Text.cc index 190e233..8dc91d9 100644 --- a/src/FbTk/Text.cc +++ b/src/FbTk/Text.cc @@ -19,7 +19,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Text.cc,v 1.2 2003/08/11 14:59:57 fluxgen Exp $ +// $Id: Text.cc,v 1.3 2004/04/26 15:04:37 rathnor Exp $ #include "Text.hh" @@ -82,7 +82,7 @@ void ThemeItem::setFromString(const char *value) { // do nothing template <> -void ThemeItem::load() { +void ThemeItem::load(const std::string *name, const std::string *altname) { } }; // end namespace FbTk diff --git a/src/FbTk/Theme.cc b/src/FbTk/Theme.cc index 224ae6f..f9c3366 100644 --- a/src/FbTk/Theme.cc +++ b/src/FbTk/Theme.cc @@ -19,7 +19,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Theme.cc,v 1.25 2004/01/12 20:24:06 fluxgen Exp $ +// $Id: Theme.cc,v 1.26 2004/04/26 15:04:37 rathnor Exp $ #include "Theme.hh" @@ -157,11 +157,10 @@ bool ThemeManager::loadItem(ThemeItem_base &resource) { bool ThemeManager::loadItem(ThemeItem_base &resource, const std::string &name, const std::string &alt_name) { XrmValue value; char *value_type; - if (XrmGetResource(*m_database, name.c_str(), alt_name.c_str(), &value_type, &value)) { resource.setFromString(value.addr); - resource.load(); // load additional stuff by the ThemeItem + resource.load(&name, &alt_name); // load additional stuff by the ThemeItem } else return false; @@ -171,11 +170,10 @@ bool ThemeManager::loadItem(ThemeItem_base &resource, const std::string &name, c std::string ThemeManager::resourceValue(const std::string &name, const std::string &altname) { XrmValue value; char *value_type; - if (*m_database != 0 && XrmGetResource(*m_database, name.c_str(), - altname.c_str(), &value_type, &value) && value.addr != 0) { + altname.c_str(), &value_type, &value) && value.addr != 0) return string(value.addr); - } + return ""; } diff --git a/src/FbTk/Theme.hh b/src/FbTk/Theme.hh index 105d860..ff84051 100644 --- a/src/FbTk/Theme.hh +++ b/src/FbTk/Theme.hh @@ -19,7 +19,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Theme.hh,v 1.15 2004/01/02 22:55:15 fluxgen Exp $ +// $Id: Theme.hh,v 1.16 2004/04/26 15:04:37 rathnor Exp $ /** @file holds ThemeItem, Theme and ThemeManager which is the base for any theme @@ -50,7 +50,7 @@ public: virtual ~ThemeItem_base() { } virtual void setFromString(const char *str) = 0; virtual void setDefaultValue() = 0; - virtual void load() = 0; // if it needs to load additional stuff + virtual void load(const std::string *name = 0, const std::string *altname = 0) = 0; // if it needs to load additional stuff const std::string &name() const { return m_name; } const std::string &altName() const { return m_altname; } private: @@ -70,7 +70,9 @@ public: /// specialized void setFromString(const char *strval); /// specialized - void load(); + // name and altname may be different to the primary ones (e.g. from fallback) + // if they are null, then the original name is used + void load(const std::string *name = 0, const std::string *altname = 0); /** @name access operators */ diff --git a/src/FbTk/ThemeItems.hh b/src/FbTk/ThemeItems.hh index 63c17df..57a5f11 100644 --- a/src/FbTk/ThemeItems.hh +++ b/src/FbTk/ThemeItems.hh @@ -19,7 +19,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: ThemeItems.hh,v 1.5 2004/02/10 19:03:04 fluxgen Exp $ +// $Id: ThemeItems.hh,v 1.6 2004/04/26 15:04:37 rathnor Exp $ /// @file implements common theme items @@ -42,7 +42,7 @@ using namespace std; // create default handlers for Color, Font, Texture, int and string template <> -void FbTk::ThemeItem::load() { } +void FbTk::ThemeItem::load(const std::string *name, const std::string *altname) { } template <> void FbTk::ThemeItem::setDefaultValue() { @@ -55,7 +55,7 @@ void FbTk::ThemeItem::setFromString(const char *str) { } template <> -void FbTk::ThemeItem::load() { } +void FbTk::ThemeItem::load(const std::string *name, const std::string *altname) { } template <> void FbTk::ThemeItem::setDefaultValue() { @@ -103,18 +103,21 @@ void ThemeItem::setFromString(const char *str) { // do nothing template <> -void ThemeItem::load() { +void ThemeItem::load(const std::string *name, const std::string *altname) { } template <> -void ThemeItem::load() { +void ThemeItem::load(const std::string *o_name, const std::string *o_altname) { + const std::string &m_name = (o_name==0)?name():*o_name; + const std::string &m_altname = (o_altname==0)?altName():*o_altname; + string color_name(ThemeManager::instance(). - resourceValue(name()+".color", altName()+".Color")); + resourceValue(m_name+".color", m_altname+".Color")); string colorto_name(ThemeManager::instance(). - resourceValue(name()+".colorTo", altName()+".ColorTo")); + resourceValue(m_name+".colorTo", m_altname+".ColorTo")); string pixmap_name(ThemeManager::instance(). - resourceValue(name()+".pixmap", altName()+".Pixmap")); + resourceValue(m_name+".pixmap", m_altname+".Pixmap")); // set default value if we failed to load color @@ -137,7 +140,7 @@ void ThemeItem::load() { m_tm.screenNum())); if (pm.get() == 0) { if (FbTk::ThemeManager::instance().verbose()) { - cerr<<"Resource("<::setFromString(const char *str) { // not used template <> -void FbTk::ThemeItem:: -load() { } +void FbTk::ThemeItem::load(const std::string *name, const std::string *altname) { } template <> void FbTk::ThemeItem:: @@ -211,7 +213,7 @@ void ThemeItem::setFromString(const char *str) { // does nothing template <> -void ThemeItem::load() { } +void ThemeItem::load(const std::string *name, const std::string *altname) { } } // end namespace FbTk diff --git a/src/IconbarTheme.cc b/src/IconbarTheme.cc index 69e0a7b..9710dfc 100644 --- a/src/IconbarTheme.cc +++ b/src/IconbarTheme.cc @@ -20,7 +20,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: IconbarTheme.cc,v 1.8 2004/01/13 14:41:32 rathnor Exp $ +// $Id: IconbarTheme.cc,v 1.9 2004/04/26 15:04:36 rathnor Exp $ #include "IconbarTheme.hh" #include "FbTk/App.hh" @@ -64,25 +64,17 @@ bool IconbarTheme::fallback(FbTk::ThemeItem_base &item) { ThemeManager &tm = ThemeManager::instance(); if (&m_focused_texture == &item) { - // special case for textures since they're using .load() - FbTk::ThemeItem tmp_item(m_focused_texture.theme(), - "window.label.focus", "Window.Title.Focus"); - tmp_item.load(); - // copy texture - *m_focused_texture = *tmp_item; - return true; + return (tm.loadItem(item, "window.label.focus", "Window.Label.Focus") || + tm.loadItem(item, "toolbar.windowLabel", "toolbar.windowLabel")); + } else if (&m_unfocused_texture == &item) { - // special case for textures since they're using .load() - FbTk::ThemeItem tmp_item(m_unfocused_texture.theme(), - "window.label.unfocus", "Window.Label.Unfocus"); - tmp_item.load(); - // copy texture - *m_unfocused_texture = *tmp_item; - return true; - } else if (&m_empty_texture == &item) { - return (tm.loadItem(item, m_focused_texture.name(), m_focused_texture.altName()) ? - true : + return (tm.loadItem(item, "window.label.unfocus", "Window.Label.Unfocus") || tm.loadItem(item, "toolbar.windowLabel", "toolbar.windowLabel")); + } else if (&m_empty_texture == &item) { + return (tm.loadItem(item, m_focused_texture.name(), m_focused_texture.altName()) || + tm.loadItem(item, "toolbar.windowLabel", "toolbar.windowLabel") || + tm.loadItem(item, "toolbar", "toolbar") + ); } else if (item.name() == m_name + ".borderWidth" || item.name() == m_name + ".focused.borderWidth" || item.name() == m_name + ".unfocused.borderWidth") diff --git a/src/IconbarTool.cc b/src/IconbarTool.cc index d4cdd3d..ae14fc3 100644 --- a/src/IconbarTool.cc +++ b/src/IconbarTool.cc @@ -20,7 +20,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: IconbarTool.cc,v 1.35 2004/03/22 20:08:08 fluxgen Exp $ +// $Id: IconbarTool.cc,v 1.36 2004/04/26 15:04:37 rathnor Exp $ #include "IconbarTool.hh" @@ -597,9 +597,10 @@ void IconbarTool::renderButton(IconButton &button) { button.setPixmap(*m_rc_use_pixmap); button.setAlpha(m_theme.alpha()); - // if we're rendering a button, there must be a back button. // The last button is always the regular width - bool wider_button = (button.width() != m_icon_container.back()->width()); + bool wider_button = false; + if (!m_icon_container.empty()) + wider_button = (button.width() != m_icon_container.back()->width()); if (button.win().isFocused()) { // focused texture m_icon_container.setSelected(m_icon_container.find(&button)); @@ -685,6 +686,7 @@ void IconbarTool::addWindow(FluxboxWindow &win) { return; IconButton *button = new IconButton(m_icon_container, m_theme.focusedText().font(), win); + renderButton(*button); m_icon_container.insertItem(button); m_icon_list.push_back(button); diff --git a/src/MenuTheme.cc b/src/MenuTheme.cc index b06e489..fe8cac2 100644 --- a/src/MenuTheme.cc +++ b/src/MenuTheme.cc @@ -19,7 +19,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: MenuTheme.cc,v 1.2 2003/07/10 14:16:11 fluxgen Exp $ +// $Id: MenuTheme.cc,v 1.3 2004/04/26 15:04:37 rathnor Exp $ #include "MenuTheme.hh" #include "StringUtil.hh" @@ -27,7 +27,7 @@ using namespace std; template <> -void FbTk::ThemeItem::load() { } +void FbTk::ThemeItem::load(const std::string *name, const std::string *altname) { } template <> void FbTk::ThemeItem::setDefaultValue() { diff --git a/src/SlitTheme.cc b/src/SlitTheme.cc index a745ec4..8414bd9 100644 --- a/src/SlitTheme.cc +++ b/src/SlitTheme.cc @@ -19,7 +19,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: SlitTheme.cc,v 1.2 2003/08/29 23:52:14 fluxgen Exp $ +// $Id: SlitTheme.cc,v 1.3 2004/04/26 15:04:37 rathnor Exp $ #include "SlitTheme.hh" @@ -42,13 +42,9 @@ void SlitTheme::reconfigTheme() { bool SlitTheme::fallback(FbTk::ThemeItem_base &item) { if (&item == &m_texture) { - // special case for textures since they're using .load() - FbTk::ThemeItem tmp_item(m_texture.theme(), - "toolbar", "Toolbar"); - tmp_item.load(); - // copy texture - *m_texture = *tmp_item; - return true; + return FbTk::ThemeManager::instance().loadItem(item, + "toolbar", + "Toolbar"); } else if (item.name().find(".borderWidth") != std::string::npos) { return FbTk::ThemeManager::instance().loadItem(item, "borderWidth", diff --git a/src/Toolbar.cc b/src/Toolbar.cc index 7dd4c58..15efb99 100644 --- a/src/Toolbar.cc +++ b/src/Toolbar.cc @@ -22,7 +22,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Toolbar.cc,v 1.138 2004/01/21 13:36:09 fluxgen Exp $ +// $Id: Toolbar.cc,v 1.139 2004/04/26 15:04:37 rathnor Exp $ #include "Toolbar.hh" @@ -876,9 +876,24 @@ void Toolbar::rearrangeItems() { int fixed_width = 0; // combined size of all fixed items int fixed_items = 0; // number of fixed items int relative_items = 0; + int last_bw = 0; // we show the largest border of adjoining items + bool first = true; for (; item_it != item_it_end; ++item_it) { + if (!(*item_it)->active()) + continue; + + if (!first) { + if ((*item_it)->borderWidth() > last_bw) + fixed_width += (*item_it)->borderWidth(); + else + fixed_width += last_bw; + } else + first = false; + + last_bw = (*item_it)->borderWidth(); + if ((*item_it)->type() == ToolbarItem::FIXED && (*item_it)->active()) { - fixed_width += (*item_it)->width() + (*item_it)->borderWidth()*2; + fixed_width += (*item_it)->width(); fixed_items++; } else if ((*item_it)->type() == ToolbarItem::RELATIVE && (*item_it)->active()) { relative_items++; @@ -899,14 +914,22 @@ void Toolbar::rearrangeItems() { } } // now move and resize the items - int next_x = 0; + // borderWidth added back on straight away + int next_x = -2*m_item_list.front()->borderWidth(); // list isn't empty + last_bw = 0; for (item_it = m_item_list.begin(); item_it != item_it_end; ++item_it) { if (!(*item_it)->active()) { (*item_it)->hide(); continue; } - int borderW = (*item_it)->borderWidth(); + + if (borderW > last_bw) + next_x += borderW; + else + next_x += last_bw; + last_bw = borderW; + (*item_it)->show(); if ((*item_it)->type() == ToolbarItem::RELATIVE) { int extra = 0; @@ -915,12 +938,12 @@ void Toolbar::rearrangeItems() { --rounding_error; } - (*item_it)->moveResize(next_x, -borderW, extra + relative_width-2*borderW, height()); + (*item_it)->moveResize(next_x, -borderW, extra + relative_width, height()); } else { // fixed size (*item_it)->moveResize(next_x, -borderW, (*item_it)->width(), height()); } - next_x += (*item_it)->width() + borderW*2; + next_x += (*item_it)->width(); } // unlock m_resize_lock = false; diff --git a/src/ToolbarTheme.cc b/src/ToolbarTheme.cc index f1a68c7..999b142 100644 --- a/src/ToolbarTheme.cc +++ b/src/ToolbarTheme.cc @@ -19,7 +19,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: ToolbarTheme.cc,v 1.13 2003/10/13 23:47:38 fluxgen Exp $ +// $Id: ToolbarTheme.cc,v 1.14 2004/04/26 15:04:37 rathnor Exp $ #include "ToolbarTheme.hh" @@ -29,7 +29,7 @@ using namespace std; template<> -void FbTk::ThemeItem::load() { } +void FbTk::ThemeItem::load(const std::string *name, const std::string *altname) { } template<> void FbTk::ThemeItem::setDefaultValue() { diff --git a/src/WorkspaceNameTheme.hh b/src/WorkspaceNameTheme.hh index a29dd51..ee4f12d 100644 --- a/src/WorkspaceNameTheme.hh +++ b/src/WorkspaceNameTheme.hh @@ -20,7 +20,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: WorkspaceNameTheme.hh,v 1.1 2003/08/29 00:51:55 fluxgen Exp $ +// $Id: WorkspaceNameTheme.hh,v 1.2 2004/04/26 15:04:37 rathnor Exp $ #ifndef WORKSPACENAMETHEME_HH #define WORKSPACENAMETHEME_HH @@ -40,14 +40,9 @@ public: "toolbar.label.textColor", "Toolbar.Label.TextColor"); } else if (item.name() == "toolbar.workspace") { - - // special case for textures since they're using .load() - FbTk::ThemeItem tmp_item(*this, - "toolbar.label", "Toolbar.Label"); - tmp_item.load(); - // copy texture - *textureTheme() = *tmp_item; - return true; + return FbTk::ThemeManager::instance().loadItem(item, + "toolbar.label", + "Toolbar.Label"); } return ToolTheme::fallback(item); -- cgit v0.11.2