[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 {
|
void ProjectExplorer::draw(turbine::Context *ctx) noexcept {
|
||||||
const auto viewport = ImGui::GetMainViewport();
|
const auto viewport = ImGui::GetContentRegionAvail();
|
||||||
ImGui::SetNextWindowPos(ImVec2(viewport->Pos.x, viewport->Pos.y + 20));
|
ImGui::BeginChild("ProjectExplorer", ImVec2(300, viewport.y));
|
||||||
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);
|
|
||||||
ImGui::SetNextItemOpen(true);
|
ImGui::SetNextItemOpen(true);
|
||||||
if (m_treeModel) {
|
if (m_treeModel) {
|
||||||
m_treeModel->draw(ctx);
|
m_treeModel->draw(ctx);
|
||||||
}
|
}
|
||||||
ImGui::End();
|
ImGui::EndChild();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProjectExplorer::setModel(ox::UniquePtr<ProjectTreeModel> model) noexcept {
|
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) {
|
if constexpr(!ox::defines::Debug) {
|
||||||
oxErrf("Could not open studio config file: {}: {}\n", err.errCode, toStr(err));
|
oxErrf("Could not open studio config file: {}: {}\n", err.errCode, toStr(err));
|
||||||
} else {
|
} 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 {
|
void StudioUI::draw() noexcept {
|
||||||
glutils::clearScreen();
|
glutils::clearScreen();
|
||||||
drawMenu();
|
drawMenu();
|
||||||
drawTabBar();
|
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) {
|
if (m_showProjectExplorer) {
|
||||||
m_projectExplorer->draw(m_ctx);
|
m_projectExplorer->draw(m_ctx);
|
||||||
|
ImGui::SameLine();
|
||||||
}
|
}
|
||||||
for (auto &w : m_widgets) {
|
drawTabBar();
|
||||||
|
for (auto &w: m_widgets) {
|
||||||
w->draw(m_ctx);
|
w->draw(m_ctx);
|
||||||
}
|
}
|
||||||
for (auto p : m_popups) {
|
for (auto p: m_popups) {
|
||||||
p->draw(m_ctx);
|
p->draw(m_ctx);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
ImGui::End();
|
||||||
}
|
}
|
||||||
|
|
||||||
void StudioUI::drawMenu() noexcept {
|
void StudioUI::drawMenu() noexcept {
|
||||||
@ -187,22 +203,14 @@ void StudioUI::drawMenu() noexcept {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void StudioUI::drawTabBar() noexcept {
|
void StudioUI::drawTabBar() noexcept {
|
||||||
const auto viewport = ImGui::GetMainViewport();
|
const auto viewport = ImGui::GetContentRegionAvail();
|
||||||
const auto mod = m_showProjectExplorer ? 316.f : 0.f;
|
ImGui::BeginChild("TabWindow##MainWindow##Studio", ImVec2(viewport.x, viewport.y));
|
||||||
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);
|
|
||||||
constexpr auto tabBarFlags = ImGuiTabBarFlags_Reorderable | ImGuiTabBarFlags_TabListPopupButton;
|
constexpr auto tabBarFlags = ImGuiTabBarFlags_Reorderable | ImGuiTabBarFlags_TabListPopupButton;
|
||||||
if (ImGui::BeginTabBar("TabBar##TabWindow##MainWindow", tabBarFlags)) {
|
if (ImGui::BeginTabBar("TabBar##TabWindow##MainWindow##Studio", tabBarFlags)) {
|
||||||
drawTabs();
|
drawTabs();
|
||||||
ImGui::EndTabBar();
|
ImGui::EndTabBar();
|
||||||
}
|
}
|
||||||
ImGui::End();
|
ImGui::EndChild();
|
||||||
}
|
}
|
||||||
|
|
||||||
void StudioUI::drawTabs() noexcept {
|
void StudioUI::drawTabs() noexcept {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user