Fix editor dockspace tabs missing
Update to calculate menu bar height sooner. (Same logic as IMGUI uses internally) and use it to offset the dockspace, such that it doesn't overlap with toolbar.
Before:
After:
Your screenshot "before" is clearly a bug, but I don't think that this PR fixes it.
I think that something is wrong with toolbar rendering specifically. On your system, toolbar is abnormally thick. It should have been thinner. And I assume that toolbarHeight does not include this abnormal thickness.
Good solution would be to make toolbar thinner, it clearly wastes space on your system.
Okay solution would be to include this wasted space into toolbarHeight.
@rokups any ideas?
I tested the code in this PR, and it just pushes the problem to different place without truly fixing it:
By the way, what is your OS, resolution and DPI?
From the screenshots it is obvious that toolbar is too high. We need to make it smaller, not move things around. While i do not immediately see whats wrong (without debugging), toolbarWindowPadding looks fishy. I do not see how it could cause this issue, but if one thing is weird more issues might be hiding there. I also do not see how DPI could be cause of issues here, but who knows. Any chance @AaronKel you are using MacOS? There are subtle differences.
@eugeneko My resolution is 1920x1200 ar 96 DPI, I am using ubuntu linux 22.04 LTS
@rokups From seeing the working editor example I agree that the tool bar seems too wide, I'd expect it to be button size + couple pixels padding. I'll have a look at this line
const float toolbarWindowPadding = ea::max(3.0f, (g.Style.WindowMinSize.y - toolbarButtonHeight) / 2);
and see if this may be the solution.
Running with the ImGui::ShowMetricsWindow() it looks like the culprit might be
ImGuiStyleVar_WindowMinSize
@eugeneko Could you show me what the following looks like on windows?
// TODO(editor): Refactor this function
if (hasToolbar)
{
ui::SetNextWindowPos(ImVec2(viewport->Pos.x, viewport->Pos.y + menuBarHeight));
ui::SetNextWindowSize(ImVec2(viewport->Size.x, toolbarHeight));
ui::SetNextWindowViewport(viewport->ID);
const ImGuiWindowFlags toolbarWindowFlags = ImGuiWindowFlags_NoDocking | ImGuiWindowFlags_NoTitleBar
| ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoScrollbar
| ImGuiWindowFlags_NoSavedSettings;
ui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0);
ui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(toolbarWindowPadding, toolbarWindowPadding));
ui::PushStyleVar(ImGuiStyleVar_WindowMinSize, ImVec2(0,0));
ui::Begin("Toolbar", nullptr, toolbarWindowFlags);
if (project_)
project_->RenderToolbar();
ui::End();
ui::PopStyleVar(3);
}
@AaronKel yeah this is much closer to a real fix. Setting WindowMinSize to zero does not break anything on my system.
While it looks better, your version still looks somewhat wonky. Inspector window also looks weird. I think there is some deep issue with margins and paddings and shit, and it would be great if you can pinpoint it. Notice how buttons in "Hierarchy" window have different sizes? Also, a lot of wasted space on paddings. It's probably just a few incorrect numbers somewhere that break entire UI.
One possible direction of debugging is to check why these two buttons are so different. All your buttons should have looked like first one. The code that renders these two buttons is located in SceneHierarchy::RenderToolbar. There are two calls to ToolbarButton from Widgets.cpp. Is dimension the same or different in these two calls? Why?
Maybe my hdpi patch broke in some subtle way during last update. If thst is the case I would rather not fix it. Omar is working on a proper hdpi support so soon enough we can drop that monster. Testing with almost unpatched imgui should be possible, maybe with slight modifications to get it building