FIX:cursor invalid when it overlaps with imgui window

jira: STUDIO-7356
Change-Id: Id16cb4cd878bbb26782f1a470c8b74b476214bac
(cherry picked from commit 668a147e916bc114df513326fc7b743b738f4306)
This commit is contained in:
zhou.xu 2024-06-20 09:41:38 +08:00 committed by Lane.Wei
parent 4d7715cc11
commit 17d3915733
5 changed files with 31 additions and 5 deletions

View File

@ -220,7 +220,8 @@ void GLGizmoFdmSupports::on_render_input_window(float x, float y, float bottom_l
init_print_instance();
if (! m_c->selection_info()->model_object())
return;
m_imgui_start_pos[0] = x;
m_imgui_start_pos[1] = y;
// BBS
wchar_t old_tool = m_current_tool;
@ -494,7 +495,8 @@ void GLGizmoFdmSupports::on_render_input_window(float x, float y, float bottom_l
m_parent.set_as_dirty();
}
ImGui::PopStyleVar(2);
m_imgui_end_pos[0] = m_imgui_start_pos[0] + ImGui::GetWindowWidth();
m_imgui_end_pos[1] = m_imgui_start_pos[1] + ImGui::GetWindowHeight();
GizmoImguiEnd();
// BBS

View File

@ -392,7 +392,8 @@ void GLGizmoMmuSegmentation::on_render_input_window(float x, float y, float bott
const float approx_height = m_imgui->scaled(22.0f);
y = std::min(y, bottom_limit - approx_height);
GizmoImguiSetNextWIndowPos(x, y, ImGuiCond_Always);
m_imgui_start_pos[0] = x;
m_imgui_start_pos[1] = y;
wchar_t old_tool = m_current_tool;
// BBS
@ -835,6 +836,8 @@ void GLGizmoMmuSegmentation::on_render_input_window(float x, float y, float bott
m_parent.set_as_dirty();
}
ImGui::PopStyleVar(2);
m_imgui_end_pos[0] = m_imgui_start_pos[0] + ImGui::GetWindowWidth();
m_imgui_end_pos[1] = m_imgui_start_pos[1] + ImGui::GetWindowHeight();
GizmoImguiEnd();
// BBS

View File

@ -156,6 +156,10 @@ void GLGizmoPainterBase::render_cursor() const
else {
m_rr.mouse_position = m_parent.get_local_mouse_position();
}
if (is_mouse_hit_in_imgui()) {
m_rr.mesh_id = -1;
return;
}
if (m_rr.mesh_id == -1) {
m_is_cursor_in_imgui = false;
m_x_for_height_input = -1;
@ -689,6 +693,10 @@ std::vector<GLGizmoPainterBase::ProjectedHeightRange> GLGizmoPainterBase::get_pr
bool GLGizmoPainterBase::gizmo_event(SLAGizmoEventType action, const Vec2d& mouse_position, bool shift_down, bool alt_down, bool control_down)
{
Vec2d _mouse_position = mouse_position;
if (is_mouse_hit_in_imgui()) {
m_rr.mesh_id = -1;
return false;
}
if (action == SLAGizmoEventType::MouseWheelUp
|| action == SLAGizmoEventType::MouseWheelDown) {
if (control_down) {
@ -1098,6 +1106,14 @@ CommonGizmosDataID GLGizmoPainterBase::on_get_requirements() const
| int(CommonGizmosDataID::ObjectClipper));
}
bool GLGizmoPainterBase::is_mouse_hit_in_imgui() const
{
if (m_rr.mouse_position[0] >= m_imgui_start_pos[0] && m_rr.mouse_position[1] >= m_imgui_start_pos[1]&&
m_rr.mouse_position[0] <= m_imgui_end_pos[0] && m_rr.mouse_position[1] <= m_imgui_end_pos[1]) {
return true;
}
return false;
}
void GLGizmoPainterBase::on_set_state()
{

View File

@ -403,8 +403,10 @@ protected:
bool wants_enter_leave_snapshots() const override { return true; }
virtual wxString handle_snapshot_action_name(bool shift_down, Button button_down) const = 0;
bool is_mouse_hit_in_imgui()const;
friend class ::Slic3r::GUI::GLGizmoMmuSegmentation;
mutable Vec2i m_imgui_start_pos{0, 0};
mutable Vec2i m_imgui_end_pos{0, 0};
};

View File

@ -187,7 +187,8 @@ void GLGizmoSeam::on_render_input_window(float x, float y, float bottom_limit)
{
if (! m_c->selection_info()->model_object())
return;
m_imgui_start_pos[0] = x;
m_imgui_start_pos[1] = y;
const float approx_height = m_imgui->scaled(12.5f);
y = std::min(y, bottom_limit - approx_height);
//BBS: GUI refactor: move gizmo to the right
@ -370,6 +371,8 @@ void GLGizmoSeam::on_render_input_window(float x, float y, float bottom_limit)
m_parent.set_as_dirty();
}
ImGui::PopStyleVar(2);
m_imgui_end_pos[0] = m_imgui_start_pos[0] + ImGui::GetWindowWidth();
m_imgui_end_pos[1] = m_imgui_start_pos[1] + ImGui::GetWindowHeight();
GizmoImguiEnd();
//BBS