Compare commits

...

8 Commits

6 changed files with 30 additions and 15 deletions

View File

@ -258,7 +258,7 @@ void PaletteEditorImGui::drawColorEditor() noexcept {
std::ignore = pushCommand<ApplyColorAllPagesCommand>(
m_pal, m_page, m_selectedColorRow);
}
if (!inputFocused && !m_pageRenameDlg.isOpen()) {
if (ig::mainWinHasFocus()) {
if (!ImGui::IsKeyDown(ImGuiKey_ModAlt)) {
numShortcuts(m_selectedColorRow, largestPage(m_pal));
} else {

View File

@ -445,7 +445,7 @@ void TileSheetEditorImGui::drawPaletteMenu() noexcept {
}
if (ig::DragDropTarget const dragDropTarget; dragDropTarget) {
auto const [ref, err] = ig::getDragDropPayload<studio::FileRef>("FileRef");
if (!err) {
if (!err && endsWith(ref.path, FileExt_npal)) {
if (ref.path != m_selectedPalette) {
oxLogError(m_model.setPalette(ref.path));
}

View File

@ -39,13 +39,15 @@ void NewDir::draw(StudioContext &ctx) noexcept {
case Stage::Opening:
ImGui::OpenPopup(title().c_str());
m_open = true;
m_stage = Stage::Open;
[[fallthrough]];
case Stage::Open:
drawWindow(ctx.tctx, m_open, [this] {
if (m_stage == Stage::Opening) {
if (ImGui::IsWindowAppearing()) {
ImGui::SetKeyboardFocusHere();
}
ig::InputText("Name", m_str);
ImGui::SetItemDefaultFocus();
if (ImGui::IsItemFocused() && ImGui::IsKeyPressed(ImGuiKey_Enter)) {
newDir.emit(m_path + "/" + m_str);
close();
@ -55,7 +57,6 @@ void NewDir::draw(StudioContext &ctx) noexcept {
close();
}
});
m_stage = Stage::Open;
break;
}
}

View File

@ -18,6 +18,9 @@
namespace studio {
namespace ig {
extern bool s_mainWinHasFocus;
}
static ox::Vector<Module const*> modules;
void registerModule(Module const*mod) noexcept {
@ -102,23 +105,26 @@ void StudioUI::handleKeyEvent(turbine::Key const key, bool const down) noexcept
void StudioUI::draw() noexcept {
glutils::clearScreen();
drawMenu();
auto const viewport = ImGui::GetMainViewport();
constexpr auto menuHeight = 18;
ImGui::SetNextWindowPos(ImVec2(viewport->Pos.x, viewport->Pos.y + menuHeight));
ImGui::SetNextWindowSize(ImVec2(viewport->Size.x, viewport->Size.y - menuHeight));
constexpr auto windowFlags = ImGuiWindowFlags_NoTitleBar
| ImGuiWindowFlags_NoResize
| ImGuiWindowFlags_NoMove
| ImGuiWindowFlags_NoScrollbar
| ImGuiWindowFlags_NoSavedSettings;
auto const&viewport = *ImGui::GetMainViewport();
ImGui::SetNextWindowPos(viewport.WorkPos);
ImGui::SetNextWindowSize(viewport.WorkSize);
ImGui::SetNextWindowViewport(viewport.ID);
auto constexpr windowFlags =
ImGuiWindowFlags_NoTitleBar |
ImGuiWindowFlags_NoResize |
ImGuiWindowFlags_NoMove |
ImGuiWindowFlags_NoScrollbar |
ImGuiWindowFlags_NoSavedSettings;
ImGui::Begin("MainWindow##Studio", nullptr, windowFlags);
{
ig::s_mainWinHasFocus = ImGui::IsWindowFocused(
ImGuiFocusedFlags_RootAndChildWindows | ImGuiFocusedFlags_NoPopupHierarchy);
if (m_showProjectExplorer) {
m_projectExplorer.draw(m_sctx);
ImGui::SameLine();
}
drawTabBar();
for (auto &w: m_widgets) {
for (auto const&w : m_widgets) {
w->draw(m_sctx);
}
for (auto const p : m_popups) {

View File

@ -256,4 +256,7 @@ class FilePicker {
};
[[nodiscard]]
bool mainWinHasFocus() noexcept;
}

View File

@ -208,4 +208,9 @@ void FilePicker::show() noexcept {
m_show = true;
}
bool s_mainWinHasFocus{};
bool mainWinHasFocus() noexcept {
return s_mainWinHasFocus;
}
}