ImguiDoubleSlider: Respect to "Collapse sidebar" button

+ use scale from canvas Size
This commit is contained in:
YuSanka 2024-04-23 14:01:16 +02:00 committed by Lukas Matena
parent b02e0e6fd1
commit 0bb9233da7
10 changed files with 24 additions and 26 deletions

View File

@ -10,7 +10,7 @@ namespace DoubleSlider {
static const float LEFT_MARGIN = 13.0f + 100.0f; // avoid thumbnail toolbar
static const float HORIZONTAL_SLIDER_HEIGHT = 45.0f;
void DSForGcode::Render(const int canvas_width, const int canvas_height, float extra_scale/* = 0.1f*/)
void DSForGcode::Render(const int canvas_width, const int canvas_height, float extra_scale/* = 0.1f*/, float offset/* = 0.f*/)
{
if (!m_ctrl.IsShown())
return;

View File

@ -22,7 +22,7 @@ public:
}
~DSForGcode() {}
void Render(const int canvas_width, const int canvas_height, float extra_scale = 1.f) override;
void Render(const int canvas_width, const int canvas_height, float extra_scale = 1.f, float offset = 0.f) override;
void set_render_as_disabled(bool value) { m_render_as_disabled = value; }
bool is_rendering_as_disabled() const { return m_render_as_disabled; }

View File

@ -615,7 +615,7 @@ bool DSForLayers::render_jump_to_window(const ImVec2& pos, double* active_value,
return enter_pressed || ok_pressed;
}
void DSForLayers::Render(const int canvas_width, const int canvas_height, float extra_scale/* = 0.1f*/)
void DSForLayers::Render(const int canvas_width, const int canvas_height, float extra_scale/* = 0.1f*/, float offset /*= 0.f*/)
{
if (!m_ctrl.IsShown())
return;
@ -627,11 +627,11 @@ void DSForLayers::Render(const int canvas_width, const int canvas_height, float
ImVec2 pos;
pos.x = canvas_width - VERTICAL_SLIDER_WIDTH * m_scale - tick_icon_side;
pos.y = 1.5f * action_btn_sz;
pos.y = 1.5f * action_btn_sz + offset;
if (m_allow_editing)
pos.y += 2.f;
ImVec2 size = ImVec2(VERTICAL_SLIDER_WIDTH * m_scale, canvas_height - 4.f * action_btn_sz);
ImVec2 size = ImVec2(VERTICAL_SLIDER_WIDTH * m_scale, canvas_height - 4.f * action_btn_sz - offset);
m_ctrl.Init(pos, size, m_scale);
if (m_ctrl.render()) {

View File

@ -73,7 +73,7 @@ public:
void SetModeAndOnlyExtruder(const bool is_one_extruder_printed_model, const int only_extruder);
void Render(const int canvas_width, const int canvas_height, float extra_scale = 1.f) override;
void Render(const int canvas_width, const int canvas_height, float extra_scale = 1.f, float offset = 0.f) override;
// jump to selected layer
void jump_to_value();

View File

@ -1947,13 +1947,7 @@ void GLCanvas3D::render()
wxGetApp().plater()->get_notification_manager()->render_notifications(*this, get_overlay_window_width());
wxGetApp().plater()->render_sliders(*this,
#if ENABLE_RETINA_GL
m_retina_helper->get_scale_factor()
#else
1.f
#endif
);
wxGetApp().plater()->render_sliders(*this);
wxGetApp().imgui()->render();

View File

@ -322,14 +322,18 @@ void Preview::msw_rescale()
reload_print();
}
void Preview::render_sliders(GLCanvas3D& canvas, float extra_scale/* = 0.1f*/)
void Preview::render_sliders(GLCanvas3D& canvas)
{
const Size cnv_size = canvas.get_canvas_size();
const int canvas_width = cnv_size.get_width();
const int canvas_height = cnv_size.get_height();
const Size cnv_size = canvas.get_canvas_size();
const int canvas_width = cnv_size.get_width();
const int canvas_height = cnv_size.get_height();
const float extra_scale = cnv_size.get_scale_factor();
GLToolbar& collapse_toolbar = wxGetApp().plater()->get_collapse_toolbar();
const bool is_collapse_btn_shown = collapse_toolbar.is_enabled();
if (m_layers_slider)
m_layers_slider->Render(canvas_width, canvas_height, extra_scale);
m_layers_slider->Render(canvas_width, canvas_height, extra_scale, is_collapse_btn_shown ? collapse_toolbar.get_height() : 0.f);
if (m_moves_slider)
m_moves_slider->Render(canvas_width, canvas_height, extra_scale);
}

View File

@ -135,7 +135,7 @@ public:
void msw_rescale();
void render_sliders(GLCanvas3D& canvas, float extra_scale = 0.1f);
void render_sliders(GLCanvas3D& canvas);
float get_layers_slider_width();
float get_moves_slider_height();

View File

@ -243,7 +243,7 @@ public:
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;
virtual void Render(const int canvas_width, const int canvas_height, float extra_scale = 1.f, float offset = 0.f) = 0;
void set_callback_on_thumb_move(std::function<void()> cb) { m_cb_thumb_move = cb; };

View File

@ -385,7 +385,7 @@ struct Plater::priv
void set_current_canvas_as_dirty();
GLCanvas3D* get_current_canvas3D();
void render_sliders(GLCanvas3D& canvas, float extra_scale = 0.1f);
void render_sliders(GLCanvas3D& canvas);
void unbind_canvas_event_handlers();
void reset_canvas_volumes();
@ -3185,10 +3185,10 @@ GLCanvas3D* Plater::priv::get_current_canvas3D()
return (current_panel == view3D) ? view3D->get_canvas3d() : ((current_panel == preview) ? preview->get_canvas3d() : nullptr);
}
void Plater::priv::render_sliders(GLCanvas3D& canvas, float extra_scale /*= 0.1f*/)
void Plater::priv::render_sliders(GLCanvas3D& canvas)
{
if (current_panel == preview)
preview->render_sliders(canvas, extra_scale);
preview->render_sliders(canvas);
}
void Plater::priv::unbind_canvas_event_handlers()
@ -6404,9 +6404,9 @@ GLCanvas3D* Plater::get_current_canvas3D()
return p->get_current_canvas3D();
}
void Plater::render_sliders(GLCanvas3D& canvas, float extra_scale)
void Plater::render_sliders(GLCanvas3D& canvas)
{
p->render_sliders(canvas, extra_scale);
p->render_sliders(canvas);
}
static std::string concat_strings(const std::set<std::string> &strings,

View File

@ -272,7 +272,7 @@ public:
const GLCanvas3D * canvas3D() const;
GLCanvas3D* get_current_canvas3D();
void render_sliders(GLCanvas3D& canvas, float extra_scale = 0.1f);
void render_sliders(GLCanvas3D& canvas);
void arrange();
void arrange(Worker &w, bool selected);