Lay out the welcome window and dockspace with one helper

This commit is contained in:
shweet committed 2026-11-22 19:00:42 -05:00
1 parent ada48aefdd
commit d2c50b5548
3 files changed
+13 -16

No files matched your search

+2 -8
View File
@@ -1,4 +1,5 @@
#include "ui/dockspace.h"
#include "ui/layout.h"
bool Dockspace::is_canvas_focused_get() const
{
@@ -31,14 +32,7 @@ void Dockspace::update(Taskbar& taskbar, Documents& documents, Manager& manager,
{
isCanvasFocused = false;
auto viewport = ImGui::GetMainViewport();
auto windowHeight = viewport->Size.y - taskbar.height - documents.height;
if (windowHeight < 1.0f)
windowHeight = 1.0f;
ImGui::SetNextWindowViewport(viewport->ID);
ImGui::SetNextWindowPos(ImVec2(viewport->Pos.x, viewport->Pos.y + taskbar.height + documents.height));
ImGui::SetNextWindowSize(ImVec2(viewport->Size.x, windowHeight));
main_area_next_set(taskbar.height + documents.height);
if (ImGui::Begin("##DockSpace", nullptr,
ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize |
+10
View File
@@ -1,5 +1,6 @@
#pragma once
#include <algorithm>
#include <string>
#include "vec.h"
@@ -52,3 +53,12 @@ inline void tooltip_set(StringType type)
{
ImGui::SetItemTooltip("%s", localize.get(type));
}
// The next window fills the main viewport below `top`.
inline void main_area_next_set(float top)
{
auto viewport = ImGui::GetMainViewport();
ImGui::SetNextWindowViewport(viewport->ID);
ImGui::SetNextWindowPos(ImVec2(viewport->Pos.x, viewport->Pos.y + top));
ImGui::SetNextWindowSize(ImVec2(viewport->Size.x, std::max(viewport->Size.y - top, 1.0f)));
}
+1 -8
View File
@@ -12,14 +12,7 @@
void welcome_update(Manager& manager, Resources& resources, Dialog& dialog, Taskbar& taskbar, Documents& documents)
{
auto viewport = ImGui::GetMainViewport();
auto windowHeight = viewport->Size.y - taskbar.height - documents.height;
if (windowHeight < 1.0f)
windowHeight = 1.0f;
ImGui::SetNextWindowViewport(viewport->ID);
ImGui::SetNextWindowPos(ImVec2(viewport->Pos.x, viewport->Pos.y + taskbar.height + documents.height));
ImGui::SetNextWindowSize(ImVec2(viewport->Size.x, windowHeight));
main_area_next_set(taskbar.height + documents.height);
if (ImGui::Begin(localize.get(LABEL_WELCOME_WINDOW), nullptr,
ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize |