diff --git a/src/nostalgia/studio/projectexplorer.cpp b/src/nostalgia/studio/projectexplorer.cpp index 3e2b68ba..a5307054 100644 --- a/src/nostalgia/studio/projectexplorer.cpp +++ b/src/nostalgia/studio/projectexplorer.cpp @@ -39,8 +39,8 @@ ProjectExplorer::ProjectExplorer(core::Context *ctx) noexcept { void ProjectExplorer::draw(core::Context *ctx) noexcept { const auto viewport = ImGui::GetMainViewport(); - ImGui::SetNextWindowPos(ImVec2(viewport->Pos.x, viewport->Pos.y + 71)); - ImGui::SetNextWindowSize(ImVec2(313, viewport->Size.y - 71)); + ImGui::SetNextWindowPos(ImVec2(viewport->Pos.x, viewport->Pos.y + 20)); + ImGui::SetNextWindowSize(ImVec2(313, viewport->Size.y - 20)); const auto flags = ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove diff --git a/src/nostalgia/studio/studioapp.cpp b/src/nostalgia/studio/studioapp.cpp index f42a1eb5..c235c9f3 100644 --- a/src/nostalgia/studio/studioapp.cpp +++ b/src/nostalgia/studio/studioapp.cpp @@ -95,7 +95,6 @@ void StudioUI::handleKeyEvent(core::Key key, bool down) noexcept { void StudioUI::draw() noexcept { drawMenu(); - drawToolbar(); drawTabBar(); if (m_showProjectExplorer) { m_projectExplorer->draw(m_ctx); @@ -161,39 +160,11 @@ void StudioUI::drawMenu() noexcept { } } -void StudioUI::drawToolbar() noexcept { - constexpr auto BtnWidth = 96; - constexpr auto BtnHeight = 32; - const auto viewport = ImGui::GetMainViewport(); - ImGui::SetNextWindowPos(ImVec2(viewport->Pos.x + 1, viewport->Pos.y + 21)); - ImGui::SetNextWindowSize(ImVec2(viewport->Size.x - 1, 48)); - const auto flags = ImGuiWindowFlags_NoTitleBar - | ImGuiWindowFlags_NoResize - | ImGuiWindowFlags_NoMove - | ImGuiWindowFlags_NoScrollbar - | ImGuiWindowFlags_NoSavedSettings; - ImGui::Begin("MainToolbar##MainWindow", nullptr, flags); - { - ImGui::Button("New##MainToolbar##MainWindow", ImVec2(BtnWidth, BtnHeight)); - ImGui::SameLine(); - if (ImGui::Button("Open Project##MainToolbar##MainWindow", ImVec2(BtnWidth, BtnHeight))) { - m_taskRunner.add(new FileDialogManager(this, &StudioUI::openProject)); - } - ImGui::SameLine(); - if (ImGui::Button("Save##MainToolbar##MainWindow", ImVec2(BtnWidth, BtnHeight))) { - if (m_acitveEditor) { - m_acitveEditor->save(); - } - } - } - ImGui::End(); -} - void StudioUI::drawTabBar() noexcept { const auto viewport = ImGui::GetMainViewport(); const auto mod = m_showProjectExplorer ? 316.f : 0.f; - ImGui::SetNextWindowPos(ImVec2(viewport->Pos.x + mod, viewport->Pos.y + 71)); - ImGui::SetNextWindowSize(ImVec2(viewport->Size.x - mod, viewport->Size.y - 71)); + ImGui::SetNextWindowPos(ImVec2(viewport->Pos.x + mod, viewport->Pos.y + 20)); + ImGui::SetNextWindowSize(ImVec2(viewport->Size.x - mod, viewport->Size.y - 20)); constexpr auto windowFlags = ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove @@ -246,7 +217,7 @@ void StudioUI::drawAboutPopup() noexcept { } void StudioUI::loadEditorMaker(const studio::EditorMaker &editorMaker) noexcept { - for (auto &ext : editorMaker.fileTypes) { + for (const auto &ext : editorMaker.fileTypes) { m_editorMakers[ext] = editorMaker.make; } } @@ -313,12 +284,7 @@ ox::Error StudioUI::openFile(const ox::String &path) noexcept { if (m_openFiles.contains(path)) { return OxError(0); } - // find file extension - const auto extStart = std::find(path.crbegin(), path.crend(), '.').offset(); - if (!extStart) { - return OxError(1, "Cannot open a file without valid extension."); - } - const auto ext = path.substr(extStart + 1); + oxRequire(ext, studio::fileExt(path)); // create Editor if (!m_editorMakers.contains(ext)) { return OxError(1, "There is no editor for this file extension"); diff --git a/src/nostalgia/studio/studioapp.hpp b/src/nostalgia/studio/studioapp.hpp index d268ef39..046e9078 100644 --- a/src/nostalgia/studio/studioapp.hpp +++ b/src/nostalgia/studio/studioapp.hpp @@ -51,8 +51,6 @@ class StudioUI: public ox::SignalHandler { private: void drawMenu() noexcept; - void drawToolbar() noexcept; - void drawTabBar() noexcept; void drawTabs() noexcept;