From 416578138e899f817b875ad55a5252a19aa6cb07 Mon Sep 17 00:00:00 2001 From: markt Date: Fri, 6 Apr 2007 18:50:19 +0000 Subject: more of the same --- ChangeLog | 10 +++++++ src/FbWinFrame.cc | 68 +++++++++-------------------------------------- src/FbWinFrame.hh | 2 -- src/FbWinFrameTheme.cc | 1 - src/FbWinFrameTheme.hh | 3 --- src/IconButton.cc | 46 +++++++++++++++++++++----------- src/IconButton.hh | 3 +-- src/IconbarTheme.cc | 28 ++++++++++++++------ src/IconbarTool.cc | 72 +++++++++++--------------------------------------- src/IconbarTool.hh | 4 +-- 10 files changed, 90 insertions(+), 147 deletions(-) diff --git a/ChangeLog b/ChangeLog index 36fe570..2ad2e61 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,15 @@ (Format: Year/Month/Day) Changes for 1.1: +*07/04/06: + * More changes to theme handling (Mark) + - introduced window.label.(un)focused.{justify,border{Color,Width}}, + which fallback to window.label.{justify,border{Color,Width}} before + window.{justify,border{Color,Width}} + - this has the backwards-incompatible effect that + toolbar.iconbar.(un)focused.* fallback first to toolbar.iconbar.* and + then to window.label.* + FbWinFrame.cc/hh IconbarTool.cc/hh IconButton.cc/hh IconbarTheme.cc + FbWinFrameTheme.cc/hh *07/04/03: * Added window.label.(un)focused.font to styles (Mark) FbWinFrame.cc diff --git a/src/FbWinFrame.cc b/src/FbWinFrame.cc index cbfd0f8..bf1ab42 100644 --- a/src/FbWinFrame.cc +++ b/src/FbWinFrame.cc @@ -522,12 +522,8 @@ void FbWinFrame::setFocus(bool newvalue) { } } - if (currentLabel()) { - if (newvalue) // focused - applyFocusLabel(*m_current_label); - else // unfocused - applyUnfocusLabel(*m_current_label); - } + if (currentLabel()) + m_current_label->reconfigTheme(); applyAll(); clearAll(); @@ -630,7 +626,7 @@ IconButton *FbWinFrame::createTab(Focusable &client) { EnterWindowMask); FbTk::EventManager::instance()->add(*button, button->window()); - button->setJustify(theme().justify()); + button->setJustify(theme().iconbarTheme().unfocusedText().justify()); button->setBorderColor(theme().border().color()); button->setBorderWidth(m_window.borderWidth()); @@ -698,26 +694,18 @@ void FbWinFrame::setLabelButtonFocus(IconButton &btn) { // render label buttons if (currentLabel() != 0) - applyUnfocusLabel(*m_current_label); + m_current_label->reconfigTheme(); m_current_label = &btn; // current focused button m_label.setText(btn.text()); - - if (m_focused) - applyFocusLabel(*m_current_label); - else - applyUnfocusLabel(*m_current_label); + btn.reconfigTheme(); } void FbWinFrame::setLabelButtonFocus(IconButton &btn, bool value) { if (btn.parent() != &m_tab_container) return; - if (value) - applyFocusLabel(btn); - else - applyUnfocusLabel(btn); - + btn.reconfigTheme(); btn.clear(); } @@ -1326,8 +1314,12 @@ void FbWinFrame::applyTitlebar() { m_label.setAlpha(alpha); if (m_tabmode != INTERNAL) { - m_label.setGC(m_focused?theme().iconbarTheme().focusedText().textGC():theme().iconbarTheme().unfocusedText().textGC()); - m_label.setJustify(theme().justify()); + m_label.setGC(m_focused ? + theme().iconbarTheme().focusedText().textGC() : + theme().iconbarTheme().unfocusedText().textGC()); + m_label.setJustify(m_focused ? + theme().iconbarTheme().focusedText().justify() : + theme().iconbarTheme().unfocusedText().justify()); if (label_pm != 0) m_label.setBackgroundPixmap(label_pm); @@ -1579,10 +1571,7 @@ void FbWinFrame::applyTabContainer() { Container::ItemList::iterator btn_it_end = m_tab_container.end(); for (; btn_it != btn_it_end; ++btn_it) { IconButton *btn = static_cast(*btn_it); - if (btn == m_current_label && m_focused) - applyFocusLabel(*btn); - else - applyUnfocusLabel(*btn); + btn->reconfigTheme(); } } @@ -1618,15 +1607,6 @@ void FbWinFrame::setBorderWidth(unsigned int border_width) { gripRight().setBorderWidth(border_width); gripRight().setBorderColor(theme().border().color()); - // and the labelbuttons - Container::ItemList::iterator btn_it = m_tab_container.begin(); - Container::ItemList::iterator btn_it_end = m_tab_container.end(); - for (; btn_it != btn_it_end; ++btn_it) { - (*btn_it)->setBorderWidth(border_width); - (*btn_it)->setBorderColor(theme().border().color()); - } - m_tab_container.update(); - if (bw_changes != 0) resize(width(), height() + bw_changes); @@ -1640,28 +1620,6 @@ void FbWinFrame::setBorderWidth(unsigned int border_width) { } -void FbWinFrame::applyFocusLabel(IconButton &button) { - - button.setGC(theme().iconbarTheme().focusedText().textGC()); - button.setFont(theme().iconbarTheme().focusedText().font()); - button.setJustify(theme().justify()); - button.setAlpha(getAlpha(m_focused)); - button.renderTextures(); - button.updateBackground(); - -} - -void FbWinFrame::applyUnfocusLabel(IconButton &button) { - - button.setGC(theme().iconbarTheme().unfocusedText().textGC()); - button.setFont(theme().iconbarTheme().unfocusedText().font()); - button.setJustify(theme().justify()); - button.setAlpha(getAlpha(m_focused)); - button.renderTextures(); - button.updateBackground(); - -} - // this function translates its arguments according to win_gravity // if win_gravity is negative, it does an inverse translation // This function should be used when a window is mapped/unmapped/pos configured diff --git a/src/FbWinFrame.hh b/src/FbWinFrame.hh index 503317a..35e4bd8 100644 --- a/src/FbWinFrame.hh +++ b/src/FbWinFrame.hh @@ -279,8 +279,6 @@ private: void applyTitlebar(); void applyHandles(); void applyTabContainer(); // and label buttons - void applyFocusLabel(IconButton &button); - void applyUnfocusLabel(IconButton &button); void applyButtons(); // only called within applyTitlebar void getCurrentFocusPixmap(Pixmap &label_pm, Pixmap &title_pm, diff --git a/src/FbWinFrameTheme.cc b/src/FbWinFrameTheme.cc index 949beaa..6f7f9ef 100644 --- a/src/FbWinFrameTheme.cc +++ b/src/FbWinFrameTheme.cc @@ -47,7 +47,6 @@ FbWinFrameTheme::FbWinFrameTheme(int screen_num): m_button_unfocus_color(*this, "window.button.unfocus.picColor", "Window.Button.Unfocus.PicColor"), m_font(*this, "window.font", "Window.Font"), - m_textjustify(*this, "window.justify", "Window.Justify"), m_shape_place(*this, "window.roundCorners", "Window.RoundCorners"), m_title_height(*this, "window.title.height", "Window.Title.Height"), m_bevel_width(*this, "window.bevelWidth", "Window.BevelWidth"), diff --git a/src/FbWinFrameTheme.hh b/src/FbWinFrameTheme.hh index 526bd3b..04d6ee4 100644 --- a/src/FbWinFrameTheme.hh +++ b/src/FbWinFrameTheme.hh @@ -67,8 +67,6 @@ public: //@} FbTk::Font &font() { return *m_font; } - FbTk::Justify justify() const { return *m_textjustify; } - GC buttonPicFocusGC() const { return m_button_pic_focus_gc.gc(); } GC buttonPicUnfocusGC() const { return m_button_pic_unfocus_gc.gc(); } @@ -104,7 +102,6 @@ private: FbTk::ThemeItem m_button_focus_color, m_button_unfocus_color; FbTk::ThemeItem m_font; - FbTk::ThemeItem m_textjustify; FbTk::ThemeItem m_shape_place; FbTk::ThemeItem m_title_height, m_bevel_width, m_handle_width; diff --git a/src/IconButton.cc b/src/IconButton.cc index 8830b93..5cb47d1 100644 --- a/src/IconButton.cc +++ b/src/IconButton.cc @@ -115,22 +115,7 @@ void IconButton::setPixmap(bool use) { } } -void IconButton::updateBackground() { - // TODO: this ignores attention state, which isn't in Focusable.hh yet - if (m_win.isFocused()) { - if (m_focused_pm != 0) - setBackgroundPixmap(m_focused_pm); - else - setBackgroundColor(m_theme.focusedTexture().color()); - } else { - if (m_unfocused_pm != 0) - setBackgroundPixmap(m_unfocused_pm); - else - setBackgroundColor(m_theme.unfocusedTexture().color()); - } -} - -void IconButton::renderTextures() { +void IconButton::reconfigTheme() { if (m_theme.focusedTexture().usePixmap()) m_focused_pm.reset(m_win.screen().imageControl().renderImage( @@ -146,6 +131,35 @@ void IconButton::renderTextures() { else m_unfocused_pm.reset( 0 ); + setAlpha(parent()->alpha()); + + // TODO: this ignores attention state, which isn't in Focusable.hh yet + if (m_win.isFocused()) { + if (m_focused_pm != 0) + setBackgroundPixmap(m_focused_pm); + else + setBackgroundColor(m_theme.focusedTexture().color()); + + setGC(m_theme.focusedText().textGC()); + setFont(m_theme.focusedText().font()); + setJustify(m_theme.focusedText().justify()); + setBorderWidth(m_theme.focusedBorder().width()); + setBorderColor(m_theme.focusedBorder().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()); + + } + } void IconButton::update(FbTk::Subject *subj) { diff --git a/src/IconButton.hh b/src/IconButton.hh index 2c48bff..dc8203b 100644 --- a/src/IconButton.hh +++ b/src/IconButton.hh @@ -48,8 +48,7 @@ public: unsigned int width, unsigned int height); void resize(unsigned int width, unsigned int height); - void renderTextures(); - void updateBackground(); + void reconfigTheme(); void update(FbTk::Subject *subj); void setPixmap(bool use); diff --git a/src/IconbarTheme.cc b/src/IconbarTheme.cc index 1f25ac3..2ee8360 100644 --- a/src/IconbarTheme.cc +++ b/src/IconbarTheme.cc @@ -63,22 +63,30 @@ bool IconbarTheme::fallback(FbTk::ThemeItem_base &item) { 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")); + 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") - ); + 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 + ".focused.borderWidth" || item.name() == m_name + ".unfocused.borderWidth") // don't fallback for base border, for theme backwards compatibility - return tm.loadItem(item, "borderWidth", "BorderWidth"); + return (tm.loadItem(item, m_name + ".borderWidth", + m_altname + ".BorderWidth") || + tm.loadItem(item, "window.borderWidth", "Window.BorderWidth") || + tm.loadItem(item, "borderWidth", "BorderWidth")); else if (item.name() == m_name + ".focused.borderColor" || item.name() == m_name + ".unfocused.borderColor") - return tm.loadItem(item, "borderColor", "BorderColor"); + return (tm.loadItem(item, m_name + ".borderColor", + m_altname + ".BorderColor") || + tm.loadItem(item, "window.borderColor", "Window.BorderColor") || + tm.loadItem(item, "borderColor", "BorderColor")); else if (item.name() == m_name + ".focused.font" || item.name() == m_name + ".unfocused.font") @@ -91,6 +99,10 @@ bool IconbarTheme::fallback(FbTk::ThemeItem_base &item) { } else if (item.name() == m_name + ".unfocused.textColor") { return tm.loadItem(item, "window.label.unfocus.textColor", "Window.Label.Unfocus.TextColor"); + } else if (item.name() == m_name + ".focused.justify" || + item.name() == m_name + ".unfocused.justify") { + return (tm.loadItem(item, m_name + ".justify", m_altname + ".Justify") + || tm.loadItem(item, "window.justify", "Window.Justify")); } return false; diff --git a/src/IconbarTool.cc b/src/IconbarTool.cc index ef99c9a..4ba3a44 100644 --- a/src/IconbarTool.cc +++ b/src/IconbarTool.cc @@ -582,10 +582,8 @@ void IconbarTool::update(FbTk::Subject *subj) { } else if (subj == &(winsubj->win().attentionSig())) { // render with titlebar focus, on attention IconButton *button = findButton(winsubj->win()); - if (button) { - renderButton(*button, true, - winsubj->win().getAttentionState()); - } + if (button) + renderButton(*button, true); return; } else { // signal not handled @@ -657,12 +655,8 @@ void IconbarTool::updateSizing() { IconList::iterator icon_it = m_icon_list.begin(); const IconList::iterator icon_it_end = m_icon_list.end(); - for (; icon_it != icon_it_end; ++icon_it) { - if ((*icon_it)->win().isFocused()) - (*icon_it)->setBorderWidth(m_theme.focusedBorder().width()); - else // unfocused - (*icon_it)->setBorderWidth(m_theme.unfocusedBorder().width()); - } + for (; icon_it != icon_it_end; ++icon_it) + (*icon_it)->reconfigTheme(); } @@ -677,79 +671,43 @@ void IconbarTool::renderTheme() { // update button sizes before we get max width per client! updateSizing(); - unsigned int icon_width = 0, icon_height = 0; - unsigned int icon_width_off=0, icon_height_off=0; - - if (orientation() == FbTk::ROT0 || orientation() == FbTk::ROT180) { - icon_width = m_icon_container.maxWidthPerClient(); - icon_height = m_icon_container.height(); - icon_width_off = 1; - } else { - icon_width = m_icon_container.width(); - icon_height = m_icon_container.maxWidthPerClient(); - icon_height_off = 1; - } - // if we dont have any icons then we should render empty texture if (!m_theme.emptyTexture().usePixmap()) { m_empty_pm.reset( 0 ); m_icon_container.setBackgroundColor(m_theme.emptyTexture().color()); } else { - m_empty_pm.reset( m_screen.imageControl(). - renderImage(m_icon_container.width(), m_icon_container.height(), - m_theme.emptyTexture(), orientation()) ); + m_empty_pm.reset(m_screen.imageControl(). + renderImage(m_icon_container.width(), + m_icon_container.height(), + m_theme.emptyTexture(), orientation())); m_icon_container.setBackgroundPixmap(m_empty_pm); } - // set to zero so its consistent and not ugly - m_icon_container.setBorderWidth(m_theme.border().width()); - m_icon_container.setBorderColor(m_theme.border().color()); m_icon_container.setAlpha(m_alpha); // update buttons IconList::iterator icon_it = m_icon_list.begin(); const IconList::iterator icon_it_end = m_icon_list.end(); - for (; icon_it != icon_it_end; ++icon_it) { + for (; icon_it != icon_it_end; ++icon_it) renderButton(*(*icon_it)); - } + } -void IconbarTool::renderButton(IconButton &button, bool clear, - int focusOption) { +void IconbarTool::renderButton(IconButton &button, bool clear) { - button.renderTextures(); button.setPixmap(*m_rc_use_pixmap); - button.setAlpha(m_alpha); button.setTextPadding(*m_rc_client_padding); - if (focusOption == 1 || - (focusOption == -1 && - button.win().isFocused())) { + if (button.win().isFocused()) { // focused texture if (button.win().isFocused()) m_icon_container.setSelected(m_icon_container.find(&button)); - button.setGC(m_theme.focusedText().textGC()); - button.setFont(m_theme.focusedText().font()); - button.setJustify(m_theme.focusedText().justify()); - button.setBorderWidth(m_theme.focusedBorder().width()); - button.setBorderColor(m_theme.focusedBorder().color()); - button.updateBackground(); - - } else { // unfocused - if (m_icon_container.selected() == &button) - m_icon_container.setSelected(-1); - - button.setGC(m_theme.unfocusedText().textGC()); - button.setFont(m_theme.unfocusedText().font()); - button.setJustify(m_theme.unfocusedText().justify()); - button.setBorderWidth(m_theme.unfocusedBorder().width()); - button.setBorderColor(m_theme.unfocusedBorder().color()); - button.updateBackground(); - - } + } else if (m_icon_container.selected() == &button) + m_icon_container.setSelected(-1); + button.reconfigTheme(); if (clear) button.clear(); // the clear also updates transparent } diff --git a/src/IconbarTool.hh b/src/IconbarTool.hh index d7a9c09..d218b91 100644 --- a/src/IconbarTool.hh +++ b/src/IconbarTool.hh @@ -100,9 +100,7 @@ private: /// render single button, and probably apply changes (clear) /// @param button the button to render /// @param clear if the window should be cleared first - /// @param focusOption -1 = use window focus, 0 = render no focus, 1 = render focus - void renderButton(IconButton &button, bool clear = true, - int focusOption = -1); + void renderButton(IconButton &button, bool clear = true); /// render all buttons void renderTheme(); void renderTheme(unsigned char alpha); -- cgit v0.11.2