aboutsummaryrefslogtreecommitdiff
path: root/src/ArrowButton.cc
diff options
context:
space:
mode:
authorrathnor <rathnor>2004-08-26 15:09:33 (GMT)
committerrathnor <rathnor>2004-08-26 15:09:33 (GMT)
commit346a6598a62350c5d234e3177de9e6c6c1963475 (patch)
tree02706013944f306c549ca627144a13d6552cd098 /src/ArrowButton.cc
parent13bf2a7fddff4242581eec62243222acd49a1537 (diff)
downloadfluxbox-346a6598a62350c5d234e3177de9e6c6c1963475.zip
fluxbox-346a6598a62350c5d234e3177de9e6c6c1963475.tar.bz2
make arrow button's arrow size scalable by the user
Diffstat (limited to 'src/ArrowButton.cc')
-rw-r--r--src/ArrowButton.cc33
1 files changed, 25 insertions, 8 deletions
diff --git a/src/ArrowButton.cc b/src/ArrowButton.cc
index c62df2a..724562f 100644
--- a/src/ArrowButton.cc
+++ b/src/ArrowButton.cc
@@ -19,9 +19,10 @@
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: ArrowButton.cc,v 1.7 2004/08/25 17:16:40 rathnor Exp $ 22// $Id: ArrowButton.cc,v 1.8 2004/08/26 15:09:33 rathnor Exp $
23 23
24#include "ArrowButton.hh" 24#include "ArrowButton.hh"
25#include "ButtonTheme.hh"
25 26
26ArrowButton::ArrowButton(ArrowButton::Type arrow_type, 27ArrowButton::ArrowButton(ArrowButton::Type arrow_type,
27 const FbTk::FbWindow &parent, 28 const FbTk::FbWindow &parent,
@@ -29,7 +30,8 @@ ArrowButton::ArrowButton(ArrowButton::Type arrow_type,
29 unsigned int width, unsigned int height): 30 unsigned int width, unsigned int height):
30 FbTk::Button(parent, x, y, width, height), 31 FbTk::Button(parent, x, y, width, height),
31 m_arrow_type(arrow_type), 32 m_arrow_type(arrow_type),
32 m_mouse_handler(0) { 33 m_mouse_handler(0),
34 m_arrowscale(300) {
33 35
34 setEventMask(ExposureMask | ButtonPressMask | ButtonReleaseMask | 36 setEventMask(ExposureMask | ButtonPressMask | ButtonReleaseMask |
35 EnterWindowMask | LeaveWindowMask); 37 EnterWindowMask | LeaveWindowMask);
@@ -41,7 +43,8 @@ ArrowButton::ArrowButton(ArrowButton::Type arrow_type,
41 unsigned int width, unsigned int height): 43 unsigned int width, unsigned int height):
42 FbTk::Button(screen_num, x, y, width, height), 44 FbTk::Button(screen_num, x, y, width, height),
43 m_arrow_type(arrow_type), 45 m_arrow_type(arrow_type),
44 m_mouse_handler(0) { 46 m_mouse_handler(0),
47 m_arrowscale(300) {
45 48
46 setEventMask(ExposureMask | ButtonPressMask | ButtonReleaseMask | 49 setEventMask(ExposureMask | ButtonPressMask | ButtonReleaseMask |
47 EnterWindowMask | LeaveWindowMask); 50 EnterWindowMask | LeaveWindowMask);
@@ -84,15 +87,20 @@ void ArrowButton::drawArrow() {
84 XPoint pts[3]; 87 XPoint pts[3];
85 unsigned int w = width(); 88 unsigned int w = width();
86 unsigned int h = height(); 89 unsigned int h = height();
87 // arrow size: half of the button 90
88 unsigned int ax = w / 2; 91 int arrowscale_n = m_arrowscale;
89 unsigned int ay = h / 2; 92 int arrowscale_d = 100;
93 unsigned int ax = arrowscale_d * w / arrowscale_n;
94 unsigned int ay = arrowscale_d * h / arrowscale_n;
95 // if these aren't an even number, left and right arrows end up different
96 if (( ax % 2 ) == 1) ax++;
97 if (( ay % 2 ) == 1) ay++;
90 switch (m_arrow_type) { 98 switch (m_arrow_type) {
91 case LEFT: 99 case LEFT:
92 // start at the tip 100 // start at the tip
93 pts[0].x = (w / 2) - (ax / 2); pts[0].y = h / 2; 101 pts[0].x = (w / 2) - (ax / 2); pts[0].y = h / 2;
94 pts[1].x = ax; pts[1].y = ay / 2; 102 pts[1].x = ax; pts[1].y = -ay / 2;
95 pts[2].x = 0; pts[2].y = - ay; 103 pts[2].x = 0; pts[2].y = ay;
96 break; 104 break;
97 case RIGHT: 105 case RIGHT:
98 pts[0].x = (w / 2) + (ax / 2); pts[0].y = h / 2; 106 pts[0].x = (w / 2) + (ax / 2); pts[0].y = h / 2;
@@ -118,3 +126,12 @@ void ArrowButton::drawArrow() {
118 } 126 }
119} 127}
120 128
129void ArrowButton::updateTheme(const FbTk::Theme &theme) {
130 // it must be a button theme
131 const ButtonTheme &btheme = static_cast<const ButtonTheme &>(theme);
132
133 m_arrowscale = btheme.scale();
134 if (m_arrowscale == 0) m_arrowscale = 300; // default is 0 => 300
135 else if (m_arrowscale < 100) m_arrowscale = 100; // otherwise clamp
136 else if (m_arrowscale > 100000) m_arrowscale = 100000; // clamp below overflow when *100
137}