mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-11 16:57:53 -06:00
Merge branch 'et_gizmos_tooltip' of https://github.com/Prusa3d/PrusaSlicer into et_gizmos_tooltip
This commit is contained in:
commit
a901b17d33
29 changed files with 2030 additions and 2234 deletions
|
@ -1394,6 +1394,17 @@ void GLCanvas3D::Tooltip::render(const Vec2d& mouse_position, GLCanvas3D& canvas
|
|||
void GLCanvas3D::Tooltip::render(const Vec2d& mouse_position) const
|
||||
#endif // ENABLE_CANVAS_DELAYED_TOOLTIP_USING_IMGUI
|
||||
{
|
||||
#if ENABLE_CANVAS_CONSTRAINED_TOOLTIP_USING_IMGUI
|
||||
static ImVec2 size(0.0f, 0.0f);
|
||||
|
||||
auto validate_position = [](const Vec2d& position, const GLCanvas3D& canvas, const ImVec2& wnd_size) {
|
||||
Size cnv_size = canvas.get_canvas_size();
|
||||
float x = std::clamp((float)position(0), 0.0f, (float)cnv_size.get_width() - wnd_size.x);
|
||||
float y = std::clamp((float)position(1) + 16, 0.0f, (float)cnv_size.get_height() - wnd_size.y);
|
||||
return Vec2f(x, y);
|
||||
};
|
||||
#endif // ENABLE_CANVAS_CONSTRAINED_TOOLTIP_USING_IMGUI
|
||||
|
||||
#if ENABLE_CANVAS_DELAYED_TOOLTIP_USING_IMGUI
|
||||
if (m_text.empty())
|
||||
return;
|
||||
|
@ -1405,16 +1416,24 @@ void GLCanvas3D::Tooltip::render(const Vec2d& mouse_position) const
|
|||
return;
|
||||
#endif // ENABLE_CANVAS_DELAYED_TOOLTIP_USING_IMGUI
|
||||
|
||||
#if ENABLE_CANVAS_CONSTRAINED_TOOLTIP_USING_IMGUI
|
||||
Vec2f position = validate_position(mouse_position, canvas, size);
|
||||
#endif // ENABLE_CANVAS_CONSTRAINED_TOOLTIP_USING_IMGUI
|
||||
|
||||
ImGuiWrapper& imgui = *wxGetApp().imgui();
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
|
||||
#if ENABLE_CANVAS_DELAYED_TOOLTIP_USING_IMGUI
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_Alpha, alpha);
|
||||
#endif // ENABLE_CANVAS_DELAYED_TOOLTIP_USING_IMGUI
|
||||
#if ENABLE_CANVAS_CONSTRAINED_TOOLTIP_USING_IMGUI
|
||||
imgui.set_next_window_pos(position(0), position(1), ImGuiCond_Always, 0.0f, 0.0f);
|
||||
#else
|
||||
imgui.set_next_window_pos(mouse_position(0), mouse_position(1) + 16, ImGuiCond_Always, 0.0f, 0.0f);
|
||||
#endif // ENABLE_CANVAS_CONSTRAINED_TOOLTIP_USING_IMGUI
|
||||
|
||||
imgui.begin(_(L("canvas_tooltip")), ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoMouseInputs | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoFocusOnAppearing);
|
||||
ImGui::BringWindowToDisplayFront(ImGui::GetCurrentWindow());
|
||||
imgui.text(m_text);
|
||||
ImGui::TextUnformatted(m_text.c_str());
|
||||
|
||||
#if ENABLE_CANVAS_DELAYED_TOOLTIP_USING_IMGUI
|
||||
// force re-render while the windows gets to its final size (it may take several frames) or while hidden
|
||||
|
@ -1422,6 +1441,10 @@ void GLCanvas3D::Tooltip::render(const Vec2d& mouse_position) const
|
|||
canvas.request_extra_frame();
|
||||
#endif // ENABLE_CANVAS_DELAYED_TOOLTIP_USING_IMGUI
|
||||
|
||||
#if ENABLE_CANVAS_CONSTRAINED_TOOLTIP_USING_IMGUI
|
||||
size = ImGui::GetWindowSize();
|
||||
#endif // ENABLE_CANVAS_CONSTRAINED_TOOLTIP_USING_IMGUI
|
||||
|
||||
imgui.end();
|
||||
#if ENABLE_CANVAS_DELAYED_TOOLTIP_USING_IMGUI
|
||||
ImGui::PopStyleVar(2);
|
||||
|
@ -3788,7 +3811,7 @@ void GLCanvas3D::set_tooltip(const std::string& tooltip) const
|
|||
if (m_canvas != nullptr)
|
||||
{
|
||||
#if ENABLE_CANVAS_TOOLTIP_USING_IMGUI
|
||||
m_tooltip.set_text(std::string((_(L(tooltip))).ToUTF8()));
|
||||
m_tooltip.set_text(tooltip);
|
||||
#else
|
||||
wxString txt = wxString::FromUTF8(tooltip.data());
|
||||
if (m_canvas->GetToolTipText() != txt)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue