Skip to content

Commit

Permalink
Finish cleaving the rest of the imgui API
Browse files Browse the repository at this point in the history
  • Loading branch information
adamkewley committed Sep 14, 2024
1 parent ebf1df4 commit b51febd
Show file tree
Hide file tree
Showing 13 changed files with 225 additions and 71 deletions.
2 changes: 1 addition & 1 deletion src/OpenSimCreator/UI/MeshImporter/ChooseElLayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ namespace osc::mi
{
m_Shared->tick(dt);

if (ui::is_key_pressed(ImGuiKey_Escape))
if (ui::is_key_pressed(ui::Key::Escape))
{
// ESC: user cancelled out
requestPop();
Expand Down
28 changes: 14 additions & 14 deletions src/OpenSimCreator/UI/MeshImporter/MeshImporterTab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -750,79 +750,79 @@ class osc::mi::MeshImporterTab::Impl final : public IMeshImporterUILayerHost {
bool shiftDown = ui::is_shift_down();
bool ctrlOrSuperDown = ui::is_ctrl_or_super_down();

if (ctrlOrSuperDown && ui::is_key_pressed(ImGuiKey_N))
if (ctrlOrSuperDown && ui::is_key_pressed(ui::Key::N))
{
// Ctrl+N: new scene
m_Shared->requestNewMeshImporterTab();
return true;
}
else if (ctrlOrSuperDown && ui::is_key_pressed(ImGuiKey_O))
else if (ctrlOrSuperDown && ui::is_key_pressed(ui::Key::O))
{
// Ctrl+O: open osim
m_Shared->openOsimFileAsModelGraph();
return true;
}
else if (ctrlOrSuperDown && shiftDown && ui::is_key_pressed(ImGuiKey_S))
else if (ctrlOrSuperDown && shiftDown && ui::is_key_pressed(ui::Key::S))
{
// Ctrl+Shift+S: export as: export scene as osim to user-specified location
m_Shared->exportAsModelGraphAsOsimFile();
return true;
}
else if (ctrlOrSuperDown && ui::is_key_pressed(ImGuiKey_S))
else if (ctrlOrSuperDown && ui::is_key_pressed(ui::Key::S))
{
// Ctrl+S: export: export scene as osim according to typical export heuristic
m_Shared->exportModelGraphAsOsimFile();
return true;
}
else if (ctrlOrSuperDown && ui::is_key_pressed(ImGuiKey_Q))
else if (ctrlOrSuperDown && ui::is_key_pressed(ui::Key::Q))
{
// Ctrl+Q: quit application
App::upd().request_quit();
return true;
}
else if (ctrlOrSuperDown && ui::is_key_pressed(ImGuiKey_A))
else if (ctrlOrSuperDown && ui::is_key_pressed(ui::Key::A))
{
// Ctrl+A: select all
m_Shared->selectAll();
return true;
}
else if (ctrlOrSuperDown && shiftDown && ui::is_key_pressed(ImGuiKey_Z))
else if (ctrlOrSuperDown && shiftDown && ui::is_key_pressed(ui::Key::Z))
{
// Ctrl+Shift+Z: redo
m_Shared->redoCurrentModelGraph();
return true;
}
else if (ctrlOrSuperDown && ui::is_key_pressed(ImGuiKey_Z))
else if (ctrlOrSuperDown && ui::is_key_pressed(ui::Key::Z))
{
// Ctrl+Z: undo
m_Shared->undoCurrentModelGraph();
return true;
}
else if (ui::any_of_keys_down({ImGuiKey_Delete, ImGuiKey_Backspace}))
else if (ui::any_of_keys_down({ui::Key::Delete, ui::Key::Backspace}))
{
// Delete/Backspace: delete any selected elements
deleteSelected();
return true;
}
else if (ui::is_key_pressed(ImGuiKey_B))
else if (ui::is_key_pressed(ui::Key::B))
{
// B: add body to hovered element
tryAddBodyToHoveredElement();
return true;
}
else if (ui::is_key_pressed(ImGuiKey_A))
else if (ui::is_key_pressed(ui::Key::A))
{
// A: assign a parent for the hovered element
tryTransitionToAssigningHoverAndSelectionNextFrame();
return true;
}
else if (ui::is_key_pressed(ImGuiKey_J))
else if (ui::is_key_pressed(ui::Key::J))
{
// J: try to create a joint
tryCreatingJointFromHoveredElement();
return true;
}
else if (ui::is_key_pressed(ImGuiKey_T))
else if (ui::is_key_pressed(ui::Key::T))
{
// T: try to add a station to the current hover
tryAddingStationAtMousePosToHoveredElement();
Expand Down Expand Up @@ -1605,7 +1605,7 @@ class osc::mi::MeshImporterTab::Impl final : public IMeshImporterUILayerHost {


// context menu should be closed under these conditions
if (ui::any_of_keys_pressed({ImGuiKey_Enter, ImGuiKey_Escape}))
if (ui::any_of_keys_pressed({ui::Key::Enter, ui::Key::Escape}))
{
m_MaybeOpenedContextMenu.reset();
ui::close_current_popup();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ namespace osc::mi
{
m_Shared->tick(dt);

if (ui::is_key_pressed(ImGuiKey_Escape))
if (ui::is_key_pressed(ui::Key::Escape))
{
// ESC: user cancelled out
requestPop();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ namespace osc

// event: if the user is hovering the render while something is selected and the user
// presses delete then the landmarks should be deleted
if (htResult.is_hovered && ui::any_of_keys_pressed({ImGuiKey_Delete, ImGuiKey_Backspace}))
if (htResult.is_hovered && ui::any_of_keys_pressed({ui::Key::Delete, ui::Key::Backspace}))
{
ActionDeleteSceneElementsByID(
m_State->updUndoable(),
Expand Down Expand Up @@ -577,7 +577,7 @@ namespace osc
{
static_assert(num_options<TPSDocumentInputIdentifier>() == 2);
const bool isSourceMesh = m_DocumentIdentifier == TPSDocumentInputIdentifier::Source;
const bool isCtrlPressed = ui::any_of_keys_down({ImGuiKey_LeftCtrl, ImGuiKey_RightCtrl});
const bool isCtrlPressed = ui::any_of_keys_down({ui::Key::LeftCtrl, ui::Key::RightCtrl});
return isSourceMesh && isCtrlPressed;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ class osc::ChooseComponentsEditorLayer::Impl final {
m_State.renderParams = panelParams.getRenderParams();
m_IsLeftClickReleasedWithoutDragging = ui::is_mouse_released_without_dragging(ui::MouseButton::Left);
m_IsRightClickReleasedWithoutDragging = ui::is_mouse_released_without_dragging(ui::MouseButton::Right);
if (ui::is_key_released(ImGuiKey_Escape))
if (ui::is_key_released(ui::Key::Escape))
{
m_State.shouldClosePopup = true;
}
Expand Down
10 changes: 5 additions & 5 deletions src/OpenSimCreator/UI/Shared/MainMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,23 +56,23 @@ void osc::MainMenuFileTab::onDraw(
{
bool mod = ui::is_ctrl_or_super_down();

if (mod && ui::is_key_pressed(ImGuiKey_N))
if (mod && ui::is_key_pressed(ui::Key::N))
{
ActionNewModel(api);
}
else if (mod && ui::is_key_pressed(ImGuiKey_O))
else if (mod && ui::is_key_pressed(ui::Key::O))
{
ActionOpenModel(api);
}
else if (maybeModel && mod && ui::is_shift_down() && ui::is_key_pressed(ImGuiKey_S))
else if (maybeModel && mod && ui::is_shift_down() && ui::is_key_pressed(ui::Key::S))
{
ActionSaveCurrentModelAs(*maybeModel);
}
else if (maybeModel && mod && ui::is_key_pressed(ImGuiKey_S))
else if (maybeModel && mod && ui::is_key_pressed(ui::Key::S))
{
ActionSaveModel(*api, *maybeModel);
}
else if (maybeModel && ui::is_key_pressed(ImGuiKey_F5))
else if (maybeModel && ui::is_key_pressed(ui::Key::F5))
{
ActionReloadOsimFromDisk(*maybeModel, *App::singleton<SceneCache>());
}
Expand Down
2 changes: 1 addition & 1 deletion src/oscar/UI/Widgets/GuiRuler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ void osc::GuiRuler::on_draw(
}

// users can exit measuring through these actions
if (ui::is_key_down(ImGuiKey_Escape) or ui::is_mouse_released(ui::MouseButton::Right)) {
if (ui::is_key_down(ui::Key::Escape) or ui::is_mouse_released(ui::MouseButton::Right)) {
stop_measuring();
return;
}
Expand Down
Loading

0 comments on commit b51febd

Please sign in to comment.