all repos — fluxbox @ d4a871785130ab0d6533bef4f1ec55c4cfd3b8df

custom fork of the fluxbox windowmanager

toolbar themeing fixes
rathnor rathnor
commit

d4a871785130ab0d6533bef4f1ec55c4cfd3b8df

parent

ef6bf03ca19c0c96943894f9d0f0db9bc0bd58fc

M ChangeLogChangeLog

@@ -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 <mode> <dest>
M src/FbTk/MenuTheme.ccsrc/FbTk/MenuTheme.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: 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 @@ setDefaultValue();

} template <> -void ThemeItem<MenuTheme::BulletType>::load() { +void ThemeItem<MenuTheme::BulletType>::load(const std::string *name, const std::string *altname) { // do nothing, we don't have anything extra to load }

@@ -151,7 +151,7 @@ sscanf(str, "%d", &m_value);

} template <> -void ThemeItem<unsigned int>::load() { +void ThemeItem<unsigned int>::load(const std::string *name, const std::string *altname) { }
M src/FbTk/Text.ccsrc/FbTk/Text.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: 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 @@ }

// do nothing template <> -void ThemeItem<FbTk::Justify>::load() { +void ThemeItem<FbTk::Justify>::load(const std::string *name, const std::string *altname) { } }; // end namespace FbTk
M src/FbTk/Theme.ccsrc/FbTk/Theme.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: 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 @@ /// handles resource item loading with specific name/altname

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 @@

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 ""; }
M src/FbTk/Theme.hhsrc/FbTk/Theme.hh

@@ -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: 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<T>, Theme and ThemeManager which is the base for any theme

@@ -50,7 +50,7 @@ m_name(name), m_altname(altname) { }

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 @@ void setDefaultValue();

/// 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 */
M src/FbTk/ThemeItems.hhsrc/FbTk/ThemeItems.hh

@@ -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: 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<std::string>::load() { } +void FbTk::ThemeItem<std::string>::load(const std::string *name, const std::string *altname) { } template <> void FbTk::ThemeItem<std::string>::setDefaultValue() {

@@ -55,7 +55,7 @@ *(*this) = (str ? str : "");

} template <> -void FbTk::ThemeItem<int>::load() { } +void FbTk::ThemeItem<int>::load(const std::string *name, const std::string *altname) { } template <> void FbTk::ThemeItem<int>::setDefaultValue() {

@@ -103,18 +103,21 @@ }

// do nothing template <> -void ThemeItem<FbTk::Font>::load() { +void ThemeItem<FbTk::Font>::load(const std::string *name, const std::string *altname) { } template <> -void ThemeItem<FbTk::Texture>::load() { +void ThemeItem<FbTk::Texture>::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 @@ std::auto_ptr<FbTk::PixmapWithMask> pm(FbTk::Image::load(pixmap_name,

m_tm.screenNum())); if (pm.get() == 0) { if (FbTk::ThemeManager::instance().verbose()) { - cerr<<"Resource("<<name()+".pixmap" + cerr<<"Resource("<<m_name+".pixmap" <<"): Failed to load image: "<<pixmap_name<<endl; } m_value.pixmap() = 0;

@@ -163,8 +166,7 @@

// not used template <> -void FbTk::ThemeItem<PixmapWithMask>:: -load() { } +void FbTk::ThemeItem<PixmapWithMask>::load(const std::string *name, const std::string *altname) { } template <> void FbTk::ThemeItem<PixmapWithMask>::

@@ -211,7 +213,7 @@ }

// does nothing template <> -void ThemeItem<FbTk::Color>::load() { } +void ThemeItem<FbTk::Color>::load(const std::string *name, const std::string *altname) { } } // end namespace FbTk
M src/IconbarTheme.ccsrc/IconbarTheme.cc

@@ -20,7 +20,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: 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 @@ using namespace FbTk;

ThemeManager &tm = ThemeManager::instance(); if (&m_focused_texture == &item) { - // special case for textures since they're using .load() - FbTk::ThemeItem<FbTk::Texture> 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<FbTk::Texture> tmp_item(m_unfocused_texture.theme(), - "window.label.unfocus", "Window.Label.Unfocus"); - tmp_item.load(); - // copy texture - *m_unfocused_texture = *tmp_item; - return 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()) ? - true : - tm.loadItem(item, "toolbar.windowLabel", "toolbar.windowLabel")); + 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")
M src/IconbarTool.ccsrc/IconbarTool.cc

@@ -20,7 +20,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: 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 @@

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 @@ if (win.clientList().empty() || win.isIconHidden() )

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);
M src/MenuTheme.ccsrc/MenuTheme.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: 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 @@ #include <iostream>

using namespace std; template <> -void FbTk::ThemeItem<Shape::ShapePlace>::load() { } +void FbTk::ThemeItem<Shape::ShapePlace>::load(const std::string *name, const std::string *altname) { } template <> void FbTk::ThemeItem<Shape::ShapePlace>::setDefaultValue() {
M src/SlitTheme.ccsrc/SlitTheme.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: 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 @@ }

bool SlitTheme::fallback(FbTk::ThemeItem_base &item) { if (&item == &m_texture) { - // special case for textures since they're using .load() - FbTk::ThemeItem<FbTk::Texture> 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",
M src/Toolbar.ccsrc/Toolbar.cc

@@ -22,7 +22,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: 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 @@ ItemList::iterator item_it_end = m_item_list.end();

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 @@ rounding_error = width() - fixed_width - relative_items*relative_width;

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

--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;
M src/ToolbarTheme.ccsrc/ToolbarTheme.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: 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 @@ #include <iostream>

using namespace std; template<> -void FbTk::ThemeItem<bool>::load() { } +void FbTk::ThemeItem<bool>::load(const std::string *name, const std::string *altname) { } template<> void FbTk::ThemeItem<bool>::setDefaultValue() {
M src/WorkspaceNameTheme.hhsrc/WorkspaceNameTheme.hh

@@ -20,7 +20,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: 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 @@ return FbTk::ThemeManager::instance().loadItem(item,

"toolbar.label.textColor", "Toolbar.Label.TextColor"); } else if (item.name() == "toolbar.workspace") { - - // special case for textures since they're using .load() - FbTk::ThemeItem<FbTk::Texture> 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);