OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::GUI::SpeedDialWebDialog Class Reference

#include </home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/GUI/SpeedDialDialog.hpp>

Inheritance diagram for Slic3r::GUI::SpeedDialWebDialog:
Collaboration diagram for Slic3r::GUI::SpeedDialWebDialog:

Public Member Functions

 SpeedDialWebDialog (wxWindow *parent)
 ~SpeedDialWebDialog () override
void request_show ()
bool create_webview (const std::string &resource_path, const wxString &title, const wxSize &dialog_size=wxSize(820, 660), const wxSize &min_size=wxSize(640, 640))
void load_url (const wxString &url)
bool run_script (const wxString &script)
void call_web_handler (const nlohmann::json &payload, const wxString &handler=wxT("HandleStudio"))
void EndModal (int retCode) override
float scale_factor () const
float prev_scale_factor () const
void set_scale_factor (float v)
void set_prev_scale_factor (float v)
void set_em_unit (int v)
bool force_rescale () const
int em_unit () const
const wxFont & normal_font () const
void enable_force_rescale ()
int ShowModal ()

Static Public Member Functions

static std::string document_start_injector (const std::string &markup, const char *dom_id, const char *position, const std::string &prelude={}, const std::string &on_inject={})
static std::string theme_user_script ()
static std::string element_defaults_user_script ()
static std::string theme_apply_script ()
static std::string localized_strings_script (const nlohmann::json &strings)

Protected Member Functions

wxWebView * browser () const
wxString build_resource_url (const std::string &resource_path) const
bool handle_common_script_command (const nlohmann::json &payload, int close_return_code=wxID_CANCEL)
virtual void on_script_message_parse_error (const wxString &payload, const std::exception &error)
virtual bool append_language_to_url () const
void register_theme_user_scripts ()
virtual void add_user_scripts ()
void apply_theme_live ()
virtual void on_sys_color_changed ()

Private Member Functions

nlohmann::json localized_strings () const override
void on_script_message (const nlohmann::json &payload) override
void handle_web_command (const nlohmann::json &payload)
void resize_to_content (int height)
void run_action (const std::string &id, const std::string &title, const std::string &param="")
void open_wiki (const std::string &id)
void send_actions ()
void search_tabs ()
void apply_rounded_shape ()
void repaint_webview ()
void on_dpi_changed (const wxRect &suggested_rect) override
void on_script_message_event (wxWebViewEvent &event)
void on_webview_recreated (wxCommandEvent &event)
void update_em_unit ()
bool is_new_scale_factor () const
void rescale (const wxRect &suggested_rect)

Private Attributes

bool m_page_ready {false}
int m_corner_radius {7}
wxBitmap m_shape_bmp
bool m_applying_shape {false}
std::shared_ptr< std::atomic< bool > > m_alive = std::make_shared<std::atomic<bool>>(true)
wxWebView * m_browser {nullptr}
float m_scale_factor
int m_em_unit
wxFont m_normal_font
float m_prev_scale_factor
bool m_can_rescale
bool m_force_rescale
int m_new_font_point_size

Detailed Description

Constructor & Destructor Documentation

◆ SpeedDialWebDialog()

Slic3r::GUI::SpeedDialWebDialog::SpeedDialWebDialog ( wxWindow * parent)
explicit
141 : WebViewHostDialog(parent,
142 wxID_ANY,
143 wxEmptyString,
144 wxDefaultPosition,
145 wxDefaultSize,
146 wxBORDER_NONE | wxFRAME_NO_TASKBAR | wxFRAME_FLOAT_ON_PARENT | wxFRAME_SHAPED)
147{
148 SetBackgroundColour(bg_color());
149 Bind(wxEVT_ACTIVATE, [this](wxActivateEvent& event) {
150 // Focus the WebKit widget exactly when the WM makes the popup the active window
151 // (modeless focus is granted asynchronously, so a focus request made right after
152 // Show() is dropped). Also re-corrects focus on every re-open.
153 if (event.GetActive() && IsShown())
155 else if (!event.GetActive() && IsShown())
156 Hide();
157 event.Skip();
158 });
159 if (!create_webview("web/dialog/SpeedDial/index.html", wxEmptyString, wxSize(kPopupWidth, kPopupMaxHeight),
160 wxSize(kPopupWidth, kPopupMinHeight))) {
161 auto* sizer = new wxBoxSizer(wxVERTICAL);
162 sizer->Add(new wxStaticText(this, wxID_ANY, _L("Web view is unavailable.")), wxSizerFlags().Border(wxALL, 20));
163 SetSizer(sizer);
164 SetClientSize(FromDIP(wxSize(kPopupWidth, kPopupMinHeight)));
165 }
166 // WebView2's browser accelerator keys include Ctrl +/-/0 and Ctrl+wheel zoom, which would resize
167 // the page inside the fixed-size popup. No-op on the other backends (wxWidgets 3.3 base virtual).
168 if (wxWebView* wv = browser())
169 wv->EnableBrowserAcceleratorKeys(false);
170 // Re-cut the shape whenever layout changes the client size. wxOSX SetShape resizes the
171 // NSWindow, which fires this synchronously; apply_rounded_shape() guards re-entry.
172 Bind(wxEVT_SIZE, [this](wxSizeEvent& event) {
173 event.Skip();
175 });
177}
#define _L(s)
Definition OBJ.cpp:34
class WXDLLIMPEXP_FWD_CORE wxStaticText
Definition ProgressDialog.hpp:30
bool m_page_ready
Definition SpeedDialDialog.hpp:40
void apply_rounded_shape()
Definition SpeedDialDialog.cpp:312
wxWebView * browser() const
Definition WebViewHostDialog.hpp:75
WebViewHostDialog(wxWindow *parent, wxWindowID id=wxID_ANY, const wxString &title=wxT(""), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxSYSTEM_MENU|wxCAPTION|wxCLOSE_BOX|wxMAXIMIZE_BOX|wxRESIZE_BORDER)
Definition WebViewHostDialog.cpp:161
bool create_webview(const std::string &resource_path, const wxString &title, const wxSize &dialog_size=wxSize(820, 660), const wxSize &min_size=wxSize(640, 640))
Definition WebViewHostDialog.cpp:172
wxColour bg_color()
Definition SpeedDialDialog.cpp:69
void focus_webview(wxWebView *browser, bool page_ready)
Definition SpeedDialDialog.cpp:75

References Slic3r::GUI::WebViewHostDialog::WebViewHostDialog(), _L, apply_rounded_shape(), Slic3r::GUI::WebViewHostDialog::browser(), Slic3r::GUI::WebViewHostDialog::create_webview(), m_page_ready, and wxStaticText.

Here is the call graph for this function:

◆ ~SpeedDialWebDialog()

Slic3r::GUI::SpeedDialWebDialog::~SpeedDialWebDialog ( )
override
179{ m_alive->store(false, std::memory_order_release); }
std::shared_ptr< std::atomic< bool > > m_alive
Definition SpeedDialDialog.hpp:48

References m_alive.

Member Function Documentation

◆ add_user_scripts()

virtual void Slic3r::GUI::WebViewHostDialog::add_user_scripts ( )
inlineprotectedvirtualinherited

Reimplemented in Slic3r::GUI::ColorPickerDialog, and Slic3r::GUI::WebDialog.

95{}

Referenced by register_theme_user_scripts().

Here is the caller graph for this function:

◆ append_language_to_url()

virtual bool Slic3r::GUI::WebViewHostDialog::append_language_to_url ( ) const
inlineprotectedvirtualinherited

Reimplemented in Slic3r::GUI::WebDialog.

84{ return true; }

Referenced by build_resource_url().

Here is the caller graph for this function:

◆ apply_rounded_shape()

void Slic3r::GUI::SpeedDialWebDialog::apply_rounded_shape ( )
private
313{
314 // wxOSX SetShape resizes the NSWindow (setContentSize 10x10 then back), which synchronously
315 // fires wxEVT_SIZE -> apply_rounded_shape() -> SetShape() and recurses until the stack
316 // overflows. GTK/MSW set a region without resizing, so they are unaffected.
318 return;
319
320 // BORDER_NONE means the window is all client area, so the client size is the shape size.
321 const wxSize size = GetClientSize();
322 if (size.GetWidth() <= 0 || size.GetHeight() <= 0)
323 return;
324
325 m_applying_shape = true;
326
327#ifdef __WXOSX__
328 // wxOSX ignores the region (it only clears the window background), so round the native view.
330#else
331 m_shape_bmp.Create(size.GetWidth(), size.GetHeight(), 32);
332 if (m_shape_bmp.IsOk()) {
333 wxMemoryDC dc;
334 dc.SelectObject(m_shape_bmp);
335 dc.SetBackground(wxBrush(wxColour(0, 0, 0)));
336 dc.Clear();
337 dc.SetBrush(wxBrush(wxColour(255, 255, 255, 255)));
338 dc.SetPen(*wxTRANSPARENT_PEN);
339 dc.DrawRoundedRectangle(0, 0, size.GetWidth(), size.GetHeight(), FromDIP(m_corner_radius));
340 dc.SelectObject(wxNullBitmap);
341
342 wxRegion region(m_shape_bmp, wxColour(0, 0, 0));
343 if (region.IsOk())
344 SetShape(region);
345 }
346#endif
347
348 m_applying_shape = false;
349}
int m_corner_radius
Definition SpeedDialDialog.hpp:42
bool m_applying_shape
Definition SpeedDialDialog.hpp:45
wxBitmap m_shape_bmp
Definition SpeedDialDialog.hpp:43
void set_window_corner_radius(wxWindow *win, int radius)
Definition GUI_UtilsMac.mm:27

References m_applying_shape, m_corner_radius, m_shape_bmp, and Slic3r::GUI::set_window_corner_radius().

Referenced by SpeedDialWebDialog(), on_dpi_changed(), request_show(), and resize_to_content().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ apply_theme_live()

void Slic3r::GUI::WebViewHostDialog::apply_theme_live ( )
protectedinherited
300{
301 if (!m_browser)
302 return;
303 // Update the already-loaded document in place (no reload, no flash) by rewriting the
304 // injected :root variables + data-orca-theme; the whole cascade re-flows from these.
305 // The document-start script keeps the creation-time theme for any later reload, and
306 // these dialogs are not reloaded on a theme toggle (see WebView::RecreateAll).
307 run_script(wxString::FromUTF8(host_theme_apply_js()));
308}
bool run_script(const wxString &script)
Definition WebViewHostDialog.cpp:234
wxWebView * m_browser
Definition WebViewHostDialog.hpp:109
std::string host_theme_apply_js()
Definition WebViewHostDialog.cpp:73

References m_browser, and run_script().

Referenced by on_webview_recreated().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ browser()

◆ build_resource_url()

wxString Slic3r::GUI::WebViewHostDialog::build_resource_url ( const std::string & resource_path) const
protectedinherited
210{
211 wxString target_url = file_url_from_path(boost::filesystem::path(resources_dir()) / resource_path);
212
214 const wxString lang = wxGetApp().current_language_code_safe();
215 if (!lang.empty()) {
216 target_url += wxT("?lang=");
217 target_url += lang;
218 }
219 }
220
221 return target_url;
222}
virtual bool append_language_to_url() const
Definition WebViewHostDialog.hpp:84
wxString file_url_from_path(const boost::filesystem::path &path)
Definition GUI.cpp:569
const std::string & resources_dir()
Definition utils.cpp:296

References append_language_to_url(), Slic3r::GUI::file_url_from_path(), and Slic3r::resources_dir().

Referenced by create_webview().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ call_web_handler()

void Slic3r::GUI::WebViewHostDialog::call_web_handler ( const nlohmann::json & payload,
const wxString & handler = wxT("HandleStudio") )
inherited
243{
244 const wxString payload_text = wxString::FromUTF8(payload.dump(-1, ' ', false, nlohmann::json::error_handler_t::ignore));
245 const wxString script = handler + wxT("(") + payload_text + wxT(")");
246
247 wxGetApp().CallAfter([this, script] { run_script(script); });
248}

References run_script().

Referenced by Slic3r::GUI::SpeedDialWebDialog::handle_web_command(), Slic3r::GUI::PresetBundleDialog::ListBundles(), Slic3r::GUI::ExportPresetBundleDialog::OnRequestPresets(), Slic3r::GUI::WebDialog::push_message(), Slic3r::GUI::TerminalDialog::resolve_and_run(), Slic3r::GUI::PluginsDialog::restore_capability_config(), Slic3r::GUI::PluginsDialog::save_capability_config(), Slic3r::GUI::SpeedDialWebDialog::search_tabs(), Slic3r::GUI::SpeedDialWebDialog::send_actions(), Slic3r::GUI::PluginsConfigDialog::send_capabilities(), Slic3r::GUI::PluginsConfigDialog::send_capability_config(), Slic3r::GUI::PluginsDialog::send_capability_config(), Slic3r::GUI::PluginsDialog::send_plugins(), Slic3r::GUI::PluginsConfigDialog::send_save_error(), Slic3r::GUI::PluginsConfigDialog::show_status(), and Slic3r::GUI::PluginsDialog::show_status().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ create_webview()

bool Slic3r::GUI::WebViewHostDialog::create_webview ( const std::string & resource_path,
const wxString & title,
const wxSize & dialog_size = wxSize(820, 660),
const wxSize & min_size = wxSize(640, 640) )
inherited
176{
177 SetTitle(title);
178 SetMinSize(FromDIP(min_size));
179
180 const wxString target_url = build_resource_url(resource_path);
181 wxBoxSizer* topsizer = new wxBoxSizer(wxVERTICAL);
182
183 // Created empty and loaded below, after the user scripts are added, so the first load already has them.
184 m_browser = WebView::CreateWebView(this, wxEmptyString);
185 if (m_browser == nullptr) {
186 wxLogError("Could not init m_browser");
187 delete topsizer;
188 return false;
189 }
190
191 SetSizer(topsizer);
192 topsizer->Add(m_browser, wxSizerFlags().Expand().Proportion(1));
193
194 SetSize(FromDIP(dialog_size));
195 CenterOnParent();
196
197 Bind(wxEVT_WEBVIEW_SCRIPT_MESSAGE_RECEIVED, &WebViewHostDialog::on_script_message_event, this, m_browser->GetId());
198
199 // Inject the shared host theme contract BEFORE the first load so the page paints in
200 // the app theme with no flash, and re-theme live when the app theme toggles.
202 m_browser->Bind(EVT_WEBVIEW_RECREATED, &WebViewHostDialog::on_webview_recreated, this);
203
204 load_url(target_url);
205 wxGetApp().UpdateDlgDarkUI(this);
206 return true;
207}
void on_webview_recreated(wxCommandEvent &event)
Definition WebViewHostDialog.cpp:310
wxString build_resource_url(const std::string &resource_path) const
Definition WebViewHostDialog.cpp:209
void register_theme_user_scripts()
Definition WebViewHostDialog.cpp:285
void on_script_message_event(wxWebViewEvent &event)
Definition WebViewHostDialog.cpp:274
void load_url(const wxString &url)
Definition WebViewHostDialog.cpp:224
static wxWebView * CreateWebView(wxWindow *parent, wxString const &url)
Definition WebView.cpp:313

References build_resource_url(), WebView::CreateWebView(), load_url(), m_browser, on_script_message_event(), on_webview_recreated(), and register_theme_user_scripts().

Referenced by Slic3r::GUI::ColorPickerDialog::ColorPickerDialog(), Slic3r::GUI::PluginsConfigDialog::PluginsConfigDialog(), Slic3r::GUI::PluginsDialog::PluginsDialog(), Slic3r::GUI::SpeedDialWebDialog::SpeedDialWebDialog(), Slic3r::GUI::TerminalDialog::TerminalDialog(), Slic3r::GUI::WebDialog::WebDialog(), Slic3r::GUI::PresetBundleDialog::create(), and Slic3r::GUI::ExportPresetBundleDialog::Init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ document_start_injector()

std::string Slic3r::GUI::WebViewHostDialog::document_start_injector ( const std::string & markup,
const char * dom_id,
const char * position,
const std::string & prelude = {},
const std::string & on_inject = {} )
staticinherited
135{
136 const std::string literal = nlohmann::json(markup).dump();
137 std::string s;
138 s += "(function(){";
139 // wxWebView's AddUserScript runs in child frames too (including cross-origin
140 // frames on WebView2). Host theme state belongs only to the top-level page.
141 s += "if(window.top!==window.self)return;";
142 s += prelude;
143 s += "var css=" + literal + ";";
144 s += "function inject(){";
145 s += "var root=document.head||document.documentElement;if(!root)return false;";
146 s += "if(!document.getElementById('" + std::string(dom_id) + "'))root.insertAdjacentHTML('" +
147 std::string(position) + "',css);";
148 s += on_inject;
149 s += "return true;}";
150 s += "if(inject())return;";
151 s += "var obs=new MutationObserver(function(){if(inject())obs.disconnect();});";
152 s += "obs.observe(document,{childList:true});})();";
153 return s;
154}

Referenced by element_defaults_user_script(), and theme_user_script().

Here is the caller graph for this function:

◆ element_defaults_user_script()

std::string Slic3r::GUI::WebViewHostDialog::element_defaults_user_script ( )
staticinherited
103{
104 std::string css;
105 css += "<style id=\"orca-plugin-defaults\">";
106 css += "html,body{background:var(--orca-bg);color:var(--orca-fg);"
107 "font-family:var(--orca-font);font-size:13px;}";
108 css += "body{margin:0;}";
109 css += "h1,h2,h3,h4,h5,h6{color:var(--orca-fg);font-weight:600;}";
110 css += "a{color:var(--orca-accent);}";
111 css += "hr{border:0;border-top:1px solid var(--orca-border);}";
112 css += "button{font:inherit;color:var(--orca-accent-fg);background:var(--orca-accent);"
113 "border:1px solid var(--orca-accent);border-radius:4px;padding:5px 14px;cursor:pointer;}";
114 css += "button:hover{filter:brightness(1.1);}";
115 css += "button:disabled{opacity:.5;cursor:default;}";
116 css += "input,select,textarea{font:inherit;color:var(--orca-fg);"
117 "background:var(--orca-bg);border:1px solid var(--orca-border);"
118 "border-radius:4px;padding:4px 8px;}";
119 css += "input:focus,select:focus,textarea:focus{outline:none;border-color:var(--orca-accent);}";
120 css += "table{border-collapse:collapse;}";
121 css += "th,td{text-align:left;padding:6px 10px;border-bottom:1px solid var(--orca-border);}";
122 css += "th{color:var(--orca-muted);font-weight:600;}";
123 css += "::-webkit-scrollbar{width:12px;height:12px;}";
124 css += "::-webkit-scrollbar-thumb{background:var(--orca-border);border-radius:6px;}";
125 css += "::-webkit-scrollbar-track{background:transparent;}";
126 css += "</style>";
127 return document_start_injector(css, "orca-plugin-defaults", "beforeend");
128}
static std::string document_start_injector(const std::string &markup, const char *dom_id, const char *position, const std::string &prelude={}, const std::string &on_inject={})
Definition WebViewHostDialog.cpp:130

References document_start_injector().

Referenced by Slic3r::GUI::WebPanel::WebPanel(), and Slic3r::GUI::WebDialog::add_user_scripts().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ em_unit()

int Slic3r::GUI::DPIAware< wxDialog >::em_unit ( ) const
inlineinherited
203{ return m_em_unit; }
Definition GUI_Utils.hpp:107

Referenced by Slic3r::GUI::AuxiliaryDialog::AuxiliaryDialog(), Slic3r::GUI::CopyrightsDialog::CopyrightsDialog(), Slic3r::GUI::DesignTextDialog::DesignTextDialog(), Slic3r::GUI::EditGCodeDialog::EditGCodeDialog(), Slic3r::GUI::FileArchiveDialog::FileArchiveDialog(), Slic3r::GUI::MsgNoUpdates::MsgNoUpdates(), Slic3r::GUI::MsgUpdateForced::MsgUpdateForced(), Slic3r::GUI::OAuthDialog::OAuthDialog(), Slic3r::GUI::ParamsDialog::ParamsDialog(), Slic3r::GUI::PhysicalPrinterDialog::PhysicalPrinterDialog(), Slic3r::GUI::SettingsDialog::SettingsDialog(), anonymous_namespace{3DPrinterOS.cpp}::TokenAuthDialog::TokenAuthDialog(), anonymous_namespace{3DPrinterOS.cpp}::UploadOptionsDialog::UploadOptionsDialog(), Slic3r::GUI::PublishSettingsDialog::add_row_ui(), Slic3r::GUI::DiffPresetDialog::complete_dialog_creation(), Slic3r::GUI::DiffPresetDialog::create_edit_sizer(), Slic3r::GUI::DiffPresetDialog::create_presets_sizer(), Slic3r::GUI::DiffPresetDialog::create_tree(), Slic3r::GUI::ElegooPrintHostSendDialog::init(), Slic3r::GUI::FlashforgePrintHostSendDialog::init(), Slic3r::GUI::PrintHostSendDialog::init(), Slic3r::GUI::AboutDialog::on_dpi_changed(), Slic3r::GUI::AuxiliaryDialog::on_dpi_changed(), Slic3r::GUI::BedShapeDialog::on_dpi_changed(), Slic3r::GUI::ConfigWizard::on_dpi_changed(), Slic3r::GUI::CopyrightsDialog::on_dpi_changed(), Slic3r::GUI::DiffPresetDialog::on_dpi_changed(), Slic3r::GUI::EditGCodeDialog::on_dpi_changed(), Slic3r::GUI::FileArchiveDialog::on_dpi_changed(), Slic3r::GUI::OAuthDialog::on_dpi_changed(), Slic3r::GUI::ObjectTableDialog::on_dpi_changed(), Slic3r::GUI::ParamsDialog::on_dpi_changed(), Slic3r::GUI::PhysicalPrinterDialog::on_dpi_changed(), Slic3r::GUI::PrintHostQueueDialog::on_dpi_changed(), Slic3r::GUI::PurgeModeDialog::on_dpi_changed(), Slic3r::GUI::SavePresetDialog::on_dpi_changed(), Slic3r::GUI::SendSystemInfoDialog::on_dpi_changed(), Slic3r::GUI::SettingsDialog::on_dpi_changed(), and Slic3r::GUI::UnsavedChangesDialog::on_dpi_changed().

Here is the caller graph for this function:

◆ enable_force_rescale()

void Slic3r::GUI::DPIAware< wxDialog >::enable_force_rescale ( )
inlineinherited
206{ m_force_rescale = true; }

◆ EndModal()

void Slic3r::GUI::DPIDialog::EndModal ( int retCode)
inlineoverrideinherited
306 {
307 if (!dialogStack.empty() && dialogStack.front() != this) {
308 // This is a bug in wxWidgets
309 // when the dialog is not top modal dialog, EndModal() just hide dialog without quit
310 // the modal event loop. And the modal event loop blocks us from bottom widgets.
311 // Solution: let user click it manually or close outside. FIXME
312 BOOST_LOG_TRIVIAL(warning) << "DPIAware::EndModal Error: dialogStack is not empty, but top dialog is not this one. retCode=" << retCode;
313 return;
314 }
315
316 return wxDialog::EndModal(retCode);
317 }
std::deque< wxDialog * > dialogStack
Definition GUI_Utils.cpp:549

References Slic3r::GUI::dialogStack.

Referenced by Slic3r::GUI::CloneDialog::CloneDialog(), Slic3r::GUI::ConfigWizard::ConfigWizard(), Slic3r::GUI::CreatePresetSuccessfulDialog::CreatePresetSuccessfulDialog(), Slic3r::GUI::DeleteConfirmDialog::DeleteConfirmDialog(), Slic3r::GUI::DesignVariableDialog::DesignVariableDialog(), Slic3r::GUI::anonymous_namespace{PrintHostDialogs.cpp}::FlashforgeSlotDialog::FlashforgeSlotDialog(), Slic3r::GUI::GuideFrame::GuideFrame(), Slic3r::GUI::InputIpAddressDialog::InputIpAddressDialog(), Slic3r::GUI::ManualNozzleCountDialog::ManualNozzleCountDialog(), Slic3r::GUI::MsgUpdateConfig::MsgUpdateConfig(), Slic3r::GUI::MsgUpdateForced::MsgUpdateForced(), Slic3r::GUI::MultiChoiceDialog::MultiChoiceDialog(), Slic3r::GUI::NetworkErrorDialog::NetworkErrorDialog(), Slic3r::GUI::NetworkPluginRestartDialog::NetworkPluginRestartDialog(), Slic3r::GUI::PartSkipConfirmDialog::PartSkipConfirmDialog(), Slic3r::GUI::PhysicalPrinterDialog::PhysicalPrinterDialog(), Slic3r::GUI::PlateNameEditDialog::PlateNameEditDialog(), Slic3r::GUI::PlateSettingsDialog::PlateSettingsDialog(), Slic3r::GUI::PublishSettingsDialog::PublishSettingsDialog(), Slic3r::GUI::SelectMachineDialog::SelectMachineDialog(), Slic3r::GUI::SendFailedConfirm::SendFailedConfirm(), Slic3r::GUI::SendSystemInfoDialog::SendSystemInfoDialog(), Slic3r::GUI::ShortcutCaptureDialog::ShortcutCaptureDialog(), Slic3r::GUI::SingleChoiceDialog::SingleChoiceDialog(), StepMeshDialog::StepMeshDialog(), Slic3r::GUI::SyncAmsInfoDialog::SyncAmsInfoDialog(), anonymous_namespace{3DPrinterOS.cpp}::TokenAuthDialog::TokenAuthDialog(), Slic3r::GUI::UpdatePluginDialog::UpdatePluginDialog(), Slic3r::GUI::UpdateVersionDialog::UpdateVersionDialog(), Slic3r::GUI::wgtDeviceNozzleRackUpgradeDlg::wgtDeviceNozzleRackUpgradeDlg(), Slic3r::GUI::SavePresetDialog::accept(), Slic3r::GUI::MsgDialog::add_button(), Slic3r::GUI::TipsDialog::add_button(), Slic3r::GUI::FilamentPickerDialog::BindEvents(), Slic3r::GUI::PluginPickerDialog::build_capability_ui(), Slic3r::GUI::BedShapeDialog::build_dialog(), Slic3r::GUI::PluginPickerDialog::build_ui(), Slic3r::GUI::UnsavedChangesDialog::close(), Slic3r::GUI::FileArchiveDialog::create_btn_sizer(), Slic3r::GUI::ColorDecomposeDialog::create_button_panel(), Slic3r::GUI::MixedFilamentDialog::create_button_panel(), Slic3r::GUI::CreateFilamentPresetDialog::create_dialog_buttons(), Slic3r::GUI::CreatePresetForPrinterDialog::create_dialog_buttons(), Slic3r::GUI::EditFilamentPresetDialog::create_dialog_buttons(), Slic3r::GUI::ExportConfigsDialog::create_dialog_buttons(), Slic3r::GUI::PreferencesDialog::create_item_language_combobox(), Slic3r::GUI::PreferencesDialog::create_item_region_combobox(), Slic3r::GUI::PreferencesDialog::create_items(), Slic3r::GUI::CreatePrinterPresetDialog::create_page1_dialog_buttons(), Slic3r::GUI::CreatePrinterPresetDialog::create_page2_dialog_buttons(), Slic3r::GUI::ExportConfigsDialog::data_init(), Slic3r::GUI::WebDialog::destroy_silently(), Slic3r::GUI::EditFilamentPresetDialog::edit_preset(), Slic3r::GUI::ConnectPrinterDialog::end_modal(), Slic3r::GUI::PrintHostSendDialog::EndModal(), Slic3r::GUI::ColorPickerDialog::finish(), Slic3r::GUI::WebDialog::finish(), Slic3r::GUI::Newer3mfVersionDialog::get_btn_sizer(), Slic3r::GUI::ScoreDialog::get_button_sizer(), Slic3r::GUI::WebViewHostDialog::handle_common_script_command(), Slic3r::GUI::ExportPresetBundleDialog::InitExportData(), Slic3r::GUI::SelectMachineDialog::navigate_to_timelapse_page(), Slic3r::GUI::BindMachineDialog::on_bind_success(), Slic3r::GUI::ConnectPrinterDialog::on_button_confirm(), Slic3r::GUI::RecenterDialog::on_button_confirm(), Slic3r::GUI::BindMachineDialog::on_cancel(), Slic3r::GUI::EditCalibrationHistoryDialog::on_cancel(), Slic3r::GUI::InputIpAddressDialog::on_cancel(), Slic3r::GUI::NewCalibrationHistoryDialog::on_cancel(), Slic3r::GUI::OAuthDialog::on_cancel(), Slic3r::GUI::PingCodeBindDialog::on_cancel(), Slic3r::GUI::SelectMachineDialog::on_cancel(), Slic3r::GUI::SendToPrinterDialog::on_cancel(), Slic3r::GUI::SyncAmsInfoDialog::on_cancel(), Slic3r::GUI::UnBindMachineDialog::on_cancel(), Slic3r::GUI::WebDialog::on_close_window(), Slic3r::GUI::NetworkPluginDownloadDialog::on_dont_ask(), Slic3r::GUI::NetworkPluginDownloadDialog::on_download(), Slic3r::GUI::EditDevNameDialog::on_edit_name(), Slic3r::GUI::ConfirmBeforeSendDialog::on_hide(), Slic3r::GUI::PrivacyUpdateDialog::on_hide(), Slic3r::GUI::ShortcutCaptureDialog::on_key(), Slic3r::GUI::TextureImportDialog::on_ok_clicked(), Slic3r::GUI::FileArchiveDialog::on_open_button(), Slic3r::GUI::NetworkPluginDownloadDialog::on_remind_later(), Slic3r::GUI::ProjectDropDialog::on_select_cancel(), Slic3r::GUI::SavePresetDialog::on_select_cancel(), Slic3r::GUI::ProjectDropDialog::on_select_ok(), Slic3r::GUI::SendMultiMachinePage::on_send(), Slic3r::GUI::NetworkPluginDownloadDialog::on_skip(), Slic3r::GUI::TextureImportDialog::on_skip_clicked(), Slic3r::GUI::NetworkPluginDownloadDialog::on_skip_version(), Slic3r::GUI::Cornering_Test_Dlg::on_start(), Slic3r::GUI::FlowRateCalibrationDialog::on_start(), Slic3r::GUI::Input_Shaping_Damp_Test_Dlg::on_start(), Slic3r::GUI::Input_Shaping_Freq_Test_Dlg::on_start(), Slic3r::GUI::MaxVolumetricSpeed_Test_Dlg::on_start(), Slic3r::GUI::PA_Calibration_Dlg::on_start(), Slic3r::GUI::Retraction_Test_Dlg::on_start(), Slic3r::GUI::Temp_Calibration_Dlg::on_start(), Slic3r::GUI::VFA_Test_Dlg::on_start(), Slic3r::GUI::CalibrationDialog::on_start_calibration(), Slic3r::GUI::UnBindMachineDialog::on_unbind_printer(), Slic3r::GUI::PartSkipDialog::OnApplyDialog(), anonymous_namespace{3DPrinterOS.cpp}::TokenAuthDialog::OnCancel(), Slic3r::GUI::AboutDialog::onCloseDialog(), Slic3r::GUI::CopyrightsDialog::onCloseDialog(), Slic3r::GUI::MultiNozzleSyncDialog::OnRackStatusReadingFinished(), Slic3r::GUI::GuideFrame::OnScriptMessage(), Slic3r::GUI::InputIpAddressDialog::OnTimer(), Slic3r::GUI::KBShortcutsDialog::open_mouse_preferences(), Slic3r::GUI::TroubleshootDialog::PackAll(), Slic3r::GUI::TroubleshootDialog::RebuildSystemProfiles(), Slic3r::GUI::SpeedDialWebDialog::run_action(), Slic3r::GUI::OAuthDialog::Show(), Slic3r::GUI::MultiNozzleSyncDialog::UpdateButton(), and Slic3r::GUI::CreatePrinterPresetDialog::validate_input_valid().

◆ force_rescale()

bool Slic3r::GUI::DPIAware< wxDialog >::force_rescale ( ) const
inlineinherited
201{ return m_force_rescale; }

◆ handle_common_script_command()

bool Slic3r::GUI::WebViewHostDialog::handle_common_script_command ( const nlohmann::json & payload,
int close_return_code = wxID_CANCEL )
protectedinherited
251{
252 const std::string command = payload.value("command", "");
253 if (command == "close_page") {
254 if (IsModal())
255 EndModal(close_return_code);
256 else
257 Close();
258 return true;
259 }
260
261 return false;
262}
void EndModal(int retCode) override
Definition GUI_Utils.hpp:305

References Slic3r::GUI::DPIDialog::EndModal().

Referenced by Slic3r::GUI::ExportPresetBundleDialog::on_script_message(), Slic3r::GUI::PluginsConfigDialog::on_script_message(), Slic3r::GUI::PluginsDialog::on_script_message(), Slic3r::GUI::PresetBundleDialog::on_script_message(), Slic3r::GUI::SpeedDialWebDialog::on_script_message(), Slic3r::GUI::TerminalDialog::on_script_message(), and Slic3r::GUI::WebDialog::on_script_message().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ handle_web_command()

void Slic3r::GUI::SpeedDialWebDialog::handle_web_command ( const nlohmann::json & payload)
private
219{
220 const std::string command = payload.value("command", "");
221 if (command == "request_actions") {
222 m_page_ready = true;
223 send_actions();
224 } else if (command == "toggle_favourite") {
225 // set_favourite() refuses once the bar hits kFavLimit; tell the page so it can undo the
226 // pin and show a "favourites are full" hint instead of silently losing the favourite.
227 const std::string fav_id = payload.value("id", "");
228 const bool ok = wxGetApp().action_registry().set_favourite(fav_id, payload.value("fav", false));
229 if (!ok)
230 call_web_handler({{"command", "favourite_full"}, {"limit", (int) ActionRegistry::kFavLimit}, {"id", fav_id}});
231 } else if (command == "reorder_favourites") {
232 std::vector<std::string> ids;
233 if (payload.contains("ids") && payload["ids"].is_array())
234 for (const auto& id : payload["ids"])
235 if (id.is_string())
236 ids.push_back(id.get<std::string>());
237 wxGetApp().action_registry().reorder_favourites(ids);
238 } else if (command == "set_tooltip_expanded")
239 wxGetApp().action_registry().set_tooltip_expanded(payload.value("expanded", true));
240 else if (command == "run_action")
241 run_action(payload.value("id", ""), payload.value("title", ""), payload.value("param", ""));
242 else if (command == "open_wiki")
243 open_wiki(payload.value("id", ""));
244 else if (command == "search_tabs")
245 search_tabs();
246 else if (command == "resize")
247 resize_to_content(json_int_or(payload, "height", 0));
248}
static constexpr size_t kFavLimit
Definition ActionRegistry.hpp:195
void open_wiki(const std::string &id)
Definition SpeedDialDialog.cpp:424
void resize_to_content(int height)
Definition SpeedDialDialog.cpp:262
void send_actions()
Definition SpeedDialDialog.cpp:433
void run_action(const std::string &id, const std::string &title, const std::string &param="")
Definition SpeedDialDialog.cpp:357
void search_tabs()
Definition SpeedDialDialog.cpp:250
void call_web_handler(const nlohmann::json &payload, const wxString &handler=wxT("HandleStudio"))
Definition WebViewHostDialog.cpp:242
int json_int_or(const nlohmann::json &j, const char *key, int fallback)
Definition SpeedDialDialog.cpp:52

References Slic3r::GUI::WebViewHostDialog::call_web_handler(), Slic3r::GUI::ActionRegistry::kFavLimit, m_page_ready, open_wiki(), resize_to_content(), run_action(), search_tabs(), and send_actions().

Referenced by on_script_message().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ is_new_scale_factor()

bool Slic3r::GUI::DPIAware< wxDialog >::is_new_scale_factor ( ) const
inlineprivateinherited
262{ return fabs(m_scale_factor - m_prev_scale_factor) > 0.001; }

◆ load_url()

void Slic3r::GUI::WebViewHostDialog::load_url ( const wxString & url)
inherited
225{
226 if (!m_browser)
227 return;
228
229 BOOST_LOG_TRIVIAL(trace) << __FUNCTION__ << " enter, url=" << into_u8(url);
231 m_browser->SetFocus();
232}
static void LoadUrl(wxWebView *webView, wxString const &url)
Definition WebView.cpp:480
std::string into_u8(const wxString &str)
Definition GUI.cpp:549
void trace(unsigned int level, const char *message)
Definition utils.cpp:247

References Slic3r::GUI::into_u8(), WebView::LoadUrl(), m_browser, and Slic3r::trace().

Referenced by create_webview().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ localized_strings()

nlohmann::json Slic3r::GUI::SpeedDialWebDialog::localized_strings ( ) const
overrideprivatevirtual

Reimplemented from Slic3r::GUI::WebViewHostDialog.

181{ return speed_dial_ui_strings(); }
nlohmann::json speed_dial_ui_strings()
Definition SpeedDialDialog.cpp:93

◆ localized_strings_script()

std::string Slic3r::GUI::WebViewHostDialog::localized_strings_script ( const nlohmann::json & strings)
staticinherited
157{
158 return "window.ORCA_UI_STRINGS = " + strings.dump(-1, ' ', false, nlohmann::json::error_handler_t::ignore) + ";";
159}

Referenced by Slic3r::GUI::GuideFrame::GuideFrame(), WipingDialog::WipingDialog(), Slic3r::GUI::add_page_strings(), Slic3r::GUI::ProjectPanel::create_browser(), Slic3r::GUI::WebViewPanel::create_browser(), and register_theme_user_scripts().

Here is the caller graph for this function:

◆ normal_font()

◆ on_dpi_changed()

void Slic3r::GUI::SpeedDialWebDialog::on_dpi_changed ( const wxRect & suggested_rect)
overrideprivatevirtual

Implements Slic3r::GUI::DPIAware< wxDialog >.

352{
354 Refresh();
355}

References apply_rounded_shape().

Here is the call graph for this function:

◆ on_script_message()

void Slic3r::GUI::SpeedDialWebDialog::on_script_message ( const nlohmann::json & payload)
overrideprivatevirtual

Implements Slic3r::GUI::WebViewHostDialog.

204{
205 if (handle_common_script_command(payload))
206 return;
207
208 // Defer command handling out of the webview script-message callback: GTK and macOS deliver
209 // it synchronously inside the native webview callback, and window work on that stack is the
210 // crash class fixed in b779a7bfed/f2ccbfc8b5 (see PluginsDialog::on_script_message).
211 // run_action puts a modal confirm on that stack, which is the same bug.
212 wxGetApp().CallAfter([this, alive = m_alive, payload]() {
213 if (alive->load(std::memory_order_acquire))
214 handle_web_command(payload);
215 });
216}
void handle_web_command(const nlohmann::json &payload)
Definition SpeedDialDialog.cpp:218
bool handle_common_script_command(const nlohmann::json &payload, int close_return_code=wxID_CANCEL)
Definition WebViewHostDialog.cpp:250

References Slic3r::GUI::WebViewHostDialog::handle_common_script_command(), handle_web_command(), and m_alive.

Here is the call graph for this function:

◆ on_script_message_event()

void Slic3r::GUI::WebViewHostDialog::on_script_message_event ( wxWebViewEvent & event)
privateinherited
275{
276 const wxString payload = event.GetString();
277
278 try {
279 on_script_message(nlohmann::json::parse(payload.utf8_string()));
280 } catch (const std::exception& e) {
282 }
283}
virtual void on_script_message_parse_error(const wxString &payload, const std::exception &error)
Definition WebViewHostDialog.cpp:269
virtual void on_script_message(const nlohmann::json &payload)=0

References on_script_message(), and on_script_message_parse_error().

Referenced by create_webview().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ on_script_message_parse_error()

void Slic3r::GUI::WebViewHostDialog::on_script_message_parse_error ( const wxString & payload,
const std::exception & error )
protectedvirtualinherited
270{
271 BOOST_LOG_TRIVIAL(trace) << __FUNCTION__ << "; payload=" << into_u8(payload) << "; error=" << error.what();
272}

References Slic3r::GUI::into_u8(), and Slic3r::trace().

Referenced by on_script_message_event().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ on_sys_color_changed()

◆ on_webview_recreated()

void Slic3r::GUI::WebViewHostDialog::on_webview_recreated ( wxCommandEvent & event)
privateinherited
311{
312 // Handled: do NOT Skip(), so WebView::RecreateAll skips the redundant reload.
314}
void apply_theme_live()
Definition WebViewHostDialog.cpp:299

References apply_theme_live().

Referenced by create_webview().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ open_wiki()

void Slic3r::GUI::SpeedDialWebDialog::open_wiki ( const std::string & id)
private
425{
426 const AppAction* a = wxGetApp().action_registry().by_id(id);
427 if (!a || a->help_url.empty())
428 return;
429 Hide();
430 wxLaunchDefaultBrowser(from_u8(a->help_url));
431}
wxString from_u8(const std::string &str)
Definition GUI.cpp:544

References Slic3r::GUI::from_u8(), and Slic3r::GUI::AppAction::help_url.

Referenced by handle_web_command().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ prev_scale_factor()

float Slic3r::GUI::DPIAware< wxDialog >::prev_scale_factor ( ) const
inlineinherited
196{ return m_prev_scale_factor; }

◆ register_theme_user_scripts()

void Slic3r::GUI::WebViewHostDialog::register_theme_user_scripts ( )
protectedinherited
286{
287 if (!m_browser)
288 return;
289 // Added once, at creation. Deliberately no RemoveAllUserScripts() here: the "wx"
290 // script message handler is registered separately (AddScriptMessageHandler), but on
291 // some backends RemoveAllUserScripts() drops it too, which would break
292 // window.wx.postMessage / HandleStudio. Live re-theme goes through apply_theme_live().
293 m_browser->AddUserScript(wxString::FromUTF8(theme_user_script()));
294 if (const nlohmann::json strings = localized_strings(); !strings.is_null())
295 m_browser->AddUserScript(wxString::FromUTF8(localized_strings_script(strings)));
297}
static std::string theme_user_script()
Definition WebViewHostDialog.cpp:93
static std::string localized_strings_script(const nlohmann::json &strings)
Definition WebViewHostDialog.cpp:156
virtual void add_user_scripts()
Definition WebViewHostDialog.hpp:95
virtual nlohmann::json localized_strings() const
Definition WebViewHostDialog.hpp:99

References add_user_scripts(), localized_strings(), localized_strings_script(), m_browser, and theme_user_script().

Referenced by create_webview().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ repaint_webview()

void Slic3r::GUI::SpeedDialWebDialog::repaint_webview ( )
private
289{
290 wxWebView* wv = browser();
291 if (!wv)
292 return;
293 // Portable invalidate; the platform blocks below reach the widget/layer that actually paints.
294 wv->Refresh();
295#ifdef __WXOSX__
296 if (void* nb = wv->GetNativeBackend())
298 wv->Update();
299#elif defined(__linux__)
300 // WebKitGTK's WebKitWebView owns its own GdkWindow, so invalidating the wxWebView wrapper
301 // (the GtkScrolledWindow) does not redraw it.
302 if (void* nb = wv->GetNativeBackend())
303 gtk_widget_queue_draw((GtkWidget*) nb);
304#else
305 wv->Update();
306#endif
307}
void WKWebView_force_display(void *web)
Definition MacDarkMode.mm:109

References Slic3r::GUI::WebViewHostDialog::browser(), and Slic3r::GUI::WKWebView_force_display().

Referenced by request_show(), and resize_to_content().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ request_show()

void Slic3r::GUI::SpeedDialWebDialog::request_show ( )
184{
185 if (IsShown()) {
186 Raise();
189 return;
190 }
191
192 Show();
193 Raise();
195 if (m_page_ready)
196 send_actions();
197 // Grab focus now and again on wxEVT_ACTIVATE; grabbing directly on the WebKit widget is
198 // what makes typing reach the search field immediately on open.
201}
void repaint_webview()
Definition SpeedDialDialog.cpp:288

References apply_rounded_shape(), Slic3r::GUI::WebViewHostDialog::browser(), m_page_ready, repaint_webview(), and send_actions().

Here is the call graph for this function:

◆ rescale()

void Slic3r::GUI::DPIAware< wxDialog >::rescale ( const wxRect & suggested_rect)
inlineprivateinherited
265 {
266 this->Freeze();
267
268 m_force_rescale = false;
269
270 // set normal application font as a current window font
271 m_normal_font = this->GetFont();
272
274
275 // rescale missed controls sizes and images
277
278 this->Layout();
279 this->Thaw();
280
281 // reset previous scale factor from current scale factor value
283 }
virtual void on_dpi_changed(const wxRect &suggested_rect)=0
void update_em_unit()
Definition GUI_Utils.hpp:249

◆ resize_to_content()

void Slic3r::GUI::SpeedDialWebDialog::resize_to_content ( int height)
private
263{
264 if (height <= 0)
265 return;
266
267 int display_index = wxDisplay::GetFromWindow(this);
268 if (display_index == wxNOT_FOUND)
269 display_index = 0;
270 const int screen_dip = ToDIP(wxDisplay(display_index).GetClientArea().GetHeight());
271 const int max_dip = std::max(kPopupMinHeight, screen_dip * 85 / 100);
272 const int height_dip = std::max(kPopupMinHeight, std::min(height, max_dip));
273 SetClientSize(FromDIP(wxSize(kPopupWidth, height_dip)));
274 Layout();
275#ifdef __WXOSX__
276 // WKWebView can lag the dialog's new client size; force the viewport to match so the page is
277 // never painted (and clipped by the rounded layer) below the footer. Unconditional: on a
278 // re-open the size is often unchanged, and skipping the sync leaves the fresh render unpainted.
279 if (wxWebView* wv = browser())
280 wv->SetSize(GetClientSize());
281#endif
283 // A re-open re-renders at (usually) the same size, so nothing above may generate damage.
284 // Repaint explicitly so the newly rendered list is shown without needing user input.
286}

References apply_rounded_shape(), Slic3r::GUI::WebViewHostDialog::browser(), and repaint_webview().

Referenced by handle_web_command().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ run_action()

void Slic3r::GUI::SpeedDialWebDialog::run_action ( const std::string & id,
const std::string & title,
const std::string & param = "" )
private
358{
359 ActionRegistry& reg = wxGetApp().action_registry();
360 const AppAction* a = reg.by_id(id);
361 if (!a)
362 return;
363
364 // Only plugin actions get the "Run plugin?" confirm. Built-in commands act immediately.
365 const bool ask = a->kind == AppActionKind::Plugin && reg.should_ask(id);
366 const std::string atitle = a->title();
367 const ConfigOptionMode required = a->required_mode;
368
369 // Settings the current mode hides require a switch first. Ask while the dial is still up; a
370 // cancel dismisses both (the dial also auto-hides when the modal takes activation).
371 if (requires_mode_switch(required, wxGetApp().get_mode())) {
372 const wxString setting = title.empty() ? from_u8(atitle) : from_u8(title);
373 if (required == comDevelop) {
374 RichMessageDialog dlg(wxGetApp().mainframe,
375 wxString::Format(_L("\"%s\" is a Developer setting. Enable Developer mode to edit it?"), setting),
376 _L("Developer setting"), wxOK | wxCANCEL);
377 if (dlg.ShowModal() != wxID_OK)
378 return;
379 wxGetApp().enable_developer_mode();
380 } else {
381 RichMessageDialog dlg(wxGetApp().mainframe,
382 wxString::Format(_L("\"%s\" is a %s setting. Switch from %s mode to %s mode to edit it?"), setting,
383 mode_label(required), mode_label(wxGetApp().get_mode()), mode_label(required)),
384 _L("Switch settings mode"), wxOK | wxCANCEL);
385 if (dlg.ShowModal() != wxID_OK)
386 return;
387 wxGetApp().save_mode(required);
388 }
389 }
390
391 if (IsModal())
392 EndModal(wxID_CANCEL);
393 else
394 Hide();
395
396 if (ask) {
397 const wxString label = title.empty() ? from_u8(atitle) : from_u8(title);
398 RichMessageDialog dlg(wxGetApp().mainframe, wxString::Format(_L("Run \"%s\"?"), label), _L("Run plugin"), wxOK | wxCANCEL);
399 dlg.ShowCheckBox(_L("Don't ask again for this action"));
400 if (dlg.ShowModal() != wxID_OK)
401 return;
402 if (dlg.IsCheckBoxChecked())
403 wxGetApp().action_registry().suppress_ask(id);
404 }
405
406 wxGetApp().CallAfter([id, param] {
407 if (wxGetApp().is_closing())
408 return;
409 AppActionRunResult result = wxGetApp().action_registry().run(id, param);
410 if (result.level == AppActionRunResult::Level::Busy)
411 return;
412 if (!result.message.IsEmpty() && wxGetApp().plater())
413 wxGetApp()
414 .plater()
415 ->get_notification_manager()
416 ->push_notification(NotificationType::CustomNotification,
417 result.level == AppActionRunResult::Level::Error ?
420 into_u8(result.message));
421 });
422}
@ RegularNotificationLevel
Definition NotificationManager.hpp:216
@ ErrorNotificationLevel
Definition NotificationManager.hpp:228
wxString mode_label(ConfigOptionMode mode)
Definition SpeedDialDialog.cpp:59
static Plater * plater()
Definition GUI_Factories.cpp:400
@ Plugin
Definition ActionRegistry.hpp:25
@ CustomNotification
Definition NotificationManager.hpp:66
bool requires_mode_switch(ConfigOptionMode setting_mode, ConfigOptionMode current_mode)
Definition ActionRegistry.hpp:140
ConfigOptionMode
Definition Config.hpp:221
@ comDevelop
Definition Config.hpp:225
@ Error
Definition ActionRegistry.hpp:31
@ Busy
Definition ActionRegistry.hpp:31

References _L, Slic3r::GUI::AppActionRunResult::Busy, Slic3r::GUI::ActionRegistry::by_id(), Slic3r::comDevelop, Slic3r::GUI::CustomNotification, Slic3r::GUI::DPIDialog::EndModal(), Slic3r::GUI::AppActionRunResult::Error, Slic3r::GUI::NotificationManager::ErrorNotificationLevel, Slic3r::GUI::from_u8(), Slic3r::GUI::into_u8(), Slic3r::GUI::RichMessageDialog::IsCheckBoxChecked(), Slic3r::GUI::AppAction::kind, Slic3r::GUI::AppActionRunResult::level, Slic3r::GUI::AppActionRunResult::message, Slic3r::GUI::plater(), Slic3r::GUI::Plugin, Slic3r::GUI::NotificationManager::RegularNotificationLevel, Slic3r::GUI::AppAction::required_mode, Slic3r::GUI::requires_mode_switch(), Slic3r::GUI::ActionRegistry::should_ask(), Slic3r::GUI::RichMessageDialog::ShowCheckBox(), Slic3r::GUI::RichMessageDialog::ShowModal(), and Slic3r::GUI::AppAction::title().

Referenced by handle_web_command().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ run_script()

bool Slic3r::GUI::WebViewHostDialog::run_script ( const wxString & script)
inherited
235{
236 if (!m_browser)
237 return false;
238
239 return WebView::RunScript(m_browser, script);
240}
static bool RunScript(wxWebView *webView, wxString const &msg)
Definition WebView.cpp:491

References m_browser, and WebView::RunScript().

Referenced by apply_theme_live(), call_web_handler(), Slic3r::GUI::ColorPickerDialog::focus_webview(), Slic3r::GUI::ColorPickerDialog::handle_web_command(), and Slic3r::GUI::ColorPickerDialog::send_initial_state().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ scale_factor()

float Slic3r::GUI::DPIAware< wxDialog >::scale_factor ( ) const
inlineinherited
195{ return m_scale_factor; }

◆ search_tabs()

void Slic3r::GUI::SpeedDialWebDialog::search_tabs ( )
private
251{
252 // Round-trip is async because the webview delivers script messages synchronously on the
253 // GTK/macOS stack; defer the (cheap) enumeration and push the result back to the page.
254 wxGetApp().CallAfter([this, alive = m_alive]() {
255 if (!alive->load(std::memory_order_acquire))
256 return;
257 auto tabs = wxGetApp().action_registry().tab_options();
258 call_web_handler({{"command", "tab_results"}, {"tabs", std::move(tabs)}});
259 });
260}

References Slic3r::GUI::WebViewHostDialog::call_web_handler(), and m_alive.

Referenced by handle_web_command().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ send_actions()

void Slic3r::GUI::SpeedDialWebDialog::send_actions ( )
private
434{
435 nlohmann::json snap = wxGetApp().action_registry().snapshot();
436 call_web_handler({{"command", "list_actions"},
437 {"actions", std::move(snap["actions"])},
438 {"favourites", std::move(snap["favourites"])},
439 {"recent", std::move(snap["recent"])},
440 {"user_mode", std::move(snap["user_mode"])},
441 {"tooltip_expanded", std::move(snap["tooltip_expanded"])}});
442}

References Slic3r::GUI::WebViewHostDialog::call_web_handler().

Referenced by handle_web_command(), and request_show().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_em_unit()

void Slic3r::GUI::DPIAware< wxDialog >::set_em_unit ( int v)
inlineinherited
200{ m_em_unit = v; }

◆ set_prev_scale_factor()

void Slic3r::GUI::DPIAware< wxDialog >::set_prev_scale_factor ( float v)
inlineinherited

◆ set_scale_factor()

void Slic3r::GUI::DPIAware< wxDialog >::set_scale_factor ( float v)
inlineinherited
198{ m_scale_factor = v; }

◆ ShowModal()

◆ theme_apply_script()

std::string Slic3r::GUI::WebViewHostDialog::theme_apply_script ( )
staticinherited
88{ return host_theme_apply_js(); }

Referenced by Slic3r::GUI::WebPanel::apply_theme().

Here is the caller graph for this function:

◆ theme_user_script()

std::string Slic3r::GUI::WebViewHostDialog::theme_user_script ( )
staticinherited
94{
95 const std::string style = "<style id=\"orca-host-theme-vars\">" + host_theme_vars_css() + "</style>";
97 style, "orca-host-theme-vars", "afterbegin",
98 "window.__orcaHostThemed=true;var theme=\"" + host_theme_name() + "\";",
99 "if(document.documentElement)document.documentElement.setAttribute('data-orca-theme',theme);");
100}
#define style
Definition WipeTowerDialog.cpp:101
std::string host_theme_vars_css()
Definition WebViewHostDialog.cpp:40
std::string host_theme_name()
Definition WebViewHostDialog.cpp:35

References document_start_injector(), and style.

Referenced by Slic3r::GUI::WebPanel::WebPanel(), and register_theme_user_scripts().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ update_em_unit()

void Slic3r::GUI::DPIAware< wxDialog >::update_em_unit ( )
inlineprivateinherited
250 {
251 // Linux specific issue : get_dpi_for_window(this) still doesn't responce to the Display's scale in new wxWidgets(3.1.3).
252 // So, calculate the m_em_unit value from the font size, as before
253#if !defined(__WXGTK__)
255#else
256 // initialize default width_unit according to the width of the one symbol ("m") of the currently active font of this window.
257 m_em_unit = std::max<size_t>(10, this->GetTextExtent("m").x - 1);
258#endif // __WXGTK__
259 }

Member Data Documentation

◆ m_alive

std::shared_ptr<std::atomic<bool> > Slic3r::GUI::SpeedDialWebDialog::m_alive = std::make_shared<std::atomic<bool>>(true)
private

◆ m_applying_shape

bool Slic3r::GUI::SpeedDialWebDialog::m_applying_shape {false}
private
45{false};

Referenced by apply_rounded_shape().

◆ m_browser

wxWebView* Slic3r::GUI::WebViewHostDialog::m_browser {nullptr}
privateinherited

◆ m_can_rescale

bool Slic3r::GUI::DPIAware< wxDialog >::m_can_rescale
privateinherited
235{ true };

◆ m_corner_radius

int Slic3r::GUI::SpeedDialWebDialog::m_corner_radius {7}
private
42{7};

Referenced by apply_rounded_shape().

◆ m_em_unit

int Slic3r::GUI::DPIAware< wxDialog >::m_em_unit
privateinherited

◆ m_force_rescale

bool Slic3r::GUI::DPIAware< wxDialog >::m_force_rescale
privateinherited
236{ false };

◆ m_new_font_point_size

int Slic3r::GUI::DPIAware< wxDialog >::m_new_font_point_size
privateinherited

◆ m_normal_font

wxFont Slic3r::GUI::DPIAware< wxDialog >::m_normal_font
privateinherited

◆ m_page_ready

bool Slic3r::GUI::SpeedDialWebDialog::m_page_ready {false}
private
40{false};

Referenced by SpeedDialWebDialog(), handle_web_command(), and request_show().

◆ m_prev_scale_factor

float Slic3r::GUI::DPIAware< wxDialog >::m_prev_scale_factor
privateinherited

◆ m_scale_factor

float Slic3r::GUI::DPIAware< wxDialog >::m_scale_factor
privateinherited

◆ m_shape_bmp

wxBitmap Slic3r::GUI::SpeedDialWebDialog::m_shape_bmp
private

Referenced by apply_rounded_shape().


The documentation for this class was generated from the following files: