[nostalgia,studio] Update for new ImGui's Mac awareness
All checks were successful
Build / build (push) Successful in 2m39s
All checks were successful
Build / build (push) Successful in 2m39s
This commit is contained in:
@ -83,7 +83,6 @@ void StudioUI::update() noexcept {
|
||||
}
|
||||
|
||||
void StudioUI::handleKeyEvent(turbine::Key key, bool down) noexcept {
|
||||
auto const ctrlDown = turbine::buttonDown(m_ctx, turbine::Key::Mod_Ctrl);
|
||||
for (auto p : m_popups) {
|
||||
if (p->isOpen()) {
|
||||
if (key == turbine::Key::Escape) {
|
||||
@ -92,55 +91,7 @@ void StudioUI::handleKeyEvent(turbine::Key key, bool down) noexcept {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (down && ctrlDown) {
|
||||
switch (key) {
|
||||
case turbine::Key::Num_1:
|
||||
toggleProjectExplorer();
|
||||
break;
|
||||
case turbine::Key::Alpha_C:
|
||||
if (m_activeEditor && m_activeEditor->copyEnabled()) {
|
||||
m_activeEditor->copy();
|
||||
}
|
||||
break;
|
||||
case turbine::Key::Alpha_N:
|
||||
if (turbine::buttonDown(m_ctx, turbine::Key::Mod_Shift)) {
|
||||
m_newProject.open();
|
||||
} else {
|
||||
m_newMenu.open();
|
||||
}
|
||||
break;
|
||||
case turbine::Key::Alpha_O:
|
||||
m_taskRunner.add(*ox::make<FileDialogManager>(this, &StudioUI::openProjectPath));
|
||||
break;
|
||||
case turbine::Key::Alpha_Q:
|
||||
turbine::requestShutdown(m_ctx);
|
||||
break;
|
||||
case turbine::Key::Alpha_S:
|
||||
save();
|
||||
break;
|
||||
case turbine::Key::Alpha_V:
|
||||
if (m_activeEditor && m_activeEditor->pasteEnabled()) {
|
||||
m_activeEditor->paste();
|
||||
}
|
||||
break;
|
||||
case turbine::Key::Alpha_X:
|
||||
if (m_activeEditor && m_activeEditor->cutEnabled()) {
|
||||
m_activeEditor->cut();
|
||||
}
|
||||
break;
|
||||
case turbine::Key::Alpha_Y:
|
||||
redo();
|
||||
break;
|
||||
case turbine::Key::Alpha_Z:
|
||||
undo();
|
||||
break;
|
||||
default:
|
||||
if (m_activeEditor) {
|
||||
m_activeEditor->keyStateChanged(key, down);
|
||||
}
|
||||
break;
|
||||
}
|
||||
} else if (m_activeEditor && !ctrlDown) {
|
||||
if (m_activeEditor && !ImGui::IsKeyDown(ImGuiKey_ModCtrl)) {
|
||||
m_activeEditor->keyStateChanged(key, down);
|
||||
}
|
||||
}
|
||||
@ -172,6 +123,7 @@ void StudioUI::draw() noexcept {
|
||||
}
|
||||
}
|
||||
ImGui::End();
|
||||
handleKeyInput();
|
||||
}
|
||||
|
||||
void StudioUI::drawMenu() noexcept {
|
||||
@ -332,6 +284,44 @@ void StudioUI::save() noexcept {
|
||||
}
|
||||
}
|
||||
|
||||
void StudioUI::handleKeyInput() noexcept {
|
||||
if (ImGui::IsKeyDown(ImGuiKey_ModCtrl)) {
|
||||
if (ImGui::IsKeyPressed(ImGuiKey_C)) {
|
||||
if (m_activeEditor && m_activeEditor->copyEnabled()) {
|
||||
m_activeEditor->copy();
|
||||
}
|
||||
} else if (ImGui::IsKeyPressed(ImGuiKey_N)) {
|
||||
if (turbine::buttonDown(m_ctx, turbine::Key::Mod_Shift)) {
|
||||
m_newProject.open();
|
||||
} else {
|
||||
m_newMenu.open();
|
||||
}
|
||||
} else if (ImGui::IsKeyPressed(ImGuiKey_O)) {
|
||||
m_taskRunner.add(*ox::make<FileDialogManager>(this, &StudioUI::openProjectPath));
|
||||
} else if (ImGui::IsKeyPressed(ImGuiKey_S)) {
|
||||
save();
|
||||
} else if (ImGui::IsKeyPressed(ImGuiKey_Q)) {
|
||||
turbine::requestShutdown(m_ctx);
|
||||
} else if (ImGui::IsKeyPressed(ImGuiKey_V)) {
|
||||
if (m_activeEditor && m_activeEditor->pasteEnabled()) {
|
||||
m_activeEditor->paste();
|
||||
}
|
||||
} else if (ImGui::IsKeyPressed(ImGuiKey_X)) {
|
||||
if (m_activeEditor && m_activeEditor->cutEnabled()) {
|
||||
m_activeEditor->cut();
|
||||
}
|
||||
} else if (ImGui::IsKeyPressed(ImGuiKey_Y)) {
|
||||
auto const undoStack = m_activeEditor ? m_activeEditor->undoStack() : nullptr;
|
||||
if (undoStack) { oxLogError(undoStack->redo()); }
|
||||
} else if (ImGui::IsKeyPressed(ImGuiKey_Z)) {
|
||||
auto const undoStack = m_activeEditor ? m_activeEditor->undoStack() : nullptr;
|
||||
if (undoStack) { oxLogError(undoStack->undo()); }
|
||||
} else if (ImGui::IsKeyPressed(ImGuiKey_1)) {
|
||||
toggleProjectExplorer();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ox::Error StudioUI::createOpenProject(ox::CRStringView path) noexcept {
|
||||
std::error_code ec;
|
||||
std::filesystem::create_directories(toStdStringView(path), ec);
|
||||
|
@ -83,6 +83,8 @@ class StudioUI: public ox::SignalHandler {
|
||||
|
||||
void save() noexcept;
|
||||
|
||||
void handleKeyInput() noexcept;
|
||||
|
||||
ox::Error createOpenProject(ox::CRStringView path) noexcept;
|
||||
|
||||
ox::Error openProjectPath(ox::CRStringView path) noexcept;
|
||||
|
Reference in New Issue
Block a user