mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-15 20:06:01 +08:00
Remove undo button after style selector
This commit is contained in:
parent
a1914f5f94
commit
a6ffbb63f0
@ -1136,7 +1136,7 @@ void GLGizmoEmboss::draw_text_input()
|
|||||||
append_warning(_u8L("To small"),
|
append_warning(_u8L("To small"),
|
||||||
_u8L("Enlarged font height inside text input."));
|
_u8L("Enlarged font height inside text input."));
|
||||||
if (!who.empty())
|
if (!who.empty())
|
||||||
warning = GUI::format(_u8L("%1% is NOT shown."), who);
|
warning = GUI::format(_L("%1% is NOT shown."), who);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!warning.empty()) {
|
if (!warning.empty()) {
|
||||||
@ -1470,7 +1470,7 @@ void GLGizmoEmboss::draw_model_type()
|
|||||||
void GLGizmoEmboss::draw_style_rename_popup() {
|
void GLGizmoEmboss::draw_style_rename_popup() {
|
||||||
std::string& new_name = m_style_manager.get_style().name;
|
std::string& new_name = m_style_manager.get_style().name;
|
||||||
const std::string &old_name = m_style_manager.get_stored_style()->name;
|
const std::string &old_name = m_style_manager.get_stored_style()->name;
|
||||||
std::string text_in_popup = GUI::format(_u8L("Rename style(%1%) for embossing text: "), old_name);
|
std::string text_in_popup = GUI::format(_L("Rename style(%1%) for embossing text: "), old_name);
|
||||||
ImGui::Text("%s", text_in_popup.c_str());
|
ImGui::Text("%s", text_in_popup.c_str());
|
||||||
|
|
||||||
bool is_unique = true;
|
bool is_unique = true;
|
||||||
@ -1536,36 +1536,20 @@ void GLGizmoEmboss::draw_style_rename_button()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLGizmoEmboss::draw_style_save_button()
|
void GLGizmoEmboss::draw_style_save_button(bool is_modified)
|
||||||
{
|
{
|
||||||
bool is_stored_style = m_style_manager.exist_stored_style();
|
if (draw_button(IconType::save, !is_modified)) {
|
||||||
const EmbossStyle *stored_syle = nullptr;
|
|
||||||
if (is_stored_style)
|
|
||||||
stored_syle = m_style_manager.get_stored_style();
|
|
||||||
|
|
||||||
const EmbossStyle &style = m_style_manager.get_style();
|
|
||||||
bool is_changed = (stored_syle)? !(*stored_syle == style) : true;
|
|
||||||
|
|
||||||
bool is_style_order_changed = m_style_manager.is_style_order_changed();
|
|
||||||
bool is_activ_style_changed = m_style_manager.is_activ_style_changed();
|
|
||||||
bool can_save = is_changed || is_style_order_changed || is_activ_style_changed;
|
|
||||||
if (!is_stored_style) can_save = false;
|
|
||||||
|
|
||||||
if (draw_button(IconType::save, !can_save)) {
|
|
||||||
// save styles to app config
|
// save styles to app config
|
||||||
m_style_manager.store_styles_to_app_config(wxGetApp().app_config);
|
m_style_manager.store_styles_to_app_config(wxGetApp().app_config);
|
||||||
}else if (ImGui::IsItemHovered()) {
|
}else if (ImGui::IsItemHovered()) {
|
||||||
if (!is_stored_style) {
|
if (!m_style_manager.exist_stored_style()) {
|
||||||
ImGui::SetTooltip("%s", _u8L("First Add style to be able save.").c_str());
|
ImGui::SetTooltip("%s", _u8L("First Add style to list.").c_str());
|
||||||
} else if (is_changed) {
|
} else if (is_modified) {
|
||||||
ImGui::SetTooltip("%s", _u8L("Save changes into style.").c_str());
|
ImGui::SetTooltip("%s", _u8L("Save changes into style.").c_str());
|
||||||
} else if (is_style_order_changed) {
|
|
||||||
ImGui::SetTooltip("%s", _u8L("Save order of styles.").c_str());
|
|
||||||
} else if (is_activ_style_changed) {
|
|
||||||
ImGui::SetTooltip("%s", _u8L("Save style selection.").c_str());
|
|
||||||
} else {
|
} else {
|
||||||
ImGui::SetTooltip("%s", _u8L("No changes to save into style").c_str());
|
ImGui::SetTooltip("%s", _u8L("No changes to save into style").c_str());
|
||||||
}
|
}
|
||||||
|
ImGui::SetTooltip(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1691,7 +1675,7 @@ void GLGizmoEmboss::draw_delete_style_button() {
|
|||||||
|
|
||||||
if (ImGui::BeginPopupModal(popup_id)) {
|
if (ImGui::BeginPopupModal(popup_id)) {
|
||||||
const std::string &style_name = m_style_manager.get_style().name;
|
const std::string &style_name = m_style_manager.get_style().name;
|
||||||
std::string text_in_popup = GUI::format(_u8L("Are you sure,\nthat you want permanently and unrecoverable \nremove style \"%1%\"?"), style_name);
|
std::string text_in_popup = GUI::format(_L("Are you sure,\nthat you want permanently and unrecoverable \nremove style \"%1%\"?"), style_name);
|
||||||
ImGui::Text("%s", text_in_popup.c_str());
|
ImGui::Text("%s", text_in_popup.c_str());
|
||||||
if (ImGui::Button(_u8L("Yes").c_str())) {
|
if (ImGui::Button(_u8L("Yes").c_str())) {
|
||||||
size_t activ_index = m_style_manager.get_style_index();
|
size_t activ_index = m_style_manager.get_style_index();
|
||||||
@ -1766,8 +1750,16 @@ void GLGizmoEmboss::draw_revert_all_styles_button() {
|
|||||||
|
|
||||||
void GLGizmoEmboss::draw_style_list() {
|
void GLGizmoEmboss::draw_style_list() {
|
||||||
if (!m_style_manager.is_activ_font()) return;
|
if (!m_style_manager.is_activ_font()) return;
|
||||||
const float &max_style_name_width = m_gui_cfg->max_style_name_width;
|
|
||||||
|
const EmbossStyle *stored_style = nullptr;
|
||||||
|
bool is_stored = m_style_manager.exist_stored_style();
|
||||||
|
if (is_stored)
|
||||||
|
stored_style = m_style_manager.get_stored_style();
|
||||||
const EmbossStyle &actual_style = m_style_manager.get_style();
|
const EmbossStyle &actual_style = m_style_manager.get_style();
|
||||||
|
bool is_changed = (stored_style)? !(*stored_style == actual_style) : true;
|
||||||
|
bool is_modified = is_stored && is_changed;
|
||||||
|
|
||||||
|
const float &max_style_name_width = m_gui_cfg->max_style_name_width;
|
||||||
std::string &trunc_name = m_style_manager.get_truncated_name();
|
std::string &trunc_name = m_style_manager.get_truncated_name();
|
||||||
if (trunc_name.empty()) {
|
if (trunc_name.empty()) {
|
||||||
// generate trunc name
|
// generate trunc name
|
||||||
@ -1781,7 +1773,11 @@ void GLGizmoEmboss::draw_style_list() {
|
|||||||
|
|
||||||
ImGui::SameLine(m_gui_cfg->style_offset);
|
ImGui::SameLine(m_gui_cfg->style_offset);
|
||||||
ImGui::SetNextItemWidth(m_gui_cfg->input_width);
|
ImGui::SetNextItemWidth(m_gui_cfg->input_width);
|
||||||
if (ImGui::BeginCombo("##style_selector", trunc_name.c_str())) {
|
auto add_text_modify = [&is_modified](const std::string& name) {
|
||||||
|
if (!is_modified) return name;
|
||||||
|
return name + " (" + _u8L("modified") + ")";
|
||||||
|
};
|
||||||
|
if (ImGui::BeginCombo("##style_selector", add_text_modify(trunc_name).c_str())) {
|
||||||
m_style_manager.init_style_images(m_gui_cfg->max_style_image_size, m_text);
|
m_style_manager.init_style_images(m_gui_cfg->max_style_image_size, m_text);
|
||||||
m_style_manager.init_trunc_names(max_style_name_width);
|
m_style_manager.init_trunc_names(max_style_name_width);
|
||||||
std::optional<std::pair<size_t,size_t>> swap_indexes;
|
std::optional<std::pair<size_t,size_t>> swap_indexes;
|
||||||
@ -1837,15 +1833,20 @@ void GLGizmoEmboss::draw_style_list() {
|
|||||||
} else {
|
} else {
|
||||||
// do not keep in memory style images when no combo box open
|
// do not keep in memory style images when no combo box open
|
||||||
m_style_manager.free_style_images();
|
m_style_manager.free_style_images();
|
||||||
if (ImGui::IsItemHovered())
|
if (ImGui::IsItemHovered()) {
|
||||||
ImGui::SetTooltip("%s", _u8L("Style selector").c_str());
|
std::string style_name = add_text_modify(actual_style.name);
|
||||||
|
std::string tooltip = is_modified?
|
||||||
|
GUI::format(_L("Modified style \"%1%\""), actual_style.name):
|
||||||
|
GUI::format(_L("Current style is \"%1%\""), actual_style.name);
|
||||||
|
ImGui::SetTooltip(" %s", tooltip.c_str());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
draw_style_rename_button();
|
draw_style_rename_button();
|
||||||
|
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
draw_style_save_button();
|
draw_style_save_button(is_modified);
|
||||||
|
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
draw_style_add_button();
|
draw_style_add_button();
|
||||||
|
@ -104,7 +104,7 @@ private:
|
|||||||
void draw_revert_all_styles_button();
|
void draw_revert_all_styles_button();
|
||||||
void draw_style_rename_popup();
|
void draw_style_rename_popup();
|
||||||
void draw_style_rename_button();
|
void draw_style_rename_button();
|
||||||
void draw_style_save_button();
|
void draw_style_save_button(bool is_modified);
|
||||||
void draw_style_save_as_popup();
|
void draw_style_save_as_popup();
|
||||||
void draw_style_add_button();
|
void draw_style_add_button();
|
||||||
void draw_font_list();
|
void draw_font_list();
|
||||||
|
@ -135,7 +135,6 @@ void EmbossStyleManager::discard_style_changes() {
|
|||||||
load_first_valid_font();
|
load_first_valid_font();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool EmbossStyleManager::is_style_order_changed() const { return m_change_order; }
|
bool EmbossStyleManager::is_style_order_changed() const { return m_change_order; }
|
||||||
bool EmbossStyleManager::is_activ_style_changed() const {
|
bool EmbossStyleManager::is_activ_style_changed() const {
|
||||||
if (m_stored_activ_index == std::numeric_limits<size_t>::max())
|
if (m_stored_activ_index == std::numeric_limits<size_t>::max())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user