aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMathias Gumz <akira at fluxbox dot org>2013-02-06 12:47:11 (GMT)
committerMathias Gumz <akira at fluxbox dot org>2013-02-06 12:47:17 (GMT)
commit34343bb20bdb3dc94fe426f69e5db16315353d57 (patch)
treecbf01e0b2af4ca14c093ada589f82558ec7d3a66 /src
parent94fddc09c064555721dc521e3e94ed6f610653b9 (diff)
downloadfluxbox-34343bb20bdb3dc94fe426f69e5db16315353d57.zip
fluxbox-34343bb20bdb3dc94fe426f69e5db16315353d57.tar.bz2
Feature #3602124: 'LHalf' and 'RHalf' buttons to the titlebar
First draft of feature request of #3602124: Having 2 buttons in the titlebar which allow quick positioning of a Window into the left or right half of the current monitor.
Diffstat (limited to 'src')
-rw-r--r--src/Resources.cc10
-rw-r--r--src/WinButton.cc35
-rw-r--r--src/WinButton.hh14
-rw-r--r--src/WinButtonTheme.cc6
-rw-r--r--src/WinButtonTheme.hh12
-rw-r--r--src/Window.cc27
6 files changed, 85 insertions, 19 deletions
diff --git a/src/Resources.cc b/src/Resources.cc
index 2e07725..128eedd 100644
--- a/src/Resources.cc
+++ b/src/Resources.cc
@@ -108,6 +108,12 @@ getString() const {
108 case WinButton::MENUICON: 108 case WinButton::MENUICON:
109 retval.append("MenuIcon"); 109 retval.append("MenuIcon");
110 break; 110 break;
111 case WinButton::LEFT_HALF:
112 retval.append("LHalf");
113 break;
114 case WinButton::RIGHT_HALF:
115 retval.append("RHalf");
116 break;
111 default: 117 default:
112 break; 118 break;
113 } 119 }
@@ -142,6 +148,10 @@ setFromString(char const *strval) {
142 m_value.push_back(WinButton::MENUICON); 148 m_value.push_back(WinButton::MENUICON);
143 else if (v == "close") 149 else if (v == "close")
144 m_value.push_back(WinButton::CLOSE); 150 m_value.push_back(WinButton::CLOSE);
151 else if (v == "lhalf")
152 m_value.push_back(WinButton::LEFT_HALF);
153 else if (v == "rhalf")
154 m_value.push_back(WinButton::RIGHT_HALF);
145 } 155 }
146} 156}
147 157
diff --git a/src/WinButton.cc b/src/WinButton.cc
index e1b79a2..bb841fb 100644
--- a/src/WinButton.cc
+++ b/src/WinButton.cc
@@ -137,6 +137,10 @@ Pixmap WinButton::getPixmap(const FbTk::ThemeProxy<WinButtonTheme> &theme) const
137 return theme->titlePixmap().pixmap().drawable(); 137 return theme->titlePixmap().pixmap().drawable();
138 else 138 else
139 return theme->menuiconPixmap().pixmap().drawable(); 139 return theme->menuiconPixmap().pixmap().drawable();
140 case LEFT_HALF:
141 return theme->leftHalfPixmap().pixmap().drawable();
142 case RIGHT_HALF:
143 return theme->rightHalfPixmap().pixmap().drawable();
140 default: 144 default:
141 return None; 145 return None;
142 } 146 }
@@ -160,18 +164,14 @@ void WinButton::drawType() {
160 // otherwise draw old style imagery 164 // otherwise draw old style imagery
161 switch (m_type) { 165 switch (m_type) {
162 case MAXIMIZE: 166 case MAXIMIZE:
163 // if no pixmap was used, use old style 167 drawRectangle(gc(), 2, 2, width() - 5, height() - 5);
164 if (gc() == 0) // must have valid graphic context 168 drawLine(gc(), 2, 3, width() - 3, 3);
165 return;
166
167 drawRectangle(gc(),
168 2, 2, width() - 5, height() - 5);
169 drawLine(gc(),
170 2, 3, width() - 3, 3);
171 break; 169 break;
170
172 case MINIMIZE: 171 case MINIMIZE:
173 drawRectangle(gc(), 2, height() - 5, width() - 5, 2); 172 drawRectangle(gc(), 2, height() - 5, width() - 5, 2);
174 break; 173 break;
174
175 case STICK: 175 case STICK:
176 // width/4 != width/2, so we use /4*2 so that it's properly centred 176 // width/4 != width/2, so we use /4*2 so that it's properly centred
177 if (m_listen_to.isStuck()) { 177 if (m_listen_to.isStuck()) {
@@ -184,6 +184,7 @@ void WinButton::drawType() {
184 width()/10*2 + oddW, height()/10*2 + oddH); 184 width()/10*2 + oddW, height()/10*2 + oddH);
185 } 185 }
186 break; 186 break;
187
187 case CLOSE: 188 case CLOSE:
188 drawLine(gc(), 189 drawLine(gc(),
189 2, 2, 190 2, 2,
@@ -199,15 +200,12 @@ void WinButton::drawType() {
199 // XFree86 Version 4.3.0.1 (Debian 4.3.0.dfsg.1-1 20040428170728) 200 // XFree86 Version 4.3.0.1 (Debian 4.3.0.dfsg.1-1 20040428170728)
200 // (X Protocol Version 11, Revision 0, Release 6.6) 201 // (X Protocol Version 11, Revision 0, Release 6.6)
201 202
202 drawLine(gc(), 203 drawLine(gc(), 2, height() - 3, width() - 3, 2);
203 2, height() - 3,
204 width() - 3, 2);
205 break; 204 break;
206 case SHADE:
207 205
206 case SHADE:
208 { 207 {
209 int size = width() - 5 - oddW; 208 int size = width() - 5 - oddW;
210
211 drawRectangle(gc(), 2, 2, size, 2); 209 drawRectangle(gc(), 2, 2, size, 2);
212 210
213 // draw a one-quarter triangle below the rectangle 211 // draw a one-quarter triangle below the rectangle
@@ -220,6 +218,7 @@ void WinButton::drawType() {
220 218
221 break; 219 break;
222 } 220 }
221
223 case MENUICON: 222 case MENUICON:
224 if (m_icon_pixmap.drawable()) { 223 if (m_icon_pixmap.drawable()) {
225 224
@@ -242,10 +241,16 @@ void WinButton::drawType() {
242 for (unsigned int y = height()/3; y <= height() - height()/3; y+=3) { 241 for (unsigned int y = height()/3; y <= height() - height()/3; y+=3) {
243 drawLine(gc(), width()/4, y, width() - width()/4 - oddW - 1, y); 242 drawLine(gc(), width()/4, y, width() - width()/4 - oddW - 1, y);
244 } 243 }
245 drawRectangle(gc(), 244 drawRectangle(gc(), 2, 2, width() - 5, height() - 5);
246 2, 2, width() - 5, height() - 5);
247 } 245 }
248 break; 246 break;
247
248 case LEFT_HALF:
249 fillRectangle(gc(), 2, 2, (width() / 2) - oddW, height() - 4);
250 break;
251 case RIGHT_HALF:
252 fillRectangle(gc(), width() / 2, 2, (width() / 2) - 2 + oddW, height() - 4);
253 break;
249 } 254 }
250} 255}
251 256
diff --git a/src/WinButton.hh b/src/WinButton.hh
index 3912a1a..f64342e 100644
--- a/src/WinButton.hh
+++ b/src/WinButton.hh
@@ -38,7 +38,17 @@ template <class T> class ThemeProxy;
38class WinButton:public FbTk::Button, public FbTk::SignalTracker { 38class WinButton:public FbTk::Button, public FbTk::SignalTracker {
39public: 39public:
40 /// draw type for the button 40 /// draw type for the button
41 enum Type {MAXIMIZE, MINIMIZE, SHADE, STICK, CLOSE, MENUICON}; 41 enum Type {
42 MAXIMIZE,
43 MINIMIZE,
44 SHADE,
45 STICK,
46 CLOSE,
47 MENUICON,
48 LEFT_HALF,
49 RIGHT_HALF
50 };
51
42 WinButton(FluxboxWindow &listen_to, 52 WinButton(FluxboxWindow &listen_to,
43 FbTk::ThemeProxy<WinButtonTheme> &theme, 53 FbTk::ThemeProxy<WinButtonTheme> &theme,
44 FbTk::ThemeProxy<WinButtonTheme> &pressed, 54 FbTk::ThemeProxy<WinButtonTheme> &pressed,
@@ -66,7 +76,7 @@ private:
66 76
67 FbTk::FbPixmap m_icon_pixmap; 77 FbTk::FbPixmap m_icon_pixmap;
68 FbTk::FbPixmap m_icon_mask; 78 FbTk::FbPixmap m_icon_mask;
69 79
70 bool overrode_bg, overrode_pressed; 80 bool overrode_bg, overrode_pressed;
71}; 81};
72 82
diff --git a/src/WinButtonTheme.cc b/src/WinButtonTheme.cc
index c6e6ddf..aa043b1 100644
--- a/src/WinButtonTheme.cc
+++ b/src/WinButtonTheme.cc
@@ -52,6 +52,10 @@ WinButtonTheme::WinButtonTheme(int screen_num,
52 "Window.Stick" + altextra + ".Pixmap"), 52 "Window.Stick" + altextra + ".Pixmap"),
53 m_stuck_pm(*this, "window.stuck" + extra + ".pixmap", 53 m_stuck_pm(*this, "window.stuck" + extra + ".pixmap",
54 "Window.Stuck" + altextra + ".Pixmap"), 54 "Window.Stuck" + altextra + ".Pixmap"),
55 m_lefthalf_pm(*this, "window.lhalf" + extra + ".pixmap",
56 "Window.LHalf" + altextra + ".Pixmap"),
57 m_righthalf_pm(*this, "window.rhalf" + extra + ".pixmap",
58 "Window.RHalf" + altextra + ".Pixmap"),
55 m_frame_theme(frame_theme) { 59 m_frame_theme(frame_theme) {
56 60
57 FbTk::ThemeManager::instance().loadTheme(*this); 61 FbTk::ThemeManager::instance().loadTheme(*this);
@@ -82,5 +86,7 @@ void WinButtonTheme::reconfigTheme() {
82 m_title_pm->scale(size, size); 86 m_title_pm->scale(size, size);
83 m_stick_pm->scale(size, size); 87 m_stick_pm->scale(size, size);
84 m_stuck_pm->scale(size, size); 88 m_stuck_pm->scale(size, size);
89 m_lefthalf_pm->scale(size, size);
90 m_righthalf_pm->scale(size, size);
85} 91}
86 92
diff --git a/src/WinButtonTheme.hh b/src/WinButtonTheme.hh
index 224fc6c..9e3c5ed 100644
--- a/src/WinButtonTheme.hh
+++ b/src/WinButtonTheme.hh
@@ -62,10 +62,18 @@ public:
62 62
63 const FbTk::PixmapWithMask &menuiconPixmap() const { return *m_menuicon_pm; } 63 const FbTk::PixmapWithMask &menuiconPixmap() const { return *m_menuicon_pm; }
64 FbTk::PixmapWithMask &menuiconPixmap() { return *m_menuicon_pm; } 64 FbTk::PixmapWithMask &menuiconPixmap() { return *m_menuicon_pm; }
65 65
66 FbTk::PixmapWithMask &titlePixmap() { return *m_title_pm; } 66 FbTk::PixmapWithMask &titlePixmap() { return *m_title_pm; }
67 const FbTk::PixmapWithMask &titlePixmap() const { return *m_title_pm; } 67 const FbTk::PixmapWithMask &titlePixmap() const { return *m_title_pm; }
68 68
69
70 FbTk::PixmapWithMask &leftHalfPixmap() { return *m_lefthalf_pm; }
71 const FbTk::PixmapWithMask &leftHalfPixmap() const { return *m_lefthalf_pm; }
72
73 FbTk::PixmapWithMask &rightHalfPixmap() { return *m_righthalf_pm; }
74 const FbTk::PixmapWithMask &rightHalfPixmap() const { return *m_righthalf_pm; }
75
76
69 virtual FbTk::Signal<> &reconfigSig() { return FbTk::Theme::reconfigSig(); } 77 virtual FbTk::Signal<> &reconfigSig() { return FbTk::Theme::reconfigSig(); }
70 78
71 virtual WinButtonTheme &operator *() { return *this; } 79 virtual WinButtonTheme &operator *() { return *this; }
@@ -75,7 +83,7 @@ private:
75 83
76 FbTk::ThemeItem<FbTk::PixmapWithMask> m_close_pm, m_maximize_pm, 84 FbTk::ThemeItem<FbTk::PixmapWithMask> m_close_pm, m_maximize_pm,
77 m_iconify_pm, m_shade_pm, m_unshade_pm, m_menuicon_pm, m_title_pm, 85 m_iconify_pm, m_shade_pm, m_unshade_pm, m_menuicon_pm, m_title_pm,
78 m_stick_pm, m_stuck_pm; 86 m_stick_pm, m_stuck_pm, m_lefthalf_pm, m_righthalf_pm;
79 87
80 FbTk::ThemeProxy<FbWinFrameTheme> &m_frame_theme; 88 FbTk::ThemeProxy<FbWinFrameTheme> &m_frame_theme;
81}; 89};
diff --git a/src/Window.cc b/src/Window.cc
index 1ee8853..98486be 100644
--- a/src/Window.cc
+++ b/src/Window.cc
@@ -48,6 +48,7 @@
48 48
49#include "FbTk/StringUtil.hh" 49#include "FbTk/StringUtil.hh"
50#include "FbTk/Compose.hh" 50#include "FbTk/Compose.hh"
51#include "FbTk/CommandParser.hh"
51#include "FbTk/EventManager.hh" 52#include "FbTk/EventManager.hh"
52#include "FbTk/KeyUtil.hh" 53#include "FbTk/KeyUtil.hh"
53#include "FbTk/SimpleCommand.hh" 54#include "FbTk/SimpleCommand.hh"
@@ -3600,6 +3601,32 @@ void FluxboxWindow::updateButtons() {
3600 winbtn->setOnClick(show_menu_cmd); 3601 winbtn->setOnClick(show_menu_cmd);
3601 } 3602 }
3602 break; 3603 break;
3604
3605 case WinButton::LEFT_HALF:
3606 {
3607 winbtn = new WinButton(*this, m_button_theme,
3608 screen().pressedWinButtonTheme(),
3609 dir[i],
3610 frame().titlebar(),
3611 0, 0, 10, 10);
3612
3613 CommandRef lhalf_cmd(FbTk::CommandParser<void>::instance().parse("MacroCmd {MoveTo 0 0} {ResizeTo 50% 100%}"));
3614 winbtn->setOnClick(lhalf_cmd);
3615 }
3616 break;
3617
3618 case WinButton::RIGHT_HALF:
3619 {
3620 winbtn = new WinButton(*this, m_button_theme,
3621 screen().pressedWinButtonTheme(),
3622 dir[i],
3623 frame().titlebar(),
3624 0, 0, 10, 10);
3625 CommandRef rhalf_cmd(FbTk::CommandParser<void>::instance().parse("MacroCmd {MoveTo 50% 0} {ResizeTo 50% 100%}"));
3626 winbtn->setOnClick(rhalf_cmd);
3627 }
3628 break;
3629
3603 } 3630 }
3604 3631
3605 3632