aboutsummaryrefslogtreecommitdiff
path: root/src/FbTk/Menu.cc
diff options
context:
space:
mode:
authorrathnor <rathnor>2004-05-17 15:01:32 (GMT)
committerrathnor <rathnor>2004-05-17 15:01:32 (GMT)
commitc1fb3b3e1a08ef8ad479cf76ba2520bc72591c6c (patch)
treebea96a100cf871864bc93e5ae9c9d1dd695bef96 /src/FbTk/Menu.cc
parent949a932036354d9b7ce8cc31b2c153c9acfaf4be (diff)
downloadfluxbox-c1fb3b3e1a08ef8ad479cf76ba2520bc72591c6c.zip
fluxbox-c1fb3b3e1a08ef8ad479cf76ba2520bc72591c6c.tar.bz2
fix menu transparency rendering bug, and add save_under to menu windows
Diffstat (limited to 'src/FbTk/Menu.cc')
-rw-r--r--src/FbTk/Menu.cc48
1 files changed, 26 insertions, 22 deletions
diff --git a/src/FbTk/Menu.cc b/src/FbTk/Menu.cc
index f6cbca4..60c40f8 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.59 2004/04/19 22:47:36 fluxgen Exp $ 25// $Id: Menu.cc,v 1.60 2004/05/17 15:01:32 rathnor Exp $
26 26
27//use GNU extensions 27//use GNU extensions
28#ifndef _GNU_SOURCE 28#ifndef _GNU_SOURCE
@@ -122,7 +122,8 @@ Menu::Menu(MenuTheme &tm, ImageControl &imgctrl):
122 menu.window = FbTk::FbWindow(tm.screenNum(), 122 menu.window = FbTk::FbWindow(tm.screenNum(),
123 0, 0, 10, 10, 123 0, 0, 10, 10,
124 event_mask, 124 event_mask,
125 true); // override redirect 125 true, // override redirect
126 true); // save_under
126 127
127 // strip focus change mask from attrib, since we should only use it with main window 128 // strip focus change mask from attrib, since we should only use it with main window
128 event_mask ^= FocusChangeMask; 129 event_mask ^= FocusChangeMask;
@@ -143,7 +144,7 @@ Menu::Menu(MenuTheme &tm, ImageControl &imgctrl):
143 menu.frame = FbTk::FbWindow(menu.window, 144 menu.frame = FbTk::FbWindow(menu.window,
144 0, menu.title_h, 145 0, menu.title_h,
145 width(), menu.frame_h ? menu.frame_h : 1, 146 width(), menu.frame_h ? menu.frame_h : 1,
146 event_mask); 147 event_mask, false, true);
147 evm.add(*this, menu.frame); 148 evm.add(*this, menu.frame);
148 // update style 149 // update style
149 reconfigure(); 150 reconfigure();
@@ -1226,29 +1227,34 @@ void Menu::exposeEvent(XExposeEvent &ee) {
1226 // this is a compilicated algorithm... lets do it step by step... 1227 // this is a compilicated algorithm... lets do it step by step...
1227 // first... we see in which sub level the expose starts... and how many 1228 // first... we see in which sub level the expose starts... and how many
1228 // items down in that sublevel 1229 // items down in that sublevel
1230
1231 // Simon was here :-) I think this all makes much more sense when
1232 // we rename sbl to "start_col", sbl_d to "end_col", ditto id -> row
1233 // a "sublevel" is basically a column in a multi-column menu (e.g. placement)
1234
1229 if (menu.item_w == 0) 1235 if (menu.item_w == 0)
1230 menu.item_w = 1; 1236 menu.item_w = 1;
1231 if (menu.item_h == 0) 1237 if (menu.item_h == 0)
1232 menu.item_h = 1; 1238 menu.item_h = 1;
1233 unsigned int sbl = (ee.x / menu.item_w), id = (ee.y / menu.item_h), 1239 unsigned int
1234 // next... figure out how many sublevels over the redraw spans 1240 start_column = (ee.x / menu.item_w),
1235 sbl_d = ((ee.x + ee.width) / menu.item_w), 1241 end_column = ((ee.x + ee.width) / menu.item_w),
1236 // then we see how many items down to redraw 1242 start_row = (ee.y / menu.item_h),
1237 id_d = ((ee.y + ee.height) / menu.item_h); 1243 end_row = ((ee.y + ee.height) / menu.item_h);
1238 if (static_cast<signed>(id_d) > menu.persub) 1244 if (static_cast<signed>(end_row) > menu.persub)
1239 id_d = menu.persub; 1245 end_row = menu.persub;
1240 1246
1241 // draw the sublevels and the number of items the exposure spans 1247 // draw the sublevels and the number of items the exposure spans
1242 unsigned int i, ii; 1248 unsigned int col, row;
1243 int max_y = 0; 1249 int max_y = 0;
1244 for (i = sbl; i <= sbl_d; i++) { 1250 for (col = start_column; col <= end_column; col++) {
1245 // set the iterator to the first item in the sublevel needing redrawing 1251 // set the iterator to the first item in the column needing redrawing
1246 unsigned int index = id + i * menu.persub; 1252 unsigned int index = start_row + col * menu.persub;
1247 if (index < menuitems.size()) { 1253 if (index < menuitems.size()) {
1248 Menuitems::iterator it = menuitems.begin() + index; 1254 Menuitems::iterator it = menuitems.begin() + index;
1249 Menuitems::iterator it_end = menuitems.end(); 1255 Menuitems::iterator it_end = menuitems.end();
1250 for (ii = id; ii <= id_d && it != it_end; ++it, ii++) { 1256 for (row = start_row; row <= end_row && it != it_end; ++it, row++) {
1251 unsigned int index = ii + (i * menu.persub); 1257 unsigned int index = row + (col * menu.persub);
1252 max_y = max(drawItem(index, 1258 max_y = max(drawItem(index,
1253 (which_sub == static_cast<signed>(index)), // highlight 1259 (which_sub == static_cast<signed>(index)), // highlight
1254 true, // clear 1260 true, // clear
@@ -1257,12 +1263,10 @@ void Menu::exposeEvent(XExposeEvent &ee) {
1257 } 1263 }
1258 } 1264 }
1259 } 1265 }
1260 if (menu.persub != 0) { 1266 menu.frame.updateTransparent(start_column * menu.item_w,
1261 int index_min = id + sbl * menu.persub; 1267 start_row * menu.item_h,
1262 int min_y = (index_min - (index_min/menu.persub)*menu.persub) * menu.item_h; 1268 (end_column-start_column+1) * menu.item_w,
1263 menu.frame.updateTransparent(0, min_y, 1269 (end_row-start_row+1) * menu.item_h);
1264 width(), max_y + menu.item_h);
1265 }
1266 } 1270 }
1267} 1271}
1268 1272