summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog2
-rw-r--r--src/IntResMenuItem.hh30
2 files changed, 18 insertions, 14 deletions
diff --git a/ChangeLog b/ChangeLog
index 3393cb6..20ea2e9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,8 @@
1 (Format: Year/Month/Day) 1 (Format: Year/Month/Day)
2Changes for 1.0rc3: 2Changes for 1.0rc3:
3*07/01/15: 3*07/01/15:
4 * Prevent per-window alpha menu from scrolling past 0 or 255 (Mark)
5 IntResMenuItem.hh
4 * Fix rootmenu disappearing on reconfigure (Mark) 6 * Fix rootmenu disappearing on reconfigure (Mark)
5 Screen.cc 7 Screen.cc
6*07/01/14: 8*07/01/14:
diff --git a/src/IntResMenuItem.hh b/src/IntResMenuItem.hh
index 0be2775..768870e 100644
--- a/src/IntResMenuItem.hh
+++ b/src/IntResMenuItem.hh
@@ -56,20 +56,22 @@ public:
56 if (time - last_time <= 200) 56 if (time - last_time <= 200)
57 inc_val = 5; 57 inc_val = 5;
58 58
59
60 last_time = time; 59 last_time = time;
61 60
62 if ((button == 4 || button == 3)&& *m_res < m_max) // scroll up 61 // make sure values stay within bounds _before_ we try to set m_res
63 m_res.get() += inc_val; 62 // otherwise, this may cause bugs (say, with casting to unsigned char)
64 else if ((button == 5 || button == 1) && *m_res > m_min) // scroll down 63 if ((button == 4 || button == 3) && *m_res < m_max) { // up
65 m_res.get() -= inc_val; 64 if (*m_res + inc_val < m_max)
66 65 m_res.get() += inc_val;
67 // clamp value 66 else
68 if (*m_res > m_max) 67 m_res.get() = m_max;
69 m_res.get() = m_max; 68 } else if ((button == 5 || button == 1) && *m_res > m_min) { // down
70 else if (*m_res < m_min) 69 if (*m_res - inc_val >= m_min)
71 m_res.get() = m_min; 70 m_res.get() -= inc_val;
72 71 else
72 m_res.get() = m_min;
73 }
74
73 // update label 75 // update label
74 updateLabel(); 76 updateLabel();
75 // call other commands 77 // call other commands
@@ -86,7 +88,7 @@ public:
86 void updateLabel() { 88 void updateLabel() {
87 setLabel(appendIntValue(m_org_label, *m_res)); 89 setLabel(appendIntValue(m_org_label, *m_res));
88 } 90 }
89 91
90private: 92private:
91 std::string m_org_label; ///< original label 93 std::string m_org_label; ///< original label
92 const int m_max; ///< maximum value the integer can have 94 const int m_max; ///< maximum value the integer can have