aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrathnor <rathnor>2003-07-20 10:41:56 (GMT)
committerrathnor <rathnor>2003-07-20 10:41:56 (GMT)
commit734b99611b0937a94407df0536fcdcd7cad45d13 (patch)
tree393c6e4870a395105d48f419350875fe397935ac /src
parent1741ac072dd6516b4dcfdf6dbe9099a335c7bc7d (diff)
downloadfluxbox_pavel-734b99611b0937a94407df0536fcdcd7cad45d13.zip
fluxbox_pavel-734b99611b0937a94407df0536fcdcd7cad45d13.tar.bz2
fix menu redrawing, particularly so that selecting an option will update
properly upon selection, rather than subsequent movement
Diffstat (limited to 'src')
-rw-r--r--src/FbTk/Menu.cc36
-rw-r--r--src/FbTk/Menu.hh4
2 files changed, 22 insertions, 18 deletions
diff --git a/src/FbTk/Menu.cc b/src/FbTk/Menu.cc
index 9dccb6f..ee7c231 100644
--- a/src/FbTk/Menu.cc
+++ b/src/FbTk/Menu.cc
@@ -22,7 +22,7 @@
22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23// DEALINGS IN THE SOFTWARE. 23// DEALINGS IN THE SOFTWARE.
24 24
25// $Id: Menu.cc,v 1.30 2003/07/20 08:12:36 rathnor Exp $ 25// $Id: Menu.cc,v 1.31 2003/07/20 10:41:56 rathnor Exp $
26 26
27//use GNU extensions 27//use GNU extensions
28#ifndef _GNU_SOURCE 28#ifndef _GNU_SOURCE
@@ -384,7 +384,7 @@ void Menu::enableTitle() {
384 setTitleVisibility(true); 384 setTitleVisibility(true);
385} 385}
386 386
387void Menu::update() { 387void Menu::update(int active_index) {
388 388
389 if (menu.bevel_w > 10) // clamp to "normal" size 389 if (menu.bevel_w > 10) // clamp to "normal" size
390 menu.bevel_w = 10; 390 menu.bevel_w = 10;
@@ -539,10 +539,10 @@ void Menu::update() {
539 if (m_need_update) { 539 if (m_need_update) {
540 for (unsigned int i = 0; visible && i < menuitems.size(); i++) { 540 for (unsigned int i = 0; visible && i < menuitems.size(); i++) {
541 if (i == (unsigned int)which_sub) { 541 if (i == (unsigned int)which_sub) {
542 drawItem(i, true, false, false); 542 drawItem(i, true, true, false);
543 drawSubmenu(i); 543 drawSubmenu(i);
544 } else 544 } else
545 drawItem(i, false, false, false); 545 drawItem(i, (i == active_index), true, false);
546 } 546 }
547 547
548 if (m_parent && visible) 548 if (m_parent && visible)
@@ -978,7 +978,6 @@ void Menu::drawItem(unsigned int index, bool highlight, bool clear, bool render_
978 978
979} 979}
980 980
981
982void Menu::setLabel(const char *labelstr) { 981void Menu::setLabel(const char *labelstr) {
983 //make sure we don't send 0 to std::string 982 //make sure we don't send 0 to std::string
984 menu.label = (labelstr ? labelstr : ""); 983 menu.label = (labelstr ? labelstr : "");
@@ -1095,16 +1094,16 @@ void Menu::buttonReleaseEvent(XButtonEvent &re) {
1095 p = (which_sbl * menu.persub) + which_press; 1094 p = (which_sbl * menu.persub) + which_press;
1096 1095
1097 if (w < static_cast<int>(menuitems.size()) && w >= 0) { 1096 if (w < static_cast<int>(menuitems.size()) && w >= 0) {
1098 drawItem(p, (p == which_sub), true, true);
1099
1100 if (p == w && isItemEnabled(w)) { 1097 if (p == w && isItemEnabled(w)) {
1101 if (re.x > ix && re.x < (signed) (ix + menu.item_w) && 1098 if (re.x > ix && re.x < (signed) (ix + menu.item_w) &&
1102 re.y > iy && re.y < (signed) (iy + menu.item_h)) { 1099 re.y > iy && re.y < (signed) (iy + menu.item_h)) {
1103 menuitems[w]->click(re.button, re.time); 1100 menuitems[w]->click(re.button, re.time);
1104 itemSelected(re.button, w); 1101 itemSelected(re.button, w);
1105 1102 m_need_update = true;
1106 update(); // update any changed item 1103 update(w); // update any changed item
1107 } 1104 }
1105 } else {
1106 drawItem(p, isItemEnabled(p) && (p == which_sub), true, true);
1108 } 1107 }
1109 } else 1108 } else
1110 drawItem(p, false, true, true); 1109 drawItem(p, false, true, true);
@@ -1147,12 +1146,15 @@ void Menu::motionNotifyEvent(XMotionEvent &me) {
1147 int p = which_sbl * menu.persub + which_press; 1146 int p = which_sbl * menu.persub + which_press;
1148 MenuItem *item = menuitems[p]; 1147 MenuItem *item = menuitems[p];
1149 1148
1150 drawItem(p, false, true, true); 1149 // don't redraw disabled items on enter/leave
1151 if (item->submenu()) { 1150 if (item->isEnabled()) {
1152 if (item->submenu()->isVisible() && 1151 drawItem(p, false, true, true);
1153 (! item->submenu()->isTorn())) { 1152 if (item->submenu()) {
1154 item->submenu()->internal_hide(); 1153 if (item->submenu()->isVisible() &&
1155 which_sub = -1; 1154 (! item->submenu()->isTorn())) {
1155 item->submenu()->internal_hide();
1156 which_sub = -1;
1157 }
1156 } 1158 }
1157 } 1159 }
1158 } 1160 }
@@ -1165,7 +1167,8 @@ void Menu::motionNotifyEvent(XMotionEvent &me) {
1165 if (itmp->submenu()) 1167 if (itmp->submenu())
1166 drawSubmenu(w); 1168 drawSubmenu(w);
1167 else 1169 else
1168 drawItem(w, itmp->isEnabled(), true, true); 1170 if (itmp->isEnabled())
1171 drawItem(w, true, true, true);
1169 } 1172 }
1170 } 1173 }
1171} 1174}
@@ -1305,6 +1308,7 @@ void Menu::keyPressEvent(XKeyEvent &event) {
1305 if (which_press >= 0 && which_press < menuitems.size()) { 1308 if (which_press >= 0 && which_press < menuitems.size()) {
1306 menuitems[which_press]->click(1, event.time); 1309 menuitems[which_press]->click(1, event.time);
1307 itemSelected(1, which_press); 1310 itemSelected(1, which_press);
1311 m_need_update = true;
1308 update(); 1312 update();
1309 } 1313 }
1310 break; 1314 break;
diff --git a/src/FbTk/Menu.hh b/src/FbTk/Menu.hh
index 2610ad9..9ab69b4 100644
--- a/src/FbTk/Menu.hh
+++ b/src/FbTk/Menu.hh
@@ -22,7 +22,7 @@
22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23// DEALINGS IN THE SOFTWARE. 23// DEALINGS IN THE SOFTWARE.
24 24
25// $Id: Menu.hh,v 1.20 2003/07/20 08:12:36 rathnor Exp $ 25// $Id: Menu.hh,v 1.21 2003/07/20 10:41:56 rathnor Exp $
26 26
27#ifndef FBTK_MENU_HH 27#ifndef FBTK_MENU_HH
28#define FBTK_MENU_HH 28#define FBTK_MENU_HH
@@ -115,7 +115,7 @@ public:
115 void setLabel(const char *labelstr); 115 void setLabel(const char *labelstr);
116 /// move menu to x,y 116 /// move menu to x,y
117 void move(int x, int y); 117 void move(int x, int y);
118 void update(); 118 void update(int active_index = -1);
119 void setItemSelected(unsigned int index, bool val); 119 void setItemSelected(unsigned int index, bool val);
120 void setItemEnabled(unsigned int index, bool val); 120 void setItemEnabled(unsigned int index, bool val);
121 inline void setMinimumSublevels(int m) { menu.minsub = m; } 121 inline void setMinimumSublevels(int m) { menu.minsub = m; }