]> Dogcows Code - chaz/openbox/commitdiff
add config menu entries for all the new window snapping/resistance options
authorDana Jansens <danakj@orodu.net>
Fri, 2 Aug 2002 19:24:38 +0000 (19:24 +0000)
committerDana Jansens <danakj@orodu.net>
Fri, 2 Aug 2002 19:24:38 +0000 (19:24 +0000)
nls/C/Configmenu.m
src/Configmenu.cc
src/Configmenu.hh

index 97a8fa273480a7b179848603f89a921ad5abaaa2..3fb5bab404688c003d8be203c7fada442f40f5a7 100644 (file)
@@ -20,6 +20,14 @@ $ #FocusLast
 # Focus Window on Workspace Change
 $ #WindowToWindowSnap
 # Window-To-Window Snapping
+$ #WindowToEdgeSnap
+# Window-To-Edge Snapping
+$ #WindowDoSnapNo
+# No Snapping
+$ #WindowDoSnap
+# Edge Snapping
+$ #WindowDoResistance
+# Edge Resistance
 $ #WindowCornerSnap
 # Window Corner Snapping
 $ #WorkspaceWarping
index 8a15b4e119ad900408692a211883bf735a8382bc..99b282093414e54006fdd03235c1d00beb364f2f 100644 (file)
@@ -38,6 +38,8 @@ Configmenu::Configmenu(BScreen *scr) : Basemenu(scr) {
 
   focusmenu = new Focusmenu(this);
   placementmenu = new Placementmenu(this);
+  windowsnapmenu = new WindowToWindowSnapmenu(this);
+  edgesnapmenu = new WindowToEdgeSnapmenu(this);
 #ifdef    XINERAMA
   xineramamenu = new Xineramamenu(this);
 #endif // XINERAMA
@@ -46,6 +48,12 @@ Configmenu::Configmenu(BScreen *scr) : Basemenu(scr) {
               "Focus Model"), focusmenu);
   insert(i18n(ConfigmenuSet, ConfigmenuWindowPlacement,
               "Window Placement"), placementmenu);
+  insert(i18n(ConfigmenuSet, ConfigmenuWindowToWindowSnap,
+              "Window-To-Window Snapping"), windowsnapmenu);
+  insert(i18n(ConfigmenuSet, ConfigmenuWindowToEdgeSnap,
+              "Window-To-Edge Snapping"), edgesnapmenu);
+  insert(i18n(ConfigmenuSet, ConfigmenuWindowPlacement,
+              "Window Placement"), placementmenu);
 #ifdef    XINERAMA
   insert(i18n(ConfigmenuSet, ConfigmenuXineramaSupport,
               "XineramaSupport"), xineramamenu);
@@ -62,21 +70,17 @@ Configmenu::Configmenu(BScreen *scr) : Basemenu(scr) {
               "Focus New Windows"), 5);
   insert(i18n(ConfigmenuSet, ConfigmenuFocusLast,
               "Focus Last Window on Workspace"), 6);
-  insert(i18n(ConfigmenuSet, ConfigmenuWindowToWindowSnap,
-              "Window-To-Window Snapping"), 7);
-  insert(i18n(ConfigmenuSet, ConfigmenuWindowCornerSnap,
-              "Window Corner Snapping"), 8);
   insert(i18n(ConfigmenuSet, ConfigmenuDisableBindings,
-              "Disable Mouse with Scroll Lock"), 9);
+              "Disable Mouse with Scroll Lock"), 7);
   insert(i18n(ConfigmenuSet, ConfigmenuHideToolbar,
-              "Hide Toolbar"), 10);
+              "Hide Toolbar"), 8);
   update();
   setValues();
 }
 
 
 void Configmenu::setValues(void) {
-  int index = 2;
+  int index = 4;
 #ifdef    XINERAMA
   ++index;
 #endif // XINERAMA
@@ -86,11 +90,6 @@ void Configmenu::setValues(void) {
   setItemSelected(index++, getScreen()->doFullMax());
   setItemSelected(index++, getScreen()->doFocusNew());
   setItemSelected(index++, getScreen()->doFocusLast());
-  setItemSelected(index++, getScreen()->getWindowToWindowSnap());
-
-  setItemSelected(index, getScreen()->getWindowCornerSnap());
-  setItemEnabled(index++, getScreen()->getWindowToWindowSnap());
-  
   setItemSelected(index++, getScreen()->allowScrollLock());
   setItemSelected(index++, getScreen()->doHideToolbar());
 }
@@ -99,6 +98,8 @@ void Configmenu::setValues(void) {
 Configmenu::~Configmenu(void) {
   delete focusmenu;
   delete placementmenu;
+  delete windowsnapmenu;
+  delete edgesnapmenu;
 #ifdef    XINERAMA
   delete xineramamenu;
 #endif // XINERAMA
@@ -145,24 +146,13 @@ void Configmenu::itemSelected(int button, unsigned int index) {
     setItemSelected(index, getScreen()->doFocusLast());
     break;
 
-  case 7: // window-to-window snapping
-    getScreen()->saveWindowToWindowSnap(! getScreen()->getWindowToWindowSnap());
-    setItemSelected(index, getScreen()->getWindowToWindowSnap());
-    setItemEnabled(index + 1, getScreen()->getWindowToWindowSnap());
-    break;
-
-  case 8: // window corner snapping
-    getScreen()->saveWindowCornerSnap(! getScreen()->getWindowCornerSnap());
-    setItemSelected(index, getScreen()->getWindowCornerSnap());
-    break;
-
-  case 9: // disable mouse bindings with Scroll Lock
+  case 7: // disable mouse bindings with Scroll Lock
     getScreen()->saveAllowScrollLock(! getScreen()->allowScrollLock());
     setItemSelected(index, getScreen()->allowScrollLock());
     getScreen()->reconfigure();
     break;
 
-  case 10: // hide toolbar
+  case 8: // hide toolbar
     getScreen()->saveHideToolbar(! getScreen()->doHideToolbar());
     setItemSelected(index, getScreen()->doHideToolbar());
     break;
@@ -174,6 +164,8 @@ void Configmenu::reconfigure(void) {
   setValues();
   focusmenu->reconfigure();
   placementmenu->reconfigure();
+  windowsnapmenu->reconfigure();
+  edgesnapmenu->reconfigure();
 #ifdef    XINERAMA
   xineramamenu->reconfigure();
 #endif // XINERAMA
@@ -445,6 +437,131 @@ void Configmenu::Placementmenu::itemSelected(int button, unsigned int index) {
 }
 
 
+Configmenu::WindowToWindowSnapmenu::WindowToWindowSnapmenu(Configmenu *cm) :
+    Basemenu(cm->getScreen()) {
+  setLabel(i18n(ConfigmenuSet, ConfigmenuWindowToWindowSnap,
+                "Window-To-Window Snapping"));
+  setInternalMenu();
+
+  insert(i18n(ConfigmenuSet, ConfigmenuWindowDoSnapNo, "No Snapping"), 1);
+  insert(i18n(ConfigmenuSet, ConfigmenuWindowDoSnap, "Edge Snapping"), 2);
+  insert(i18n(ConfigmenuSet, ConfigmenuWindowDoResistance,
+              "Edge Resistance"), 3);
+  insert(i18n(ConfigmenuSet, ConfigmenuWindowCornerSnap,
+              "Window Corner Snapping"), 4);
+  update();
+  setValues();
+}
+
+
+void Configmenu::WindowToWindowSnapmenu::setValues(void) {
+  setItemSelected(0, (getScreen()->getWindowToWindowSnap() ==
+                      BScreen::WindowNoSnap));
+  setItemSelected(1, (getScreen()->getWindowToWindowSnap() ==
+                      BScreen::WindowSnap));
+  setItemSelected(2, (getScreen()->getWindowToWindowSnap() ==
+                      BScreen::WindowResistance));
+
+  setItemEnabled(3, (getScreen()->getWindowToWindowSnap() ==
+                     BScreen::WindowSnap));
+  setItemSelected(3, getScreen()->getWindowCornerSnap());
+}
+
+
+void Configmenu::WindowToWindowSnapmenu::reconfigure(void) {
+  setValues();
+  Basemenu::reconfigure();
+}
+
+
+void Configmenu::WindowToWindowSnapmenu::itemSelected(int button, unsigned int index) {
+  if (button != 1)
+    return;
+
+  BasemenuItem *item = find(index);
+
+  if (! item->function())
+    return;
+
+  switch (item->function()) {
+  case 1: // none
+    getScreen()->saveWindowToWindowSnap(BScreen::WindowNoSnap);
+    break;
+
+  case 2: // edge snapping
+    getScreen()->saveWindowToWindowSnap(BScreen::WindowSnap);
+    break;
+
+  case 3: // edge resistance
+    getScreen()->saveWindowToWindowSnap(BScreen::WindowResistance);
+    break;
+
+  case 4: // window corner snapping
+    getScreen()->saveWindowCornerSnap(! getScreen()->getWindowCornerSnap());
+    break;
+
+  }
+  setValues();
+}
+
+
+Configmenu::WindowToEdgeSnapmenu::WindowToEdgeSnapmenu(Configmenu *cm) :
+    Basemenu(cm->getScreen()) {
+  setLabel(i18n(ConfigmenuSet, ConfigmenuWindowToEdgeSnap,
+                "Window-To-Edge Snapping"));
+  setInternalMenu();
+
+  insert(i18n(ConfigmenuSet, ConfigmenuWindowDoSnapNo, "No Snapping"), 1);
+  insert(i18n(ConfigmenuSet, ConfigmenuWindowDoSnap, "Edge Snapping"), 2);
+  insert(i18n(ConfigmenuSet, ConfigmenuWindowDoResistance,
+              "Edge Resistance"), 3);
+  update();
+  setValues();
+}
+
+
+void Configmenu::WindowToEdgeSnapmenu::setValues(void) {
+  setItemSelected(0, (getScreen()->getWindowToEdgeSnap() ==
+                      BScreen::WindowNoSnap));
+  setItemSelected(1, (getScreen()->getWindowToEdgeSnap() ==
+                      BScreen::WindowSnap));
+  setItemSelected(2, (getScreen()->getWindowToEdgeSnap() ==
+                      BScreen::WindowResistance));
+}
+
+
+void Configmenu::WindowToEdgeSnapmenu::reconfigure(void) {
+  setValues();
+  Basemenu::reconfigure();
+}
+
+
+void Configmenu::WindowToEdgeSnapmenu::itemSelected(int button, unsigned int index) {
+  if (button != 1)
+    return;
+
+  BasemenuItem *item = find(index);
+
+  if (! item->function())
+    return;
+
+  switch (item->function()) {
+  case 1: // none
+    getScreen()->saveWindowToEdgeSnap(BScreen::WindowNoSnap);
+    break;
+
+  case 2: // edge snapping
+    getScreen()->saveWindowToEdgeSnap(BScreen::WindowSnap);
+    break;
+
+  case 3: // edge resistance
+    getScreen()->saveWindowToEdgeSnap(BScreen::WindowResistance);
+    break;
+  }
+  setValues();
+}
+
+
 #ifdef    XINERAMA
 Configmenu::Xineramamenu::Xineramamenu(Configmenu *cm):
   Basemenu(cm->getScreen()) {
index 3ff3222de11992ed96e8a4f96f609796073c6b02..489bd32326dc6319dce3a88d38eafcdac2b131c9 100644 (file)
@@ -61,6 +61,34 @@ private:
     virtual void reconfigure(void);
   };
 
+  class WindowToWindowSnapmenu : public Basemenu {
+  private:
+    WindowToWindowSnapmenu(const WindowToWindowSnapmenu&);
+    WindowToWindowSnapmenu& operator=(const WindowToWindowSnapmenu&);
+
+  protected:
+    virtual void itemSelected(int button, unsigned int index);
+    virtual void setValues(void);
+
+  public:
+    WindowToWindowSnapmenu(Configmenu *cm);
+    virtual void reconfigure(void);
+  };
+
+  class WindowToEdgeSnapmenu : public Basemenu {
+  private:
+    WindowToEdgeSnapmenu(const WindowToEdgeSnapmenu&);
+    WindowToEdgeSnapmenu& operator=(const WindowToEdgeSnapmenu&);
+
+  protected:
+    virtual void itemSelected(int button, unsigned int index);
+    virtual void setValues(void);
+
+  public:
+    WindowToEdgeSnapmenu(Configmenu *cm);
+    virtual void reconfigure(void);
+  };
+
 #ifdef    XINERAMA
   class Xineramamenu : public Basemenu {
   private:
@@ -79,12 +107,14 @@ private:
 
   Focusmenu *focusmenu;
   Placementmenu *placementmenu;
+  WindowToWindowSnapmenu *windowsnapmenu;
+  WindowToEdgeSnapmenu *edgesnapmenu;
 #ifdef    XINERAMA
   Xineramamenu *xineramamenu;
 #endif // XINERAMA
 
-  friend class Focusmenu;
-  friend class Placementmenu;
+//  friend class Focusmenu;
+//  friend class Placementmenu;
 
   Configmenu(const Configmenu&);
   Configmenu& operator=(const Configmenu&);
This page took 0.031697 seconds and 4 git commands to generate.