소스 검색

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 년 전
부모
커밋
19589b0a8c
2개의 변경된 파일32개의 추가작업 그리고 10개의 파일을 삭제
  1. 1 1
      editor/GuiEditor/scripts/GuiEditorBrain.cs
  2. 31 9
      engine/source/gui/editor/guiEditCtrl.cc

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

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

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

@@ -224,14 +224,6 @@ bool GuiEditCtrl::onWake()
 
 
    setEditMode(true);
    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;
    return true;
 }
 }
 
 
@@ -1373,7 +1365,7 @@ bool GuiEditCtrl::onKeyDown(const GuiEvent &event)
    if (! mActive)
    if (! mActive)
       return Parent::onKeyDown(event);
       return Parent::onKeyDown(event);
 
 
-   if (!(event.modifier & SI_CTRL))
+   if (!(event.modifier & SI_CTRL) && !(event.modifier & SI_SHIFT))
    {
    {
       switch(event.keyCode)
       switch(event.keyCode)
       {
       {
@@ -1382,8 +1374,38 @@ bool GuiEditCtrl::onKeyDown(const GuiEvent &event)
             deleteSelection();
             deleteSelection();
             Con::executef(this,1,"onDelete");
             Con::executef(this,1,"onDelete");
             return true;
             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;
    return false;
 }
 }