From 32b8be600cb29543fa50866e2c60fb6e1b5177e3 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Thu, 29 Oct 2020 21:53:33 +0100 Subject: [PATCH] Custom control: Fixed bitmaps layout under OSX + Implemented hyperlinks for parameters labels to the help page --- src/slic3r/GUI/OG_CustomCtrl.cpp | 111 ++++++++++++-------- src/slic3r/GUI/OG_CustomCtrl.hpp | 6 +- src/slic3r/GUI/OptionsGroup.cpp | 3 +- src/slic3r/GUI/OptionsGroup.hpp | 30 +++--- src/slic3r/GUI/Tab.cpp | 175 +++++++++++++++++-------------- src/slic3r/GUI/Tab.hpp | 2 +- 6 files changed, 187 insertions(+), 140 deletions(-) diff --git a/src/slic3r/GUI/OG_CustomCtrl.cpp b/src/slic3r/GUI/OG_CustomCtrl.cpp index 03b790df54..f0fd4975e5 100644 --- a/src/slic3r/GUI/OG_CustomCtrl.cpp +++ b/src/slic3r/GUI/OG_CustomCtrl.cpp @@ -1,14 +1,10 @@ #include "OG_CustomCtrl.hpp" #include "OptionsGroup.hpp" -#include "ConfigExceptions.hpp" #include "Plater.hpp" #include "GUI_App.hpp" -#include -#include +#include #include -#include -#include "libslic3r/Exception.hpp" #include "libslic3r/Utils.hpp" #include "I18N.hpp" @@ -20,15 +16,6 @@ static bool is_point_in_rect(const wxPoint& pt, const wxRect& rect) rect.GetTop() <= pt.y && pt.y <= rect.GetBottom(); } -static int get_bitmap_height(const wxBitmap& bmp) -{ -#ifdef __APPLE__ - return bmp.GetScaledHeight(); -#else - return bmp.GetHeight(); -#endif -} - static wxSize get_bitmap_size(const wxBitmap& bmp) { #ifdef __APPLE__ @@ -38,6 +25,13 @@ static wxSize get_bitmap_size(const wxBitmap& bmp) #endif } +static wxString get_url(const wxString& path_end) +{ + if (path_end.IsEmpty()) + return wxEmptyString; + return wxString("https://help.prusa3d.com/") + "en" + "/article/" + path_end; +} + OG_CustomCtrl::OG_CustomCtrl( wxWindow* parent, OptionsGroup* og, const wxPoint& pos /* = wxDefaultPosition*/, @@ -216,7 +210,13 @@ void OG_CustomCtrl::OnMotion(wxMouseEvent& event) const wxPoint pos = event.GetLogicalPosition(wxClientDC(this)); wxString tooltip; - for (const CtrlLine& line : ctrl_lines) { + for (CtrlLine& line : ctrl_lines) { + line.is_focused = is_point_in_rect(pos, line.rect_label); + if (line.is_focused) { + tooltip = get_url(line.og_line.label_path); + break; + } + for (size_t opt_idx = 0; opt_idx < line.rects_undo_icon.size(); opt_idx++) if (is_point_in_rect(pos, line.rects_undo_icon[opt_idx])) { const std::vector