EditGCodeDialog: Added new icons.

+ BitmapCache: Fixed replaces during SVG loading(quotation marks are redundant).
This commit is contained in:
YuSanka 2023-10-19 09:56:58 +02:00
parent e8ba79a0ad
commit 37afe79c60
11 changed files with 26 additions and 14 deletions

View File

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg id="a" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><g id="b"><path d="m8.02,7.18h3.98v3.08c0,2.6-1.23,3.72-4.05,3.72s-3.95-1.12-3.95-3.68v-4.75c0-2.42,1.09-3.54,3.95-3.54s4.05,1,4.05,3.54h-2.12c0-1.11-.28-1.66-1.92-1.66-1.54,0-1.83.69-1.83,1.77v4.65c0,1.12.29,1.77,1.83,1.77s2.08-.65,2.08-1.82v-1.16h-2.02v-1.92Z" style="fill:#808080;"/></g></svg>

After

Width:  |  Height:  |  Size: 402 B

View File

@ -0,0 +1 @@
<?xml version="1.0" encoding="UTF-8"?><svg id="a" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><path d="m13.6,5h-.6v3.5c0,.28-.22.5-.5.5s-.5-.22-.5-.5v-3.5h-2v3.5c0,.28-.22.5-.5.5s-.5-.22-.5-.5v-3.5h-2v3.5c0,.28-.22.5-.5.5s-.5-.22-.5-.5v-3.5h-2v3.5c0,.28-.22.5-.5.5s-.5-.22-.5-.5v-3.5h-.6c-.77,0-1.4.62-1.4,1.4v3.21c0,.77.62,1.4,1.4,1.4h11.21c.77,0,1.4-.62,1.4-1.4v-3.21c0-.77-.62-1.4-1.4-1.4Z" style="fill:#808080;"/></svg>

After

Width:  |  Height:  |  Size: 434 B

View File

@ -0,0 +1 @@
<?xml version="1.0" encoding="UTF-8"?><svg id="a" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><path id="b" d="m8.54,4.31c-.53-.19-.81-.69-.73-1.32.08-.62.55-1.01,1.21-1.01.46,0,.82.21,1,.58.1.2.1.22.1.55,0,.43-.07.61-.31.87-.24.26-.46.35-.84.36-.21,0-.33,0-.43-.04Z" style="fill:#ed6b21; isolation:isolate; opacity:1;"/><path id="c" d="m6.82,13.97c-.51-.14-.74-.4-.77-.86-.02-.28-.04-.15.57-3.12.22-1.07.44-2.13.48-2.34.13-.71.07-.77-.77-.81-.21-.01-.38-.03-.39-.04s0-.09.02-.18c.04-.18,0-.16.69-.31.62-.14,1.09-.19,1.63-.2.67,0,.9.07,1.13.36.09.11.09.13.09.41,0,.25-.06.57-.39,2.17-.78,3.74-.79,3.82-.68,3.99.03.04.08.1.12.13.12.08.47.14.8.14h.3s-.02.18-.02.18c-.01.1-.04.19-.05.2-.05.03-.88.2-1.24.26-.45.07-1.31.09-1.51.03h0Z" style="fill:#ed6b21; isolation:isolate; opacity:1;"/><polyline points="14.5 3.5 14.5 1.5 12.5 1.5" style="fill:none; stroke:808080; stroke-linecap:round; stroke-miterlimit:10;"/><polyline points="3.5 1.5 1.5 1.5 1.5 3.5" style="fill:none; stroke:#808080; stroke-linecap:round; stroke-miterlimit:10;"/><polyline points="1.5 12.5 1.5 14.5 3.5 14.5" style="fill:none; stroke:#808080; stroke-linecap:round; stroke-miterlimit:10;"/><polyline points="12.5 14.5 14.5 14.5 14.5 12.5" style="fill:none; stroke:#808080; stroke-linecap:round; stroke-miterlimit:10;"/></svg>

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

@ -0,0 +1 @@
<?xml version="1.0" encoding="UTF-8"?><svg id="a" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><circle cx="8" cy="8" r="2" style="fill:#808080;"/></svg>

After

Width:  |  Height:  |  Size: 162 B

View File

@ -0,0 +1 @@
<?xml version="1.0" encoding="UTF-8"?><svg id="a" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><g id="b"><path d="m13.77,6.39c-.13-.47-.32-.92-.55-1.33l.43-1.3-1.41-1.41-1.3.43c-.42-.23-.86-.42-1.33-.55l-.61-1.23h-2l-.61,1.23c-.47.13-.92.31-1.33.55l-1.3-.43-1.42,1.41.43,1.3c-.23.41-.41.86-.54,1.33l-1.23.61v2l1.23.61c.13.47.32.92.55,1.33l-.43,1.3,1.41,1.41,1.3-.43c.42.23.86.42,1.33.55l.61,1.23h2l.61-1.23c.47-.13.92-.32,1.33-.55l1.3.43,1.41-1.41-.43-1.3c.23-.42.42-.86.55-1.33l1.23-.61v-2l-1.23-.61Zm-5.77,6.61c-2.76,0-5-2.24-5-5s2.24-5,5-5,5,2.24,5,5-2.24,5-5,5Z" style="fill:#808080;"/></g></svg>

After

Width:  |  Height:  |  Size: 610 B

View File

@ -0,0 +1,3 @@
<?xml version="1.0" encoding="UTF-8"?><svg id="a" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><g id="b">
<path d="m13.77,6.39c-.13-.47-.32-.92-.55-1.33l.43-1.3-1.41-1.41-1.3.43c-.42-.23-.86-.42-1.33-.55l-.61-1.23h-2l-.61,1.23c-.47.13-.92.31-1.33.55l-1.3-.43-1.42,1.41.43,1.3c-.23.41-.41.86-.54,1.33l-1.23.61v2l1.23.61c.13.47.32.92.55,1.33l-.43,1.3,1.41,1.41,1.3-.43c.42.23.86.42,1.33.55l.61,1.23h2l.61-1.23c.47-.13.92-.32,1.33-.55l1.3.43,1.41-1.41-.43-1.3c.23-.42.42-.86.55-1.33l1.23-.61v-2l-1.23-.61Zm-5.77,6.61c-2.76,0-5-2.24-5-5s2.24-5,5-5,5,2.24,5,5-2.24,5-5,5Z" style="fill:#808080"/>
</g><circle cx="8" cy="8" r="2" style="fill:#ed6b21; isolation:isolate; opacity:1;"/></svg>

After

Width:  |  Height:  |  Size: 694 B

View File

@ -0,0 +1 @@
<?xml version="1.0" encoding="UTF-8"?><svg id="a" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><rect x="1" y="7" width="2" height="6" rx="1" ry="1" style="fill:#ed6b21;"/><rect x="5" y="2" width="2" height="11" rx="1" ry="1" style="fill:#ed6b21;"/><rect x="9" y="3" width="2" height="10" rx="1" ry="1" style="fill:#ed6b21;"/><rect x="13" y="5" width="2" height="8" rx="1" ry="1" style="fill:#ed6b21;"/></svg>

After

Width:  |  Height:  |  Size: 418 B

View File

@ -0,0 +1 @@
<?xml version="1.0" encoding="UTF-8"?><svg id="a" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><path d="m9,8v3.14c0,.47-.45.86-1,.86h0c-.55,0-1-.38-1-.86v-3.14h2Z" style="fill:#ed6b21;"/><circle cx="8" cy="6" r="1" style="fill:#ed6b21;"/><polyline points="4.5 2.5 2.5 2.5 2.5 13.5 4.5 13.5" style="fill:none; stroke:#808080; stroke-linecap:round; stroke-miterlimit:10;"/><polyline points="11.5 13.5 13.5 13.5 13.5 2.5 11.5 2.5" style="fill:none; stroke:#808080; stroke-linecap:round; stroke-miterlimit:10;"/></svg>

After

Width:  |  Height:  |  Size: 524 B

View File

@ -0,0 +1 @@
<?xml version="1.0" encoding="UTF-8"?><svg id="a" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><polyline points="4.5 2.5 2.5 2.5 2.5 13.5 4.5 13.5" style="fill:none; stroke:808080; stroke-linecap:round; stroke-miterlimit:10;"/><polyline points="11.5 13.5 13.5 13.5 13.5 2.5 11.5 2.5" style="fill:none; stroke:808080; stroke-linecap:round; stroke-miterlimit:10;"/><path d="m9,8v3.14c0,.47-.45.86-1,.86h0c-.55,0-1-.38-1-.86v-3.14h2Z" style="fill:#808080;"/><circle cx="8" cy="6" r="1" style="fill:#808080;"/></svg>

After

Width:  |  Height:  |  Size: 522 B

View File

@ -410,11 +410,11 @@ wxBitmapBundle* BitmapCache::from_svg(const std::string& bitmap_name, unsigned t
// map of color replaces
std::map<std::string, std::string> replaces;
if (dark_mode)
replaces["\"#808080\""] = "\"#FFFFFF\"";
replaces["#808080"] = "#FFFFFF";
if (!new_color.empty())
replaces["\"#ED6B21\""] = "\"" + new_color + "\"";
replaces["#ED6B21"] = new_color;
replaces["\"#ButtonBG\""] = dark_mode ? "\"#4E4E4E\"" : "\"#828282\"";
replaces["#ButtonBG"] = dark_mode ? "#4E4E4E" : "#828282";
std::string str;
nsvgGetDataFromFileWithReplace(Slic3r::var(bitmap_name + ".svg").c_str(), str, replaces);
@ -468,9 +468,9 @@ wxBitmap* BitmapCache::load_svg(const std::string &bitmap_name, unsigned target_
// map of color replaces
std::map<std::string, std::string> replaces;
if (dark_mode)
replaces["\"#808080\""] = "\"#FFFFFF\"";
replaces["#808080"] = "#FFFFFF";
if (!new_color.empty())
replaces["\"#ED6B21\""] = "\"" + new_color + "\"";
replaces["#ED6B21"] = new_color;
NSVGimage *image = nsvgParseFromFileWithReplace(Slic3r::var(bitmap_name + ".svg").c_str(), "px", 96.0f, replaces);
if (image == nullptr)

View File

@ -159,7 +159,7 @@ void EditGCodeDialog::init_params_list(const std::string& custom_gcode_name)
// Add slicing states placeholders
wxDataViewItem slicing_state = m_params_list->AppendGroup(_L("[Global] Slicing state"), "re_slice");
wxDataViewItem slicing_state = m_params_list->AppendGroup(_L("[Global] Slicing state"), "custom-gcode_slicing-state_global");
if (!cgp_ro_slicing_states_config_def.empty()) {
wxDataViewItem read_only = m_params_list->AppendSubGroup(slicing_state, _L("Read only"), "lock_closed");
for (const auto& [opt_key, def]: cgp_ro_slicing_states_config_def.options)
@ -175,7 +175,7 @@ void EditGCodeDialog::init_params_list(const std::string& custom_gcode_name)
// add other universal params, which are related to slicing state
if (!cgp_other_slicing_states_config_def.empty()) {
slicing_state = m_params_list->AppendGroup(_L("Slicing state"), "re_slice");
slicing_state = m_params_list->AppendGroup(_L("Slicing state"), "custom-gcode_slicing-state");
for (const auto& [opt_key, def] : cgp_other_slicing_states_config_def.options)
m_params_list->AppendParam(slicing_state, get_type(opt_key, def), opt_key);
}
@ -186,7 +186,7 @@ void EditGCodeDialog::init_params_list(const std::string& custom_gcode_name)
// Add print statistics subgroup
if (!cgp_print_statistics_config_def.empty()) {
wxDataViewItem statistics = m_params_list->AppendGroup(_L("Print statistics"), "info");
wxDataViewItem statistics = m_params_list->AppendGroup(_L("Print statistics"), "custom-gcode_stats");
for (const auto& [opt_key, def] : cgp_print_statistics_config_def.options)
m_params_list->AppendParam(statistics, get_type(opt_key, def), opt_key);
}
@ -194,7 +194,7 @@ void EditGCodeDialog::init_params_list(const std::string& custom_gcode_name)
// Add objects info subgroup
if (!cgp_objects_info_config_def.empty()) {
wxDataViewItem objects_info = m_params_list->AppendGroup(_L("Objects info"), "advanced_plus");
wxDataViewItem objects_info = m_params_list->AppendGroup(_L("Objects info"), "custom-gcode_object-info");
for (const auto& [opt_key, def] : cgp_objects_info_config_def.options)
m_params_list->AppendParam(objects_info, get_type(opt_key, def), opt_key);
}
@ -202,7 +202,7 @@ void EditGCodeDialog::init_params_list(const std::string& custom_gcode_name)
// Add dimensions subgroup
if (!cgp_dimensions_config_def.empty()) {
wxDataViewItem dimensions = m_params_list->AppendGroup(_L("Dimensions"), "measure");
wxDataViewItem dimensions = m_params_list->AppendGroup(_L("Dimensions"), "custom-gcode_measure");
for (const auto& [opt_key, def] : cgp_dimensions_config_def.options)
m_params_list->AppendParam(dimensions, get_type(opt_key, def), opt_key);
}
@ -220,7 +220,7 @@ void EditGCodeDialog::init_params_list(const std::string& custom_gcode_name)
if (!specific_params.empty()) {
// TRN: The argument is the name of currently edited custom gcode. The string starts a section of placeholders only available in this gcode.
wxDataViewItem group = m_params_list->AppendGroup(format_wxstr(_L("Specific for %1%"), custom_gcode_name), "add_gcode");
wxDataViewItem group = m_params_list->AppendGroup(format_wxstr(_L("Specific for %1%"), custom_gcode_name), "custom-gcode_gcode");
for (const auto& opt_key : specific_params)
if (custom_gcode_specific_config_def.has(opt_key)) {
auto def = custom_gcode_specific_config_def.get(opt_key);
@ -389,9 +389,9 @@ void EditGCodeDialog::on_sys_color_changed()
const std::map<ParamType, std::string> ParamsInfo {
// Type BitmapName
{ ParamType::Scalar, "scalar_param" },
{ ParamType::Vector, "vector_param" },
{ ParamType::FilamentVector,"vector_filament_param" },
{ ParamType::Scalar, "custom-gcode_single" },
{ ParamType::Vector, "custom-gcode_vector" },
{ ParamType::FilamentVector,"custom-gcode_vector-index" },
};
static void make_bold(wxString& str)