From ea184b3566bfee3f720763edf4e11cd27e9cd1d0 Mon Sep 17 00:00:00 2001 From: rathnor Date: Tue, 23 Dec 2003 01:55:07 +0000 Subject: fix rendering of icon buttons when they are slightly larger because of rounding --- ChangeLog | 3 +++ src/Container.hh | 4 +++- src/IconbarTool.cc | 46 ++++++++++++++++++++++++++++++++++++++-------- src/IconbarTool.hh | 4 +++- 4 files changed, 47 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1bde984..a9ca978 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,9 @@ (Format: Year/Month/Day) Changes for 0.9.7: *03/12/22: + * Fix rendering of icon buttons when larger from rounding (Simon) + Container.hh IconbarTool.hh/cc +*03/12/22: * Added Lock Screen to fluxbox-generate_menu (Thanks Han) *03/12/21: * Fix rounding on Iconbar (Simon) diff --git a/src/Container.hh b/src/Container.hh index f620d3a..6880aa3 100644 --- a/src/Container.hh +++ b/src/Container.hh @@ -20,7 +20,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Container.hh,v 1.4 2003/12/12 14:35:34 fluxgen Exp $ +// $Id: Container.hh,v 1.5 2003/12/23 01:55:07 rathnor Exp $ #ifndef CONTAINER_HH #define CONTAINER_HH @@ -55,6 +55,8 @@ public: void setMaxSizePerClient(unsigned int size); void setAlignment(Alignment a); + Item back() { return m_item_list.back(); } + /// force update inline void update() { repositionItems(); } /// so we can add items without having an graphic update for each item diff --git a/src/IconbarTool.cc b/src/IconbarTool.cc index 8602a2b..13143d0 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.24 2003/12/19 14:58:48 fluxgen Exp $ +// $Id: IconbarTool.cc,v 1.25 2003/12/23 01:55:07 rathnor Exp $ #include "IconbarTool.hh" @@ -237,6 +237,8 @@ IconbarTool::IconbarTool(const FbTk::FbWindow &parent, IconbarTheme &theme, BScr m_theme(theme), m_focused_pm(0), m_unfocused_pm(0), + m_focused_err_pm(0), + m_unfocused_err_pm(0), m_empty_pm(0), m_rc_mode(screen.resourceManager(), WORKSPACE, screen.name() + ".iconbar.mode", screen.altName() + ".Iconbar.Mode"), @@ -292,7 +294,11 @@ IconbarTool::~IconbarTool() { if (m_focused_pm) m_screen.imageControl().removeImage(m_focused_pm); if (m_unfocused_pm) - m_screen.imageControl().removeImage(m_focused_pm); + m_screen.imageControl().removeImage(m_unfocused_pm); + if (m_focused_err_pm) + m_screen.imageControl().removeImage(m_focused_err_pm); + if (m_unfocused_err_pm) + m_screen.imageControl().removeImage(m_unfocused_err_pm); if (m_empty_pm) m_screen.imageControl().removeImage(m_empty_pm); @@ -510,27 +516,43 @@ void IconbarTool::renderWindow(FluxboxWindow &win) { void IconbarTool::renderTheme() { Pixmap tmp = m_focused_pm; + Pixmap err_tmp = m_focused_err_pm; + unsigned int icon_width = m_icon_container.maxWidthPerClient(); if (!m_theme.focusedTexture().usePixmap()) { - m_focused_pm = 0; + m_focused_pm = 0; + m_focused_err_pm = 0; } else { - m_focused_pm = m_screen.imageControl().renderImage(m_icon_container.maxWidthPerClient(), + m_focused_pm = m_screen.imageControl().renderImage(icon_width, + m_icon_container.height(), + m_theme.focusedTexture()); + m_focused_err_pm = m_screen.imageControl().renderImage(icon_width+1, m_icon_container.height(), m_theme.focusedTexture()); } if (tmp) m_screen.imageControl().removeImage(tmp); + if (err_tmp) + m_screen.imageControl().removeImage(err_tmp); tmp = m_unfocused_pm; + err_tmp = m_unfocused_err_pm; + if (!m_theme.unfocusedTexture().usePixmap()) { - m_unfocused_pm = 0; + m_unfocused_pm = 0; + m_unfocused_err_pm = 0; } else { - m_unfocused_pm = m_screen.imageControl().renderImage(m_icon_container.maxWidthPerClient(), + m_unfocused_pm = m_screen.imageControl().renderImage(icon_width, + m_icon_container.height(), + m_theme.unfocusedTexture()); + m_unfocused_err_pm = m_screen.imageControl().renderImage(icon_width+1, m_icon_container.height(), m_theme.unfocusedTexture()); } if (tmp) m_screen.imageControl().removeImage(tmp); + if (err_tmp) + m_screen.imageControl().removeImage(err_tmp); // if we dont have any icons then we should render empty texture tmp = m_empty_pm; @@ -561,14 +583,20 @@ void IconbarTool::renderButton(IconButton &button) { button.setPixmap(*m_rc_use_pixmap); + // 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()); + if (button.win().isFocused()) { // focused texture 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()); - if (m_focused_pm != 0) + if (!wider_button && m_focused_pm != 0) button.setBackgroundPixmap(m_focused_pm); + else if (wider_button && m_focused_err_pm != 0) + button.setBackgroundPixmap(m_focused_err_pm); else button.setBackgroundColor(m_theme.focusedTexture().color()); @@ -583,8 +611,10 @@ void IconbarTool::renderButton(IconButton &button) { button.setFont(m_theme.unfocusedText().font()); button.setJustify(m_theme.unfocusedText().justify()); - if (m_unfocused_pm != 0) + if (!wider_button && m_unfocused_pm != 0) button.setBackgroundPixmap(m_unfocused_pm); + else if (wider_button && m_unfocused_err_pm != 0) + button.setBackgroundPixmap(m_unfocused_err_pm); else button.setBackgroundColor(m_theme.unfocusedTexture().color()); diff --git a/src/IconbarTool.hh b/src/IconbarTool.hh index 0f2574e..bfcac34 100644 --- a/src/IconbarTool.hh +++ b/src/IconbarTool.hh @@ -20,7 +20,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: IconbarTool.hh,v 1.12 2003/12/19 14:57:44 fluxgen Exp $ +// $Id: IconbarTool.hh,v 1.13 2003/12/23 01:55:07 rathnor Exp $ #ifndef ICONBARTOOL_HH #define ICONBARTOOL_HH @@ -107,6 +107,8 @@ private: const IconbarTheme &m_theme; // cached pixmaps Pixmap m_focused_pm, m_unfocused_pm; + // some are a fraction bigger due to rounding + Pixmap m_focused_err_pm, m_unfocused_err_pm; Pixmap m_empty_pm; ///< pixmap for empty container -- cgit v0.11.2