Skip to content

Commit

Permalink
Allow viewport and node panels to use select all and clear hotkeys
Browse files Browse the repository at this point in the history
  • Loading branch information
r888800009 committed Sep 22, 2024
1 parent a70f146 commit f1c3f40
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 8 deletions.
25 changes: 25 additions & 0 deletions source/creator/package.d
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,31 @@ void incSelectAll() {
}
}

/**
Unselects nodes
*/
void incUnselectNodes() {
if (incArmedParameter()) return;
incSelectNode();
}

/**
ModelEdit common Hotkeys
this hotkeys are used in Viewport Panel and Node Panel
*/
void incModelEditorCommonHotKeys() {
import creator.core.input;
if (incEditMode == EditMode.ModelEdit) {
if (!incArmedParameter && (igIsWindowFocused(ImGuiFocusedFlags.ChildWindows) || igIsWindowHovered(ImGuiHoveredFlags.ChildWindows))) {
if (incShortcut("Ctrl+A"))
incSelectAll();

if (igIsKeyDown(ImGuiKey.Escape))
incUnselectNodes();
}
}
}

/**
Gets whether the node is in the selection
*/
Expand Down
9 changes: 1 addition & 8 deletions source/creator/panels/nodes.d
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import creator;
import creator.widgets;
import creator.ext;
import creator.core;
import creator.core.input;
import creator.utils;
import inochi2d;
import std.string;
Expand Down Expand Up @@ -476,13 +475,7 @@ protected:
override
void onUpdate() {

if (incEditMode == EditMode.ModelEdit) {
if (!incArmedParameter && (igIsWindowFocused(ImGuiFocusedFlags.ChildWindows) || igIsWindowHovered(ImGuiHoveredFlags.ChildWindows))) {
if (incShortcut("Ctrl+A")) {
incSelectAll();
}
}
}
incModelEditorCommonHotKeys();

if (incEditMode == EditMode.VertexEdit) {
incLabelOver(_("In vertex edit mode..."), ImVec2(0, 0), true);
Expand Down
2 changes: 2 additions & 0 deletions source/creator/panels/viewport.d
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ protected:
auto drawList = igGetWindowDrawList();
auto window = igGetCurrentWindow();

incModelEditorCommonHotKeys();

// Draw viewport itself
ImVec2 currSize;
igGetContentRegionAvail(&currSize);
Expand Down

0 comments on commit f1c3f40

Please sign in to comment.