Skip to content

Commit bd646e5

Browse files
committed
Create group by key press.
1 parent 8a796b2 commit bd646e5

8 files changed

Lines changed: 136 additions & 0 deletions

File tree

Sources/NodeEngineTest/NodeEditorVisualTest.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,23 @@ TEST (SelectionTest)
164164
}
165165
}
166166

167+
TEST (CreateGroupTest)
168+
{
169+
SimpleNodeEditorTestEnv env (GetDefaultSkinParams ());
170+
171+
{ // select two nodes with selection rect
172+
Point rectSelectStart = env.rangeInputRect.GetTopLeft () - Point (10.0, 10.0);
173+
Point rectSelectEnd (env.viewer2InputRect.GetRight () + 10.0, env.rangeInputRect.GetBottom () + 10.0);
174+
env.DragDrop (rectSelectStart, rectSelectEnd);
175+
ASSERT (env.CheckReference ("CreateGroup_NodesSelected.svg"));
176+
}
177+
178+
{ // create group
179+
env.KeyPress (Key (KeyCode::Group));
180+
ASSERT (env.CheckReference ("CreateGroup_GroupCreated.svg"));
181+
}
182+
}
183+
167184
TEST (MoveNodesTest)
168185
{
169186
SimpleNodeEditorTestEnv env (GetDefaultSkinParams ());
Lines changed: 53 additions & 0 deletions
Loading
Lines changed: 51 additions & 0 deletions
Loading

Sources/NodeEngineTest/VisualTestFramework.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,11 @@ void NodeEditorTestEnv::DragDrop (const ModifierKeys& keys, const Point& from, c
380380
nodeEditor.OnMouseUp (keys, MouseButton::Left, (int) to.GetX (), (int) to.GetY ());
381381
}
382382

383+
void NodeEditorTestEnv::KeyPress (const NUIE::Key& key)
384+
{
385+
nodeEditor.OnKeyPress (key);
386+
}
387+
383388
void NodeEditorTestEnv::SetNextCommandName (const std::wstring& nextCommandName)
384389
{
385390
uiEnvironment.SetNextCommandName (nextCommandName);

Sources/NodeEngineTest/VisualTestFramework.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ class NodeEditorTestEnv
8282
void Wheel (MouseWheelRotation rotation, const Point& point);
8383
void DragDrop (const Point& from, const Point& to, const std::function<void ()>& beforeMouseUp = nullptr);
8484
void DragDrop (const ModifierKeys& keys, const Point& from, const Point& to, const std::function<void ()>& beforeMouseUp = nullptr);
85+
void KeyPress (const NUIE::Key& key);
8586
void SetNextCommandName (const std::wstring& nextCommandName);
8687
void SetNextCommandParameterSettings (const ParameterSettingsHandler& handler);
8788

Sources/NodeUIEngine/NUIE_InputEventHandler.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ enum class KeyCode
3737
SelectAll,
3838
Copy,
3939
Paste,
40+
Group,
4041
Undo,
4142
Redo
4243
};

Sources/NodeUIEngine/NUIE_InteractionHandler.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -865,6 +865,11 @@ EventHandlerResult InteractionHandler::HandleKeyPress (NodeUIEnvironment& env, c
865865
command.reset (new PasteNodesMenuCommand (uiManager, modelPastePosition));
866866
}
867867
break;
868+
case KeyCode::Group:
869+
{
870+
command.reset (new CreateGroupMenuCommand (uiManager, selectedNodes));
871+
}
872+
break;
868873
case KeyCode::Undo:
869874
{
870875
command.reset (new UndoMenuCommand (uiManager, env));

Sources/WindowsAppSupport/WAS_NodeEditorHwndControl.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,9 @@ static LRESULT CALLBACK NodeEditorStaticWindowProc (HWND hwnd, UINT msg, WPARAM
173173
case 'V':
174174
pressedKey.SetKeyCode (NUIE::KeyCode::Paste);
175175
break;
176+
case 'G':
177+
pressedKey.SetKeyCode (NUIE::KeyCode::Group);
178+
break;
176179
case 'Z':
177180
pressedKey.SetKeyCode (NUIE::KeyCode::Undo);
178181
break;

0 commit comments

Comments
 (0)