change windows position on one line only
This commit is contained in:
parent
8a44a754ca
commit
f4ad435ec5
@ -218,27 +218,29 @@ void GLGizmoSimplify::on_render_input_window(float x, float y, float bottom_limi
|
|||||||
start_process = true;
|
start_process = true;
|
||||||
|
|
||||||
// set window position
|
// set window position
|
||||||
if (m_move_to_center && change_window_position) {
|
if (change_window_position) {
|
||||||
|
ImVec2 pos;
|
||||||
|
Size parent_size = m_parent.get_canvas_size();
|
||||||
|
if (m_move_to_center) {
|
||||||
m_move_to_center = false;
|
m_move_to_center = false;
|
||||||
auto parent_size = m_parent.get_canvas_size();
|
pos = ImVec2(parent_size.get_width() / 2 - m_gui_cfg->window_offset_x,
|
||||||
ImVec2 pos(parent_size.get_width() / 2 - m_gui_cfg->window_offset_x,
|
|
||||||
parent_size.get_height() / 2 - m_gui_cfg->window_offset_y);
|
parent_size.get_height() / 2 - m_gui_cfg->window_offset_y);
|
||||||
ImGui::SetNextWindowPos(pos, ImGuiCond_Always);
|
} else {
|
||||||
}else if (change_window_position) {
|
// keep window wisible on canvas and close to mouse click
|
||||||
ImVec2 pos = ImGui::GetMousePos();
|
pos = ImGui::GetMousePos();
|
||||||
pos.x -= m_gui_cfg->window_offset_x;
|
pos.x -= m_gui_cfg->window_offset_x;
|
||||||
pos.y -= m_gui_cfg->window_offset_y;
|
pos.y -= m_gui_cfg->window_offset_y;
|
||||||
// minimal top left value
|
// minimal top left value
|
||||||
ImVec2 tl(m_gui_cfg->window_padding, m_gui_cfg->window_padding);
|
ImVec2 tl(m_gui_cfg->window_padding,
|
||||||
|
m_gui_cfg->window_padding);
|
||||||
if (pos.x < tl.x) pos.x = tl.x;
|
if (pos.x < tl.x) pos.x = tl.x;
|
||||||
if (pos.y < tl.y) pos.y = tl.y;
|
if (pos.y < tl.y) pos.y = tl.y;
|
||||||
// maximal bottom right value
|
// maximal bottom right value
|
||||||
auto parent_size = m_parent.get_canvas_size();
|
ImVec2 br(parent_size.get_width() - (2 * m_gui_cfg->window_offset_x + m_gui_cfg->window_padding),
|
||||||
ImVec2 br(
|
parent_size.get_height() -(2 * m_gui_cfg->window_offset_y + m_gui_cfg->window_padding));
|
||||||
parent_size.get_width() - (2 * m_gui_cfg->window_offset_x + m_gui_cfg->window_padding),
|
|
||||||
parent_size.get_height() - (2 * m_gui_cfg->window_offset_y + m_gui_cfg->window_padding));
|
|
||||||
if (pos.x > br.x) pos.x = br.x;
|
if (pos.x > br.x) pos.x = br.x;
|
||||||
if (pos.y > br.y) pos.y = br.y;
|
if (pos.y > br.y) pos.y = br.y;
|
||||||
|
}
|
||||||
ImGui::SetNextWindowPos(pos, ImGuiCond_Always);
|
ImGui::SetNextWindowPos(pos, ImGuiCond_Always);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user