diff options
author | rathnor <rathnor> | 2003-12-23 01:55:07 (GMT) |
---|---|---|
committer | rathnor <rathnor> | 2003-12-23 01:55:07 (GMT) |
commit | ea184b3566bfee3f720763edf4e11cd27e9cd1d0 (patch) | |
tree | 193bb9f6fc150ed128b5a5b8fa008d1c05432ad9 | |
parent | 3e41157a3532537a859cbbeb2d6adf367de25f96 (diff) | |
download | fluxbox-ea184b3566bfee3f720763edf4e11cd27e9cd1d0.zip fluxbox-ea184b3566bfee3f720763edf4e11cd27e9cd1d0.tar.bz2 |
fix rendering of icon buttons when they are slightly larger because of
rounding
-rw-r--r-- | ChangeLog | 3 | ||||
-rw-r--r-- | src/Container.hh | 4 | ||||
-rw-r--r-- | src/IconbarTool.cc | 46 | ||||
-rw-r--r-- | src/IconbarTool.hh | 4 |
4 files changed, 47 insertions, 10 deletions
@@ -1,6 +1,9 @@ | |||
1 | (Format: Year/Month/Day) | 1 | (Format: Year/Month/Day) |
2 | Changes for 0.9.7: | 2 | Changes for 0.9.7: |
3 | *03/12/22: | 3 | *03/12/22: |
4 | * Fix rendering of icon buttons when larger from rounding (Simon) | ||
5 | Container.hh IconbarTool.hh/cc | ||
6 | *03/12/22: | ||
4 | * Added Lock Screen to fluxbox-generate_menu (Thanks Han) | 7 | * Added Lock Screen to fluxbox-generate_menu (Thanks Han) |
5 | *03/12/21: | 8 | *03/12/21: |
6 | * Fix rounding on Iconbar (Simon) | 9 | * 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 @@ | |||
20 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | 20 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
21 | // DEALINGS IN THE SOFTWARE. | 21 | // DEALINGS IN THE SOFTWARE. |
22 | 22 | ||
23 | // $Id: Container.hh,v 1.4 2003/12/12 14:35:34 fluxgen Exp $ | 23 | // $Id: Container.hh,v 1.5 2003/12/23 01:55:07 rathnor Exp $ |
24 | 24 | ||
25 | #ifndef CONTAINER_HH | 25 | #ifndef CONTAINER_HH |
26 | #define CONTAINER_HH | 26 | #define CONTAINER_HH |
@@ -55,6 +55,8 @@ public: | |||
55 | void setMaxSizePerClient(unsigned int size); | 55 | void setMaxSizePerClient(unsigned int size); |
56 | void setAlignment(Alignment a); | 56 | void setAlignment(Alignment a); |
57 | 57 | ||
58 | Item back() { return m_item_list.back(); } | ||
59 | |||
58 | /// force update | 60 | /// force update |
59 | inline void update() { repositionItems(); } | 61 | inline void update() { repositionItems(); } |
60 | /// so we can add items without having an graphic update for each item | 62 | /// 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 @@ | |||
20 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | 20 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
21 | // DEALINGS IN THE SOFTWARE. | 21 | // DEALINGS IN THE SOFTWARE. |
22 | 22 | ||
23 | // $Id: IconbarTool.cc,v 1.24 2003/12/19 14:58:48 fluxgen Exp $ | 23 | // $Id: IconbarTool.cc,v 1.25 2003/12/23 01:55:07 rathnor Exp $ |
24 | 24 | ||
25 | #include "IconbarTool.hh" | 25 | #include "IconbarTool.hh" |
26 | 26 | ||
@@ -237,6 +237,8 @@ IconbarTool::IconbarTool(const FbTk::FbWindow &parent, IconbarTheme &theme, BScr | |||
237 | m_theme(theme), | 237 | m_theme(theme), |
238 | m_focused_pm(0), | 238 | m_focused_pm(0), |
239 | m_unfocused_pm(0), | 239 | m_unfocused_pm(0), |
240 | m_focused_err_pm(0), | ||
241 | m_unfocused_err_pm(0), | ||
240 | m_empty_pm(0), | 242 | m_empty_pm(0), |
241 | m_rc_mode(screen.resourceManager(), WORKSPACE, | 243 | m_rc_mode(screen.resourceManager(), WORKSPACE, |
242 | screen.name() + ".iconbar.mode", screen.altName() + ".Iconbar.Mode"), | 244 | screen.name() + ".iconbar.mode", screen.altName() + ".Iconbar.Mode"), |
@@ -292,7 +294,11 @@ IconbarTool::~IconbarTool() { | |||
292 | if (m_focused_pm) | 294 | if (m_focused_pm) |
293 | m_screen.imageControl().removeImage(m_focused_pm); | 295 | m_screen.imageControl().removeImage(m_focused_pm); |
294 | if (m_unfocused_pm) | 296 | if (m_unfocused_pm) |
295 | m_screen.imageControl().removeImage(m_focused_pm); | 297 | m_screen.imageControl().removeImage(m_unfocused_pm); |
298 | if (m_focused_err_pm) | ||
299 | m_screen.imageControl().removeImage(m_focused_err_pm); | ||
300 | if (m_unfocused_err_pm) | ||
301 | m_screen.imageControl().removeImage(m_unfocused_err_pm); | ||
296 | if (m_empty_pm) | 302 | if (m_empty_pm) |
297 | m_screen.imageControl().removeImage(m_empty_pm); | 303 | m_screen.imageControl().removeImage(m_empty_pm); |
298 | 304 | ||
@@ -510,27 +516,43 @@ void IconbarTool::renderWindow(FluxboxWindow &win) { | |||
510 | 516 | ||
511 | void IconbarTool::renderTheme() { | 517 | void IconbarTool::renderTheme() { |
512 | Pixmap tmp = m_focused_pm; | 518 | Pixmap tmp = m_focused_pm; |
519 | Pixmap err_tmp = m_focused_err_pm; | ||
520 | unsigned int icon_width = m_icon_container.maxWidthPerClient(); | ||
513 | if (!m_theme.focusedTexture().usePixmap()) { | 521 | if (!m_theme.focusedTexture().usePixmap()) { |
514 | m_focused_pm = 0; | 522 | m_focused_pm = 0; |
523 | m_focused_err_pm = 0; | ||
515 | } else { | 524 | } else { |
516 | m_focused_pm = m_screen.imageControl().renderImage(m_icon_container.maxWidthPerClient(), | 525 | m_focused_pm = m_screen.imageControl().renderImage(icon_width, |
526 | m_icon_container.height(), | ||
527 | m_theme.focusedTexture()); | ||
528 | m_focused_err_pm = m_screen.imageControl().renderImage(icon_width+1, | ||
517 | m_icon_container.height(), | 529 | m_icon_container.height(), |
518 | m_theme.focusedTexture()); | 530 | m_theme.focusedTexture()); |
519 | } | 531 | } |
520 | 532 | ||
521 | if (tmp) | 533 | if (tmp) |
522 | m_screen.imageControl().removeImage(tmp); | 534 | m_screen.imageControl().removeImage(tmp); |
535 | if (err_tmp) | ||
536 | m_screen.imageControl().removeImage(err_tmp); | ||
523 | 537 | ||
524 | tmp = m_unfocused_pm; | 538 | tmp = m_unfocused_pm; |
539 | err_tmp = m_unfocused_err_pm; | ||
540 | |||
525 | if (!m_theme.unfocusedTexture().usePixmap()) { | 541 | if (!m_theme.unfocusedTexture().usePixmap()) { |
526 | m_unfocused_pm = 0; | 542 | m_unfocused_pm = 0; |
543 | m_unfocused_err_pm = 0; | ||
527 | } else { | 544 | } else { |
528 | m_unfocused_pm = m_screen.imageControl().renderImage(m_icon_container.maxWidthPerClient(), | 545 | m_unfocused_pm = m_screen.imageControl().renderImage(icon_width, |
546 | m_icon_container.height(), | ||
547 | m_theme.unfocusedTexture()); | ||
548 | m_unfocused_err_pm = m_screen.imageControl().renderImage(icon_width+1, | ||
529 | m_icon_container.height(), | 549 | m_icon_container.height(), |
530 | m_theme.unfocusedTexture()); | 550 | m_theme.unfocusedTexture()); |
531 | } | 551 | } |
532 | if (tmp) | 552 | if (tmp) |
533 | m_screen.imageControl().removeImage(tmp); | 553 | m_screen.imageControl().removeImage(tmp); |
554 | if (err_tmp) | ||
555 | m_screen.imageControl().removeImage(err_tmp); | ||
534 | 556 | ||
535 | // if we dont have any icons then we should render empty texture | 557 | // if we dont have any icons then we should render empty texture |
536 | tmp = m_empty_pm; | 558 | tmp = m_empty_pm; |
@@ -561,14 +583,20 @@ void IconbarTool::renderButton(IconButton &button) { | |||
561 | 583 | ||
562 | button.setPixmap(*m_rc_use_pixmap); | 584 | button.setPixmap(*m_rc_use_pixmap); |
563 | 585 | ||
586 | // if we're rendering a button, there must be a back button. | ||
587 | // The last button is always the regular width | ||
588 | bool wider_button = (button.width() != m_icon_container.back()->width()); | ||
589 | |||
564 | if (button.win().isFocused()) { // focused texture | 590 | if (button.win().isFocused()) { // focused texture |
565 | m_icon_container.setSelected(m_icon_container.find(&button)); | 591 | m_icon_container.setSelected(m_icon_container.find(&button)); |
566 | button.setGC(m_theme.focusedText().textGC()); | 592 | button.setGC(m_theme.focusedText().textGC()); |
567 | button.setFont(m_theme.focusedText().font()); | 593 | button.setFont(m_theme.focusedText().font()); |
568 | button.setJustify(m_theme.focusedText().justify()); | 594 | button.setJustify(m_theme.focusedText().justify()); |
569 | 595 | ||
570 | if (m_focused_pm != 0) | 596 | if (!wider_button && m_focused_pm != 0) |
571 | button.setBackgroundPixmap(m_focused_pm); | 597 | button.setBackgroundPixmap(m_focused_pm); |
598 | else if (wider_button && m_focused_err_pm != 0) | ||
599 | button.setBackgroundPixmap(m_focused_err_pm); | ||
572 | else | 600 | else |
573 | button.setBackgroundColor(m_theme.focusedTexture().color()); | 601 | button.setBackgroundColor(m_theme.focusedTexture().color()); |
574 | 602 | ||
@@ -583,8 +611,10 @@ void IconbarTool::renderButton(IconButton &button) { | |||
583 | button.setFont(m_theme.unfocusedText().font()); | 611 | button.setFont(m_theme.unfocusedText().font()); |
584 | button.setJustify(m_theme.unfocusedText().justify()); | 612 | button.setJustify(m_theme.unfocusedText().justify()); |
585 | 613 | ||
586 | if (m_unfocused_pm != 0) | 614 | if (!wider_button && m_unfocused_pm != 0) |
587 | button.setBackgroundPixmap(m_unfocused_pm); | 615 | button.setBackgroundPixmap(m_unfocused_pm); |
616 | else if (wider_button && m_unfocused_err_pm != 0) | ||
617 | button.setBackgroundPixmap(m_unfocused_err_pm); | ||
588 | else | 618 | else |
589 | button.setBackgroundColor(m_theme.unfocusedTexture().color()); | 619 | button.setBackgroundColor(m_theme.unfocusedTexture().color()); |
590 | 620 | ||
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 @@ | |||
20 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | 20 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
21 | // DEALINGS IN THE SOFTWARE. | 21 | // DEALINGS IN THE SOFTWARE. |
22 | 22 | ||
23 | // $Id: IconbarTool.hh,v 1.12 2003/12/19 14:57:44 fluxgen Exp $ | 23 | // $Id: IconbarTool.hh,v 1.13 2003/12/23 01:55:07 rathnor Exp $ |
24 | 24 | ||
25 | #ifndef ICONBARTOOL_HH | 25 | #ifndef ICONBARTOOL_HH |
26 | #define ICONBARTOOL_HH | 26 | #define ICONBARTOOL_HH |
@@ -107,6 +107,8 @@ private: | |||
107 | const IconbarTheme &m_theme; | 107 | const IconbarTheme &m_theme; |
108 | // cached pixmaps | 108 | // cached pixmaps |
109 | Pixmap m_focused_pm, m_unfocused_pm; | 109 | Pixmap m_focused_pm, m_unfocused_pm; |
110 | // some are a fraction bigger due to rounding | ||
111 | Pixmap m_focused_err_pm, m_unfocused_err_pm; | ||
110 | Pixmap m_empty_pm; ///< pixmap for empty container | 112 | Pixmap m_empty_pm; ///< pixmap for empty container |
111 | 113 | ||
112 | 114 | ||