OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::GUI::anonymous_namespace{WebViewHostDialog.cpp} Namespace Reference

Functions

std::string css_color (const wxColour &c)
std::string host_theme_name ()
std::string host_theme_vars_css ()
std::string host_theme_apply_js ()

Function Documentation

◆ css_color()

std::string Slic3r::GUI::anonymous_namespace{WebViewHostDialog.cpp}::css_color ( const wxColour & c)
32{ return c.GetAsString(wxC2S_HTML_SYNTAX).ToStdString(); }

References css_color().

Referenced by css_color(), and host_theme_vars_css().

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

◆ host_theme_apply_js()

std::string Slic3r::GUI::anonymous_namespace{WebViewHostDialog.cpp}::host_theme_apply_js ( )
74{
75 const std::string vars_literal = nlohmann::json(host_theme_vars_css()).dump();
76 const std::string theme = host_theme_name();
77 return "(function(){var css=" + vars_literal + ";var theme=\"" + theme + "\";" + R"JS(
78var el=document.getElementById('orca-host-theme-vars');
std::string host_theme_vars_css()
Definition WebViewHostDialog.cpp:40
std::string host_theme_name()
Definition WebViewHostDialog.cpp:35

References host_theme_apply_js(), host_theme_name(), and host_theme_vars_css().

Referenced by host_theme_apply_js().

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

◆ host_theme_name()

std::string Slic3r::GUI::anonymous_namespace{WebViewHostDialog.cpp}::host_theme_name ( )
35{ return wxGetApp().dark_mode() ? "dark" : "light"; }

References host_theme_name().

Referenced by host_theme_apply_js(), host_theme_name(), and host_theme_vars_css().

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

◆ host_theme_vars_css()

std::string Slic3r::GUI::anonymous_namespace{WebViewHostDialog.cpp}::host_theme_vars_css ( )
41{
42 GUI_App& app = wxGetApp();
43 const wxColour bg = app.get_window_default_clr();
44 const wxColour fg = app.get_label_clr_default();
45 const wxColour muted = app.get_label_clr_sys();
46 const wxColour border = app.get_highlight_default_clr();
47 const wxColour accent = StateColor::darkModeColorFor(wxColour("#009688"));
48 std::string font = app.normal_font().GetFaceName().ToStdString();
49 // Strip characters that could break out of the CSS value / <style> block.
50 font.erase(std::remove_if(font.begin(), font.end(), [](char c) {
51 return c == '\'' || c == '"' || c == '<' || c == '>' || c == '{' || c == '}' || c == ';';
52 }),
53 font.end());
54
55 std::string s;
56 s += ":root{";
57 s += "--orca-bg:" + css_color(bg) + ";";
58 s += "--orca-fg:" + css_color(fg) + ";";
59 s += "--orca-muted:" + css_color(muted) + ";";
60 s += "--orca-border:" + css_color(border) + ";";
61 s += "--orca-accent:" + css_color(accent) + ";";
62 s += "--orca-accent-fg:#ffffff;";
63 s += "--orca-font:" + (font.empty() ? std::string() : "'" + font + "',") +
64 "system-ui,-apple-system,'Segoe UI',Roboto,sans-serif;";
65 s += "color-scheme:" + host_theme_name() + ";";
66 s += "}";
67 return s;
68}
Definition GUI_App.hpp:255
const wxColour & get_label_clr_sys()
Definition GUI_App.hpp:514
const wxColour & get_label_clr_default()
Definition GUI_App.hpp:515
const wxColour & get_highlight_default_clr()
Definition GUI_App.hpp:521
const wxFont & normal_font()
Definition GUI_App.hpp:532
const wxColour & get_window_default_clr()
Definition GUI_App.hpp:516
static wxColour darkModeColorFor(wxColour const &color)
Definition StateColor.cpp:219
std::string css_color(const wxColour &c)
Definition WebViewHostDialog.cpp:32

References css_color(), StateColor::darkModeColorFor(), Slic3r::GUI::GUI_App::get_highlight_default_clr(), Slic3r::GUI::GUI_App::get_label_clr_default(), Slic3r::GUI::GUI_App::get_label_clr_sys(), Slic3r::GUI::GUI_App::get_window_default_clr(), host_theme_name(), host_theme_vars_css(), and Slic3r::GUI::GUI_App::normal_font().

Referenced by host_theme_apply_js(), and host_theme_vars_css().

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