mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-15 05:15:58 +08:00
Fix order of filling stored items
This commit is contained in:
parent
8f9887acdb
commit
f3f2dddcd1
@ -565,7 +565,6 @@ void GLGizmoEmboss::initialize()
|
|||||||
const AppConfig *app_cfg = wxGetApp().app_config;
|
const AppConfig *app_cfg = wxGetApp().app_config;
|
||||||
size_t activ_index = -1;
|
size_t activ_index = -1;
|
||||||
FontList font_list = load_font_list_from_app_config(app_cfg, activ_index);
|
FontList font_list = load_font_list_from_app_config(app_cfg, activ_index);
|
||||||
fill_stored_font_items(font_list);
|
|
||||||
m_font_manager.add_fonts(font_list);
|
m_font_manager.add_fonts(font_list);
|
||||||
if (!m_font_manager.load_font(activ_index) &&
|
if (!m_font_manager.load_font(activ_index) &&
|
||||||
!m_font_manager.load_first_valid_font()) {
|
!m_font_manager.load_first_valid_font()) {
|
||||||
@ -574,6 +573,7 @@ void GLGizmoEmboss::initialize()
|
|||||||
bool success = m_font_manager.load_first_valid_font();
|
bool success = m_font_manager.load_first_valid_font();
|
||||||
assert(success);
|
assert(success);
|
||||||
}
|
}
|
||||||
|
fill_stored_font_items();
|
||||||
set_default_text();
|
set_default_text();
|
||||||
select_stored_font_item();
|
select_stored_font_item();
|
||||||
}
|
}
|
||||||
@ -683,13 +683,19 @@ void GLGizmoEmboss::close()
|
|||||||
m_parent.get_gizmos_manager().open_gizmo(GLGizmosManager::Emboss);
|
m_parent.get_gizmos_manager().open_gizmo(GLGizmosManager::Emboss);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLGizmoEmboss::fill_stored_font_items(const FontList &font_list)
|
void GLGizmoEmboss::fill_stored_font_items()
|
||||||
{
|
{
|
||||||
m_stored_font_items.clear();
|
m_stored_font_items.clear();
|
||||||
for (const FontItem &fi : font_list) {
|
const auto& fonts = m_font_manager.get_fonts();
|
||||||
|
for (const auto &item : fonts) {
|
||||||
|
const FontItem &fi = item.font_item;
|
||||||
|
// skip file paths + fonts from other OS(loaded from .3mf)
|
||||||
|
if (fi.type != WxFontUtils::get_actual_type()) continue;
|
||||||
|
|
||||||
assert(m_stored_font_items.find(fi.name) == m_stored_font_items.end());
|
assert(m_stored_font_items.find(fi.name) == m_stored_font_items.end());
|
||||||
m_stored_font_items[fi.name] = fi; // copy
|
m_stored_font_items[fi.name] = fi; // copy
|
||||||
}
|
}
|
||||||
|
select_stored_font_item();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLGizmoEmboss::select_stored_font_item()
|
void GLGizmoEmboss::select_stored_font_item()
|
||||||
@ -722,14 +728,17 @@ void GLGizmoEmboss::draw_window()
|
|||||||
draw_model_type();
|
draw_model_type();
|
||||||
draw_style_list();
|
draw_style_list();
|
||||||
if (ImGui::TreeNode(_u8L("Edit style").c_str())) {
|
if (ImGui::TreeNode(_u8L("Edit style").c_str())) {
|
||||||
|
|
||||||
#ifdef SHOW_WX_FONT_DESCRIPTOR
|
#ifdef SHOW_WX_FONT_DESCRIPTOR
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
m_imgui->text_colored(ImGuiWrapper::COL_GREY_DARK, m_font_manager.get_font_item().path);
|
m_imgui->text_colored(ImGuiWrapper::COL_GREY_DARK, m_font_manager.get_font_item().path);
|
||||||
#endif // SHOW_WX_FONT_DESCRIPTOR
|
#endif // SHOW_WX_FONT_DESCRIPTOR
|
||||||
draw_style_edit();
|
if (!m_is_edit_style) {
|
||||||
ImGui::TreePop();
|
|
||||||
if (!m_is_edit_style)
|
|
||||||
set_minimal_window_size(true, m_is_advanced_edit_style);
|
set_minimal_window_size(true, m_is_advanced_edit_style);
|
||||||
|
} else {
|
||||||
|
draw_style_edit();
|
||||||
|
}
|
||||||
|
ImGui::TreePop();
|
||||||
} else if (m_is_edit_style)
|
} else if (m_is_edit_style)
|
||||||
set_minimal_window_size(false, m_is_advanced_edit_style);
|
set_minimal_window_size(false, m_is_advanced_edit_style);
|
||||||
|
|
||||||
@ -1448,10 +1457,12 @@ void GLGizmoEmboss::draw_style_edit() {
|
|||||||
process();
|
process();
|
||||||
|
|
||||||
if (ImGui::TreeNode(_u8L("advanced").c_str())) {
|
if (ImGui::TreeNode(_u8L("advanced").c_str())) {
|
||||||
draw_advanced();
|
if (!m_is_advanced_edit_style) {
|
||||||
ImGui::TreePop();
|
|
||||||
if (!m_is_advanced_edit_style)
|
|
||||||
set_minimal_window_size(true, true);
|
set_minimal_window_size(true, true);
|
||||||
|
} else {
|
||||||
|
draw_advanced();
|
||||||
|
}
|
||||||
|
ImGui::TreePop();
|
||||||
} else if (m_is_advanced_edit_style)
|
} else if (m_is_advanced_edit_style)
|
||||||
set_minimal_window_size(true, false);
|
set_minimal_window_size(true, false);
|
||||||
}
|
}
|
||||||
@ -2117,16 +2128,13 @@ void GLGizmoEmboss::store_font_list_to_app_config()
|
|||||||
std::string activ_font = std::to_string(activ_index + 1);
|
std::string activ_font = std::to_string(activ_index + 1);
|
||||||
cfg->set(AppConfig::SECTION_FONT, APP_CONFIG_ACTIVE_FONT, activ_font);
|
cfg->set(AppConfig::SECTION_FONT, APP_CONFIG_ACTIVE_FONT, activ_font);
|
||||||
|
|
||||||
FontList font_list;
|
|
||||||
font_list.reserve(fonts.size());
|
|
||||||
for (const auto& item : fonts) {
|
for (const auto& item : fonts) {
|
||||||
const FontItem &fi = item.font_item;
|
const FontItem &fi = item.font_item;
|
||||||
// skip file paths + fonts from other OS(loaded from .3mf)
|
// skip file paths + fonts from other OS(loaded from .3mf)
|
||||||
if (fi.type != WxFontUtils::get_actual_type()) continue;
|
if (fi.type != WxFontUtils::get_actual_type()) continue;
|
||||||
font_list.emplace_back(fi);
|
|
||||||
FontListSerializable::store_font_item(*cfg, fi, index++);
|
FontListSerializable::store_font_item(*cfg, fi, index++);
|
||||||
}
|
}
|
||||||
fill_stored_font_items(font_list);
|
fill_stored_font_items();
|
||||||
|
|
||||||
// remove rest of font sections
|
// remove rest of font sections
|
||||||
std::string section_name = FontListSerializable::create_section_name(index);
|
std::string section_name = FontListSerializable::create_section_name(index);
|
||||||
|
@ -198,7 +198,7 @@ private:
|
|||||||
// Track stored values in AppConfig
|
// Track stored values in AppConfig
|
||||||
std::optional<FontItem> m_stored_font_item;
|
std::optional<FontItem> m_stored_font_item;
|
||||||
std::map<std::string, FontItem> m_stored_font_items;
|
std::map<std::string, FontItem> m_stored_font_items;
|
||||||
void fill_stored_font_items(const FontList &font_list);
|
void fill_stored_font_items();
|
||||||
void select_stored_font_item();
|
void select_stored_font_item();
|
||||||
|
|
||||||
//FontList m_font_list;
|
//FontList m_font_list;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user