Prechádzať zdrojové kódy

Control Nudging

You can now nudge controls in the GuiEditor to move them around. You can hold shift to move them faster. The grid is actually on by default.
Peter Robinson 2 rokov pred
rodič
commit
19589b0a8c

+ 1 - 1
editor/GuiEditor/scripts/GuiEditorBrain.cs

@@ -2,7 +2,7 @@
 function GuiEditorBrain::onAdd(%this)
 {
     %this.setFirstResponder();
-    %this.setSnapToGrid("8");
+    %this.setSnapToGrid("10");
 }
 
 function GuiEditorBrain::onControlDragged(%this, %payload, %position)

+ 31 - 9
engine/source/gui/editor/guiEditCtrl.cc

@@ -224,14 +224,6 @@ bool GuiEditCtrl::onWake()
 
    setEditMode(true);
 
-   // TODO: paxorr: I'm not sure this is the best way to set these defaults.
-   bool snap = Con::getBoolVariable("$pref::GuiEditor::snap2grid",false);
-   U32 grid = Con::getIntVariable("$pref::GuiEditor::snap2gridsize",8);
-   Con::setBoolVariable("$pref::GuiEditor::snap2grid", snap);
-   Con::setIntVariable("$pref::GuiEditor::snap2gridsize",grid);
-
-   setSnapToGrid( snap ? grid : 0);
-
    return true;
 }
 
@@ -1373,7 +1365,7 @@ bool GuiEditCtrl::onKeyDown(const GuiEvent &event)
    if (! mActive)
       return Parent::onKeyDown(event);
 
-   if (!(event.modifier & SI_CTRL))
+   if (!(event.modifier & SI_CTRL) && !(event.modifier & SI_SHIFT))
    {
       switch(event.keyCode)
       {
@@ -1382,8 +1374,38 @@ bool GuiEditCtrl::onKeyDown(const GuiEvent &event)
             deleteSelection();
             Con::executef(this,1,"onDelete");
             return true;
+		 case KEY_LEFT:
+			moveSelection(Point2I(-1, 0));
+			return true;
+		 case KEY_RIGHT:
+			 moveSelection(Point2I(1, 0));
+			 return true;
+		 case KEY_UP:
+			 moveSelection(Point2I(0, -1));
+			 return true;
+		 case KEY_DOWN:
+			 moveSelection(Point2I(0, 1));
+			 return true;
       }
    }
+   else if (event.modifier & SI_SHIFT)
+   {
+	   switch (event.keyCode)
+	   {
+	   case KEY_LEFT:
+		   moveSelection(Point2I(mGridSnap.x != 0 ? -mGridSnap.x : -10, 0));
+		   return true;
+	   case KEY_RIGHT:
+		   moveSelection(Point2I(mGridSnap.x != 0 ? mGridSnap.x : 10, 0));
+		   return true;
+	   case KEY_UP:
+		   moveSelection(Point2I(0, mGridSnap.y != 0 ? -mGridSnap.y : -10));
+		   return true;
+	   case KEY_DOWN:
+		   moveSelection(Point2I(0, mGridSnap.y != 0 ? mGridSnap.y : 10));
+		   return true;
+	   }
+   }
    return false;
 }