Keep the Design tab's status line clear of the view buttons at any display scale

The line started at a fixed inset scaled like the ImGui style, while the navigator and the
round canvas buttons scale with the monitor's DPI on Windows, so at 150% the buttons covered
its first words. It now starts past the edge the canvas reports for that corner.
This commit is contained in:
SoftFever
2026-10-06 11:55:41 +08:00
parent 840d44b611
commit 56ebde968a
3 changed files with 30 additions and 8 deletions
+4 -4
View File
@@ -1183,9 +1183,6 @@ void DesignCanvas::set_readout(const std::string& text)
if (m_canvas) m_canvas->set_as_dirty(); // drawn by the next frame (the tool feeds this from one)
}
// Clear of the view cube and the two round view buttons, which own the bottom-left corner.
static constexpr float kStatusHudLeftInset = 190.f;
void DesignCanvas::set_status_text(const wxString& text, const wxColour& colour)
{
if (text == m_status_hud_last && colour == m_status_hud_colour) return;
@@ -1220,8 +1217,11 @@ void DesignCanvas::render_hud()
ImGuiWrapper::pop_common_window_style();
};
if (!m_status_hud_last.IsEmpty()) {
// Past the view cube and the round view buttons, which own the bottom-left corner. Asked
// of the canvas, which lays them out: they follow the monitor's DPI on Windows, where `em`
// does not, so a fixed inset in `em` let them cover the start of the line at 150%.
// A sentence can be a sentence: it wraps to the room left of the readout chip.
const float left = kStatusHudLeftInset * em;
const float left = m_canvas->get_canvas_toolbar_right() + margin;
const ImVec4 col = m_status_hud_colour.IsOk()
? ImVec4(m_status_hud_colour.Red() / 255.f, m_status_hud_colour.Green() / 255.f,
m_status_hud_colour.Blue() / 255.f, 1.f)
+23 -4
View File
@@ -2088,6 +2088,25 @@ float GLCanvas3D::get_collapse_toolbar_height() const
return collapse_side() != CollapseSide::None ? collapse_toolbar().get_height() : 0;
}
// The bottom-left corner: the 3D navigator, then the column of round canvas buttons beside it, in
// units of the toolbar scale. Shared by _render_3d_navigator, _render_canvas_toolbar and
// get_canvas_toolbar_right, so an overlay kept clear of the corner follows its layout.
static constexpr float NAVIGATOR_SIZE = 128.f;
static constexpr float CANVAS_TOOLBAR_MARGIN = 10.f; // off the canvas edge, when there is no navigator
static constexpr float CANVAS_TOOLBAR_PADDING = 2.f;
static constexpr float CANVAS_TOOLBAR_BUTTON = 36.f;
float GLCanvas3D::get_canvas_toolbar_right() const
{
// The toolbar scale, which on Windows follows the monitor's DPI where the ImGui style does not.
float sc = get_scale();
#ifdef WIN32
sc *= (float) get_dpi_for_window(wxGetApp().GetTopWindow()) / (float) DPI_DEFAULT;
#endif // WIN32
const float left = wxGetApp().show_3d_navigator() ? NAVIGATOR_SIZE : CANVAS_TOOLBAR_MARGIN;
return (left + 2.f * CANVAS_TOOLBAR_PADDING + CANVAS_TOOLBAR_BUTTON) * sc;
}
GLToolbar& GLCanvas3D::collapse_toolbar() const
{
return m_collapse_toolbar != nullptr ? *m_collapse_toolbar : wxGetApp().plater()->get_collapse_toolbar();
@@ -6358,7 +6377,7 @@ void GLCanvas3D::_render_3d_navigator()
}
}
const float size = 128 * sc;
const float size = NAVIGATOR_SIZE * sc;
m_canvas_toolbar_pos[0] = size;
const auto result = ImGuizmo::ViewManipulate(cameraView, cameraProjection, ImGuizmo::OPERATION::ROTATE, ImGuizmo::MODE::WORLD, nullptr,
camDistance, ImVec2(viewManipulateLeft, viewManipulateTop - size), ImVec2(size, size),
@@ -10064,10 +10083,10 @@ void GLCanvas3D::_render_canvas_toolbar()
sc *= (float) dpi / (float) DPI_DEFAULT;
#endif // WIN32
ImVec2 btn_size = ImVec2(36.f, 36.f) * sc;
ImVec2 margin = ImVec2(m_canvas_toolbar_pos[0] > 0 ? 0.f : (10.f * sc), 10.f * sc);
ImVec2 btn_size = ImVec2(CANVAS_TOOLBAR_BUTTON, CANVAS_TOOLBAR_BUTTON) * sc;
ImVec2 margin = ImVec2(m_canvas_toolbar_pos[0] > 0 ? 0.f : (CANVAS_TOOLBAR_MARGIN * sc), CANVAS_TOOLBAR_MARGIN * sc);
ImVec2 spacing = ImVec2(6.f, 6.f) * sc;
ImVec2 padding = ImVec2(2.f, 2.f) * sc;
ImVec2 padding = ImVec2(CANVAS_TOOLBAR_PADDING, CANVAS_TOOLBAR_PADDING) * sc;
Vec2i32 pos = {
m_canvas_toolbar_pos[0] + margin.x,
get_canvas_size().get_height() - margin.y
+3
View File
@@ -1061,6 +1061,9 @@ public:
bool is_collapse_toolbar_on_left() const;
float get_collapse_toolbar_width() const;
float get_collapse_toolbar_height() const;
// Right edge, in canvas pixels, of the bottom-left corner the 3D navigator and the round
// canvas buttons own. An overlay along the bottom edge starts past it.
float get_canvas_toolbar_right() const;
void update_volumes_colors_by_extruder();