mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-04 00:40:38 +08:00
ImguiDoubleSlider: Respect to "Collapse sidebar" button
+ use scale from canvas Size
This commit is contained in:
parent
b02e0e6fd1
commit
0bb9233da7
@ -10,7 +10,7 @@ namespace DoubleSlider {
|
|||||||
static const float LEFT_MARGIN = 13.0f + 100.0f; // avoid thumbnail toolbar
|
static const float LEFT_MARGIN = 13.0f + 100.0f; // avoid thumbnail toolbar
|
||||||
static const float HORIZONTAL_SLIDER_HEIGHT = 45.0f;
|
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())
|
if (!m_ctrl.IsShown())
|
||||||
return;
|
return;
|
||||||
|
@ -22,7 +22,7 @@ public:
|
|||||||
}
|
}
|
||||||
~DSForGcode() {}
|
~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; }
|
void set_render_as_disabled(bool value) { m_render_as_disabled = value; }
|
||||||
bool is_rendering_as_disabled() const { return m_render_as_disabled; }
|
bool is_rendering_as_disabled() const { return m_render_as_disabled; }
|
||||||
|
@ -615,7 +615,7 @@ bool DSForLayers::render_jump_to_window(const ImVec2& pos, double* active_value,
|
|||||||
return enter_pressed || ok_pressed;
|
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())
|
if (!m_ctrl.IsShown())
|
||||||
return;
|
return;
|
||||||
@ -627,11 +627,11 @@ void DSForLayers::Render(const int canvas_width, const int canvas_height, float
|
|||||||
ImVec2 pos;
|
ImVec2 pos;
|
||||||
|
|
||||||
pos.x = canvas_width - VERTICAL_SLIDER_WIDTH * m_scale - tick_icon_side;
|
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)
|
if (m_allow_editing)
|
||||||
pos.y += 2.f;
|
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);
|
m_ctrl.Init(pos, size, m_scale);
|
||||||
if (m_ctrl.render()) {
|
if (m_ctrl.render()) {
|
||||||
|
@ -73,7 +73,7 @@ public:
|
|||||||
|
|
||||||
void SetModeAndOnlyExtruder(const bool is_one_extruder_printed_model, const int only_extruder);
|
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
|
// jump to selected layer
|
||||||
void jump_to_value();
|
void jump_to_value();
|
||||||
|
@ -1947,13 +1947,7 @@ void GLCanvas3D::render()
|
|||||||
|
|
||||||
wxGetApp().plater()->get_notification_manager()->render_notifications(*this, get_overlay_window_width());
|
wxGetApp().plater()->get_notification_manager()->render_notifications(*this, get_overlay_window_width());
|
||||||
|
|
||||||
wxGetApp().plater()->render_sliders(*this,
|
wxGetApp().plater()->render_sliders(*this);
|
||||||
#if ENABLE_RETINA_GL
|
|
||||||
m_retina_helper->get_scale_factor()
|
|
||||||
#else
|
|
||||||
1.f
|
|
||||||
#endif
|
|
||||||
);
|
|
||||||
|
|
||||||
wxGetApp().imgui()->render();
|
wxGetApp().imgui()->render();
|
||||||
|
|
||||||
|
@ -322,14 +322,18 @@ void Preview::msw_rescale()
|
|||||||
reload_print();
|
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 Size cnv_size = canvas.get_canvas_size();
|
||||||
const int canvas_width = cnv_size.get_width();
|
const int canvas_width = cnv_size.get_width();
|
||||||
const int canvas_height = cnv_size.get_height();
|
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)
|
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)
|
if (m_moves_slider)
|
||||||
m_moves_slider->Render(canvas_width, canvas_height, extra_scale);
|
m_moves_slider->Render(canvas_width, canvas_height, extra_scale);
|
||||||
}
|
}
|
||||||
|
@ -135,7 +135,7 @@ public:
|
|||||||
|
|
||||||
void msw_rescale();
|
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_layers_slider_width();
|
||||||
float get_moves_slider_height();
|
float get_moves_slider_height();
|
||||||
|
|
||||||
|
@ -243,7 +243,7 @@ public:
|
|||||||
|
|
||||||
float GetWidth() { return m_ctrl.GetCtrlSize().x; }
|
float GetWidth() { return m_ctrl.GetCtrlSize().x; }
|
||||||
float GetHeight() { return m_ctrl.GetCtrlSize().y; }
|
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; };
|
void set_callback_on_thumb_move(std::function<void()> cb) { m_cb_thumb_move = cb; };
|
||||||
|
|
||||||
|
@ -385,7 +385,7 @@ struct Plater::priv
|
|||||||
|
|
||||||
void set_current_canvas_as_dirty();
|
void set_current_canvas_as_dirty();
|
||||||
GLCanvas3D* get_current_canvas3D();
|
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 unbind_canvas_event_handlers();
|
||||||
void reset_canvas_volumes();
|
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);
|
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)
|
if (current_panel == preview)
|
||||||
preview->render_sliders(canvas, extra_scale);
|
preview->render_sliders(canvas);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Plater::priv::unbind_canvas_event_handlers()
|
void Plater::priv::unbind_canvas_event_handlers()
|
||||||
@ -6404,9 +6404,9 @@ GLCanvas3D* Plater::get_current_canvas3D()
|
|||||||
return p->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,
|
static std::string concat_strings(const std::set<std::string> &strings,
|
||||||
|
@ -272,7 +272,7 @@ public:
|
|||||||
const GLCanvas3D * canvas3D() const;
|
const GLCanvas3D * canvas3D() const;
|
||||||
GLCanvas3D* get_current_canvas3D();
|
GLCanvas3D* get_current_canvas3D();
|
||||||
|
|
||||||
void render_sliders(GLCanvas3D& canvas, float extra_scale = 0.1f);
|
void render_sliders(GLCanvas3D& canvas);
|
||||||
|
|
||||||
void arrange();
|
void arrange();
|
||||||
void arrange(Worker &w, bool selected);
|
void arrange(Worker &w, bool selected);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user