[nostalgia/studio] Start on ImGui version of Studio
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright 2016 - 2021 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#include <imgui.h>
|
||||
|
||||
#include <nostalgia/core/gfx.hpp>
|
||||
|
||||
#include "filedialogmanager.hpp"
|
||||
|
||||
namespace nostalgia {
|
||||
|
||||
studio::TaskState FileDialogManager::update(core::Context *ctx) noexcept {
|
||||
switch (m_state) {
|
||||
case UpdateProjectPathState::EnableSystemCursor: {
|
||||
// switch to system cursor in this update and open file dialog in the next
|
||||
// the cursor state has to be set before the ImGui frame starts
|
||||
auto &io = ImGui::GetIO();
|
||||
io.MouseDrawCursor = false;
|
||||
m_state = UpdateProjectPathState::RunFileDialog;
|
||||
break;
|
||||
}
|
||||
case UpdateProjectPathState::RunFileDialog: {
|
||||
// switch to system cursor
|
||||
auto [path, err] = studio::chooseDirectory();
|
||||
// Mac file dialog doesn't restore focus to main window when closed...
|
||||
core::focusWindow(ctx);
|
||||
if (!err) {
|
||||
err = pathChosen.emitCheckError(path);
|
||||
oxAssert(err, "Path chosen response failed");
|
||||
}
|
||||
auto &io = ImGui::GetIO();
|
||||
io.MouseDrawCursor = true;
|
||||
m_state = UpdateProjectPathState::None;
|
||||
return nostalgia::studio::TaskState::Done;
|
||||
}
|
||||
case UpdateProjectPathState::None:
|
||||
break;
|
||||
}
|
||||
return nostalgia::studio::TaskState::Running;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user