aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfluxgen <fluxgen>2003-08-22 14:48:10 (GMT)
committerfluxgen <fluxgen>2003-08-22 14:48:10 (GMT)
commitec5c2b77a11e2762921ff4736539d4f5239b5866 (patch)
tree0219fc8772b66df95b41316e1fea8479aad5a323
parent697c38a6940a63137a1bd46790657662e464a468 (diff)
downloadfluxbox_pavel-ec5c2b77a11e2762921ff4736539d4f5239b5866.zip
fluxbox_pavel-ec5c2b77a11e2762921ff4736539d4f5239b5866.tar.bz2
fixed scaling for winbuttons
-rw-r--r--src/WinButtonTheme.cc46
-rw-r--r--src/WinButtonTheme.hh20
2 files changed, 52 insertions, 14 deletions
diff --git a/src/WinButtonTheme.cc b/src/WinButtonTheme.cc
index d90d4c8..38d2de5 100644
--- a/src/WinButtonTheme.cc
+++ b/src/WinButtonTheme.cc
@@ -19,11 +19,12 @@
19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20// DEALINGS IN THE SOFTWARE. 20// DEALINGS IN THE SOFTWARE.
21 21
22// $Id: WinButtonTheme.cc,v 1.3 2003/05/06 23:56:46 fluxgen Exp $ 22// $Id: WinButtonTheme.cc,v 1.4 2003/08/22 14:48:10 fluxgen Exp $
23 23
24#include "WinButtonTheme.hh" 24#include "WinButtonTheme.hh"
25 25
26#include "App.hh" 26#include "FbTk/App.hh"
27#include "FbWinFrameTheme.hh"
27 28
28#ifdef HAVE_CONFIG_H 29#ifdef HAVE_CONFIG_H
29#include "config.h" 30#include "config.h"
@@ -44,8 +45,6 @@ setDefaultValue() {
44 // create empty pixmap 45 // create empty pixmap
45 (*this)->pixmap = FbTk::FbPixmap(); // pixmap 46 (*this)->pixmap = FbTk::FbPixmap(); // pixmap
46 (*this)->mask = FbTk::FbPixmap(); // mask 47 (*this)->mask = FbTk::FbPixmap(); // mask
47 (*this)->pixmap_scaled = FbTk::FbPixmap();
48 (*this)->mask_scaled = FbTk::FbPixmap();
49} 48}
50 49
51template <> 50template <>
@@ -77,7 +76,7 @@ setFromString(const char *str) {
77 } 76 }
78} 77}
79 78
80WinButtonTheme::WinButtonTheme(int screen_num): 79WinButtonTheme::WinButtonTheme(int screen_num, const FbWinFrameTheme &frame_theme):
81 FbTk::Theme(screen_num), 80 FbTk::Theme(screen_num),
82 m_close_pm(*this, "window.close.pixmap", "Window.Close.Pixmap"), 81 m_close_pm(*this, "window.close.pixmap", "Window.Close.Pixmap"),
83 m_close_unfocus_pm(*this, "window.close.unfocus.pixmap", "Window.Close.Unfocus.Pixmap"), 82 m_close_unfocus_pm(*this, "window.close.unfocus.pixmap", "Window.Close.Unfocus.Pixmap"),
@@ -95,7 +94,8 @@ WinButtonTheme::WinButtonTheme(int screen_num):
95 m_stick_unfocus_pm(*this, "window.stick.unfocus.pixmap", "Window.Stick.Unfocus.Pixmap"), 94 m_stick_unfocus_pm(*this, "window.stick.unfocus.pixmap", "Window.Stick.Unfocus.Pixmap"),
96 m_stick_pressed_pm(*this, "window.stick.pressed.pixmap", "Window.Stick.Pressed.Pixmap"), 95 m_stick_pressed_pm(*this, "window.stick.pressed.pixmap", "Window.Stick.Pressed.Pixmap"),
97 m_stuck_pm(*this, "window.stuck.pixmap", "Window.Stuck.Pixmap"), 96 m_stuck_pm(*this, "window.stuck.pixmap", "Window.Stuck.Pixmap"),
98 m_stuck_unfocus_pm(*this, "window.stuck.unfocus.pixmap", "Window.Stuck.Unfocus.Pixmap") { 97 m_stuck_unfocus_pm(*this, "window.stuck.unfocus.pixmap", "Window.Stuck.Unfocus.Pixmap"),
98 m_frame_theme(frame_theme) {
99 99
100} 100}
101 101
@@ -104,6 +104,38 @@ WinButtonTheme::~WinButtonTheme() {
104} 104}
105 105
106void WinButtonTheme::reconfigTheme() { 106void WinButtonTheme::reconfigTheme() {
107 reconfigSig().notify(); 107 // rescale the pixmaps to match frame theme height
108
109 unsigned int size = m_frame_theme.titleHeight();
110 if (m_frame_theme.titleHeight() == 0) {
111 // calculate height from font and border width to scale pixmaps
112 const int bevel = 1;
113 size = m_frame_theme.font().height() + bevel*2 + 2;
114
115 } // else use specified height to scale pixmaps
116
117 // scale all pixmaps
118 m_close_pm->scale(size, size);
119 m_close_unfocus_pm->scale(size, size);
120 m_close_pressed_pm->scale(size, size);
121
122 m_maximize_pm->scale(size, size);
123 m_maximize_unfocus_pm->scale(size, size);
124 m_maximize_pressed_pm->scale(size, size);
125
126 m_iconify_pm->scale(size, size);
127 m_iconify_unfocus_pm->scale(size, size);
128 m_iconify_pressed_pm->scale(size, size);
129
130 m_shade_pm->scale(size, size);
131 m_shade_unfocus_pm->scale(size, size);
132 m_shade_pressed_pm->scale(size, size);
133
134 m_stick_pm->scale(size, size);
135 m_stick_unfocus_pm->scale(size, size);
136 m_stick_pressed_pm->scale(size, size);
137
138 m_stuck_pm->scale(size, size);
139 m_stuck_unfocus_pm->scale(size, size);
108} 140}
109 141
diff --git a/src/WinButtonTheme.hh b/src/WinButtonTheme.hh
index af2f011..dea88cf 100644
--- a/src/WinButtonTheme.hh
+++ b/src/WinButtonTheme.hh
@@ -19,25 +19,30 @@
19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20// DEALINGS IN THE SOFTWARE. 20// DEALINGS IN THE SOFTWARE.
21 21
22// $Id: WinButtonTheme.hh,v 1.2 2003/05/06 23:52:55 fluxgen Exp $ 22// $Id: WinButtonTheme.hh,v 1.3 2003/08/22 14:48:10 fluxgen Exp $
23 23
24#ifndef WINBUTTONTHEME_HH 24#ifndef WINBUTTONTHEME_HH
25#define WINBUTTONTHEME_HH 25#define WINBUTTONTHEME_HH
26 26
27#include "Theme.hh" 27#include "Theme.hh"
28#include "Subject.hh"
29#include "FbPixmap.hh" 28#include "FbPixmap.hh"
30 29
30class FbWinFrameTheme;
31
31class WinButtonTheme: public FbTk::Theme { 32class WinButtonTheme: public FbTk::Theme {
32public: 33public:
34 /// holds pixmap and a mask
33 struct PixmapWithMask { 35 struct PixmapWithMask {
36 /// scale both pixmap and mask to specified size
37 void scale(unsigned int width, unsigned int height) {
38 pixmap.scale(width, height);
39 mask.scale(width, height);
40 }
34 FbTk::FbPixmap pixmap; 41 FbTk::FbPixmap pixmap;
35 FbTk::FbPixmap pixmap_scaled;
36 FbTk::FbPixmap mask; 42 FbTk::FbPixmap mask;
37 FbTk::FbPixmap mask_scaled;
38 }; 43 };
39 44
40 explicit WinButtonTheme(int screen_num); 45 WinButtonTheme(int screen_num, const FbWinFrameTheme &frame_theme);
41 ~WinButtonTheme(); 46 ~WinButtonTheme();
42 47
43 void reconfigTheme(); 48 void reconfigTheme();
@@ -74,9 +79,8 @@ public:
74 inline PixmapWithMask &shadeUnfocusPixmap() { return *m_shade_unfocus_pm; } 79 inline PixmapWithMask &shadeUnfocusPixmap() { return *m_shade_unfocus_pm; }
75 inline const PixmapWithMask &shadePressedPixmap() const { return *m_shade_pressed_pm; } 80 inline const PixmapWithMask &shadePressedPixmap() const { return *m_shade_pressed_pm; }
76 inline PixmapWithMask &shadePressedPixmap() { return *m_shade_pressed_pm; } 81 inline PixmapWithMask &shadePressedPixmap() { return *m_shade_pressed_pm; }
77 FbTk::Subject &reconfigSig() { return m_reconf_sig; } 82
78private: 83private:
79 FbTk::Subject m_reconf_sig;
80 84
81 FbTk::ThemeItem<PixmapWithMask> m_close_pm, m_close_unfocus_pm, m_close_pressed_pm; 85 FbTk::ThemeItem<PixmapWithMask> m_close_pm, m_close_unfocus_pm, m_close_pressed_pm;
82 FbTk::ThemeItem<PixmapWithMask> m_maximize_pm, m_maximize_unfocus_pm, m_maximize_pressed_pm; 86 FbTk::ThemeItem<PixmapWithMask> m_maximize_pm, m_maximize_unfocus_pm, m_maximize_pressed_pm;
@@ -84,6 +88,8 @@ private:
84 FbTk::ThemeItem<PixmapWithMask> m_shade_pm, m_shade_unfocus_pm, m_shade_pressed_pm; 88 FbTk::ThemeItem<PixmapWithMask> m_shade_pm, m_shade_unfocus_pm, m_shade_pressed_pm;
85 FbTk::ThemeItem<PixmapWithMask> m_stick_pm, m_stick_unfocus_pm, m_stick_pressed_pm; 89 FbTk::ThemeItem<PixmapWithMask> m_stick_pm, m_stick_unfocus_pm, m_stick_pressed_pm;
86 FbTk::ThemeItem<PixmapWithMask> m_stuck_pm, m_stuck_unfocus_pm; 90 FbTk::ThemeItem<PixmapWithMask> m_stuck_pm, m_stuck_unfocus_pm;
91
92 const FbWinFrameTheme &m_frame_theme;
87}; 93};
88 94
89#endif // WINBUTTONTHEME_HH 95#endif // WINBUTTONTHEME_HH