Merge branch 'ys_spe2277'

This commit is contained in:
Lukas Matena 2024-04-30 16:03:02 +02:00
commit 69bb0d87e7
5 changed files with 27 additions and 10 deletions

View File

@ -534,6 +534,10 @@ void Preview::create_sliders()
// m_canvas_widget
m_canvas_widget->Bind(wxEVT_KEY_DOWN, &Preview::update_sliders_from_canvas, this);
m_canvas_widget->Bind(EVT_GLCANVAS_SLIDERS_MANIPULATION, &Preview::update_sliders_from_canvas, this);
// Hide sliders from the very begibing. Visibility will be set later
m_layers_slider->Hide();
m_moves_slider->Hide();
}
// Find an index of a value in a sorted vector, which is in <z-eps, z+eps>.

View File

@ -360,11 +360,12 @@ void ImGuiControl::draw_thumb(const ImVec2& center, bool mark/* = false*/)
const float line_width = 1.5f * m_draw_opts.scale;
const float radius = m_draw_opts.thumb_radius();
const float line_offset = 0.5f * radius;
const float rounding = 1.5f * m_draw_opts.rounding();
const float hexagon_angle = is_horizontal() ? 0.f : IM_PI * 0.5f;
ImGuiPureWrap::draw_hexagon(center, radius, border_clr, hexagon_angle);
ImGuiPureWrap::draw_hexagon(center, radius - line_width, thumb_bg_clr, hexagon_angle);
ImGuiPureWrap::draw_hexagon(center, radius, border_clr, hexagon_angle, rounding);
ImGuiPureWrap::draw_hexagon(center, radius - line_width, thumb_bg_clr, hexagon_angle, rounding);
if (mark) {
ImGuiWindow* window = ImGui::GetCurrentWindow();
@ -413,12 +414,12 @@ void ImGuiControl::check_and_correct_thumbs(int* higher_pos, int* lower_pos)
if (is_horizontal()) {
if (lower_thumb_center_pos + thumb_radius > higher_thumb_center_pos) {
if (m_selection == ssHigher) {
m_regions.lower_thumb = m_regions.higher_thumb;
m_regions.higher_thumb = m_regions.lower_thumb;
m_regions.higher_thumb.TranslateX(thumb_radius);
*lower_pos = *higher_pos;
}
else {
m_regions.higher_thumb = m_regions.lower_thumb;
m_regions.lower_thumb = m_regions.higher_thumb;
m_regions.lower_thumb.TranslateX(-thumb_radius);
*higher_pos = *lower_pos;
}
@ -433,7 +434,7 @@ void ImGuiControl::check_and_correct_thumbs(int* higher_pos, int* lower_pos)
}
else {
m_regions.higher_thumb = m_regions.lower_thumb;
m_regions.lower_thumb.TranslateY(-thumb_radius);
m_regions.higher_thumb.TranslateY(-thumb_radius);
*higher_pos = *lower_pos;
}
}

View File

@ -296,7 +296,7 @@ bool combo(const std::string& label, const std::vector<std::string>& options, in
return res;
}
void draw_hexagon(const ImVec2& center, float radius, ImU32 col, float start_angle)
void draw_hexagon(const ImVec2& center, float radius, ImU32 col, float start_angle, float rounding)
{
if ((col & IM_COL32_A_MASK) == 0)
return;
@ -306,7 +306,21 @@ void draw_hexagon(const ImVec2& center, float radius, ImU32 col, float start_ang
float a_min = start_angle;
float a_max = start_angle + 2.f * IM_PI;
if (rounding <= 0) {
window->DrawList->PathArcTo(center, radius, a_min, a_max, 6);
}
else {
const float a_delta = IM_PI / 4.f;
radius -= rounding;
for (int i = 0; i <= 6; i++) {
float a = a_min + ((float)i / (float)6) * (a_max - a_min);
if (a >= 2.f * IM_PI)
a -= 2.f * IM_PI;
ImVec2 pos = ImVec2(center.x + ImCos(a) * radius, center.y + ImSin(a) * radius);
window->DrawList->PathArcTo(pos, rounding, a - a_delta, a + a_delta, 5);
}
}
window->DrawList->PathFillConvex(col);
}

View File

@ -53,7 +53,7 @@ namespace ImGuiPureWrap
// Use selection = -1 to not mark any option as selected
bool combo(const std::string& label, const std::vector<std::string>& options, int& selection, ImGuiComboFlags flags = 0, float label_width = 0.0f, float item_width = 0.0f);
void draw_hexagon(const ImVec2& center, float radius, ImU32 col, float start_angle = 0.f);
void draw_hexagon(const ImVec2& center, float radius, ImU32 col, float start_angle = 0.f, float rounding = 0.f);
void text(const char* label);
void text(const std::string& label);

View File

@ -753,8 +753,6 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame)
q->Layout();
set_current_panel(wxGetApp().is_editor() ? static_cast<wxPanel*>(view3D) : static_cast<wxPanel*>(preview));
if (wxGetApp().is_gcode_viewer())
preview->hide_layers_slider();
// updates camera type from .ini file
camera.enable_update_config_on_type_change(true);