mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-05-18 02:52:10 +00:00
ENH: add global map mode tag for pop up
1. Add tag to mark the global map mode 2. Fix some wrong usage of bmp in code 3. Fix display error in dark mode jira:STUDIO-9729 Signed-off-by: xun.zhang <xun.zhang@bambulab.com> Change-Id: Idb36a5022c403e02c26d7fe23a95dd6877deca90 (cherry picked from commit 5a2abf7e211327cde57717b5ab7b79b63c967bbd)
This commit is contained in:
@@ -24,10 +24,10 @@ CapsuleButton::CapsuleButton(wxWindow *parent, wxWindowID id, const wxString &la
|
||||
|
||||
auto sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
|
||||
std::string icon_name = selected ? "capsule_tag_on" : "capsule_tag_off";
|
||||
auto bmp = create_scaled_bitmap(icon_name, nullptr, FromDIP(16));
|
||||
tag_on_bmp = create_scaled_bitmap("capsule_tag_on", nullptr, FromDIP(16));
|
||||
tag_off_bmp = create_scaled_bitmap("capsule_tag_off", nullptr, FromDIP(16));
|
||||
|
||||
m_btn = new wxBitmapButton(this, wxID_ANY, bmp, wxDefaultPosition, wxDefaultSize, wxNO_BORDER);
|
||||
m_btn = new wxBitmapButton(this, wxID_ANY, selected?tag_on_bmp:tag_off_bmp, wxDefaultPosition, wxDefaultSize, wxNO_BORDER);
|
||||
m_btn->SetBackgroundColour(*wxWHITE);
|
||||
|
||||
m_label = new Label(this, label);
|
||||
@@ -109,15 +109,13 @@ void CapsuleButton::OnLeaveWindow(wxMouseEvent &event)
|
||||
|
||||
void CapsuleButton::UpdateStatus()
|
||||
{
|
||||
std::string icon_name = m_selected ? "capsule_tag_on" : "capsule_tag_off";
|
||||
auto bmp = create_scaled_bitmap(icon_name, nullptr, FromDIP(16));
|
||||
m_btn->SetBitmap(bmp);
|
||||
|
||||
if (m_selected) {
|
||||
m_btn->SetBitmap(tag_on_bmp);
|
||||
m_label->SetForegroundColour(TextSelectColor);
|
||||
m_label->SetBackgroundColour(BgSelectColor);
|
||||
m_btn->SetBackgroundColour(BgSelectColor);
|
||||
} else {
|
||||
m_btn->SetBitmap(tag_off_bmp);
|
||||
m_label->SetForegroundColour(TextNormalColor);
|
||||
m_label->SetBackgroundColour(BgNormalColor);
|
||||
m_btn->SetBackgroundColour(BgNormalColor);
|
||||
|
||||
@@ -21,6 +21,9 @@ private:
|
||||
wxBitmapButton *m_btn;
|
||||
Label *m_label;
|
||||
|
||||
wxBitmap tag_on_bmp;
|
||||
wxBitmap tag_off_bmp;
|
||||
|
||||
bool m_hovered;
|
||||
bool m_selected;
|
||||
};
|
||||
|
||||
@@ -78,18 +78,23 @@ FilamentGroupPopup::FilamentGroupPopup(wxWindow *parent) : PopupWindow(parent, w
|
||||
button_labels.resize(ButtonType::btCount);
|
||||
button_desps.resize(ButtonType::btCount);
|
||||
detail_infos.resize(ButtonType::btCount);
|
||||
global_mode_tags.resize(ButtonType::btCount);
|
||||
|
||||
std::vector<wxString> btn_texts = {AutoForFlushLabel, AutoForMatchLabel, ManualLabel};
|
||||
std::vector<wxString> btn_desps = {AutoForFlushDesp, AutoForMatchDesp, ManualDesp};
|
||||
std::vector<wxString> mode_details = {AutoForFlushDetail, AutoForMatchDetail, ManualDetail};
|
||||
|
||||
top_sizer->AddSpacer(vertical_margin);
|
||||
|
||||
auto checked_bmp = create_scaled_bitmap("map_mode_on", nullptr, 16);
|
||||
auto unchecked_bmp = create_scaled_bitmap("map_mode_off", nullptr, 16);
|
||||
checked_bmp = create_scaled_bitmap("map_mode_on", nullptr, 16);;
|
||||
unchecked_bmp = create_scaled_bitmap("map_mode_off", nullptr, 16);
|
||||
disabled_bmp = create_scaled_bitmap("map_mode_disabled", nullptr, 16);
|
||||
checked_hover_bmp = create_scaled_bitmap("map_mode_on_hovered", nullptr, 16);
|
||||
unchecked_hover_bmp = create_scaled_bitmap("map_mode_off_hovered", nullptr, 16);
|
||||
global_tag_bmp = create_scaled_bitmap("global_map_mode_tag", nullptr, 16);
|
||||
|
||||
for (size_t idx = 0; idx < ButtonType::btCount; ++idx) {
|
||||
wxBoxSizer *button_sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
radio_btns[idx] = new wxBitmapButton(this, idx, unchecked_bmp, wxDefaultPosition, wxDefaultSize, wxNO_BORDER);
|
||||
radio_btns[idx] = new wxBitmapButton(this, wxID_ANY, unchecked_bmp, wxDefaultPosition, wxDefaultSize, wxNO_BORDER);
|
||||
radio_btns[idx]->SetBackgroundColour(BackGroundColor);
|
||||
|
||||
button_labels[idx] = new Label(this, btn_texts[idx]);
|
||||
@@ -102,10 +107,16 @@ FilamentGroupPopup::FilamentGroupPopup(wxWindow *parent) : PopupWindow(parent, w
|
||||
button_desps[idx]->SetForegroundColour(LabelEnableColor);
|
||||
button_desps[idx]->SetFont(Label::Body_14);
|
||||
|
||||
button_sizer->Add(radio_btns[idx], 0, wxALIGN_CENTER_VERTICAL);
|
||||
global_mode_tags[idx] = new wxBitmapButton(this, wxID_ANY, global_tag_bmp, wxDefaultPosition, wxDefaultSize, wxNO_BORDER);
|
||||
global_mode_tags[idx]->SetBackgroundColour(BackGroundColor);
|
||||
global_mode_tags[idx]->SetToolTip(_L("Global settings"));
|
||||
|
||||
button_sizer->Add(radio_btns[idx], 0, wxALIGN_CENTER);
|
||||
button_sizer->AddSpacer(ratio_spacing);
|
||||
button_sizer->Add(button_labels[idx], 0, wxALIGN_CENTER_VERTICAL);
|
||||
button_sizer->Add(button_desps[idx], 0, wxALIGN_CENTER_VERTICAL);
|
||||
button_sizer->Add(button_labels[idx], 0, wxALIGN_CENTER);
|
||||
button_sizer->Add(button_desps[idx], 0, wxALIGN_CENTER);
|
||||
button_sizer->AddSpacer(ratio_spacing);
|
||||
button_sizer->Add(global_mode_tags[idx], 0, wxALIGN_CENTER);
|
||||
|
||||
wxBoxSizer *label_sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
|
||||
@@ -170,23 +181,11 @@ void FilamentGroupPopup::DrawRoundedCorner(int radius)
|
||||
HWND hwnd = GetHWND();
|
||||
if (hwnd) {
|
||||
HRGN hrgn = CreateRoundRectRgn(0, 0, GetRect().GetWidth(), GetRect().GetHeight(), radius, radius);
|
||||
SetWindowRgn(hwnd, hrgn, TRUE);
|
||||
SetWindowRgn(hwnd, hrgn, FALSE);
|
||||
|
||||
SetWindowLong(hwnd, GWL_EXSTYLE, GetWindowLong(hwnd, GWL_EXSTYLE) | WS_EX_LAYERED);
|
||||
SetLayeredWindowAttributes(hwnd, 0, 0, LWA_COLORKEY);
|
||||
}
|
||||
#else
|
||||
wxClientDC dc(this);
|
||||
wxGraphicsContext *gc = wxGraphicsContext::Create(dc);
|
||||
if (gc) {
|
||||
gc->SetBrush(*wxWHITE_BRUSH);
|
||||
gc->SetPen(*wxTRANSPARENT_PEN);
|
||||
wxRect rect(0, 0, GetSize().GetWidth(), GetSize().GetHeight());
|
||||
wxGraphicsPath path = wxGraphicsRenderer::GetDefaultRenderer()->CreatePath();
|
||||
path.AddRoundedRectangle(0, 0, rect.width, rect.height, radius);
|
||||
gc->DrawPath(path);
|
||||
delete gc;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -195,8 +194,6 @@ void FilamentGroupPopup::Init()
|
||||
const wxString AutoForMatchDesp = _L("(Arrange before slicing)");
|
||||
const wxString MachineSyncTip = _L("(Please sync printer)");
|
||||
|
||||
auto disabled_bmp = create_scaled_bitmap("map_mode_disabled", nullptr, 16);
|
||||
auto unchecked_bmp = create_scaled_bitmap("map_mode_off", nullptr, 16);
|
||||
radio_btns[ButtonType::btForMatch]->Enable(m_connected);
|
||||
if (m_connected) {
|
||||
button_labels[ButtonType::btForMatch]->SetForegroundColour(LabelEnableColor);
|
||||
@@ -239,6 +236,7 @@ void FilamentGroupPopup::tryPopup(Plater* plater,PartPlate* partplate,bool skip_
|
||||
m_active = true;
|
||||
Init();
|
||||
ResetTimer();
|
||||
DrawRoundedCorner(16);
|
||||
PopupWindow::Popup();
|
||||
}
|
||||
}
|
||||
@@ -308,13 +306,12 @@ void FilamentGroupPopup::OnEnterWindow(wxMouseEvent &) { ResetTimer(); }
|
||||
|
||||
void FilamentGroupPopup::UpdateButtonStatus(int hover_idx)
|
||||
{
|
||||
auto checked_bmp = create_scaled_bitmap("map_mode_on", nullptr, 16);
|
||||
auto unchecked_bmp = create_scaled_bitmap("map_mode_off", nullptr, 16);
|
||||
auto checked_hover_bmp = create_scaled_bitmap("map_mode_on_hovered", nullptr, 16);
|
||||
auto unchecked_hover_bmp = create_scaled_bitmap("map_mode_off_hovered", nullptr, 16);
|
||||
|
||||
|
||||
auto global_mode = plater_ref->get_global_filament_map_mode();
|
||||
for (int i = 0; i < ButtonType::btCount; ++i) {
|
||||
if (mode_list.at(i) == global_mode)
|
||||
global_mode_tags[i]->Show();
|
||||
else
|
||||
global_mode_tags[i]->Hide();
|
||||
if (ButtonType::btForMatch == i && !m_connected) {
|
||||
button_labels[i]->SetFont(Label::Body_14);
|
||||
continue;
|
||||
|
||||
@@ -48,11 +48,20 @@ private:
|
||||
FilamentMapMode m_mode;
|
||||
wxTimer *m_timer;
|
||||
|
||||
std::vector<wxBitmapButton *> radio_btns;
|
||||
std::vector<wxBitmapButton*> radio_btns;
|
||||
std::vector<wxBitmapButton*> global_mode_tags;
|
||||
std::vector<Label *> button_labels;
|
||||
std::vector<Label *> button_desps;
|
||||
std::vector<Label *> detail_infos;
|
||||
|
||||
wxBitmap checked_bmp;
|
||||
wxBitmap unchecked_bmp;
|
||||
wxBitmap disabled_bmp;
|
||||
wxBitmap checked_hover_bmp;
|
||||
wxBitmap unchecked_hover_bmp;
|
||||
wxBitmap global_tag_bmp;
|
||||
|
||||
|
||||
wxStaticText *wiki_link;
|
||||
|
||||
PartPlate* partplate_ref{ nullptr };
|
||||
|
||||
@@ -92,8 +92,6 @@ bool try_pop_up_before_slice(bool skip_plate_sync, Plater* plater_ref, PartPlate
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
static const StateColor btn_bg_green(std::pair<wxColour, int>(wxColour(27, 136, 68), StateColor::Pressed),
|
||||
std::pair<wxColour, int>(wxColour(61, 203, 115), StateColor::Hovered),
|
||||
std::pair<wxColour, int>(wxColour(0, 174, 66), StateColor::Normal));
|
||||
|
||||
@@ -115,9 +115,10 @@ GUI::FilamentMapBtnPanel::FilamentMapBtnPanel(wxWindow *parent, const wxString &
|
||||
|
||||
auto sizer = new wxBoxSizer(wxVERTICAL);
|
||||
|
||||
m_icon_path = icon;
|
||||
auto bmp = create_scaled_bitmap(icon, nullptr, 20);
|
||||
m_btn = new wxBitmapButton(this, wxID_ANY, bmp, wxDefaultPosition, wxDefaultSize, wxNO_BORDER);
|
||||
icon_enabled = create_scaled_bitmap(icon, nullptr, 20);
|
||||
icon_disabled = create_scaled_bitmap(icon + "_disabled", nullptr, 20);
|
||||
|
||||
m_btn = new wxBitmapButton(this, wxID_ANY, icon_enabled, wxDefaultPosition, wxDefaultSize, wxNO_BORDER);
|
||||
m_btn->SetBackgroundColour(*wxWHITE);
|
||||
|
||||
m_label = new wxStaticText(this, wxID_ANY, label);
|
||||
@@ -204,13 +205,13 @@ void FilamentMapBtnPanel::UpdateStatus()
|
||||
m_detail->SetBackgroundColour(BgNormalColor);
|
||||
}
|
||||
if (!m_enabled) {
|
||||
m_btn->SetBitmap(create_scaled_bitmap(m_icon_path + "_disabled", nullptr, 20));
|
||||
m_btn->SetBitmap(icon_disabled);
|
||||
m_btn->SetForegroundColour(BgDisableColor);
|
||||
m_label->SetForegroundColour(TextDisableColor);
|
||||
m_detail->SetForegroundColour(TextDisableColor);
|
||||
}
|
||||
else {
|
||||
m_btn->SetBitmap(create_scaled_bitmap(m_icon_path, nullptr, 20));
|
||||
m_btn->SetBitmap(icon_enabled);
|
||||
m_btn->SetForegroundColour(BgNormalColor);
|
||||
m_label->SetForegroundColour(TextNormalBlackColor);
|
||||
m_detail->SetForegroundColour(TextNormalGreyColor);
|
||||
|
||||
@@ -52,6 +52,9 @@ private:
|
||||
|
||||
void UpdateStatus();
|
||||
|
||||
wxBitmap icon_enabled;
|
||||
wxBitmap icon_disabled;
|
||||
|
||||
wxBitmapButton *m_btn;
|
||||
wxStaticText *m_label;
|
||||
Label *m_detail;
|
||||
|
||||
Reference in New Issue
Block a user