Files
nostalgia/src/olympic/studio/applib/src/filedialogmanager.cpp
Gary Talent a6814030ee
All checks were successful
Build / build (push) Successful in 1m13s
[studio/applib] Cleanup
2025-05-17 16:15:32 -05:00

38 lines
1.0 KiB
C++

/*
* Copyright 2016 - 2025 Gary Talent (gary@drinkingtea.net). All rights reserved.
*/
#include <turbine/gfx.hpp>
#include "filedialogmanager.hpp"
namespace studio {
TaskState FileDialogManager::update(turbine::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
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...
turbine::focusWindow(ctx);
if (!err) {
err = pathChosen.emitCheckError(path);
oxAssert(err, "Path chosen response failed");
}
m_state = UpdateProjectPathState::None;
return studio::TaskState::Done;
}
case UpdateProjectPathState::None:
break;
}
return studio::TaskState::Running;
}
}