mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-09-27 10:51:22 +00:00
Merge main + clean up code + fix missing include
This commit is contained in:
@@ -87,10 +87,18 @@ void ComboBox::SetSelection(int n)
|
||||
return;
|
||||
drop.SetSelection(n);
|
||||
SetLabel(drop.GetValue());
|
||||
if (drop.selection >= 0 && drop.iconSize.y > 0 && items[drop.selection].icon_textctrl.IsOk())
|
||||
SetIcon(items[drop.selection].icon_textctrl);
|
||||
else
|
||||
if (drop.selection >= 0 && drop.iconSize.y > 0 && items[drop.selection].icon_textctrl.IsOk()) {
|
||||
if (m_keep_drop_arrow) {
|
||||
SetIcon("drop_down");
|
||||
SetIcon_1(items[drop.selection].icon_textctrl);
|
||||
} else {
|
||||
SetIcon(items[drop.selection].icon_textctrl);
|
||||
}
|
||||
} else {
|
||||
SetIcon("drop_down");
|
||||
if (m_keep_drop_arrow)
|
||||
SetIcon_1(wxNullBitmap);
|
||||
}
|
||||
|
||||
if (drop.selection >= 0) {
|
||||
SetStaticTips(items[drop.selection].text_static_tips, wxNullBitmap);
|
||||
@@ -120,10 +128,18 @@ void ComboBox::SetValue(const wxString &value)
|
||||
{
|
||||
drop.SetValue(value);
|
||||
SetLabel(value);
|
||||
if (drop.selection >= 0 && drop.iconSize.y > 0 && items[drop.selection].icon_textctrl.IsOk())
|
||||
SetIcon(items[drop.selection].icon_textctrl);
|
||||
else
|
||||
if (drop.selection >= 0 && drop.iconSize.y > 0 && items[drop.selection].icon_textctrl.IsOk()) {
|
||||
if (m_keep_drop_arrow) {
|
||||
SetIcon("drop_down");
|
||||
SetIcon_1(items[drop.selection].icon_textctrl);
|
||||
} else {
|
||||
SetIcon(items[drop.selection].icon_textctrl);
|
||||
}
|
||||
} else {
|
||||
SetIcon("drop_down");
|
||||
if (m_keep_drop_arrow)
|
||||
SetIcon_1(wxNullBitmap);
|
||||
}
|
||||
|
||||
if (drop.selection >= 0) {
|
||||
SetStaticTips(items[drop.selection].text_static_tips, wxNullBitmap);
|
||||
|
||||
@@ -16,6 +16,7 @@ class ComboBox : public wxWindowWithItems<TextInput, wxItemContainer>
|
||||
bool drop_down = false;
|
||||
bool text_off = false;
|
||||
bool is_replace_text_to_image = false;
|
||||
bool m_keep_drop_arrow = false; // When true, item icon goes to icon_1, keeping drop_down arrow
|
||||
wxString replace_text;
|
||||
wxString image_for_text;
|
||||
|
||||
@@ -31,6 +32,11 @@ public:
|
||||
|
||||
DropDown & GetDropDown() { return drop; }
|
||||
|
||||
// When true, item icon is shown as icon_1 (secondary), preserving drop_down arrow.
|
||||
// Note: item bitmaps are set via raw wxBitmap (not ScalableBitmap), so they won't
|
||||
// auto-rescale on DPI change. Caller should recreate items after DPI change.
|
||||
void SetKeepDropArrow(bool keep) { m_keep_drop_arrow = keep; }
|
||||
|
||||
virtual bool SetFont(wxFont const & font) override;
|
||||
|
||||
public:
|
||||
|
||||
@@ -427,7 +427,10 @@ void DropDown::render(wxDC &dc)
|
||||
}
|
||||
pt.y += (rcContent.height - textSize.y) / 2;
|
||||
dc.SetFont(GetFont());
|
||||
dc.SetTextForeground(text_color.colorForStates(states2));
|
||||
// Dimmed items stay selectable, so they only borrow the disabled text tone rather
|
||||
// than taking the disabled state itself.
|
||||
const int text_states = (item.style & DD_ITEM_STYLE_DIMMED) ? (states2 & ~StateColor::Enabled) : states2;
|
||||
dc.SetTextForeground(text_color.colorForStates(text_states));
|
||||
dc.DrawText(text, pt);
|
||||
if (group.IsEmpty() && !item.group_key.IsEmpty()) {
|
||||
auto szBmp = arrow_bitmap.GetBmpSize();
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
|
||||
#define DD_ITEM_STYLE_SPLIT_ITEM 0x0001 // ----text----, text with horizontal line arounds
|
||||
#define DD_ITEM_STYLE_DISABLED 0x0002 // ----text----, text with horizontal line arounds
|
||||
#define DD_ITEM_STYLE_DIMMED 0x0004 // gray text, but still selectable
|
||||
|
||||
wxDECLARE_EVENT(EVT_DISMISS, wxCommandEvent);
|
||||
|
||||
|
||||
@@ -630,7 +630,7 @@ NozzleListTable::NozzleListTable(wxWindow* parent) : wxPanel(parent,wxID_ANY,wxD
|
||||
SetSizer(sizer);
|
||||
Layout();
|
||||
|
||||
m_web_view->Bind(wxEVT_WEBVIEW_SCRIPT_MESSAGE_RECEIVED, [this,sizer](wxWebViewEvent& evt) {
|
||||
m_web_view->Bind(wxEVT_WEBVIEW_SCRIPT_MESSAGE_RECEIVED, [this](wxWebViewEvent& evt) {
|
||||
std::string message = evt.GetString().ToStdString();
|
||||
BOOST_LOG_TRIVIAL(debug) << __FUNCTION__ << "Received message: " << message;
|
||||
try {
|
||||
@@ -1168,8 +1168,8 @@ void MultiNozzleSyncDialog::UpdateButton(std::weak_ptr<DevNozzleRack> rack, bool
|
||||
m_cancel_btn->SetLabel(_L("Ignore"));
|
||||
m_confirm_btn->SetLabel(_L("Refresh"));
|
||||
|
||||
m_cancel_btn->Bind(wxEVT_LEFT_DOWN, [this, rack, ignore_opt](auto& e) {ignore_opt(); });
|
||||
m_confirm_btn->Bind(wxEVT_LEFT_DOWN, [this, rack, refresh_cmd](auto& e) {refresh_cmd(); });
|
||||
m_cancel_btn->Bind(wxEVT_LEFT_DOWN, [rack, ignore_opt](auto& e) {ignore_opt(); });
|
||||
m_confirm_btn->Bind(wxEVT_LEFT_DOWN, [rack, refresh_cmd](auto& e) {refresh_cmd(); });
|
||||
}
|
||||
else if (has_unknown) {
|
||||
m_cancel_btn->Show();
|
||||
@@ -1178,8 +1178,8 @@ void MultiNozzleSyncDialog::UpdateButton(std::weak_ptr<DevNozzleRack> rack, bool
|
||||
m_cancel_btn->SetLabel(_L("Ignore"));
|
||||
m_confirm_btn->SetLabel(_L("Refresh"));
|
||||
|
||||
m_cancel_btn->Bind(wxEVT_LEFT_DOWN, [this, rack, ignore_opt](auto& e) {ignore_opt(); });
|
||||
m_confirm_btn->Bind(wxEVT_LEFT_DOWN, [this, rack, refresh_cmd](auto& e) {refresh_cmd(); });
|
||||
m_cancel_btn->Bind(wxEVT_LEFT_DOWN, [rack, ignore_opt](auto& e) {ignore_opt(); });
|
||||
m_confirm_btn->Bind(wxEVT_LEFT_DOWN, [rack, refresh_cmd](auto& e) {refresh_cmd(); });
|
||||
}
|
||||
else if (has_unreliable) {
|
||||
m_cancel_btn->Show();
|
||||
@@ -1188,8 +1188,8 @@ void MultiNozzleSyncDialog::UpdateButton(std::weak_ptr<DevNozzleRack> rack, bool
|
||||
m_cancel_btn->SetLabel(_L("Refresh"));
|
||||
m_confirm_btn->SetLabel(_L("Confirm"));
|
||||
|
||||
m_cancel_btn->Bind(wxEVT_LEFT_DOWN, [this, rack, refresh_cmd](auto& e) {refresh_cmd(); });
|
||||
m_confirm_btn->Bind(wxEVT_LEFT_DOWN, [this, rack, trust_cmd](auto& e) {trust_cmd(); });
|
||||
m_cancel_btn->Bind(wxEVT_LEFT_DOWN, [rack, refresh_cmd](auto& e) {refresh_cmd(); });
|
||||
m_confirm_btn->Bind(wxEVT_LEFT_DOWN, [rack, trust_cmd](auto& e) {trust_cmd(); });
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -167,7 +167,7 @@ class MultiNozzleSyncDialog : public DPIDialog
|
||||
{
|
||||
public:
|
||||
MultiNozzleSyncDialog(wxWindow* parent, std::weak_ptr<DevNozzleRack> rack);
|
||||
virtual void on_dpi_changed(const wxRect& suggested_rect) {};
|
||||
virtual void on_dpi_changed(const wxRect& suggested_rect) override {};
|
||||
std::vector<NozzleOption> GetNozzleOptions(const std::vector<MultiNozzleUtils::NozzleGroupInfo>& group_infos);
|
||||
|
||||
std::optional<NozzleOption> GetSelectedOption() {
|
||||
|
||||
@@ -56,7 +56,7 @@ protected:
|
||||
void paintEvent(wxPaintEvent &evt);
|
||||
void render(wxDC &dc);
|
||||
void doRender(wxDC &dc);
|
||||
virtual void DoSetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO);
|
||||
virtual void DoSetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO) override;
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ public:
|
||||
void OnPaint(wxPaintEvent &evt);
|
||||
virtual ~ProgressDialog();
|
||||
|
||||
virtual void DoSetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO);
|
||||
virtual void DoSetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO) override;
|
||||
bool Create(const wxString &title, const wxString &message, int maximum = 100, wxWindow *parent = NULL, int style = wxPD_APP_MODAL | wxPD_AUTO_HIDE);
|
||||
|
||||
virtual bool Update(int value, const wxString &newmsg = wxEmptyString, bool *skip = NULL);
|
||||
|
||||
@@ -31,7 +31,7 @@ public:
|
||||
|
||||
void SetLayoutStyle(int style);
|
||||
|
||||
void SetLabel(const wxString& label);
|
||||
void SetLabel(const wxString& label) override;
|
||||
|
||||
bool SetForegroundColour(wxColour const & colour) override;
|
||||
|
||||
@@ -47,7 +47,7 @@ public:
|
||||
|
||||
void SetBackgroundColor(StateColor const &color);
|
||||
|
||||
bool Enable(bool enable = true);
|
||||
bool Enable(bool enable = true) override;
|
||||
|
||||
void Rescale();
|
||||
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
#include "../GUI_Utils.hpp"
|
||||
#endif
|
||||
|
||||
wxDEFINE_EVENT(EVT_SPINCTRL_TEXT, wxCommandEvent);
|
||||
|
||||
BEGIN_EVENT_TABLE(SpinInput, StaticBox)
|
||||
|
||||
EVT_KEY_DOWN(SpinInput::keyPressed)
|
||||
@@ -74,8 +76,9 @@ void SpinInput::Create(wxWindow *parent,
|
||||
state_handler.attach_child(text_ctrl);
|
||||
text_ctrl->Bind(wxEVT_KILL_FOCUS, &SpinInput::onTextLostFocus, this);
|
||||
text_ctrl->Bind(wxEVT_TEXT_ENTER, &SpinInput::onTextEnter, this);
|
||||
text_ctrl->Bind(wxEVT_TEXT, &SpinInput::onTextChanged, 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 = createButton(true);
|
||||
button_dec = createButton(false);
|
||||
delta = 0;
|
||||
@@ -300,6 +303,19 @@ void SpinInput::onTextEnter(wxCommandEvent &event)
|
||||
ProcessEventLocally(event);
|
||||
}
|
||||
|
||||
void SpinInput::onTextChanged(wxCommandEvent &event)
|
||||
{
|
||||
long value;
|
||||
if (text_ctrl->GetValue().ToLong(&value)) {
|
||||
wxCommandEvent e(EVT_SPINCTRL_TEXT, GetId());
|
||||
e.SetEventObject(this);
|
||||
e.SetInt((int) value);
|
||||
e.SetString(text_ctrl->GetValue());
|
||||
GetEventHandler()->ProcessEvent(e);
|
||||
}
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
void SpinInput::mouseWheelMoved(wxMouseEvent &event)
|
||||
{
|
||||
auto delta = event.GetWheelRotation() < 0 ? 1 : -1;
|
||||
|
||||
@@ -9,6 +9,10 @@
|
||||
|
||||
class Button;
|
||||
|
||||
// Fired on every keystroke that leaves a parseable integer in the field, so callers can
|
||||
// react live rather than only on commit (wxEVT_SPINCTRL) or Enter. Ported from BambuStudio.
|
||||
wxDECLARE_EVENT(EVT_SPINCTRL_TEXT, wxCommandEvent);
|
||||
|
||||
class SpinInput : public wxNavigationEnabled<StaticBox>
|
||||
{
|
||||
wxSize labelSize;
|
||||
@@ -98,6 +102,7 @@ private:
|
||||
void keyPressed(wxKeyEvent& event);
|
||||
void onTimer(wxTimerEvent &evnet);
|
||||
void onTextLostFocus(wxEvent &event);
|
||||
void onTextChanged(wxCommandEvent &event);
|
||||
void onTextEnter(wxCommandEvent &event);
|
||||
|
||||
void sendSpinEvent();
|
||||
|
||||
@@ -68,7 +68,7 @@ public:
|
||||
int buttons_best_width() const;
|
||||
|
||||
private:
|
||||
virtual void DoSetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO);
|
||||
virtual void DoSetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO) override;
|
||||
|
||||
#ifdef __WIN32__
|
||||
WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam) override;
|
||||
|
||||
@@ -134,7 +134,7 @@ void TempInput::Create(wxWindow *parent, wxString text, wxString label, wxString
|
||||
}
|
||||
}
|
||||
});
|
||||
text_ctrl->Bind(wxEVT_RIGHT_DOWN, [this](auto &e) {}); // disable context menu
|
||||
text_ctrl->Bind(wxEVT_RIGHT_DOWN, [](auto &e) {}); // disable context menu
|
||||
text_ctrl->Bind(wxEVT_LEFT_DOWN, [this](auto &e) {
|
||||
if (m_read_only) {
|
||||
return;
|
||||
|
||||
@@ -107,7 +107,7 @@ public:
|
||||
wxString GetTagTemp() { return text_ctrl->GetValue(); }
|
||||
wxString GetCurrTemp() { return GetLabel(); }
|
||||
int get_max_temp() { return max_temp; }
|
||||
void SetLabel(const wxString &label);
|
||||
void SetLabel(const wxString &label) override;
|
||||
|
||||
void SetTextColor(StateColor const &color);
|
||||
|
||||
@@ -128,7 +128,7 @@ public:
|
||||
void ReSetOnChanging() { m_on_changing = false; }
|
||||
|
||||
protected:
|
||||
virtual void DoSetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO);
|
||||
virtual void DoSetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO) override;
|
||||
|
||||
void DoSetToolTipText(wxString const &tip) override;
|
||||
|
||||
|
||||
@@ -85,7 +85,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->icon = ScalableBitmap(this, icon.ToStdString(), 16);
|
||||
}
|
||||
@@ -139,6 +139,15 @@ void TextInput::SetIcon_1(const wxString &icon) {
|
||||
Rescale();
|
||||
}
|
||||
|
||||
// Set icon_1 from a raw bitmap. Note: won't auto-rescale on DPI change
|
||||
// since ScalableBitmap::name() will be empty. Caller should re-set after DPI change.
|
||||
void TextInput::SetIcon_1(const wxBitmap &icon) {
|
||||
this->icon_1 = ScalableBitmap();
|
||||
if (icon.IsOk())
|
||||
this->icon_1.bmp() = icon;
|
||||
Rescale();
|
||||
}
|
||||
|
||||
void TextInput::SetLabelColor(StateColor const &color)
|
||||
{
|
||||
label_color = color;
|
||||
|
||||
@@ -46,7 +46,7 @@ public:
|
||||
// Only meant to be used by inspector, not public API
|
||||
int GetCornerRadius() const { return static_cast<int>(radius); }
|
||||
|
||||
void SetLabel(const wxString& label);
|
||||
void SetLabel(const wxString& label) override;
|
||||
|
||||
void SetStaticTips(const wxString& tips, const wxBitmap& bitmap);
|
||||
|
||||
@@ -54,6 +54,7 @@ public:
|
||||
void SetIcon(const wxString & icon);
|
||||
|
||||
void SetIcon_1(const wxString &icon);
|
||||
void SetIcon_1(const wxBitmap &icon);
|
||||
|
||||
void SetLabelColor(StateColor const &color);
|
||||
|
||||
@@ -73,7 +74,7 @@ protected:
|
||||
virtual void OnEdit() {}
|
||||
|
||||
virtual void DoSetSize(
|
||||
int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO);
|
||||
int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO) override;
|
||||
|
||||
void DoSetToolTipText(wxString const &tip) override;
|
||||
|
||||
|
||||
@@ -104,7 +104,7 @@ DWORD DownloadAndInstallWV2RT() {
|
||||
class WebViewEdge : public wxWebViewEdge
|
||||
{
|
||||
public:
|
||||
bool SetUserAgent(const wxString &userAgent)
|
||||
bool SetUserAgent(const wxString &userAgent) override
|
||||
{
|
||||
bool dark = userAgent.Contains("dark");
|
||||
SetColorScheme(dark ? COREWEBVIEW2_PREFERRED_COLOR_SCHEME_DARK : COREWEBVIEW2_PREFERRED_COLOR_SCHEME_LIGHT);
|
||||
|
||||
Reference in New Issue
Block a user