diff options
author | fluxgen <fluxgen> | 2003-08-04 12:45:42 (GMT) |
---|---|---|
committer | fluxgen <fluxgen> | 2003-08-04 12:45:42 (GMT) |
commit | 774b2a874ea08afd3bda42669f443142627ed344 (patch) | |
tree | 5f2684828b6fd75d370ce134c200ceefbd1570e4 /src | |
parent | 93a10f6233c59e45acc1c15aa91829c851c0cadf (diff) | |
download | fluxbox_pavel-774b2a874ea08afd3bda42669f443142627ed344.zip fluxbox_pavel-774b2a874ea08afd3bda42669f443142627ed344.tar.bz2 |
using builtin transparent in FbWindow
Diffstat (limited to 'src')
-rw-r--r-- | src/FbTk/Menu.cc | 105 |
1 files changed, 59 insertions, 46 deletions
diff --git a/src/FbTk/Menu.cc b/src/FbTk/Menu.cc index f4e9340..67656ae 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.32 2003/07/21 02:45:27 rathnor Exp $ | 25 | // $Id: Menu.cc,v 1.33 2003/08/04 12:45:42 fluxgen Exp $ |
26 | 26 | ||
27 | //use GNU extensions | 27 | //use GNU extensions |
28 | #ifndef _GNU_SOURCE | 28 | #ifndef _GNU_SOURCE |
@@ -90,8 +90,8 @@ Menu::Menu(MenuTheme &tm, int screen_num, ImageControl &imgctrl): | |||
90 | m_alignment(ALIGNDONTCARE), | 90 | m_alignment(ALIGNDONTCARE), |
91 | m_border_width(0), | 91 | m_border_width(0), |
92 | m_themeobserver(*this), | 92 | m_themeobserver(*this), |
93 | m_trans(new Transparent(getRootPixmap(screen_num), 0, | 93 | /* m_trans(new Transparent(getRootPixmap(screen_num), 0, |
94 | tm.alpha(), screen_num)), | 94 | tm.alpha(), screen_num)),*/ |
95 | m_need_update(true) { | 95 | m_need_update(true) { |
96 | 96 | ||
97 | // make sure we get updated when the theme is reloaded | 97 | // make sure we get updated when the theme is reloaded |
@@ -136,44 +136,37 @@ Menu::Menu(MenuTheme &tm, int screen_num, ImageControl &imgctrl): | |||
136 | 136 | ||
137 | menu.height = menu.title_h + 2 + menu.frame_h; | 137 | menu.height = menu.title_h + 2 + menu.frame_h; |
138 | 138 | ||
139 | m_root_pm = getRootPixmap(screen_num); | 139 | // m_root_pm = getRootPixmap(screen_num); |
140 | m_trans->setSource(m_root_pm, screen_num); | 140 | // m_trans->setSource(m_root_pm, screen_num); |
141 | m_trans->setAlpha(alpha()); | 141 | // m_trans->setAlpha(alpha()); |
142 | 142 | long event_mask = ButtonPressMask | ButtonReleaseMask | | |
143 | //set attributes for menu window | ||
144 | unsigned long attrib_mask = CWOverrideRedirect | CWEventMask; | ||
145 | XSetWindowAttributes attrib; | ||
146 | attrib.override_redirect = True; | ||
147 | attrib.event_mask = ButtonPressMask | ButtonReleaseMask | | ||
148 | ButtonMotionMask | KeyPressMask | ExposureMask | FocusChangeMask; | 143 | ButtonMotionMask | KeyPressMask | ExposureMask | FocusChangeMask; |
149 | |||
150 | //create menu window | 144 | //create menu window |
151 | menu.window = XCreateWindow(m_display, RootWindow(m_display, screen_num), | 145 | menu.window = FbTk::FbWindow(screen_num, |
152 | menu.x, menu.y, menu.width, menu.height, | 146 | menu.x, menu.y, menu.width, menu.height, |
153 | 0, CopyFromParent, | 147 | event_mask, |
154 | InputOutput, CopyFromParent, attrib_mask, &attrib); | 148 | true); // override redirect |
149 | |||
155 | // strip focus change mask from attrib, since we should only use it with main window | 150 | // strip focus change mask from attrib, since we should only use it with main window |
156 | attrib.event_mask ^= FocusChangeMask; | 151 | event_mask ^= FocusChangeMask; |
157 | 152 | ||
158 | FbTk::EventManager &evm = *FbTk::EventManager::instance(); | 153 | FbTk::EventManager &evm = *FbTk::EventManager::instance(); |
159 | evm.add(*this, menu.window); | 154 | evm.add(*this, menu.window); |
160 | 155 | ||
161 | //attibutes for title to menuwindow | 156 | |
162 | attrib_mask = CWEventMask; | 157 | event_mask |= EnterWindowMask | LeaveWindowMask; |
163 | attrib.event_mask |= EnterWindowMask | LeaveWindowMask; | ||
164 | //create menu title | 158 | //create menu title |
165 | menu.title = | 159 | menu.title = FbTk::FbWindow(menu.window, |
166 | XCreateWindow(m_display, menu.window.window(), 0, 0, menu.width, menu.height, 0, | 160 | 0, 0, menu.width, menu.height, |
167 | CopyFromParent, InputOutput, CopyFromParent, | 161 | event_mask); |
168 | attrib_mask, &attrib); | 162 | |
169 | evm.add(*this, menu.title); | 163 | evm.add(*this, menu.title); |
170 | 164 | ||
171 | attrib.event_mask |= PointerMotionMask; | 165 | event_mask |= PointerMotionMask; |
172 | menu.frame = XCreateWindow(m_display, menu.window.window(), 0, | 166 | menu.frame = FbTk::FbWindow(menu.window, |
173 | menu.title_h, | 167 | 0, menu.title_h, |
174 | menu.width, menu.frame_h, 0, | 168 | menu.width, menu.frame_h, |
175 | CopyFromParent, InputOutput, | 169 | event_mask); |
176 | CopyFromParent, attrib_mask, &attrib); | ||
177 | evm.add(*this, menu.frame); | 170 | evm.add(*this, menu.frame); |
178 | // update style | 171 | // update style |
179 | reconfigure(); | 172 | reconfigure(); |
@@ -392,10 +385,10 @@ void Menu::update(int active_index) { | |||
392 | m_border_width = 20; | 385 | m_border_width = 20; |
393 | 386 | ||
394 | menu.item_h = m_theme.frameFont().height() + menu.bevel_w; | 387 | menu.item_h = m_theme.frameFont().height() + menu.bevel_w; |
395 | menu.title_h = m_theme.frameFont().height() + menu.bevel_w*2; | 388 | menu.title_h = m_theme.titleFont().height() + menu.bevel_w*2; |
396 | 389 | ||
397 | if (title_vis) { | 390 | if (title_vis) { |
398 | menu.item_w = m_theme.titleFont().textWidth(menu.label.c_str(), menu.label.size()); | 391 | menu.item_w = m_theme.frameFont().textWidth(menu.label.c_str(), menu.label.size()); |
399 | 392 | ||
400 | menu.item_w += (menu.bevel_w * 2); | 393 | menu.item_w += (menu.bevel_w * 2); |
401 | } else | 394 | } else |
@@ -440,10 +433,14 @@ void Menu::update(int active_index) { | |||
440 | if (! menu.width) menu.width = menu.item_w; | 433 | if (! menu.width) menu.width = menu.item_w; |
441 | 434 | ||
442 | menu.frame_h = (menu.item_h * menu.persub); | 435 | menu.frame_h = (menu.item_h * menu.persub); |
443 | menu.height = ((title_vis) ? menu.title_h + menu.title.borderWidth() : 0) + | 436 | if (menu.frame_h < 1) |
437 | menu.frame_h = 1; | ||
438 | |||
439 | menu.height = (title_vis ? menu.title_h + menu.title.borderWidth() : 0) + | ||
444 | menu.frame_h; | 440 | menu.frame_h; |
445 | if (! menu.frame_h) menu.frame_h = 1; | 441 | |
446 | if (menu.height < 1) menu.height = 1; | 442 | if (menu.height < 1) |
443 | menu.height = 1; | ||
447 | 444 | ||
448 | Pixmap tmp; | 445 | Pixmap tmp; |
449 | if (title_vis) { | 446 | if (title_vis) { |
@@ -657,13 +654,12 @@ void Menu::redrawTitle() { | |||
657 | break; | 654 | break; |
658 | } | 655 | } |
659 | menu.title.clear(); | 656 | menu.title.clear(); |
660 | font.drawText( | 657 | font.drawText(menu.title.window(), // drawable |
661 | menu.title.window(), // drawable | ||
662 | screenNumber(), | 658 | screenNumber(), |
663 | m_theme.titleTextGC(), // graphic context | 659 | m_theme.titleTextGC(), // graphic context |
664 | text, len, // text string with lenght | 660 | text, len, // text string with lenght |
665 | dx, font.ascent() + menu.bevel_w); // position | 661 | dx, font.ascent() + menu.bevel_w); // position |
666 | if (m_trans.get()) { | 662 | /* if (m_trans.get()) { |
667 | 663 | ||
668 | if (m_trans->alpha() != 255) { | 664 | if (m_trans->alpha() != 255) { |
669 | Pixmap root_pm = getRootPixmap(menu.window.screenNumber()); | 665 | Pixmap root_pm = getRootPixmap(menu.window.screenNumber()); |
@@ -678,7 +674,9 @@ void Menu::redrawTitle() { | |||
678 | 0, 0, | 674 | 0, 0, |
679 | menu.title.width(), menu.title.height()); | 675 | menu.title.width(), menu.title.height()); |
680 | } | 676 | } |
681 | } | 677 | }*/ |
678 | menu.title.updateTransparent(); | ||
679 | |||
682 | } | 680 | } |
683 | 681 | ||
684 | 682 | ||
@@ -953,8 +951,17 @@ void Menu::drawItem(unsigned int index, bool highlight, bool clear, bool render_ | |||
953 | item_x, item_y, | 951 | item_x, item_y, |
954 | menu.item_w, menu.item_h, False); | 952 | menu.item_w, menu.item_h, False); |
955 | 953 | ||
956 | if (m_trans->alpha() != alpha()) | 954 | // if (m_trans->alpha() != alpha()) |
957 | m_trans->setAlpha(alpha()); | 955 | // m_trans->setAlpha(alpha()); |
956 | menu.title.setAlpha(alpha()); | ||
957 | menu.frame.setAlpha(alpha()); | ||
958 | menu.window.setAlpha(alpha()); | ||
959 | |||
960 | menu.frame.updateTransparent(item_x, item_y, | ||
961 | menu.item_w, menu.item_h); | ||
962 | |||
963 | |||
964 | /* | ||
958 | if (m_trans.get() && render_trans) { | 965 | if (m_trans.get() && render_trans) { |
959 | 966 | ||
960 | if (m_trans->alpha() != 255) { | 967 | if (m_trans->alpha() != 255) { |
@@ -975,7 +982,7 @@ void Menu::drawItem(unsigned int index, bool highlight, bool clear, bool render_ | |||
975 | } | 982 | } |
976 | } | 983 | } |
977 | XSync(m_display, False); | 984 | XSync(m_display, False); |
978 | 985 | */ | |
979 | } | 986 | } |
980 | 987 | ||
981 | void Menu::setLabel(const char *labelstr) { | 988 | void Menu::setLabel(const char *labelstr) { |
@@ -1342,15 +1349,19 @@ void Menu::reconfigure() { | |||
1342 | 1349 | ||
1343 | menu.window.setBorderWidth(m_border_width); | 1350 | menu.window.setBorderWidth(m_border_width); |
1344 | menu.title.setBorderWidth(m_border_width); | 1351 | menu.title.setBorderWidth(m_border_width); |
1345 | 1352 | ||
1353 | menu.frame.setAlpha(alpha()); | ||
1354 | menu.title.setAlpha(alpha()); | ||
1355 | menu.window.setAlpha(alpha()); | ||
1356 | /* | ||
1346 | if (m_trans.get() && m_trans->alpha() != alpha()) | 1357 | if (m_trans.get() && m_trans->alpha() != alpha()) |
1347 | m_trans->setAlpha(alpha()); | 1358 | m_trans->setAlpha(alpha()); |
1348 | 1359 | */ | |
1349 | update(); | 1360 | update(); |
1350 | } | 1361 | } |
1351 | 1362 | ||
1352 | void Menu::renderTransFrame() { | 1363 | void Menu::renderTransFrame() { |
1353 | if (m_trans.get() == 0 || moving) | 1364 | /* if (m_trans.get() == 0 || moving) |
1354 | return; | 1365 | return; |
1355 | 1366 | ||
1356 | if (m_trans->alpha() != alpha()) | 1367 | if (m_trans->alpha() != alpha()) |
@@ -1372,6 +1383,8 @@ void Menu::renderTransFrame() { | |||
1372 | menu.frame.width(), menu.frame.height()); | 1383 | menu.frame.width(), menu.frame.height()); |
1373 | 1384 | ||
1374 | } | 1385 | } |
1386 | */ | ||
1387 | menu.frame.updateTransparent(); | ||
1375 | } | 1388 | } |
1376 | 1389 | ||
1377 | }; // end namespace FbTk | 1390 | }; // end namespace FbTk |