ImguiDoubleSlider: Notifications placement to avoid overlapping with sliders

This commit is contained in:
YuSanka 2024-04-22 21:08:12 +02:00 committed by Lukas Matena
parent f90ea2e8be
commit b02e0e6fd1
4 changed files with 29 additions and 1 deletions

View File

@ -334,6 +334,20 @@ void Preview::render_sliders(GLCanvas3D& canvas, float extra_scale/* = 0.1f*/)
m_moves_slider->Render(canvas_width, canvas_height, extra_scale);
}
float Preview::get_moves_slider_height()
{
if (m_moves_slider && m_moves_slider->IsShown())
return m_moves_slider->GetHeight();
return 0.0f;
}
float Preview::get_layers_slider_width()
{
if (m_layers_slider && m_layers_slider->IsShown())
return m_layers_slider->GetWidth();
return 0.0f;
}
void Preview::bind_event_handlers()
{
Bind(wxEVT_SIZE, &Preview::on_size, this);

View File

@ -136,6 +136,8 @@ public:
void msw_rescale();
void render_sliders(GLCanvas3D& canvas, float extra_scale = 0.1f);
float get_layers_slider_width();
float get_moves_slider_height();
bool is_loaded() const { return m_loaded; }

View File

@ -67,7 +67,9 @@ public:
m_size = size;
m_draw_opts.scale = scale;
}
ImVec2 GetCtrlSize() { return m_size; }
ImVec2 GetCtrlPos() { return m_pos; }
void Show(bool show) { m_is_shown = show; }
void Hide() { m_is_shown = false; }
bool IsShown() const { return m_is_shown; }
@ -239,6 +241,8 @@ public:
void SetEmUnit(int em_unit) { m_em = em_unit; }
void ShowLowerThumb(bool show) { m_ctrl.ShowLowerThumb(show); }
float GetWidth() { return m_ctrl.GetCtrlSize().x; }
float GetHeight() { return m_ctrl.GetCtrlSize().y; }
virtual void Render(const int canvas_width, const int canvas_height, float extra_scale = 1.f) = 0;
void set_callback_on_thumb_move(std::function<void()> cb) { m_cb_thumb_move = cb; };

View File

@ -174,6 +174,14 @@ void NotificationManager::PopNotification::render(GLCanvas3D& canvas, float init
m_top_y = initial_y + m_window_height;
ImVec2 win_pos(1.0f * (float)cnv_size.get_width() - right_gap, 1.0f * (float)cnv_size.get_height() - m_top_y);
if (wxGetApp().plater()->is_preview_shown()) {
if (Preview* preview = dynamic_cast<Preview*>(canvas.get_wxglcanvas()->GetParent())) {
win_pos.y -= 1.5f * preview->get_moves_slider_height();
win_pos.x -= preview->get_layers_slider_width();
}
}
ImGuiPureWrap::set_next_window_pos(win_pos.x, win_pos.y, ImGuiCond_Always, 1.0f, 0.0f);
ImGuiPureWrap::set_next_window_size(m_window_width, m_window_height, ImGuiCond_Always);