diff --git a/src/slic3r/GUI/Field.hpp b/src/slic3r/GUI/Field.hpp index 8bdf4b8d80b..a9812abf2a6 100644 --- a/src/slic3r/GUI/Field.hpp +++ b/src/slic3r/GUI/Field.hpp @@ -39,7 +39,86 @@ using t_back_to_init = std::function; wxString double_to_string(double const value, const int max_precision = 4); wxString get_thumbnails_string(const std::vector& values); -class Field { +class UndoValueUIManager +{ + struct UndoValueUI { + // Bitmap and Tooltip text for m_Undo_btn. The wxButton will be updated only if the new wxBitmap pointer differs from the currently rendered one. + const ScalableBitmap* undo_bitmap{ nullptr }; + const wxString* undo_tooltip{ nullptr }; + // Bitmap and Tooltip text for m_Undo_to_sys_btn. The wxButton will be updated only if the new wxBitmap pointer differs from the currently rendered one. + const ScalableBitmap* undo_to_sys_bitmap{ nullptr }; + const wxString* undo_to_sys_tooltip{ nullptr }; + // Color for Label. The wxColour will be updated only if the new wxColour pointer differs from the currently rendered one. + const wxColour* label_color{ nullptr }; + // State of the blinker icon + bool blink{ false }; + + bool set_undo_bitmap(const ScalableBitmap* bmp) { + if (undo_bitmap != bmp) { + undo_bitmap = bmp; + return true; + } + return false; + } + + bool set_undo_to_sys_bitmap(const ScalableBitmap* bmp) { + if (undo_to_sys_bitmap != bmp) { + undo_to_sys_bitmap = bmp; + return true; + } + return false; + } + + bool set_label_colour(const wxColour* clr) { + if (label_color != clr) { + label_color = clr; + } + return false; + } + + bool set_undo_tooltip(const wxString* tip) { + if (undo_tooltip != tip) { + undo_tooltip = tip; + return true; + } + return false; + } + + bool set_undo_to_sys_tooltip(const wxString* tip) { + if (undo_to_sys_tooltip != tip) { + undo_to_sys_tooltip = tip; + return true; + } + return false; + } + }; + + UndoValueUI m_undo_ui; + +public: + UndoValueUIManager() {} + ~UndoValueUIManager() {} + + bool set_undo_bitmap(const ScalableBitmap* bmp) { return m_undo_ui.set_undo_bitmap(bmp); } + bool set_undo_to_sys_bitmap(const ScalableBitmap* bmp) { return m_undo_ui.set_undo_to_sys_bitmap(bmp); } + bool set_label_colour(const wxColour* clr) { return m_undo_ui.set_label_colour(clr); } + bool set_undo_tooltip(const wxString* tip) { return m_undo_ui.set_undo_tooltip(tip); } + bool set_undo_to_sys_tooltip(const wxString* tip) { return m_undo_ui.set_undo_to_sys_tooltip(tip); } + + // ui items used for revert line value + bool has_undo_ui() const { return m_undo_ui.undo_bitmap != nullptr; } + const wxBitmap& undo_bitmap() const { return m_undo_ui.undo_bitmap->bmp(); } + const wxString* undo_tooltip() const { return m_undo_ui.undo_tooltip; } + const wxBitmap& undo_to_sys_bitmap() const { return m_undo_ui.undo_to_sys_bitmap->bmp(); } + const wxString* undo_to_sys_tooltip() const { return m_undo_ui.undo_to_sys_tooltip; } + const wxColour* label_color() const { return m_undo_ui.label_color; } + const bool blink() const { return m_undo_ui.blink; } + bool* get_blink_ptr() { return &m_undo_ui.blink; } +}; + + +class Field : public UndoValueUIManager +{ protected: // factory function to defer and enforce creation of derived type. virtual void PostInitialize(); @@ -137,49 +216,6 @@ class Field { return std::move(p); //!p; } - bool set_undo_bitmap(const ScalableBitmap *bmp) { - if (m_undo_bitmap != bmp) { - m_undo_bitmap = bmp; - return true; - } - return false; - } - - bool set_undo_to_sys_bitmap(const ScalableBitmap *bmp) { - if (m_undo_to_sys_bitmap != bmp) { - m_undo_to_sys_bitmap = bmp; - return true; - } - return false; - } - - bool set_label_colour(const wxColour *clr) { - if (m_label_color != clr) { - m_label_color = clr; - } - return false; - } - - bool set_undo_tooltip(const wxString *tip) { - if (m_undo_tooltip != tip) { - m_undo_tooltip = tip; - return true; - } - return false; - } - - bool set_undo_to_sys_tooltip(const wxString *tip) { - if (m_undo_to_sys_tooltip != tip) { - m_undo_to_sys_tooltip = tip; - return true; - } - return false; - } - - bool* get_blink_ptr() { - return &m_blink; - } - virtual void msw_rescale(); virtual void sys_color_changed(); @@ -191,26 +227,7 @@ class Field { static int def_width_wider() ; static int def_width_thinner() ; - const ScalableBitmap* undo_bitmap() { return m_undo_bitmap; } - const wxString* undo_tooltip() { return m_undo_tooltip; } - const ScalableBitmap* undo_to_sys_bitmap() { return m_undo_to_sys_bitmap; } - const wxString* undo_to_sys_tooltip() { return m_undo_to_sys_tooltip; } - const wxColour* label_color() { return m_label_color; } - const bool blink() { return m_blink; } - protected: - // Bitmap and Tooltip text for m_Undo_btn. The wxButton will be updated only if the new wxBitmap pointer differs from the currently rendered one. - const ScalableBitmap* m_undo_bitmap = nullptr; - const wxString* m_undo_tooltip = nullptr; - // Bitmap and Tooltip text for m_Undo_to_sys_btn. The wxButton will be updated only if the new wxBitmap pointer differs from the currently rendered one. - const ScalableBitmap* m_undo_to_sys_bitmap = nullptr; - const wxString* m_undo_to_sys_tooltip = nullptr; - - bool m_blink{ false }; - - // Color for Label. The wxColour will be updated only if the new wxColour pointer differs from the currently rendered one. - const wxColour* m_label_color = nullptr; - // current value boost::any m_value; // last maeningful value diff --git a/src/slic3r/GUI/OG_CustomCtrl.cpp b/src/slic3r/GUI/OG_CustomCtrl.cpp index 83537fd54fd..400db751aac 100644 --- a/src/slic3r/GUI/OG_CustomCtrl.cpp +++ b/src/slic3r/GUI/OG_CustomCtrl.cpp @@ -145,7 +145,7 @@ wxPoint OG_CustomCtrl::get_pos(const Line& line, Field* field_in/* = nullptr*/) int blinking_button_width = m_bmp_blinking_sz.GetWidth() + m_h_gap; if (line.widget) { - h_pos += blinking_button_width; + h_pos += (line.has_undo_ui() ? 3 : 1) * blinking_button_width; for (auto child : line.widget_sizer->GetChildren()) if (child->IsWindow()) @@ -257,22 +257,28 @@ void OG_CustomCtrl::OnMotion(wxMouseEvent& event) break; } - for (size_t opt_idx = 0; opt_idx < line.rects_undo_icon.size(); opt_idx++) + size_t undo_icons_cnt = line.rects_undo_icon.size(); + assert(line.rects_undo_icon.size() == line.rects_undo_to_sys_icon.size()); + + const std::vector