[studio] Cleanup main window drawing
This commit is contained in:
parent
4cf96878a9
commit
660c320ee9
@ -36,20 +36,13 @@ ProjectExplorer::ProjectExplorer(turbine::Context *ctx) noexcept {
|
||||
}
|
||||
|
||||
void ProjectExplorer::draw(turbine::Context *ctx) noexcept {
|
||||
const auto viewport = ImGui::GetMainViewport();
|
||||
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
|
||||
| ImGuiWindowFlags_NoScrollbar
|
||||
| ImGuiWindowFlags_NoSavedSettings;
|
||||
ImGui::Begin("ProjectExplorer", nullptr, flags);
|
||||
const auto viewport = ImGui::GetContentRegionAvail();
|
||||
ImGui::BeginChild("ProjectExplorer", ImVec2(300, viewport.y));
|
||||
ImGui::SetNextItemOpen(true);
|
||||
if (m_treeModel) {
|
||||
m_treeModel->draw(ctx);
|
||||
}
|
||||
ImGui::End();
|
||||
ImGui::EndChild();
|
||||
}
|
||||
|
||||
void ProjectExplorer::setModel(ox::UniquePtr<ProjectTreeModel> model) noexcept {
|
||||
|
@ -56,7 +56,9 @@ StudioUI::StudioUI(turbine::Context *ctx, ox::String projectDir) noexcept:
|
||||
if constexpr(!ox::defines::Debug) {
|
||||
oxErrf("Could not open studio config file: {}: {}\n", err.errCode, toStr(err));
|
||||
} else {
|
||||
oxErrf("Could not open studio config file: {}: {} ({}:{})\n", err.errCode, toStr(err), err.file, err.line);
|
||||
oxErrf(
|
||||
"Could not open studio config file: {}: {} ({}:{})\n",
|
||||
err.errCode, toStr(err), err.file, err.line);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -121,16 +123,30 @@ void StudioUI::handleKeyEvent(turbine::Key key, bool down) noexcept {
|
||||
void StudioUI::draw() noexcept {
|
||||
glutils::clearScreen();
|
||||
drawMenu();
|
||||
drawTabBar();
|
||||
if (m_showProjectExplorer) {
|
||||
m_projectExplorer->draw(m_ctx);
|
||||
}
|
||||
for (auto &w : m_widgets) {
|
||||
w->draw(m_ctx);
|
||||
}
|
||||
for (auto p : m_popups) {
|
||||
p->draw(m_ctx);
|
||||
const auto 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;
|
||||
ImGui::Begin("MainWindow##Studio", nullptr, windowFlags);
|
||||
{
|
||||
if (m_showProjectExplorer) {
|
||||
m_projectExplorer->draw(m_ctx);
|
||||
ImGui::SameLine();
|
||||
}
|
||||
drawTabBar();
|
||||
for (auto &w: m_widgets) {
|
||||
w->draw(m_ctx);
|
||||
}
|
||||
for (auto p: m_popups) {
|
||||
p->draw(m_ctx);
|
||||
}
|
||||
}
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
void StudioUI::drawMenu() noexcept {
|
||||
@ -187,22 +203,14 @@ void StudioUI::drawMenu() noexcept {
|
||||
}
|
||||
|
||||
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 + 20));
|
||||
ImGui::SetNextWindowSize(ImVec2(viewport->Size.x - mod, viewport->Size.y - 20));
|
||||
constexpr auto windowFlags = ImGuiWindowFlags_NoTitleBar
|
||||
| ImGuiWindowFlags_NoResize
|
||||
| ImGuiWindowFlags_NoMove
|
||||
| ImGuiWindowFlags_NoScrollbar
|
||||
| ImGuiWindowFlags_NoSavedSettings;
|
||||
ImGui::Begin("TabWindow##MainWindow", nullptr, windowFlags);
|
||||
const auto viewport = ImGui::GetContentRegionAvail();
|
||||
ImGui::BeginChild("TabWindow##MainWindow##Studio", ImVec2(viewport.x, viewport.y));
|
||||
constexpr auto tabBarFlags = ImGuiTabBarFlags_Reorderable | ImGuiTabBarFlags_TabListPopupButton;
|
||||
if (ImGui::BeginTabBar("TabBar##TabWindow##MainWindow", tabBarFlags)) {
|
||||
if (ImGui::BeginTabBar("TabBar##TabWindow##MainWindow##Studio", tabBarFlags)) {
|
||||
drawTabs();
|
||||
ImGui::EndTabBar();
|
||||
}
|
||||
ImGui::End();
|
||||
ImGui::EndChild();
|
||||
}
|
||||
|
||||
void StudioUI::drawTabs() noexcept {
|
||||
|
Loading…
x
Reference in New Issue
Block a user