Skip to content

Commit 3356b79

Browse files
author
wangjunxiang
committed
Merge branch 'release_0530' of http://10.33.23.250:9080/orca_soft/orca_flashforge into release_0530
2 parents 199680c + 4737ffb commit 3356b79

8 files changed

Lines changed: 123 additions & 11 deletions

File tree

src/slic3r/GUI/Field.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -965,6 +965,9 @@ void TextCtrl::set_value(const boost::any& value, bool change_event/* = false*/)
965965
text_ctrl()->SetValue(value.empty() ? "" : boost::any_cast<wxString>(value)); // BBS // BBS: null value
966966
m_disable_change_event = false;
967967

968+
if (auto *input = dynamic_cast<::TextInput *>(window))
969+
input->UpdateTextCtrlColours();
970+
968971
if (!change_event) {
969972
wxString ret_str = text_ctrl()->GetValue();
970973
/* Update m_value to correct work of next value_was_changed().
@@ -1301,6 +1304,9 @@ void SpinCtrl::set_value(const boost::any& value, bool change_event) {
13011304
dynamic_cast<SpinInput*>(window)->SetValue(tmp_value);
13021305
}
13031306
m_disable_change_event = false;
1307+
1308+
if (auto *input = dynamic_cast<SpinInput *>(window))
1309+
input->UpdateTextCtrlColours();
13041310
}
13051311

13061312
void SpinCtrl::msw_rescale()

src/slic3r/GUI/Plater.cpp

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10260,12 +10260,30 @@ void Plater::priv::on_select_preset(wxCommandEvent &evt)
1026010260
std::string old_preset_name = wxGetApp().preset_bundle->printers.get_edited_preset().name;
1026110261
wxGetApp().preset_bundle->m_pre_selected_print_name = old_preset_name;
1026210262
wxGetApp().preset_bundle->m_printer_inherit = wxGetApp().app_config->get_bool("inherit_printer");
10263-
update_objects_position_when_select_preset([this, &preset_type, &preset_name]() {
10263+
bool preset_selected = false;
10264+
{
1026410265
wxWindowUpdateLocker noUpdates2(sidebar->filament_panel());
10265-
wxGetApp().get_tab(preset_type)->select_preset(preset_name);
10266-
// update plater with new config
10267-
q->on_config_change(wxGetApp().preset_bundle->full_config());
10268-
});
10266+
preset_selected = wxGetApp().get_tab(preset_type)->select_preset(preset_name);
10267+
if (preset_selected) {
10268+
// update plater with new config
10269+
q->on_config_change(wxGetApp().preset_bundle->full_config());
10270+
}
10271+
}
10272+
10273+
if (!preset_selected) {
10274+
combo->update_from_bundle();
10275+
return;
10276+
}
10277+
10278+
wxGetApp().obj_list()->update_object_list_by_printer_technology();
10279+
10280+
// Re-clamp wipe tower positions to new bed boundaries after preset change
10281+
PartPlateList &cur_plate_list = this->partplate_list;
10282+
for (size_t plate_id = 0; plate_id < cur_plate_list.get_plate_list().size(); ++plate_id) {
10283+
cur_plate_list.set_default_wipe_tower_pos_for_plate(plate_id);
10284+
}
10285+
10286+
update();
1026910287

1027010288

1027110289
if (old_preset_name != preset_name && wxGetApp().app_config->get("auto_calculate_flush") == "all") {

src/slic3r/GUI/Widgets/SpinInput.cpp

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
#include "Label.hpp"
33
#include "Button.hpp"
44
#include "TextCtrl.h"
5+
#ifdef __APPLE__
6+
#include "slic3r/Utils/MacDarkMode.hpp"
7+
#endif
58

69
#include <wx/dcgraph.h>
710

@@ -103,6 +106,28 @@ void SpinInput::SetTextColor(StateColor const &color)
103106
{
104107
text_color = color;
105108
state_handler.update_binds();
109+
UpdateTextCtrlColours();
110+
}
111+
112+
void SpinInput::UpdateTextCtrlColours()
113+
{
114+
if (!text_ctrl)
115+
return;
116+
117+
const int states = state_handler.states();
118+
#ifdef __APPLE__
119+
const wxColour bg = background_color.colorForStatesNoDark(states);
120+
const wxColour fg = text_color.colorForStatesNoDark(states);
121+
#else
122+
const wxColour bg = background_color.colorForStates(states);
123+
const wxColour fg = text_color.colorForStates(states);
124+
#endif
125+
text_ctrl->SetBackgroundColour(bg);
126+
text_ctrl->SetForegroundColour(fg);
127+
#ifdef __APPLE__
128+
Slic3r::GUI::set_textfield_native_colours(text_ctrl->GetHandle(), bg, fg, true);
129+
#endif
130+
text_ctrl->Refresh();
106131
}
107132

108133
void SpinInput::SetSize(wxSize const &size)
@@ -157,8 +182,7 @@ bool SpinInput::Enable(bool enable)
157182
wxCommandEvent e(EVT_ENABLE_CHANGED);
158183
e.SetEventObject(this);
159184
GetEventHandler()->ProcessEvent(e);
160-
text_ctrl->SetBackgroundColour(background_color.colorForStates(state_handler.states()));
161-
text_ctrl->SetForegroundColour(text_color.colorForStates(state_handler.states()));
185+
UpdateTextCtrlColours();
162186
button_inc->Enable(enable);
163187
button_dec->Enable(enable);
164188
}

src/slic3r/GUI/Widgets/SpinInput.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ class SpinInput : public wxNavigationEnabled<StaticBox>
5858

5959
void SetTextColor(StateColor const &color);
6060

61+
void UpdateTextCtrlColours();
62+
6163
void SetSize(wxSize const &size);
6264

6365
void Rescale();

src/slic3r/GUI/Widgets/TextInput.cpp

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
#include "Label.hpp"
33
#include "TextCtrl.h"
44
#include "slic3r/GUI/Widgets/Label.hpp"
5+
#ifdef __APPLE__
6+
#include "slic3r/Utils/MacDarkMode.hpp"
7+
#endif
58

69
#include <wx/dcclient.h>
710
#include <wx/dcgraph.h>
@@ -63,8 +66,7 @@ void TextInput::Create(wxWindow * parent,
6366
text_ctrl = new TextCtrl(this, wxID_ANY, text, {4, 4}, wxDefaultSize, style | wxBORDER_NONE | wxTE_PROCESS_ENTER);
6467
text_ctrl->SetFont(Label::Body_14);
6568
text_ctrl->SetInitialSize(text_ctrl->GetBestSize());
66-
text_ctrl->SetBackgroundColour(background_color.colorForStates(state_handler.states()));
67-
text_ctrl->SetForegroundColour(text_color.colorForStates(state_handler.states()));
69+
UpdateTextCtrlColours();
6870
state_handler.attach_child(text_ctrl);
6971
text_ctrl->Bind(wxEVT_KILL_FOCUS, [this](auto &e) {
7072
OnEdit();
@@ -141,6 +143,28 @@ void TextInput::SetTextColor(StateColor const& color)
141143
{
142144
text_color= color;
143145
state_handler.update_binds();
146+
UpdateTextCtrlColours();
147+
}
148+
149+
void TextInput::UpdateTextCtrlColours()
150+
{
151+
if (!text_ctrl)
152+
return;
153+
154+
const int states = state_handler.states();
155+
#ifdef __APPLE__
156+
const wxColour bg = background_color.colorForStatesNoDark(states);
157+
const wxColour fg = text_color.colorForStatesNoDark(states);
158+
#else
159+
const wxColour bg = background_color.colorForStates(states);
160+
const wxColour fg = text_color.colorForStates(states);
161+
#endif
162+
text_ctrl->SetBackgroundColour(bg);
163+
text_ctrl->SetForegroundColour(fg);
164+
#ifdef __APPLE__
165+
Slic3r::GUI::set_textfield_native_colours(text_ctrl->GetHandle(), bg, fg, true);
166+
#endif
167+
text_ctrl->Refresh();
144168
}
145169

146170
void TextInput::Rescale()
@@ -160,8 +184,7 @@ bool TextInput::Enable(bool enable)
160184
wxCommandEvent e(EVT_ENABLE_CHANGED);
161185
e.SetEventObject(this);
162186
GetEventHandler()->ProcessEvent(e);
163-
text_ctrl->SetBackgroundColour(background_color.colorForStates(state_handler.states()));
164-
text_ctrl->SetForegroundColour(text_color.colorForStates(state_handler.states()));
187+
UpdateTextCtrlColours();
165188
}
166189
return result;
167190
}

src/slic3r/GUI/Widgets/TextInput.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ class TextInput : public wxNavigationEnabled<StaticBox>
5656

5757
void SetTextColor(StateColor const &color);
5858

59+
void UpdateTextCtrlColours();
60+
5961
virtual void Rescale();
6062

6163
virtual bool Enable(bool enable = true) override;

src/slic3r/Utils/MacDarkMode.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#define slic3r_MacDarkMode_hpp_
33

44
#include <wx/event.h>
5+
#include <wx/colour.h>
56

67
namespace Slic3r {
78
namespace GUI {
@@ -12,6 +13,7 @@ extern double mac_max_scaling_factor();
1213
extern void set_miniaturizable(void * window);
1314
void WKWebView_evaluateJavaScript(void * web, wxString const & script, void (*callback)(wxString const &));
1415
void WKWebView_setTransparentBackground(void * web);
16+
void set_textfield_native_colours(void * window, const wxColour& background, const wxColour& foreground, bool draws_background);
1517
void set_tag_when_enter_full_screen(bool isfullscreen);
1618
void set_title_colour_after_set_title(void * window);
1719
void initGestures(void * view, wxEvtHandler * handler);

src/slic3r/Utils/MacDarkMode.mm

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,27 @@ @implementation MacDarkMode
2323
NSTextField* mainframe_text_field = nil;
2424
bool is_in_full_screen_mode = false;
2525

26+
static NSTextField* find_text_field(NSView *view)
27+
{
28+
if (view == nil)
29+
return nil;
30+
if ([view isKindOfClass:[NSTextField class]])
31+
return (NSTextField *) view;
32+
for (NSView *subview in [view subviews]) {
33+
if (NSTextField *field = find_text_field(subview))
34+
return field;
35+
}
36+
return nil;
37+
}
38+
39+
static NSColor* ns_color_from_wx(const wxColour& color)
40+
{
41+
return [NSColor colorWithCalibratedRed:color.Red() / 255.0
42+
green:color.Green() / 255.0
43+
blue:color.Blue() / 255.0
44+
alpha:color.Alpha() / 255.0];
45+
}
46+
2647
bool mac_dark_mode()
2748
{
2849
NSString *style = [[NSUserDefaults standardUserDefaults] stringForKey:@"AppleInterfaceStyle"];
@@ -41,6 +62,20 @@ bool mac_dark_mode()
4162
}
4263
return scaling;
4364
}
65+
66+
void set_textfield_native_colours(void * window, const wxColour& background, const wxColour& foreground, bool draws_background)
67+
{
68+
NSTextField *field = find_text_field((NSView *) window);
69+
if (field == nil)
70+
return;
71+
72+
if (@available(macOS 10.14, *))
73+
field.appearance = [NSAppearance appearanceNamed:NSAppearanceNameAqua];
74+
75+
field.drawsBackground = draws_background ? YES : NO;
76+
field.backgroundColor = ns_color_from_wx(background);
77+
field.textColor = ns_color_from_wx(foreground);
78+
}
4479

4580
void set_miniaturizable(void * window)
4681
{

0 commit comments

Comments
 (0)