From 6274f24e93f1bffdfcf03bc29f50044a762cb419 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Thu, 19 Oct 2023 15:40:14 +0200 Subject: [PATCH] Fixed some warnings --- src/slic3r/GUI/Field.cpp | 3 ++- src/slic3r/GUI/GUI_App.cpp | 2 +- src/slic3r/GUI/Tab.cpp | 29 ++++++++++++------------- src/slic3r/GUI/Widgets/ComboBox.cpp | 2 +- src/slic3r/GUI/Widgets/DropDown.cpp | 16 ++++++++------ src/slic3r/GUI/Widgets/SpinInput.cpp | 8 +++---- src/slic3r/GUI/Widgets/StateColor.cpp | 10 ++++----- src/slic3r/GUI/Widgets/StateHandler.cpp | 4 ++-- src/slic3r/GUI/Widgets/TextInput.cpp | 8 +------ src/slic3r/GUI/Widgets/TextInput.hpp | 7 ++---- 10 files changed, 41 insertions(+), 48 deletions(-) diff --git a/src/slic3r/GUI/Field.cpp b/src/slic3r/GUI/Field.cpp index bf3aab1861..fd222d2f8a 100644 --- a/src/slic3r/GUI/Field.cpp +++ b/src/slic3r/GUI/Field.cpp @@ -899,8 +899,9 @@ void SpinCtrl::BUILD() { if (!wxOSX) temp->SetBackgroundStyle(wxBG_STYLE_PAINT); wxGetApp().UpdateDarkUI(temp); - if (m_opt.height < 0 && parent_is_custom_ctrl) + if (m_opt.height < 0 && parent_is_custom_ctrl) { opt_height = (double)temp->GetSize().GetHeight() / m_em_unit; + } temp->Bind(wxEVT_KILL_FOCUS, ([this](wxEvent& e) { diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index d76c73cc67..071e8000cc 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -1680,7 +1680,7 @@ void GUI_App::SetWindowVariantForButton(wxButton* btn) int GUI_App::get_max_font_pt_size() { const unsigned disp_count = wxDisplay::GetCount(); - for (int i = 0; i < disp_count; i++) { + for (unsigned i = 0; i < disp_count; i++) { const wxRect display_rect = wxDisplay(i).GetGeometry(); if (display_rect.width >= 2560 && display_rect.height >= 1440) return 20; diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index 6d1dc83107..9f6409e25d 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -1947,23 +1947,22 @@ void TabFilament::create_line_with_near_label_widget(ConfigOptionsGroupShp optgr else line = optgroup->create_single_option_line(optgroup->get_option(opt_key)); + line.near_label_widget = [this, optgroup_wk = ConfigOptionsGroupWkp(optgroup), opt_key, opt_index](wxWindow* parent) { + wxWindow* check_box = CheckBox::GetNewWin(parent); + wxGetApp().UpdateDarkUI(check_box); - line.near_label_widget = [this, optgroup_wk = ConfigOptionsGroupWkp(optgroup), opt_key, opt_index](wxWindow* parent) { - wxWindow* check_box = CheckBox::GetNewWin(parent); - wxGetApp().UpdateDarkUI(check_box); - - check_box->Bind(wxEVT_CHECKBOX, [optgroup_wk, opt_key, opt_index](wxCommandEvent& evt) { - const bool is_checked = evt.IsChecked(); - if (auto optgroup_sh = optgroup_wk.lock(); optgroup_sh) { - if (Field *field = optgroup_sh->get_fieldc(opt_key, opt_index); field != nullptr) { - field->toggle(is_checked); - if (is_checked) - field->set_last_meaningful_value(); - else - field->set_na_value(); - } + check_box->Bind(wxEVT_CHECKBOX, [optgroup_wk, opt_key, opt_index](wxCommandEvent& evt) { + const bool is_checked = evt.IsChecked(); + if (auto optgroup_sh = optgroup_wk.lock(); optgroup_sh) { + if (Field *field = optgroup_sh->get_fieldc(opt_key, opt_index); field != nullptr) { + field->toggle(is_checked); + if (is_checked) + field->set_last_meaningful_value(); + else + field->set_na_value(); } - }); + } + }); m_overrides_options[opt_key] = check_box; return check_box; diff --git a/src/slic3r/GUI/Widgets/ComboBox.cpp b/src/slic3r/GUI/Widgets/ComboBox.cpp index 68fc6ee8c5..f0e885ccb4 100644 --- a/src/slic3r/GUI/Widgets/ComboBox.cpp +++ b/src/slic3r/GUI/Widgets/ComboBox.cpp @@ -272,7 +272,7 @@ void ComboBox::mouseWheelMoved(wxMouseEvent &event) { event.Skip(); if (drop_down) return; - auto delta = (event.GetWheelRotation() < 0 == event.IsWheelInverted()) ? -1 : 1; + auto delta = ((event.GetWheelRotation() < 0) == event.IsWheelInverted()) ? -1 : 1; unsigned int n = GetSelection() + delta; if (n < GetCount()) { SetSelection((int) n); diff --git a/src/slic3r/GUI/Widgets/DropDown.cpp b/src/slic3r/GUI/Widgets/DropDown.cpp index 999dba41f8..259ed11e63 100644 --- a/src/slic3r/GUI/Widgets/DropDown.cpp +++ b/src/slic3r/GUI/Widgets/DropDown.cpp @@ -302,7 +302,7 @@ void DropDown::render(wxDC &dc) } // draw texts & icons dc.SetTextForeground(text_color.colorForStates(states)); - for (int i = 0; i < texts.size(); ++i) { + for (size_t i = 0; i < texts.size(); ++i) { if (rcContent.GetBottom() < 0) { rcContent.y += rowSize.y; continue; @@ -460,13 +460,14 @@ void DropDown::mouseCaptureLost(wxMouseCaptureLostEvent &event) void DropDown::mouseMove(wxMouseEvent &event) { wxPoint pt = event.GetPosition(); + int text_size = int(texts.size()); if (pressedDown) { wxPoint pt2 = offset + pt - dragStart; dragStart = pt; if (pt2.y > 0) pt2.y = 0; - else if (pt2.y + rowSize.y * texts.size() < GetSize().y) - pt2.y = GetSize().y - rowSize.y * texts.size(); + else if (pt2.y + rowSize.y * text_size < GetSize().y) + pt2.y = GetSize().y - rowSize.y * text_size; if (pt2.y != offset.y) { offset = pt2; hover_item = -1; // moved @@ -476,7 +477,7 @@ void DropDown::mouseMove(wxMouseEvent &event) } if (!pressedDown || hover_item >= 0) { int hover = (pt.y - offset.y) / rowSize.y; - if (hover >= (int) texts.size()) hover = -1; + if (hover >= text_size) hover = -1; if (hover == hover_item) return; hover_item = hover; if (hover >= 0) @@ -489,17 +490,18 @@ void DropDown::mouseWheelMoved(wxMouseEvent &event) { auto delta = event.GetWheelRotation() > 0 ? rowSize.y : -rowSize.y; wxPoint pt2 = offset + wxPoint{0, delta}; + int text_size = int(texts.size()); if (pt2.y > 0) pt2.y = 0; - else if (pt2.y + rowSize.y * texts.size() < GetSize().y) - pt2.y = GetSize().y - rowSize.y * texts.size(); + else if (pt2.y + rowSize.y * text_size < GetSize().y) + pt2.y = GetSize().y - rowSize.y * text_size; if (pt2.y != offset.y) { offset = pt2; } else { return; } int hover = (event.GetPosition().y - offset.y) / rowSize.y; - if (hover >= (int) texts.size()) hover = -1; + if (hover >= text_size) hover = -1; if (hover != hover_item) { hover_item = hover; if (hover >= 0) SetToolTip(texts[hover]); diff --git a/src/slic3r/GUI/Widgets/SpinInput.cpp b/src/slic3r/GUI/Widgets/SpinInput.cpp index c693a52843..f8471bf7b7 100644 --- a/src/slic3r/GUI/Widgets/SpinInput.cpp +++ b/src/slic3r/GUI/Widgets/SpinInput.cpp @@ -297,7 +297,7 @@ void SpinInput::Create(wxWindow *parent, text_ctrl->Bind(wxEVT_TEXT, &SpinInput::onText, this); text_ctrl->Bind(wxEVT_TEXT_ENTER, &SpinInput::onTextEnter, this); text_ctrl->Bind(wxEVT_KEY_DOWN, &SpinInput::keyPressed, this); - text_ctrl->Bind(wxEVT_RIGHT_DOWN, [this](auto &e) {}); // disable context menu + text_ctrl->Bind(wxEVT_RIGHT_DOWN, [](auto &e) {}); // disable context menu button_inc = create_button(ButtonId::btnIncrease); button_dec = create_button(ButtonId::btnDecrease); delta = 0; @@ -403,7 +403,7 @@ void SpinInput::onTextEnter(wxCommandEvent &event) void SpinInput::mouseWheelMoved(wxMouseEvent &event) { - auto delta = (event.GetWheelRotation() < 0 == event.IsWheelInverted()) ? 1 : -1; + auto delta = ((event.GetWheelRotation() < 0) == event.IsWheelInverted()) ? 1 : -1; SetValue(val + delta); sendSpinEvent(); text_ctrl->SetFocus(); @@ -473,7 +473,7 @@ void SpinInputDouble::Create(wxWindow *parent, text_ctrl->Bind(wxEVT_TEXT, &SpinInputDouble::onText, this); text_ctrl->Bind(wxEVT_TEXT_ENTER, &SpinInputDouble::onTextEnter, this); text_ctrl->Bind(wxEVT_KEY_DOWN, &SpinInputDouble::keyPressed, this); - text_ctrl->Bind(wxEVT_RIGHT_DOWN, [this](auto &e) {}); // disable context menu + text_ctrl->Bind(wxEVT_RIGHT_DOWN, [](auto &e) {}); // disable context menu button_inc = create_button(ButtonId::btnIncrease); button_dec = create_button(ButtonId::btnDecrease); delta = 0; @@ -600,7 +600,7 @@ void SpinInputDouble::onTextEnter(wxCommandEvent &event) void SpinInputDouble::mouseWheelMoved(wxMouseEvent &event) { - auto delta = (event.GetWheelRotation() < 0 == event.IsWheelInverted()) ? inc : -inc; + auto delta = ((event.GetWheelRotation() < 0) == event.IsWheelInverted()) ? inc : -inc; SetValue(val + delta); sendSpinEvent(); text_ctrl->SetFocus(); diff --git a/src/slic3r/GUI/Widgets/StateColor.cpp b/src/slic3r/GUI/Widgets/StateColor.cpp index a3419b08d3..3809033633 100644 --- a/src/slic3r/GUI/Widgets/StateColor.cpp +++ b/src/slic3r/GUI/Widgets/StateColor.cpp @@ -22,7 +22,7 @@ void StateColor::append(unsigned long color, int states) { if ((color & 0xff000000) == 0) color |= 0xff000000; - wxColour cl; cl.SetRGBA(color & 0xff00ff00 | ((color & 0xff) << 16) | ((color >> 16) & 0xff)); + wxColour cl; cl.SetRGBA((color & 0xff00ff00) | ((color & 0xff) << 16) | ((color >> 16) & 0xff)); append(cl, states); } @@ -49,7 +49,7 @@ wxColour StateColor::defaultColor() { wxColour StateColor::colorForStates(int states) { bool focused = takeFocusedAsHovered_ && (states & Focused); - for (int i = 0; i < statesList_.size(); ++i) { + for (size_t i = 0; i < statesList_.size(); ++i) { int s = statesList_[i]; int on = s & 0xffff; int off = s >> 16; @@ -69,18 +69,18 @@ wxColour StateColor::colorForStates(int states) int StateColor::colorIndexForStates(int states) { - for (int i = 0; i < statesList_.size(); ++i) { + for (size_t i = 0; i < statesList_.size(); ++i) { int s = statesList_[i]; int on = s & 0xffff; int off = s >> 16; - if ((on & states) == on && (off & ~states) == off) { return i; } + if ((on & states) == on && (off & ~states) == off) { return int(i); } } return -1; } bool StateColor::setColorForStates(wxColour const &color, int states) { - for (int i = 0; i < statesList_.size(); ++i) { + for (size_t i = 0; i < statesList_.size(); ++i) { if (statesList_[i] == states) { colors_[i] = color; return true; diff --git a/src/slic3r/GUI/Widgets/StateHandler.cpp b/src/slic3r/GUI/Widgets/StateHandler.cpp index 87d14674cc..b99c2dc483 100644 --- a/src/slic3r/GUI/Widgets/StateHandler.cpp +++ b/src/slic3r/GUI/Widgets/StateHandler.cpp @@ -52,7 +52,7 @@ void StateHandler::update_binds() int diff = bind_states ^ bind_states_; State states[] = {Enabled, Checked, Focused, Hovered, Pressed}; wxEventType events[] = {EVT_ENABLE_CHANGED, wxEVT_CHECKBOX, wxEVT_SET_FOCUS, wxEVT_ENTER_WINDOW, wxEVT_LEFT_DOWN}; - wxEventType events2[] = {{0}, {0}, wxEVT_KILL_FOCUS, wxEVT_LEAVE_WINDOW, wxEVT_LEFT_UP}; + wxEventType events2[] = {0, 0, wxEVT_KILL_FOCUS, wxEVT_LEAVE_WINDOW, wxEVT_LEFT_UP}; for (int i = 0; i < 5; ++i) { int s = states[i]; if (diff & s) { @@ -82,7 +82,7 @@ void StateHandler::changed(wxEvent &event) { event.Skip(); wxEventType events[] = {EVT_ENABLE_CHANGED, wxEVT_CHECKBOX, wxEVT_SET_FOCUS, wxEVT_ENTER_WINDOW, wxEVT_LEFT_DOWN}; - wxEventType events2[] = {{0}, {0}, wxEVT_KILL_FOCUS, wxEVT_LEAVE_WINDOW, wxEVT_LEFT_UP}; + wxEventType events2[] = { 0, 0, wxEVT_KILL_FOCUS, wxEVT_LEAVE_WINDOW, wxEVT_LEFT_UP}; int old = states_; // some events are from another window (ex: text_ctrl of TextInput), save state in states2_ to avoid conflicts for (int i = 0; i < 5; ++i) { diff --git a/src/slic3r/GUI/Widgets/TextInput.cpp b/src/slic3r/GUI/Widgets/TextInput.cpp index 959cb8e974..5fea2df008 100644 --- a/src/slic3r/GUI/Widgets/TextInput.cpp +++ b/src/slic3r/GUI/Widgets/TextInput.cpp @@ -78,7 +78,7 @@ void TextInput::Create(wxWindow * parent, e.SetId(GetId()); ProcessEventLocally(e); }); - text_ctrl->Bind(wxEVT_RIGHT_DOWN, [this](auto &e) {}); // disable context menu + text_ctrl->Bind(wxEVT_RIGHT_DOWN, [](auto &e) {}); // disable context menu if (!icon.IsEmpty()) { this->drop_down_icon = ScalableBitmap(this, icon.ToStdString(), 16); @@ -86,12 +86,6 @@ void TextInput::Create(wxWindow * parent, messureSize(); } -void TextInput::SetCornerRadius(double radius) -{ - this->radius = radius; - Refresh(); -} - void TextInput::SetLabel(const wxString& label) { wxWindow::SetLabel(label); diff --git a/src/slic3r/GUI/Widgets/TextInput.hpp b/src/slic3r/GUI/Widgets/TextInput.hpp index 84bdf7126b..d48cfc679b 100644 --- a/src/slic3r/GUI/Widgets/TextInput.hpp +++ b/src/slic3r/GUI/Widgets/TextInput.hpp @@ -37,9 +37,7 @@ public: const wxSize & size = wxDefaultSize, long style = 0); - void SetCornerRadius(double radius); - - void SetLabel(const wxString& label); + void SetLabel(const wxString& label) wxOVERRIDE; void SetIcon(const wxBitmapBundle& icon); @@ -76,8 +74,7 @@ public: protected: virtual void OnEdit() {} - virtual void DoSetSize( - int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO); + void DoSetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO) wxOVERRIDE; void DoSetToolTipText(wxString const &tip) override;