ImguiDoubleSlider: Change layout of horizontal slider and position_window

This commit is contained in:
YuSanka 2024-04-23 18:59:19 +02:00 committed by Lukas Matena
parent eada1893e6
commit 320d11d5db
6 changed files with 18 additions and 7 deletions

View File

@ -8,7 +8,7 @@
namespace DoubleSlider {
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 = 40.0f;
void DSForGcode::Render(const int canvas_width, const int canvas_height, float extra_scale/* = 0.1f*/, float offset/* = 0.f*/)
{
@ -16,7 +16,7 @@ void DSForGcode::Render(const int canvas_width, const int canvas_height, float e
return;
m_scale = extra_scale * 0.1f * m_em;
ImVec2 pos = ImVec2{std::max(LEFT_MARGIN, 0.2f * canvas_width), canvas_height - 1.5f * HORIZONTAL_SLIDER_HEIGHT * m_scale};
ImVec2 pos = ImVec2{std::max(LEFT_MARGIN, 0.2f * canvas_width), canvas_height - HORIZONTAL_SLIDER_HEIGHT * m_scale};
ImVec2 size = ImVec2(canvas_width - 2 * pos.x, HORIZONTAL_SLIDER_HEIGHT * m_scale);
m_ctrl.Init(pos, size, m_scale);

View File

@ -303,7 +303,11 @@ void GCodeViewer::SequentialView::Marker::render_position_window(const libvgcode
if (viewer != nullptr) {
ImGuiWrapper& imgui = *wxGetApp().imgui();
const Size cnv_size = wxGetApp().plater()->get_current_canvas3D()->get_canvas_size();
ImGuiPureWrap::set_next_window_pos(0.5f * static_cast<float>(cnv_size.get_width()), static_cast<float>(cnv_size.get_height()), ImGuiCond_Always, 0.5f, 1.0f);
Preview* preview = dynamic_cast<Preview*>(wxGetApp().plater()->get_current_canvas3D()->get_wxglcanvas_parent());
assert(preview);
ImGuiPureWrap::set_next_window_pos(0.5f * static_cast<float>(cnv_size.get_width()), static_cast<float>(cnv_size.get_height() - preview->get_moves_slider_height()), ImGuiCond_Always, 0.5f, 1.0f);
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
ImGui::SetNextWindowBgAlpha(0.25f);
ImGuiPureWrap::begin(std::string("ToolPosition"), ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoMove);
@ -430,7 +434,7 @@ void GCodeViewer::SequentialView::Marker::render_position_window(const libvgcode
if (table_shown) {
static float table_wnd_height = 0.0f;
const ImVec2 wnd_size = ImGui::GetWindowSize();
ImGuiPureWrap::set_next_window_pos(ImGui::GetWindowPos().x + wnd_size.x, static_cast<float>(cnv_size.get_height()), ImGuiCond_Always, 0.0f, 1.0f);
ImGuiPureWrap::set_next_window_pos(ImGui::GetWindowPos().x + wnd_size.x, static_cast<float>(cnv_size.get_height() - preview->get_moves_slider_height()), ImGuiCond_Always, 0.0f, 1.0f);
ImGui::SetNextWindowSizeConstraints({ 0.0f, 0.0f }, { -1.0f, wnd_size.y });
ImGuiPureWrap::begin(std::string("ToolPositionTableWnd"), ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoTitleBar |
ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoMove);

View File

@ -1353,6 +1353,11 @@ void GLCanvas3D::post_event(wxEvent &&event)
wxPostEvent(m_canvas, event);
}
wxWindow* GLCanvas3D::get_wxglcanvas_parent()
{
return m_canvas->GetParent();
}
bool GLCanvas3D::init()
{
if (m_initialized)

View File

@ -689,6 +689,8 @@ public:
wxGLCanvas* get_wxglcanvas() { return m_canvas; }
const wxGLCanvas* get_wxglcanvas() const { return m_canvas; }
wxWindow* get_wxglcanvas_parent();
bool init();
void post_event(wxEvent &&event);

View File

@ -100,7 +100,7 @@ private:
struct DrawOptions {
float scale { 1.f }; // used for Retina on osx
ImVec2 dummy_sz() const { return ImVec2(24.0f, 22.0f) * scale; }
ImVec2 dummy_sz() const { return ImVec2(24.0f, 16.0f) * scale; }
ImVec2 thumb_dummy_sz() const { return ImVec2(17.0f, 17.0f) * scale; }
ImVec2 groove_sz() const { return ImVec2(4.0f, 4.0f) * scale; }
ImVec2 draggable_region_sz()const { return ImVec2(20.0f, 19.0f) * scale; }

View File

@ -176,8 +176,8 @@ void NotificationManager::PopNotification::render(GLCanvas3D& canvas, float init
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();
if (Preview* preview = dynamic_cast<Preview*>(canvas.get_wxglcanvas_parent())) {
win_pos.y -= preview->get_moves_slider_height();
win_pos.x -= preview->get_layers_slider_width();
}
}