toolbar themeing fixes

This commit is contained in:
rathnor 2004-04-26 15:04:37 +00:00
parent ef6bf03ca1
commit d4a8717851
13 changed files with 91 additions and 75 deletions

View file

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

View file

@ -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<MenuTheme::BulletType>::setFromString(const char *str) {
}
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 @@ void ThemeItem<unsigned int>::setFromString(const char *str) {
}
template <>
void ThemeItem<unsigned int>::load() {
void ThemeItem<unsigned int>::load(const std::string *name, const std::string *altname) {
}

View file

@ -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<FbTk::Justify>::setFromString(const char *value) {
// do nothing
template <>
void ThemeItem<FbTk::Justify>::load() {
void ThemeItem<FbTk::Justify>::load(const std::string *name, const std::string *altname) {
}
}; // end namespace FbTk

View file

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

View file

@ -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<T>, 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
*/

View file

@ -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<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 @@ void FbTk::ThemeItem<std::string>::setFromString(const char *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 @@ void ThemeItem<FbTk::Font>::setFromString(const char *str) {
// 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 @@ void ThemeItem<FbTk::Texture>::load() {
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 @@ void ThemeItem<FbTk::Texture>::setFromString(const char *str) {
// 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 @@ void ThemeItem<FbTk::Color>::setFromString(const char *str) {
// does nothing
template <>
void ThemeItem<FbTk::Color>::load() { }
void ThemeItem<FbTk::Color>::load(const std::string *name, const std::string *altname) { }
} // end namespace FbTk

View file

@ -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<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;
} 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;
} 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.focus", "Window.Label.Focus") ||
tm.loadItem(item, "toolbar.windowLabel", "toolbar.windowLabel"));
} else if (&m_unfocused_texture == &item) {
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")

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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