added new ThemeProxy for automatically handling focused vs. unfocused ThemeItems

This commit is contained in:
Mark Tiefenbruck 2008-01-07 02:26:32 -08:00
parent ac1bd7e098
commit dbfddf8e0b
17 changed files with 196 additions and 160 deletions

View file

@ -190,12 +190,12 @@ void CommandDialog::tabComplete() {
void CommandDialog::render() { void CommandDialog::render() {
Pixmap tmp = m_pixmap; Pixmap tmp = m_pixmap;
if (!m_screen.winFrameTheme()->iconbarTheme().focusedTexture().usePixmap()) { if (!m_screen.winFrameTheme()->focusedIconbarTheme().texture().usePixmap()) {
m_label.setBackgroundColor(m_screen.winFrameTheme()->iconbarTheme().focusedTexture().color()); m_label.setBackgroundColor(m_screen.winFrameTheme()->focusedIconbarTheme().texture().color());
m_pixmap = 0; m_pixmap = 0;
} else { } else {
m_pixmap = m_screen.imageControl().renderImage(m_label.width(), m_label.height(), m_pixmap = m_screen.imageControl().renderImage(m_label.width(), m_label.height(),
m_screen.winFrameTheme()->iconbarTheme().focusedTexture()); m_screen.winFrameTheme()->focusedIconbarTheme().texture());
m_label.setBackgroundPixmap(m_pixmap); m_label.setBackgroundPixmap(m_pixmap);
} }
@ -210,7 +210,7 @@ void CommandDialog::init() {
// setup label // setup label
// we listen to motion notify too // we listen to motion notify too
m_label.setEventMask(m_label.eventMask() | ButtonPressMask | ButtonMotionMask); m_label.setEventMask(m_label.eventMask() | ButtonPressMask | ButtonMotionMask);
m_label.setGC(m_screen.winFrameTheme()->iconbarTheme().focusedText().textGC()); m_label.setGC(m_screen.winFrameTheme()->focusedIconbarTheme().text().textGC());
m_label.show(); m_label.show();
// setup text box // setup text box

View file

@ -563,19 +563,14 @@ void FbWinFrame::removeAllButtons() {
} }
} }
IconButton *FbWinFrame::createTab(Focusable &client) { void FbWinFrame::createTab(FbTk::Button &button) {
IconButton *button = new IconButton(m_tab_container, theme()->iconbarTheme(), button.show();
client); button.setEventMask(ExposureMask | ButtonPressMask |
ButtonReleaseMask | ButtonMotionMask |
EnterWindowMask);
FbTk::EventManager::instance()->add(button, button.window());
button->show(); m_tab_container.insertItem(&button);
button->setEventMask(ExposureMask | ButtonPressMask |
ButtonReleaseMask | ButtonMotionMask |
EnterWindowMask);
FbTk::EventManager::instance()->add(*button, button->window());
m_tab_container.insertItem(button);
return button;
} }
void FbWinFrame::removeTab(IconButton *btn) { void FbWinFrame::removeTab(IconButton *btn) {
@ -1140,11 +1135,11 @@ void FbWinFrame::renderTitlebar() {
//!! TODO: don't render label if internal tabs //!! TODO: don't render label if internal tabs
render(theme()->iconbarTheme()->focusedTexture(), m_label_focused_color, render(theme()->focusedIconbarTheme()->texture(), m_label_focused_color,
m_label_focused_pm, m_label_focused_pm,
m_label.width(), m_label.height()); m_label.width(), m_label.height());
render(theme()->iconbarTheme()->unfocusedTexture(), m_label_unfocused_color, render(theme()->unfocusedIconbarTheme()->texture(), m_label_unfocused_color,
m_label_unfocused_pm, m_label_unfocused_pm,
m_label.width(), m_label.height()); m_label.width(), m_label.height());
@ -1156,8 +1151,8 @@ void FbWinFrame::renderTabContainer() {
return; return;
} }
const FbTk::Texture *tc_focused = &theme()->iconbarTheme()->focusedTexture(); const FbTk::Texture *tc_focused = &theme()->focusedIconbarTheme()->texture();
const FbTk::Texture *tc_unfocused = &theme()->iconbarTheme()->unfocusedTexture(); const FbTk::Texture *tc_unfocused = &theme()->unfocusedIconbarTheme()->texture();
if (m_tabmode == EXTERNAL && tc_focused->type() & FbTk::Texture::PARENTRELATIVE) if (m_tabmode == EXTERNAL && tc_focused->type() & FbTk::Texture::PARENTRELATIVE)
tc_focused = &theme()->titleFocusTexture(); tc_focused = &theme()->titleFocusTexture();
@ -1192,11 +1187,11 @@ void FbWinFrame::applyTitlebar() {
if (m_tabmode != INTERNAL) { if (m_tabmode != INTERNAL) {
m_label.setGC(m_focused ? m_label.setGC(m_focused ?
theme()->iconbarTheme()->focusedText().textGC() : theme()->focusedIconbarTheme()->text().textGC() :
theme()->iconbarTheme()->unfocusedText().textGC()); theme()->unfocusedIconbarTheme()->text().textGC());
m_label.setJustify(m_focused ? m_label.setJustify(m_focused ?
theme()->iconbarTheme()->focusedText().justify() : theme()->focusedIconbarTheme()->text().justify() :
theme()->iconbarTheme()->unfocusedText().justify()); theme()->unfocusedIconbarTheme()->text().justify());
if (label_pm != 0) if (label_pm != 0)
m_label.setBackgroundPixmap(label_pm); m_label.setBackgroundPixmap(label_pm);

View file

@ -160,8 +160,8 @@ public:
void addRightButton(FbTk::Button *btn); void addRightButton(FbTk::Button *btn);
/// remove all buttons from titlebar /// remove all buttons from titlebar
void removeAllButtons(); void removeAllButtons();
/// adds a button to label window with specified title and command /// adds a button to tab container
IconButton *createTab(Focusable &client); void createTab(FbTk::Button &button);
/// removes a specific button from label window /// removes a specific button from label window
void removeTab(IconButton *id); void removeTab(IconButton *id);
/// move label button to the left /// move label button to the left
@ -253,7 +253,6 @@ public:
FbTk::FbWindow &gripLeft() { return m_grip_left; } FbTk::FbWindow &gripLeft() { return m_grip_left; }
const FbTk::FbWindow &gripRight() const { return m_grip_right; } const FbTk::FbWindow &gripRight() const { return m_grip_right; }
FbTk::FbWindow &gripRight() { return m_grip_right; } FbTk::FbWindow &gripRight() { return m_grip_right; }
const IconButton *currentLabel() const { return m_current_label; }
bool focused() const { return m_focused; } bool focused() const { return m_focused; }
bool isShaded() const { return m_shaded; } bool isShaded() const { return m_shaded; }
FbTk::ThemeProxy<FbWinFrameTheme> &theme() const { return m_theme; } FbTk::ThemeProxy<FbWinFrameTheme> &theme() const { return m_theme; }
@ -337,7 +336,6 @@ private:
ButtonList m_buttons_left, ///< buttons to the left ButtonList m_buttons_left, ///< buttons to the left
m_buttons_right; ///< buttons to the right m_buttons_right; ///< buttons to the right
typedef std::list<FbTk::TextButton *> LabelList; typedef std::list<FbTk::TextButton *> LabelList;
IconButton *m_current_label; ///< which client button is focused at the moment
int m_bevel; ///< bevel between titlebar items and titlebar int m_bevel; ///< bevel between titlebar items and titlebar
unsigned int m_decoration_mask; ///< bitmask of applied decorations unsigned int m_decoration_mask; ///< bitmask of applied decorations
bool m_use_titlebar; ///< if we should use titlebar bool m_use_titlebar; ///< if we should use titlebar

View file

@ -55,7 +55,10 @@ FbWinFrameTheme::FbWinFrameTheme(int screen_num):
m_button_pic_unfocus_gc(RootWindow(FbTk::App::instance()->display(), screen_num)), m_button_pic_unfocus_gc(RootWindow(FbTk::App::instance()->display(), screen_num)),
m_focused_alpha(255), m_focused_alpha(255),
m_unfocused_alpha(255), m_unfocused_alpha(255),
m_iconbar_theme(screen_num, "window.label", "Window.Label") { m_focused_iconbar_theme(screen_num, "window.label.focus",
"Window.Label.Unfocus"),
m_unfocused_iconbar_theme(screen_num, "window.label.unfocus",
"Window.Label.Unfocus") {
*m_title_height = 0; *m_title_height = 0;
// set defaults // set defaults
@ -111,6 +114,7 @@ void FbWinFrameTheme::reconfigTheme() {
m_button_pic_focus_gc.setForeground(*m_button_focus_color); m_button_pic_focus_gc.setForeground(*m_button_focus_color);
m_button_pic_unfocus_gc.setForeground(*m_button_unfocus_color); m_button_pic_unfocus_gc.setForeground(*m_button_unfocus_color);
m_iconbar_theme.reconfigTheme(); m_focused_iconbar_theme.reconfigTheme();
m_unfocused_iconbar_theme.reconfigTheme();
} }

View file

@ -92,7 +92,8 @@ public:
void setFocusedAlpha(unsigned char alpha) { m_focused_alpha = alpha; } void setFocusedAlpha(unsigned char alpha) { m_focused_alpha = alpha; }
void setUnfocusedAlpha(unsigned char alpha) { m_unfocused_alpha = alpha; } void setUnfocusedAlpha(unsigned char alpha) { m_unfocused_alpha = alpha; }
IconbarTheme &iconbarTheme() { return m_iconbar_theme; } IconbarTheme &focusedIconbarTheme() { return m_focused_iconbar_theme; }
IconbarTheme &unfocusedIconbarTheme() { return m_unfocused_iconbar_theme; }
virtual FbTk::Subject &reconfigSig() { return FbTk::Theme::reconfigSig(); } virtual FbTk::Subject &reconfigSig() { return FbTk::Theme::reconfigSig(); }
virtual const FbTk::Subject &reconfigSig() const { return FbTk::Theme::reconfigSig(); } virtual const FbTk::Subject &reconfigSig() const { return FbTk::Theme::reconfigSig(); }
@ -128,7 +129,7 @@ private:
unsigned char m_focused_alpha; unsigned char m_focused_alpha;
unsigned char m_unfocused_alpha; unsigned char m_unfocused_alpha;
IconbarTheme m_iconbar_theme; IconbarTheme m_focused_iconbar_theme, m_unfocused_iconbar_theme;
}; };
#endif // FBWINFRAMETHEME_HH #endif // FBWINFRAMETHEME_HH

71
src/FocusableTheme.hh Normal file
View file

@ -0,0 +1,71 @@
// FocusableTheme.hh
// Copyright (c) 2008 Fluxbox Team (fluxgen at fluxbox dot org)
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// 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.
#ifndef FOCUSABLETHEME_HH
#define FOCUSABLETHEME_HH
#include "Focusable.hh"
#include "FbTk/Observer.hh"
#include "FbTk/Theme.hh"
template <typename BaseTheme>
class FocusableTheme: public FbTk::ThemeProxy<BaseTheme>,
private FbTk::Observer {
public:
FocusableTheme(Focusable &win, FbTk::ThemeProxy<BaseTheme> &focused,
FbTk::ThemeProxy<BaseTheme> &unfocused):
m_win(win), m_focused_theme(focused), m_unfocused_theme(unfocused) {
m_win.focusSig().attach(this);
m_win.attentionSig().attach(this);
m_focused_theme.reconfigSig().attach(this);
m_unfocused_theme.reconfigSig().attach(this);
}
Focusable &win() { return m_win; }
const Focusable &win() const { return m_win; }
FbTk::ThemeProxy<BaseTheme> &focusedTheme() { return m_focused_theme; }
const FbTk::ThemeProxy<BaseTheme> &focusedTheme() const { return m_focused_theme; }
FbTk::ThemeProxy<BaseTheme> &unfocusedTheme() { return m_unfocused_theme; }
const FbTk::ThemeProxy<BaseTheme> &unfocusedTheme() const { return m_unfocused_theme; }
FbTk::Subject &reconfigSig() { return m_reconfig_sig; }
const FbTk::Subject &reconfigSig() const { return m_reconfig_sig; }
virtual BaseTheme &operator *() {
return (m_win.isFocused() || m_win.getAttentionState()) ?
*m_focused_theme : *m_unfocused_theme;
}
virtual const BaseTheme &operator *() const {
return (m_win.isFocused() || m_win.getAttentionState()) ?
*m_focused_theme : *m_unfocused_theme;
}
private:
void update(FbTk::Subject *subj) { m_reconfig_sig.notify(); }
Focusable &m_win;
FbTk::ThemeProxy<BaseTheme> &m_focused_theme, &m_unfocused_theme;
FbTk::Subject m_reconfig_sig;
};
#endif // FOCUSABLETHEME_HH

View file

@ -25,7 +25,6 @@
#include "IconbarTheme.hh" #include "IconbarTheme.hh"
#include "Screen.hh" #include "Screen.hh"
#include "Focusable.hh"
#include "FbTk/App.hh" #include "FbTk/App.hh"
#include "FbTk/Command.hh" #include "FbTk/Command.hh"
@ -47,15 +46,15 @@
IconButton::IconButton(const FbTk::FbWindow &parent, IconButton::IconButton(const FbTk::FbWindow &parent,
FbTk::ThemeProxy<IconbarTheme> &theme, Focusable &win): FbTk::ThemeProxy<IconbarTheme> &focused_theme,
FbTk::TextButton(parent, theme->focusedText().font(), win.title()), FbTk::ThemeProxy<IconbarTheme> &unfocused_theme, Focusable &win):
FbTk::TextButton(parent, focused_theme->text().font(), win.title()),
m_win(win), m_win(win),
m_icon_window(*this, 1, 1, 1, 1, m_icon_window(*this, 1, 1, 1, 1,
ExposureMask | ButtonPressMask | ButtonReleaseMask), ExposureMask | ButtonPressMask | ButtonReleaseMask),
m_use_pixmap(true), m_use_pixmap(true),
m_theme(theme), m_theme(win, focused_theme, unfocused_theme),
m_focused_pm(win.screen().imageControl()), m_pm(win.screen().imageControl()) {
m_unfocused_pm(win.screen().imageControl()) {
m_win.titleSig().attach(this); m_win.titleSig().attach(this);
m_win.focusSig().attach(this); m_win.focusSig().attach(this);
@ -118,47 +117,25 @@ void IconButton::setPixmap(bool use) {
void IconButton::reconfigTheme() { void IconButton::reconfigTheme() {
if (m_theme->focusedTexture().usePixmap()) if (m_theme->texture().usePixmap())
m_focused_pm.reset(m_win.screen().imageControl().renderImage( m_pm.reset(m_win.screen().imageControl().renderImage(
width(), height(), m_theme->focusedTexture(), width(), height(), m_theme->texture(),
orientation())); orientation()));
else else
m_focused_pm.reset(0); m_pm.reset(0);
if (m_theme->unfocusedTexture().usePixmap())
m_unfocused_pm.reset(m_win.screen().imageControl().renderImage(
width(), height(), m_theme->unfocusedTexture(),
orientation()));
else
m_unfocused_pm.reset(0);
setAlpha(parent()->alpha()); setAlpha(parent()->alpha());
if (m_win.isFocused() || m_win.getAttentionState()) { if (m_pm != 0)
if (m_focused_pm != 0) setBackgroundPixmap(m_pm);
setBackgroundPixmap(m_focused_pm); else
else setBackgroundColor(m_theme->texture().color());
setBackgroundColor(m_theme->focusedTexture().color());
setGC(m_theme->focusedText().textGC()); setGC(m_theme->text().textGC());
setFont(m_theme->focusedText().font()); setFont(m_theme->text().font());
setJustify(m_theme->focusedText().justify()); setJustify(m_theme->text().justify());
setBorderWidth(m_theme->focusedBorder().width()); setBorderWidth(m_theme->border().width());
setBorderColor(m_theme->focusedBorder().color()); setBorderColor(m_theme->border().color());
} else {
if (m_unfocused_pm != 0)
setBackgroundPixmap(m_unfocused_pm);
else
setBackgroundColor(m_theme->unfocusedTexture().color());
setGC(m_theme->unfocusedText().textGC());
setFont(m_theme->unfocusedText().font());
setJustify(m_theme->unfocusedText().justify());
setBorderWidth(m_theme->unfocusedBorder().width());
setBorderColor(m_theme->unfocusedBorder().color());
}
updateBackground(false); updateBackground(false);

View file

@ -23,12 +23,13 @@
#ifndef ICONBUTTON_HH #ifndef ICONBUTTON_HH
#define ICONBUTTON_HH #define ICONBUTTON_HH
#include "FocusableTheme.hh"
#include "FbTk/CachedPixmap.hh" #include "FbTk/CachedPixmap.hh"
#include "FbTk/FbPixmap.hh" #include "FbTk/FbPixmap.hh"
#include "FbTk/Observer.hh" #include "FbTk/Observer.hh"
#include "FbTk/TextButton.hh" #include "FbTk/TextButton.hh"
class Focusable;
class IconbarTheme; class IconbarTheme;
namespace FbTk { namespace FbTk {
@ -38,7 +39,9 @@ template <class T> class ThemeProxy;
class IconButton: public FbTk::TextButton, public FbTk::Observer { class IconButton: public FbTk::TextButton, public FbTk::Observer {
public: public:
IconButton(const FbTk::FbWindow &parent, IconButton(const FbTk::FbWindow &parent,
FbTk::ThemeProxy<IconbarTheme> &theme, Focusable &window); FbTk::ThemeProxy<IconbarTheme> &focused_theme,
FbTk::ThemeProxy<IconbarTheme> &unfocused_theme,
Focusable &window);
virtual ~IconButton(); virtual ~IconButton();
void exposeEvent(XExposeEvent &event); void exposeEvent(XExposeEvent &event);
@ -71,9 +74,9 @@ private:
FbTk::FbPixmap m_icon_mask; FbTk::FbPixmap m_icon_mask;
bool m_use_pixmap; bool m_use_pixmap;
FbTk::ThemeProxy<IconbarTheme> &m_theme; FocusableTheme<IconbarTheme> m_theme;
// cached pixmaps // cached pixmaps
FbTk::CachedPixmap m_focused_pm, m_unfocused_pm; FbTk::CachedPixmap m_pm;
}; };
#endif // ICONBUTTON_HH #endif // ICONBUTTON_HH

View file

@ -27,26 +27,10 @@ IconbarTheme::IconbarTheme(int screen_num,
const std::string &name, const std::string &name,
const std::string &altname): const std::string &altname):
FbTk::Theme(screen_num), FbTk::Theme(screen_num),
m_focused_texture(*this, m_texture(*this, name, altname),
name + (name == "window.label" ? ".focus" : ".focused"),
altname + (name == "window.label" ? ".Focus" : ".Focused")),
m_unfocused_texture(*this,
name + (name == "window.label" ? ".unfocus" : ".unfocused"),
altname + (name == "window.label" ? ".Unfocus" : ".Unfocused")),
m_empty_texture(*this, name + ".empty", altname + ".Empty"), m_empty_texture(*this, name + ".empty", altname + ".Empty"),
m_focused_border(*this,
name + (name == "window.label" ? ".focus" : ".focused"),
altname + (name == "window.label" ? ".Focus" : ".Focused")),
m_unfocused_border(*this,
name + (name == "window.label" ? ".unfocus" : ".unfocused"),
altname + (name == "window.label" ? ".Unfocus" : ".Unfocused")),
m_border(*this, name, altname), m_border(*this, name, altname),
m_focused_text(*this, m_text(*this, name, altname),
name + (name == "window.label" ? ".focus" : ".focused"),
altname + (name == "window.label" ? ".Focus" : ".Focused")),
m_unfocused_text(*this,
name + (name == "window.label" ? ".unfocus" : ".unfocused"),
altname + (name == "window.label" ? ".Unfocus" : ".Unfocused")),
m_name(name), m_altname(altname) { m_name(name), m_altname(altname) {
FbTk::ThemeManager::instance().loadTheme(*this); FbTk::ThemeManager::instance().loadTheme(*this);
@ -58,48 +42,46 @@ IconbarTheme::~IconbarTheme() {
void IconbarTheme::reconfigTheme() { void IconbarTheme::reconfigTheme() {
m_focused_text.updateTextColor(); m_text.updateTextColor();
m_unfocused_text.updateTextColor();
} }
// fallback resources // fallback resources
bool IconbarTheme::fallback(FbTk::ThemeItem_base &item) { bool IconbarTheme::fallback(FbTk::ThemeItem_base &item) {
using namespace FbTk; using namespace FbTk;
ThemeManager &tm = ThemeManager::instance(); ThemeManager &tm = ThemeManager::instance();
std::string focus = (m_name == "window.label" ? ".focus" : ".focused"); std::string base = m_name;
std::string un = (m_name == "window.label" ? ".unfocus" : ".unfocused"); base.erase(base.find_last_of("."));
std::string altbase = m_altname;
altbase.erase(altbase.find_last_of("."));
if (&m_focused_texture == &item || &m_unfocused_texture == &item) { if (&m_texture == &item) {
return tm.loadItem(item, "toolbar.windowLabel", "toolbar.windowLabel"); return tm.loadItem(item, "toolbar.windowLabel", "toolbar.windowLabel");
} else if (&m_empty_texture == &item) { } else if (&m_empty_texture == &item) {
return (tm.loadItem(item, m_focused_texture.name(), return (tm.loadItem(item, "toolbar.iconbar.empty",
m_focused_texture.altName()) || "Toolbar.Iconbar.Empty") ||
tm.loadItem(item, m_texture.name(), m_texture.altName()) ||
tm.loadItem(item, "toolbar.windowLabel", "toolbar.windowLabel") tm.loadItem(item, "toolbar.windowLabel", "toolbar.windowLabel")
|| tm.loadItem(item, "toolbar", "toolbar")); || tm.loadItem(item, "toolbar", "toolbar"));
} else if (item.name() == m_name + focus + ".borderWidth" || } else if (item.name() == m_name + ".borderWidth")
item.name() == m_name + un + ".borderWidth")
// don't fallback for base border, for theme backwards compatibility // don't fallback for base border, for theme backwards compatibility
return (tm.loadItem(item, m_name + ".borderWidth", return (tm.loadItem(item, base + ".borderWidth",
m_altname + ".BorderWidth") || altbase + ".BorderWidth") ||
tm.loadItem(item, "window.borderWidth", "Window.BorderWidth") || tm.loadItem(item, "window.borderWidth", "Window.BorderWidth") ||
tm.loadItem(item, "borderWidth", "BorderWidth")); tm.loadItem(item, "borderWidth", "BorderWidth"));
else if (item.name() == m_name + focus + ".borderColor" || else if (item.name() == m_name + ".borderColor")
item.name() == m_name + un + ".borderColor")
return (tm.loadItem(item, m_name + ".borderColor", return (tm.loadItem(item, base + ".borderColor",
m_altname + ".BorderColor") || altbase + ".BorderColor") ||
tm.loadItem(item, "window.borderColor", "Window.BorderColor") || tm.loadItem(item, "window.borderColor", "Window.BorderColor") ||
tm.loadItem(item, "borderColor", "BorderColor")); tm.loadItem(item, "borderColor", "BorderColor"));
else if (item.name() == m_name + focus + ".font" || else if (item.name() == m_name + ".font")
item.name() == m_name + un + ".font")
return tm.loadItem(item, "window.font", "Window.Font"); return tm.loadItem(item, "window.font", "Window.Font");
else if (item.name() == m_name + focus + ".justify" || else if (item.name() == m_name + ".justify") {
item.name() == m_name + un + ".justify") { return (tm.loadItem(item, base + ".justify", altbase + ".Justify")
return (tm.loadItem(item, m_name + ".justify", m_altname + ".Justify")
|| tm.loadItem(item, "window.justify", "Window.Justify")); || tm.loadItem(item, "window.justify", "Window.Justify"));
} }

View file

@ -36,15 +36,9 @@ public:
void reconfigTheme(); void reconfigTheme();
bool fallback(FbTk::ThemeItem_base &item); bool fallback(FbTk::ThemeItem_base &item);
FbTk::TextTheme &focusedText() { return m_focused_text; } FbTk::TextTheme &text() { return m_text; }
FbTk::TextTheme &unfocusedText() { return m_unfocused_text; }
const FbTk::BorderTheme &focusedBorder() const { return m_focused_border; }
const FbTk::BorderTheme &unfocusedBorder() const { return m_unfocused_border; }
const FbTk::BorderTheme &border() const { return m_border; } const FbTk::BorderTheme &border() const { return m_border; }
const FbTk::Texture &texture() const { return *m_texture; }
const FbTk::Texture &focusedTexture() const { return *m_focused_texture; }
const FbTk::Texture &unfocusedTexture() const { return *m_unfocused_texture; }
const FbTk::Texture &emptyTexture() const { return *m_empty_texture; } const FbTk::Texture &emptyTexture() const { return *m_empty_texture; }
virtual FbTk::Subject &reconfigSig() { return FbTk::Theme::reconfigSig(); } virtual FbTk::Subject &reconfigSig() { return FbTk::Theme::reconfigSig(); }
@ -54,9 +48,9 @@ public:
virtual const IconbarTheme &operator *() const { return *this; } virtual const IconbarTheme &operator *() const { return *this; }
private: private:
FbTk::ThemeItem<FbTk::Texture> m_focused_texture, m_unfocused_texture, m_empty_texture; FbTk::ThemeItem<FbTk::Texture> m_texture, m_empty_texture;
FbTk::BorderTheme m_focused_border, m_unfocused_border, m_border; FbTk::BorderTheme m_border;
FbTk::TextTheme m_focused_text, m_unfocused_text; FbTk::TextTheme m_text;
std::string m_name, m_altname; std::string m_name, m_altname;
}; };

View file

@ -253,12 +253,14 @@ private:
}; // end anonymous namespace }; // end anonymous namespace
IconbarTool::IconbarTool(const FbTk::FbWindow &parent, IconbarTool::IconbarTool(const FbTk::FbWindow &parent,
FbTk::ThemeProxy<IconbarTheme> &theme, FbTk::ThemeProxy<IconbarTheme> &focused_theme,
FbTk::ThemeProxy<IconbarTheme> &unfocused_theme,
BScreen &screen, FbTk::Menu &menu): BScreen &screen, FbTk::Menu &menu):
ToolbarItem(ToolbarItem::RELATIVE), ToolbarItem(ToolbarItem::RELATIVE),
m_screen(screen), m_screen(screen),
m_icon_container(parent), m_icon_container(parent),
m_theme(theme), m_focused_theme(focused_theme),
m_unfocused_theme(unfocused_theme),
m_empty_pm( screen.imageControl() ), m_empty_pm( screen.imageControl() ),
m_winlist(new FocusableList(screen)), m_winlist(new FocusableList(screen)),
m_mode("none"), m_mode("none"),
@ -297,7 +299,8 @@ IconbarTool::IconbarTool(const FbTk::FbWindow &parent,
menu.insert(m_menu.label(), &m_menu); menu.insert(m_menu.label(), &m_menu);
// setup signals // setup signals
theme.reconfigSig().attach(this); focused_theme.reconfigSig().attach(this);
unfocused_theme.reconfigSig().attach(this);
setMode(*m_rc_mode); setMode(*m_rc_mode);
} }
@ -402,7 +405,8 @@ void IconbarTool::update(FbTk::Subject *subj) {
m_icon_container.setMaxSizePerClient(*m_rc_client_width); m_icon_container.setMaxSizePerClient(*m_rc_client_width);
if (subj == &m_theme.reconfigSig()) { if (subj == &m_focused_theme.reconfigSig() ||
subj == &m_unfocused_theme.reconfigSig()) {
setMode(*m_rc_mode); setMode(*m_rc_mode);
return; return;
} }
@ -468,7 +472,7 @@ void IconbarTool::reset() {
} }
void IconbarTool::updateSizing() { void IconbarTool::updateSizing() {
m_icon_container.setBorderWidth(m_theme->border().width()); m_icon_container.setBorderWidth(m_focused_theme->border().width());
IconMap::iterator icon_it = m_icons.begin(); IconMap::iterator icon_it = m_icons.begin();
const IconMap::iterator icon_it_end = m_icons.end(); const IconMap::iterator icon_it_end = m_icons.end();
@ -489,14 +493,14 @@ void IconbarTool::renderTheme() {
updateSizing(); updateSizing();
// if we dont have any icons then we should render empty texture // if we dont have any icons then we should render empty texture
if (!m_theme->emptyTexture().usePixmap()) { if (!m_focused_theme->emptyTexture().usePixmap()) {
m_empty_pm.reset( 0 ); m_empty_pm.reset( 0 );
m_icon_container.setBackgroundColor(m_theme->emptyTexture().color()); m_icon_container.setBackgroundColor(m_focused_theme->emptyTexture().color());
} else { } else {
m_empty_pm.reset(m_screen.imageControl(). m_empty_pm.reset(m_screen.imageControl().
renderImage(m_icon_container.width(), renderImage(m_icon_container.width(),
m_icon_container.height(), m_icon_container.height(),
m_theme->emptyTexture(), orientation())); m_focused_theme->emptyTexture(), orientation()));
m_icon_container.setBackgroundPixmap(m_empty_pm); m_icon_container.setBackgroundPixmap(m_empty_pm);
} }
@ -548,7 +552,8 @@ IconButton *IconbarTool::makeButton(Focusable &win) {
#ifdef DEBUG #ifdef DEBUG
cerr<<"IconbarTool::addWindow(0x"<<&win<<" title = "<<win.title()<<")"<<endl; cerr<<"IconbarTool::addWindow(0x"<<&win<<" title = "<<win.title()<<")"<<endl;
#endif // DEBUG #endif // DEBUG
IconButton *button = new IconButton(m_icon_container, m_theme, win); IconButton *button = new IconButton(m_icon_container, m_focused_theme,
m_unfocused_theme, win);
RefCmd focus_cmd(new ::FocusCommand(win)); RefCmd focus_cmd(new ::FocusCommand(win));
RefCmd menu_cmd(new ::ShowMenu(*fbwin)); RefCmd menu_cmd(new ::ShowMenu(*fbwin));

View file

@ -44,7 +44,8 @@ public:
typedef std::map<Focusable *, IconButton *> IconMap; typedef std::map<Focusable *, IconButton *> IconMap;
IconbarTool(const FbTk::FbWindow &parent, IconbarTool(const FbTk::FbWindow &parent,
FbTk::ThemeProxy<IconbarTheme> &theme, FbTk::ThemeProxy<IconbarTheme> &focused_theme,
FbTk::ThemeProxy<IconbarTheme> &unfocused_theme,
BScreen &screen, FbTk::Menu &menu); BScreen &screen, FbTk::Menu &menu);
~IconbarTool(); ~IconbarTool();
@ -96,7 +97,7 @@ private:
BScreen &m_screen; BScreen &m_screen;
FbTk::Container m_icon_container; FbTk::Container m_icon_container;
FbTk::ThemeProxy<IconbarTheme> &m_theme; FbTk::ThemeProxy<IconbarTheme> &m_focused_theme, &m_unfocused_theme;
FbTk::CachedPixmap m_empty_pm; ///< pixmap for empty container FbTk::CachedPixmap m_empty_pm; ///< pixmap for empty container

View file

@ -141,7 +141,7 @@ fluxbox_SOURCES = AtomHandler.hh ArrowButton.hh ArrowButton.cc \
AttentionNoticeHandler.hh AttentionNoticeHandler.cc \ AttentionNoticeHandler.hh AttentionNoticeHandler.cc \
IconButton.hh IconButton.cc \ IconButton.hh IconButton.cc \
IconbarTheme.hh IconbarTheme.cc \ IconbarTheme.hh IconbarTheme.cc \
Focusable.hh FocusableList.hh FocusableList.cc \ Focusable.hh FocusableList.hh FocusableList.cc FocusableTheme.hh \
${newwmspec_SOURCE} ${gnome_SOURCE} \ ${newwmspec_SOURCE} ${gnome_SOURCE} \
${REMEMBER_SOURCE} ${TOOLBAR_SOURCE} ${REMEMBER_SOURCE} ${TOOLBAR_SOURCE}

View file

@ -1795,7 +1795,7 @@ void BScreen::showPosition(int x, int y) {
winFrameTheme()->font().drawText(m_pos_window, winFrameTheme()->font().drawText(m_pos_window,
screenNumber(), screenNumber(),
winFrameTheme()->iconbarTheme().focusedText().textGC(), winFrameTheme()->focusedIconbarTheme().text().textGC(),
label, strlen(label), label, strlen(label),
winFrameTheme()->bevelWidth(), winFrameTheme()->bevelWidth(),
winFrameTheme()->bevelWidth() + winFrameTheme()->bevelWidth() +
@ -1847,7 +1847,7 @@ void BScreen::showGeometry(int gx, int gy) {
//!! TODO: geom window again?! repeated //!! TODO: geom window again?! repeated
winFrameTheme()->font().drawText(m_geom_window, winFrameTheme()->font().drawText(m_geom_window,
screenNumber(), screenNumber(),
winFrameTheme()->iconbarTheme().focusedText().textGC(), winFrameTheme()->focusedIconbarTheme().text().textGC(),
label, strlen(label), label, strlen(label),
winFrameTheme()->bevelWidth(), winFrameTheme()->bevelWidth(),
winFrameTheme()->bevelWidth() + winFrameTheme()->bevelWidth() +
@ -1918,7 +1918,7 @@ void BScreen::renderGeomWindow() {
Pixmap tmp = geom_pixmap; Pixmap tmp = geom_pixmap;
if (winFrameTheme()->iconbarTheme().focusedTexture().type() & FbTk::Texture::PARENTRELATIVE) { if (winFrameTheme()->focusedIconbarTheme().texture().type() & FbTk::Texture::PARENTRELATIVE) {
if (!winFrameTheme()->titleFocusTexture().usePixmap()) { if (!winFrameTheme()->titleFocusTexture().usePixmap()) {
geom_pixmap = None; geom_pixmap = None;
m_geom_window.setBackgroundColor(winFrameTheme()->titleFocusTexture().color()); m_geom_window.setBackgroundColor(winFrameTheme()->titleFocusTexture().color());
@ -1928,12 +1928,12 @@ void BScreen::renderGeomWindow() {
m_geom_window.setBackgroundPixmap(geom_pixmap); m_geom_window.setBackgroundPixmap(geom_pixmap);
} }
} else { } else {
if (!winFrameTheme()->iconbarTheme().focusedTexture().usePixmap()) { if (!winFrameTheme()->focusedIconbarTheme().texture().usePixmap()) {
geom_pixmap = None; geom_pixmap = None;
m_geom_window.setBackgroundColor(winFrameTheme()->iconbarTheme().focusedTexture().color()); m_geom_window.setBackgroundColor(winFrameTheme()->focusedIconbarTheme().texture().color());
} else { } else {
geom_pixmap = imageControl().renderImage(m_geom_window.width(), m_geom_window.height(), geom_pixmap = imageControl().renderImage(m_geom_window.width(), m_geom_window.height(),
winFrameTheme()->iconbarTheme().focusedTexture()); winFrameTheme()->focusedIconbarTheme().texture());
m_geom_window.setBackgroundPixmap(geom_pixmap); m_geom_window.setBackgroundPixmap(geom_pixmap);
} }
} }
@ -1956,7 +1956,7 @@ void BScreen::renderPosWindow() {
Pixmap tmp = pos_pixmap; Pixmap tmp = pos_pixmap;
if (winFrameTheme()->iconbarTheme().focusedTexture().type() & FbTk::Texture::PARENTRELATIVE) { if (winFrameTheme()->focusedIconbarTheme().texture().type() & FbTk::Texture::PARENTRELATIVE) {
if (!winFrameTheme()->titleFocusTexture().usePixmap()) { if (!winFrameTheme()->titleFocusTexture().usePixmap()) {
pos_pixmap = None; pos_pixmap = None;
m_pos_window.setBackgroundColor(winFrameTheme()->titleFocusTexture().color()); m_pos_window.setBackgroundColor(winFrameTheme()->titleFocusTexture().color());
@ -1966,12 +1966,12 @@ void BScreen::renderPosWindow() {
m_pos_window.setBackgroundPixmap(pos_pixmap); m_pos_window.setBackgroundPixmap(pos_pixmap);
} }
} else { } else {
if (!winFrameTheme()->iconbarTheme().focusedTexture().usePixmap()) { if (!winFrameTheme()->focusedIconbarTheme().texture().usePixmap()) {
pos_pixmap = None; pos_pixmap = None;
m_pos_window.setBackgroundColor(winFrameTheme()->iconbarTheme().focusedTexture().color()); m_pos_window.setBackgroundColor(winFrameTheme()->focusedIconbarTheme().texture().color());
} else { } else {
pos_pixmap = imageControl().renderImage(m_pos_window.width(), m_pos_window.height(), pos_pixmap = imageControl().renderImage(m_pos_window.width(), m_pos_window.height(),
winFrameTheme()->iconbarTheme().focusedTexture()); winFrameTheme()->focusedIconbarTheme().texture());
m_pos_window.setBackgroundPixmap(pos_pixmap); m_pos_window.setBackgroundPixmap(pos_pixmap);
} }
} }

View file

@ -76,7 +76,8 @@ ToolFactory::ToolFactory(BScreen &screen):m_screen(screen),
m_workspace_theme(new WorkspaceNameTheme(screen.screenNumber(), "toolbar.workspace", "Toolbar.Workspace")), m_workspace_theme(new WorkspaceNameTheme(screen.screenNumber(), "toolbar.workspace", "Toolbar.Workspace")),
m_systray_theme(new ButtonTheme(screen.screenNumber(), "toolbar.systray", "Toolbar.Systray", m_systray_theme(new ButtonTheme(screen.screenNumber(), "toolbar.systray", "Toolbar.Systray",
"toolbar.clock", "Toolbar.Systray")), "toolbar.clock", "Toolbar.Systray")),
m_iconbar_theme(screen.screenNumber(), "toolbar.iconbar", "Toolbar.Iconbar") { m_focused_iconbar_theme(screen.screenNumber(), "toolbar.iconbar.focused", "Toolbar.Iconbar.Focused"),
m_unfocused_iconbar_theme(screen.screenNumber(), "toolbar.iconbar.unfocused", "Toolbar.Iconbar.Unfocused") {
} }
@ -95,7 +96,7 @@ ToolbarItem *ToolFactory::create(const std::string &name, const FbTk::FbWindow &
witem->button().setOnClick(showmenu); witem->button().setOnClick(showmenu);
item = witem; item = witem;
} else if (name == "iconbar") { } else if (name == "iconbar") {
item = new IconbarTool(parent, m_iconbar_theme, screen(), tbar.menu()); item = new IconbarTool(parent, m_focused_iconbar_theme, m_unfocused_iconbar_theme, screen(), tbar.menu());
} else if (name == "systemtray") { } else if (name == "systemtray") {
item = new SystemTray(parent, dynamic_cast<ButtonTheme &>(*m_systray_theme), screen()); item = new SystemTray(parent, dynamic_cast<ButtonTheme &>(*m_systray_theme), screen());
} else if (name == "clock") { } else if (name == "clock") {
@ -149,7 +150,8 @@ ToolbarItem *ToolFactory::create(const std::string &name, const FbTk::FbWindow &
void ToolFactory::updateThemes() { void ToolFactory::updateThemes() {
m_clock_theme.reconfigTheme(); m_clock_theme.reconfigTheme();
m_iconbar_theme.reconfigTheme(); m_focused_iconbar_theme.reconfigTheme();
m_unfocused_iconbar_theme.reconfigTheme();
m_button_theme->reconfigTheme(); m_button_theme->reconfigTheme();
m_workspace_theme->reconfigTheme(); m_workspace_theme->reconfigTheme();
} }
@ -160,11 +162,11 @@ int ToolFactory::maxFontHeight() {
if (max_height < m_clock_theme.font().height()) if (max_height < m_clock_theme.font().height())
max_height = m_clock_theme.font().height(); max_height = m_clock_theme.font().height();
if (max_height < m_iconbar_theme.focusedText().font().height()) if (max_height < m_focused_iconbar_theme.text().font().height())
max_height = m_iconbar_theme.focusedText().font().height(); max_height = m_focused_iconbar_theme.text().font().height();
if (max_height < m_iconbar_theme.unfocusedText().font().height()) if (max_height < m_unfocused_iconbar_theme.text().font().height())
max_height = m_iconbar_theme.unfocusedText().font().height(); max_height = m_unfocused_iconbar_theme.text().font().height();
if (max_height < m_workspace_theme->font().height()) if (max_height < m_workspace_theme->font().height())
max_height = m_workspace_theme->font().height(); max_height = m_workspace_theme->font().height();

View file

@ -55,7 +55,7 @@ private:
std::auto_ptr<ToolTheme> m_button_theme; std::auto_ptr<ToolTheme> m_button_theme;
std::auto_ptr<ToolTheme> m_workspace_theme; std::auto_ptr<ToolTheme> m_workspace_theme;
std::auto_ptr<ToolTheme> m_systray_theme; std::auto_ptr<ToolTheme> m_systray_theme;
IconbarTheme m_iconbar_theme; IconbarTheme m_focused_iconbar_theme, m_unfocused_iconbar_theme;
}; };
#endif // TOOLFACTORY_HH #endif // TOOLFACTORY_HH

View file

@ -4128,8 +4128,11 @@ void FluxboxWindow::ungrabPointer(Time time) {
} }
void FluxboxWindow::associateClient(WinClient &client) { void FluxboxWindow::associateClient(WinClient &client) {
IconButton *btn = new IconButton(frame().tabcontainer(),
IconButton *btn = frame().createTab(client); frame().theme()->focusedIconbarTheme(),
frame().theme()->unfocusedIconbarTheme(),
client);
frame().createTab(*btn);
FbTk::RefCount<FbTk::Command> setcmd(new SetClientCmd(client)); FbTk::RefCount<FbTk::Command> setcmd(new SetClientCmd(client));
btn->setOnClick(setcmd, 1); btn->setOnClick(setcmd, 1);