aboutsummaryrefslogtreecommitdiff
path: root/src/MenuCreator.cc
diff options
context:
space:
mode:
authorsimonb <simonb>2007-01-07 11:55:14 (GMT)
committersimonb <simonb>2007-01-07 11:55:14 (GMT)
commit1cc7b60aa2c2e7a26f9ff6f1461ca0b8a97be8de (patch)
tree1de2b149b23e589a36c81bd2aa51092db7b6e190 /src/MenuCreator.cc
parentcfd33dd7a8f392253d8af9f418d86dc3083fc27d (diff)
downloadfluxbox-1cc7b60aa2c2e7a26f9ff6f1461ca0b8a97be8de.zip
fluxbox-1cc7b60aa2c2e7a26f9ff6f1461ca0b8a97be8de.tar.bz2
per-window transparency, including apps and menu support, plus some
infrastructure and related changes. Thanks for original patch from Julien Trolet, dmxen at sourceforge dot net
Diffstat (limited to 'src/MenuCreator.cc')
-rw-r--r--src/MenuCreator.cc101
1 files changed, 82 insertions, 19 deletions
diff --git a/src/MenuCreator.cc b/src/MenuCreator.cc
index 31ef06d..5264a4d 100644
--- a/src/MenuCreator.cc
+++ b/src/MenuCreator.cc
@@ -35,7 +35,9 @@
35#include "WorkspaceMenu.hh" 35#include "WorkspaceMenu.hh"
36#include "LayerMenu.hh" 36#include "LayerMenu.hh"
37#include "SendToMenu.hh" 37#include "SendToMenu.hh"
38#include "AlphaMenu.hh"
38#include "Layer.hh" 39#include "Layer.hh"
40#include "BoolMenuItem.hh"
39 41
40#include "FbMenuParser.hh" 42#include "FbMenuParser.hh"
41#include "StyleMenuItem.hh" 43#include "StyleMenuItem.hh"
@@ -50,6 +52,7 @@
50#include "FbTk/FileUtil.hh" 52#include "FbTk/FileUtil.hh"
51#include "FbTk/MenuSeparator.hh" 53#include "FbTk/MenuSeparator.hh"
52#include "FbTk/MenuIcon.hh" 54#include "FbTk/MenuIcon.hh"
55#include "FbTk/Transparent.hh"
53 56
54#include <iostream> 57#include <iostream>
55 58
@@ -155,7 +158,7 @@ private:
155 FbTk::Menu *m_menu; 158 FbTk::Menu *m_menu;
156}; 159};
157 160
158class MenuContext: public LayerObject { 161class MenuContext: public LayerObject, public AlphaObject {
159public: 162public:
160 void moveToLayer(int layer_number) { 163 void moveToLayer(int layer_number) {
161 if (WindowCmd<void>::window() == 0) 164 if (WindowCmd<void>::window() == 0)
@@ -167,6 +170,43 @@ public:
167 return -1; 170 return -1;
168 return WindowCmd<void>::window()->layerItem().getLayerNum(); 171 return WindowCmd<void>::window()->layerItem().getLayerNum();
169 } 172 }
173
174 int getFocusedAlpha() const {
175 if (WindowCmd<void>::window() == 0)
176 return 255;
177 return WindowCmd<void>::window()->getFocusedAlpha();
178 }
179
180 int getUnfocusedAlpha() const {
181 if (WindowCmd<void>::window() == 0)
182 return 255;
183 return WindowCmd<void>::window()->getUnfocusedAlpha();
184 }
185
186 bool getUseDefaultAlpha() const {
187 if (WindowCmd<void>::window() == 0)
188 return true;
189 return WindowCmd<void>::window()->getUseDefaultAlpha();
190 }
191
192 void setFocusedAlpha(int alpha) {
193 if (WindowCmd<void>::window() == 0)
194 return;
195 WindowCmd<void>::window()->setFocusedAlpha(alpha);
196 }
197
198 void setUnfocusedAlpha(int alpha) {
199 if (WindowCmd<void>::window() == 0)
200 return;
201 WindowCmd<void>::window()->setUnfocusedAlpha(alpha);
202 }
203
204 void setUseDefaultAlpha(bool use_default) {
205 if (WindowCmd<void>::window() == 0)
206 return;
207 WindowCmd<void>::window()->setUseDefaultAlpha(use_default);
208 }
209
170}; 210};
171 211
172static void translateMenuItem(Parser &parse, ParseItem &item, FbTk::StringConvertor &labelconvertor); 212static void translateMenuItem(Parser &parse, ParseItem &item, FbTk::StringConvertor &labelconvertor);
@@ -489,6 +529,7 @@ FbTk::Menu *MenuCreator::createMenuType(const string &type, int screen_num) {
489 "lower", 529 "lower",
490 "sendto", 530 "sendto",
491 "layer", 531 "layer",
532 "alpha",
492 "extramenus", 533 "extramenus",
493 "separator", 534 "separator",
494 "close", 535 "close",
@@ -510,9 +551,14 @@ bool MenuCreator::createWindowMenuItem(const string &type,
510 typedef FbTk::RefCount<FbTk::Command> RefCmd; 551 typedef FbTk::RefCount<FbTk::Command> RefCmd;
511 _FB_USES_NLS; 552 _FB_USES_NLS;
512 553
554 static MenuContext context;
555
513 if (type == "shade") { 556 if (type == "shade") {
514 RefCmd shade_cmd(new WindowCmd<void>(&FluxboxWindow::shade)); 557 static ObjectResource<FluxboxWindow, bool> res(&WindowCmd<void>::window, &FluxboxWindow::isShaded, &FluxboxWindow::shade, false);
515 menu.insert(label.empty()?_FB_XTEXT(Windowmenu, Shade, "Shade", "Shade the window"):label, shade_cmd); 558 menu.insert(new BoolResMenuItem<ObjectResource<FluxboxWindow, bool> >(
559 label.empty()?_FB_XTEXT(Windowmenu, Shade, "Shade", "Shade the window"):label,
560 res));
561
516 } else if (type == "maximize") { 562 } else if (type == "maximize") {
517 RefCmd maximize_cmd(new WindowCmd<void>(&FluxboxWindow::maximizeFull)); 563 RefCmd maximize_cmd(new WindowCmd<void>(&FluxboxWindow::maximizeFull));
518 RefCmd maximize_vert_cmd(new WindowCmd<void>(&FluxboxWindow::maximizeVertical)); 564 RefCmd maximize_vert_cmd(new WindowCmd<void>(&FluxboxWindow::maximizeVertical));
@@ -532,41 +578,60 @@ bool MenuCreator::createWindowMenuItem(const string &type,
532 maximize_item->setCommand(3, maximize_horiz_cmd); 578 maximize_item->setCommand(3, maximize_horiz_cmd);
533 menu.insert(maximize_item); 579 menu.insert(maximize_item);
534 } else if (type == "iconify") { 580 } else if (type == "iconify") {
535 RefCmd iconify_cmd(new WindowCmd<void>(&FluxboxWindow::iconify)); 581 static ObjectResource<FluxboxWindow, bool> res(&WindowCmd<void>::window, &FluxboxWindow::isIconic, &FluxboxWindow::toggleIconic, false);
536 menu.insert(label.empty() ? 582 menu.insert(new BoolResMenuItem<ObjectResource<FluxboxWindow, bool> >(
537 _FB_XTEXT(Windowmenu, Iconify, 583 label.empty() ?
538 "Iconify", "Iconify the window") : 584 _FB_XTEXT(Windowmenu, Iconify,
539 label, iconify_cmd); 585 "Iconify", "Iconify the window") :
586 label, res));
540 } else if (type == "close") { 587 } else if (type == "close") {
541 RefCmd close_cmd(new WindowCmd<void>(&FluxboxWindow::close)); 588 RefCmd close_cmd(new WindowCmd<void>(&FluxboxWindow::close));
542 menu.insert(label.empty() ? 589 menu.insert(label.empty() ?
543 _FB_XTEXT(Windowmenu, Close, 590 _FB_XTEXT(Windowmenu, Close,
544 "Close", "Close the window") : 591 "Close", "Close the window") :
545 label, close_cmd); 592 label, close_cmd);
546 } else if (type == "kill" || type == "killwindow") { 593 } else if (type == "kill" || type == "killwindow") {
547 RefCmd kill_cmd(new WindowCmd<void>(&FluxboxWindow::kill)); 594 RefCmd kill_cmd(new WindowCmd<void>(&FluxboxWindow::kill));
548 menu.insert(label.empty() ? 595 menu.insert(label.empty() ?
549 _FB_XTEXT(Windowmenu, Kill, 596 _FB_XTEXT(Windowmenu, Kill,
550 "Kill", "Kill the window"): 597 "Kill", "Kill the window"):
551 label, kill_cmd); 598 label, kill_cmd);
552 } else if (type == "lower") { 599 } else if (type == "lower") {
553 RefCmd lower_cmd(new WindowCmd<void>(&FluxboxWindow::lower)); 600 RefCmd lower_cmd(new WindowCmd<void>(&FluxboxWindow::lower));
554 menu.insert( label.empty() ? 601 menu.insert( label.empty() ?
555 _FB_XTEXT(Windowmenu, Lower, 602 _FB_XTEXT(Windowmenu, Lower,
556 "Lower", "Lower the window"): 603 "Lower", "Lower the window"):
557 label, lower_cmd); 604 label, lower_cmd);
558 } else if (type == "raise") { 605 } else if (type == "raise") {
559 RefCmd raise_cmd(new WindowCmd<void>(&FluxboxWindow::raise)); 606 RefCmd raise_cmd(new WindowCmd<void>(&FluxboxWindow::raise));
560 menu.insert(label.empty() ? 607 menu.insert(label.empty() ?
561 _FB_XTEXT(Windowmenu, Raise, 608 _FB_XTEXT(Windowmenu, Raise,
562 "Raise", "Raise the window"): 609 "Raise", "Raise the window"):
563 label, raise_cmd); 610 label, raise_cmd);
611
564 } else if (type == "stick") { 612 } else if (type == "stick") {
565 RefCmd stick_cmd(new WindowCmd<void>(&FluxboxWindow::stick)); 613 static ObjectResource<FluxboxWindow, bool> res(&WindowCmd<void>::window, &FluxboxWindow::isStuck, &FluxboxWindow::stick, false);
566 menu.insert(label.empty() ? 614 menu.insert(new BoolResMenuItem<ObjectResource<FluxboxWindow, bool> >(
567 _FB_XTEXT(Windowmenu, Stick, 615 label.empty() ?
568 "Stick", "Stick the window"): 616 _FB_XTEXT(Windowmenu, Stick,
569 label, stick_cmd); 617 "Stick", "Stick the window"):
618 label, res));
619#ifdef HAVE_XRENDER
620 } else if (type == "alpha") {
621 if (FbTk::Transparent::haveComposite() ||
622 FbTk::Transparent::haveRender()) {
623 BScreen *screen = Fluxbox::instance()->findScreen(menu.screenNumber());
624 if (screen == 0)
625 return false;
626
627 menu.insert(label.empty() ? _FB_XTEXT(Configmenu, Transparency, "Transparency",
628 "Menu containing various transparency options"): label,
629 new AlphaMenu(screen->menuTheme(),
630 screen->imageControl(),
631 *screen->layerManager().getLayer(Layer::MENU),
632 context));
633 }
634#endif // HAVE_XRENDER
570 } else if (type == "extramenus") { 635 } else if (type == "extramenus") {
571 BScreen *screen = Fluxbox::instance()->findScreen(menu.screenNumber()); 636 BScreen *screen = Fluxbox::instance()->findScreen(menu.screenNumber());
572 BScreen::ExtraMenus::iterator it = screen->extraWindowMenus().begin(); 637 BScreen::ExtraMenus::iterator it = screen->extraWindowMenus().begin();
@@ -584,8 +649,6 @@ bool MenuCreator::createWindowMenuItem(const string &type,
584 if (screen == 0) 649 if (screen == 0)
585 return false; 650 return false;
586 651
587 static MenuContext context;
588
589 FbTk::Menu *submenu = new LayerMenu(screen->menuTheme(), 652 FbTk::Menu *submenu = new LayerMenu(screen->menuTheme(),
590 screen->imageControl(), 653 screen->imageControl(),
591 *screen->layerManager().getLayer(Layer::MENU), 654 *screen->layerManager().getLayer(Layer::MENU),