mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-15 10:45:54 +08:00
Fix blinking when undo change
This commit is contained in:
parent
1bdc291dba
commit
e86477f20a
@ -1879,21 +1879,38 @@ bool GLGizmoEmboss::bold_button() {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename T> bool exist_change(const T &value, const T *default_value){
|
||||||
|
if (default_value == nullptr) return false;
|
||||||
|
return (value != *default_value);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<> bool exist_change(const std::optional<float> &value, const std::optional<float> *default_value){
|
||||||
|
if (default_value == nullptr) return false;
|
||||||
|
return !is_approx(value, *default_value);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<> bool exist_change(const float &value, const float *default_value){
|
||||||
|
if (default_value == nullptr) return false;
|
||||||
|
return !is_approx(value, *default_value);
|
||||||
|
}
|
||||||
|
|
||||||
template<typename T, typename Draw>
|
template<typename T, typename Draw>
|
||||||
bool GLGizmoEmboss::revertible(const std::string &name,
|
bool GLGizmoEmboss::revertible(const std::string &name,
|
||||||
T &value,
|
T &value,
|
||||||
T *default_value,
|
T *default_value,
|
||||||
bool exist_change,
|
|
||||||
const std::string &undo_tooltip,
|
const std::string &undo_tooltip,
|
||||||
float undo_offset,
|
float undo_offset,
|
||||||
Draw draw)
|
Draw draw)
|
||||||
{
|
{
|
||||||
if (exist_change)
|
bool changed = exist_change(value, default_value);
|
||||||
|
if (changed)
|
||||||
ImGuiWrapper::text_colored(ImGuiWrapper::COL_ORANGE_LIGHT, name);
|
ImGuiWrapper::text_colored(ImGuiWrapper::COL_ORANGE_LIGHT, name);
|
||||||
else
|
else
|
||||||
ImGuiWrapper::text(name);
|
ImGuiWrapper::text(name);
|
||||||
|
|
||||||
|
bool result = draw();
|
||||||
// render revert changes button
|
// render revert changes button
|
||||||
if (exist_change) {
|
if (changed) {
|
||||||
ImGui::SameLine(undo_offset);
|
ImGui::SameLine(undo_offset);
|
||||||
if (draw_button(IconType::undo)) {
|
if (draw_button(IconType::undo)) {
|
||||||
value = *default_value;
|
value = *default_value;
|
||||||
@ -1901,7 +1918,7 @@ bool GLGizmoEmboss::revertible(const std::string &name,
|
|||||||
} else if (ImGui::IsItemHovered())
|
} else if (ImGui::IsItemHovered())
|
||||||
ImGui::SetTooltip("%s", undo_tooltip.c_str());
|
ImGui::SetTooltip("%s", undo_tooltip.c_str());
|
||||||
}
|
}
|
||||||
return draw();
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1924,8 +1941,7 @@ bool GLGizmoEmboss::rev_input(const std::string &name,
|
|||||||
&value, step, step_fast, format, flags);
|
&value, step, step_fast, format, flags);
|
||||||
};
|
};
|
||||||
float undo_offset = ImGui::GetStyle().FramePadding.x;
|
float undo_offset = ImGui::GetStyle().FramePadding.x;
|
||||||
bool exist_change = default_value != nullptr ? (!is_approx(value, *default_value)) : false;
|
return revertible(name, value, default_value, undo_tooltip, undo_offset, draw_offseted_input);
|
||||||
return revertible(name, value, default_value, exist_change, undo_tooltip, undo_offset, draw_offseted_input);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GLGizmoEmboss::rev_checkbox(const std::string &name,
|
bool GLGizmoEmboss::rev_checkbox(const std::string &name,
|
||||||
@ -1939,10 +1955,7 @@ bool GLGizmoEmboss::rev_checkbox(const std::string &name,
|
|||||||
return ImGui::Checkbox(("##" + name).c_str(), &value);
|
return ImGui::Checkbox(("##" + name).c_str(), &value);
|
||||||
};
|
};
|
||||||
float undo_offset = ImGui::GetStyle().FramePadding.x;
|
float undo_offset = ImGui::GetStyle().FramePadding.x;
|
||||||
bool exist_change = default_value != nullptr ?
|
return revertible(name, value, default_value, undo_tooltip,
|
||||||
(value != *default_value) :
|
|
||||||
false;
|
|
||||||
return revertible(name, value, default_value, exist_change, undo_tooltip,
|
|
||||||
undo_offset, draw_offseted_input);
|
undo_offset, draw_offseted_input);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2087,8 +2100,7 @@ bool GLGizmoEmboss::rev_slider(const std::string &name,
|
|||||||
v_min, v_max, format.c_str(), 1.f, false, tooltip);
|
v_min, v_max, format.c_str(), 1.f, false, tooltip);
|
||||||
};
|
};
|
||||||
float undo_offset = ImGui::GetStyle().FramePadding.x;
|
float undo_offset = ImGui::GetStyle().FramePadding.x;
|
||||||
bool exist_change = default_value != nullptr ? (value != *default_value) : false;
|
return revertible(name, value, default_value,
|
||||||
return revertible(name, value, default_value, exist_change,
|
|
||||||
undo_tooltip, undo_offset, draw_slider_optional_int);
|
undo_tooltip, undo_offset, draw_slider_optional_int);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2110,9 +2122,7 @@ bool GLGizmoEmboss::rev_slider(const std::string &name,
|
|||||||
v_min, v_max, format.c_str(), 1.f, false, tooltip);
|
v_min, v_max, format.c_str(), 1.f, false, tooltip);
|
||||||
};
|
};
|
||||||
float undo_offset = ImGui::GetStyle().FramePadding.x;
|
float undo_offset = ImGui::GetStyle().FramePadding.x;
|
||||||
bool exist_change = (default_value != nullptr)?
|
return revertible(name, value, default_value,
|
||||||
(!is_approx(value, *default_value)) : false;
|
|
||||||
return revertible(name, value, default_value, exist_change,
|
|
||||||
undo_tooltip, undo_offset, draw_slider_optional_float);
|
undo_tooltip, undo_offset, draw_slider_optional_float);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2134,9 +2144,7 @@ bool GLGizmoEmboss::rev_slider(const std::string &name,
|
|||||||
format.c_str(), 1.f, false, tooltip);
|
format.c_str(), 1.f, false, tooltip);
|
||||||
};
|
};
|
||||||
float undo_offset = ImGui::GetStyle().FramePadding.x;
|
float undo_offset = ImGui::GetStyle().FramePadding.x;
|
||||||
bool exist_change = default_value != nullptr ?
|
return revertible(name, value, default_value,
|
||||||
(!is_approx(value, *default_value)) : false;
|
|
||||||
return revertible(name, value, default_value, exist_change,
|
|
||||||
undo_tooltip, undo_offset, draw_slider_float);
|
undo_tooltip, undo_offset, draw_slider_float);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -132,7 +132,7 @@ private:
|
|||||||
bool rev_slider(const std::string &name, float &value, float *default_value,
|
bool rev_slider(const std::string &name, float &value, float *default_value,
|
||||||
const std::string &undo_tooltip, float v_min, float v_max, const std::string &format, const wxString &tooltip);
|
const std::string &undo_tooltip, float v_min, float v_max, const std::string &format, const wxString &tooltip);
|
||||||
template<typename T, typename Draw>
|
template<typename T, typename Draw>
|
||||||
bool revertible(const std::string &name, T &value, T *default_value, bool exist_change, const std::string &undo_tooltip, float undo_offset, Draw draw);
|
bool revertible(const std::string &name, T &value, T *default_value, const std::string &undo_tooltip, float undo_offset, Draw draw);
|
||||||
|
|
||||||
void set_minimal_window_size(bool is_advance_edit_style);
|
void set_minimal_window_size(bool is_advance_edit_style);
|
||||||
const ImVec2 &get_minimal_window_size() const;
|
const ImVec2 &get_minimal_window_size() const;
|
||||||
|
@ -773,7 +773,9 @@ void Selection::translate(const Vec3d& displacement, TransformationType transfor
|
|||||||
if (!m_valid)
|
if (!m_valid)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
assert(transformation_type.relative());
|
// Emboss use translate in local coordinate
|
||||||
|
assert(transformation_type.relative() ||
|
||||||
|
transformation_type.local());
|
||||||
|
|
||||||
for (unsigned int i : m_list) {
|
for (unsigned int i : m_list) {
|
||||||
GLVolume& v = *(*m_volumes)[i];
|
GLVolume& v = *(*m_volumes)[i];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user