[nostalgia/studio] Remove toolbar
This commit is contained in:
parent
c7c1029ad8
commit
27b7b11146
@ -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
|
||||
|
@ -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");
|
||||
|
@ -51,8 +51,6 @@ class StudioUI: public ox::SignalHandler {
|
||||
private:
|
||||
void drawMenu() noexcept;
|
||||
|
||||
void drawToolbar() noexcept;
|
||||
|
||||
void drawTabBar() noexcept;
|
||||
|
||||
void drawTabs() noexcept;
|
||||
|
Loading…
Reference in New Issue
Block a user