From 27c8c81cc1ecffa2aff4382a37e23a4048a0a981 Mon Sep 17 00:00:00 2001 From: tao wang Date: Tue, 30 May 2023 20:12:05 +0800 Subject: [PATCH] ENH:fixed transparent controls that cannot be clicked Change-Id: I36f34b73a5248299b1db20127b5cbd010592f62a --- resources/images/ts_bitmap_cube.svg | 4 ++++ src/slic3r/GUI/AMSMaterialsSetting.cpp | 8 ++++++++ src/slic3r/GUI/Widgets/AMSControl.cpp | 9 ++++++++- src/slic3r/GUI/Widgets/AMSControl.hpp | 1 + 4 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 resources/images/ts_bitmap_cube.svg diff --git a/resources/images/ts_bitmap_cube.svg b/resources/images/ts_bitmap_cube.svg new file mode 100644 index 000000000..9a8403aff --- /dev/null +++ b/resources/images/ts_bitmap_cube.svg @@ -0,0 +1,4 @@ + + + + diff --git a/src/slic3r/GUI/AMSMaterialsSetting.cpp b/src/slic3r/GUI/AMSMaterialsSetting.cpp index de9630d2e..4fc8391dd 100644 --- a/src/slic3r/GUI/AMSMaterialsSetting.cpp +++ b/src/slic3r/GUI/AMSMaterialsSetting.cpp @@ -1168,6 +1168,14 @@ ColorPickerPopup::ColorPickerPopup(wxWindow* parent) m_ts_bitmap_custom = ScalableBitmap(this, "ts_custom_color_picker", 25); m_ts_stbitmap_custom = new wxStaticBitmap(m_custom_cp, wxID_ANY, m_ts_bitmap_custom.bmp()); + m_ts_stbitmap_custom->Bind(wxEVT_LEFT_DOWN, &ColorPickerPopup::on_custom_clr_picker, this); + m_ts_stbitmap_custom->Bind(wxEVT_ENTER_WINDOW, [this](auto& e) { + SetCursor(wxCURSOR_HAND); + }); + m_ts_stbitmap_custom->Bind(wxEVT_LEAVE_WINDOW, [this](auto& e) { + SetCursor(wxCURSOR_ARROW); + }); + auto sizer_custom = new wxBoxSizer(wxVERTICAL); m_custom_cp->SetSizer(sizer_custom); sizer_custom->Add(m_ts_stbitmap_custom, 0, wxEXPAND, 0); diff --git a/src/slic3r/GUI/Widgets/AMSControl.cpp b/src/slic3r/GUI/Widgets/AMSControl.cpp index a5340e748..82417e5dd 100644 --- a/src/slic3r/GUI/Widgets/AMSControl.cpp +++ b/src/slic3r/GUI/Widgets/AMSControl.cpp @@ -1341,6 +1341,7 @@ void AMSItem::Update(AMSinfo amsinfo) void AMSItem::create(wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size) { + m_ts_bitmap_cube = new ScalableBitmap(this, "ts_bitmap_cube", 14); wxWindow::Create(parent, id, pos, size); SetBackgroundColour(AMS_CONTROL_WHITE_COLOUR); HideHumidity(); @@ -1461,7 +1462,13 @@ void AMSItem::doRender(wxDC &dc) dc.DrawRoundedRectangle(left - 1, (size.y - AMS_ITEM_CUBE_SIZE.y) / 2 - 1, AMS_ITEM_CUBE_SIZE.x + 2, AMS_ITEM_CUBE_SIZE.y + 2, 2); }else { - dc.DrawRoundedRectangle(left, (size.y - AMS_ITEM_CUBE_SIZE.y) / 2, AMS_ITEM_CUBE_SIZE.x, AMS_ITEM_CUBE_SIZE.y, 2); + if (iter->material_colour.Alpha() == 0) { + dc.DrawBitmap(m_ts_bitmap_cube->bmp(),left,(size.y - AMS_ITEM_CUBE_SIZE.y) / 2); + } + else { + dc.DrawRoundedRectangle(left, (size.y - AMS_ITEM_CUBE_SIZE.y) / 2, AMS_ITEM_CUBE_SIZE.x, AMS_ITEM_CUBE_SIZE.y, 2); + } + } diff --git a/src/slic3r/GUI/Widgets/AMSControl.hpp b/src/slic3r/GUI/Widgets/AMSControl.hpp index fc65979f6..29c01d47a 100644 --- a/src/slic3r/GUI/Widgets/AMSControl.hpp +++ b/src/slic3r/GUI/Widgets/AMSControl.hpp @@ -416,6 +416,7 @@ protected: bool m_selected = {false}; bool m_show_humidity = {false}; int m_humidity = {0}; + ScalableBitmap* m_ts_bitmap_cube; void paintEvent(wxPaintEvent &evt); void render(wxDC &dc);