Follow-up of 005fef7bf6
- Fixed imgui dialogs associated to gizmo bar and toolbar items
This commit is contained in:
parent
9fb350e3dd
commit
c17c4d2e9a
4 changed files with 66 additions and 29 deletions
|
@ -4199,8 +4199,12 @@ bool GLCanvas3D::_render_undo_redo_stack(const bool is_undo, float pos_x)
|
||||||
|
|
||||||
ImGuiWrapper* imgui = wxGetApp().imgui();
|
ImGuiWrapper* imgui = wxGetApp().imgui();
|
||||||
|
|
||||||
|
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||||
|
imgui->set_next_window_pos(pos_x, m_undoredo_toolbar.get_height(), ImGuiCond_Always, 0.5f, 0.0f);
|
||||||
|
#else
|
||||||
const float x = pos_x * (float)wxGetApp().plater()->get_camera().get_zoom() + 0.5f * (float)get_canvas_size().get_width();
|
const float x = pos_x * (float)wxGetApp().plater()->get_camera().get_zoom() + 0.5f * (float)get_canvas_size().get_width();
|
||||||
imgui->set_next_window_pos(x, m_undoredo_toolbar.get_height(), ImGuiCond_Always, 0.5f, 0.0f);
|
imgui->set_next_window_pos(x, m_undoredo_toolbar.get_height(), ImGuiCond_Always, 0.5f, 0.0f);
|
||||||
|
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||||
std::string title = is_undo ? L("Undo History") : L("Redo History");
|
std::string title = is_undo ? L("Undo History") : L("Redo History");
|
||||||
imgui->begin(_(title), ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse);
|
imgui->begin(_(title), ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse);
|
||||||
|
|
||||||
|
@ -4239,8 +4243,12 @@ bool GLCanvas3D::_render_search_list(float pos_x)
|
||||||
bool action_taken = false;
|
bool action_taken = false;
|
||||||
ImGuiWrapper* imgui = wxGetApp().imgui();
|
ImGuiWrapper* imgui = wxGetApp().imgui();
|
||||||
|
|
||||||
|
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||||
|
imgui->set_next_window_pos(pos_x, m_main_toolbar.get_height(), ImGuiCond_Always, 0.5f, 0.0f);
|
||||||
|
#else
|
||||||
const float x = /*pos_x * (float)wxGetApp().plater()->get_camera().get_zoom() + */0.5f * (float)get_canvas_size().get_width();
|
const float x = /*pos_x * (float)wxGetApp().plater()->get_camera().get_zoom() + */0.5f * (float)get_canvas_size().get_width();
|
||||||
imgui->set_next_window_pos(x, m_main_toolbar.get_height(), ImGuiCond_Always, 0.5f, 0.0f);
|
imgui->set_next_window_pos(x, m_main_toolbar.get_height(), ImGuiCond_Always, 0.5f, 0.0f);
|
||||||
|
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||||
std::string title = L("Search");
|
std::string title = L("Search");
|
||||||
imgui->begin(_(title), ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse);
|
imgui->begin(_(title), ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse);
|
||||||
|
|
||||||
|
@ -4293,9 +4301,13 @@ bool GLCanvas3D::_render_arrange_menu(float pos_x)
|
||||||
{
|
{
|
||||||
ImGuiWrapper *imgui = wxGetApp().imgui();
|
ImGuiWrapper *imgui = wxGetApp().imgui();
|
||||||
|
|
||||||
|
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||||
|
imgui->set_next_window_pos(pos_x, m_main_toolbar.get_height(), ImGuiCond_Always, 0.5f, 0.0f);
|
||||||
|
#else
|
||||||
auto canvas_w = float(get_canvas_size().get_width());
|
auto canvas_w = float(get_canvas_size().get_width());
|
||||||
const float x = pos_x * float(wxGetApp().plater()->get_camera().get_zoom()) + 0.5f * canvas_w;
|
const float x = pos_x * float(wxGetApp().plater()->get_camera().get_zoom()) + 0.5f * canvas_w;
|
||||||
imgui->set_next_window_pos(x, m_main_toolbar.get_height(), ImGuiCond_Always, 0.5f, 0.0f);
|
imgui->set_next_window_pos(x, m_main_toolbar.get_height(), ImGuiCond_Always, 0.5f, 0.0f);
|
||||||
|
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||||
|
|
||||||
imgui->begin(_L("Arrange options"), ImGuiWindowFlags_NoMove | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoCollapse);
|
imgui->begin(_L("Arrange options"), ImGuiWindowFlags_NoMove | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoCollapse);
|
||||||
|
|
||||||
|
@ -4827,9 +4839,7 @@ bool GLCanvas3D::_init_main_toolbar()
|
||||||
item.right.toggable = true;
|
item.right.toggable = true;
|
||||||
item.right.render_callback = [this](float left, float right, float, float) {
|
item.right.render_callback = [this](float left, float right, float, float) {
|
||||||
if (m_canvas != nullptr)
|
if (m_canvas != nullptr)
|
||||||
{
|
|
||||||
_render_arrange_menu(0.5f * (left + right));
|
_render_arrange_menu(0.5f * (left + right));
|
||||||
}
|
|
||||||
};
|
};
|
||||||
if (!m_main_toolbar.add_item(item))
|
if (!m_main_toolbar.add_item(item))
|
||||||
return false;
|
return false;
|
||||||
|
@ -4932,8 +4942,7 @@ bool GLCanvas3D::_init_main_toolbar()
|
||||||
item.sprite_id = 11;
|
item.sprite_id = 11;
|
||||||
item.left.toggable = true;
|
item.left.toggable = true;
|
||||||
item.left.render_callback = [this](float left, float right, float, float) {
|
item.left.render_callback = [this](float left, float right, float, float) {
|
||||||
if (m_canvas != nullptr)
|
if (m_canvas != nullptr) {
|
||||||
{
|
|
||||||
if (_render_search_list(0.5f * (left + right)))
|
if (_render_search_list(0.5f * (left + right)))
|
||||||
_deactivate_search_toolbar_item();
|
_deactivate_search_toolbar_item();
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,26 +85,29 @@ bool GLToolbarItem::update_enabled_state()
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||||
|
void GLToolbarItem::render(const GLCanvas3D& parent, unsigned int tex_id, float left, float right, float bottom, float top, unsigned int tex_width, unsigned int tex_height, unsigned int icon_size) const
|
||||||
|
#else
|
||||||
void GLToolbarItem::render(unsigned int tex_id, float left, float right, float bottom, float top, unsigned int tex_width, unsigned int tex_height, unsigned int icon_size) const
|
void GLToolbarItem::render(unsigned int tex_id, float left, float right, float bottom, float top, unsigned int tex_width, unsigned int tex_height, unsigned int icon_size) const
|
||||||
|
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||||
{
|
{
|
||||||
auto uvs = [this](unsigned int tex_width, unsigned int tex_height, unsigned int icon_size) -> GLTexture::Quad_UVs
|
auto uvs = [this](unsigned int tex_width, unsigned int tex_height, unsigned int icon_size) -> GLTexture::Quad_UVs {
|
||||||
{
|
assert(tex_width != 0 && tex_height != 0);
|
||||||
assert((tex_width != 0) && (tex_height != 0));
|
|
||||||
GLTexture::Quad_UVs ret;
|
GLTexture::Quad_UVs ret;
|
||||||
// tiles in the texture are spaced by 1 pixel
|
// tiles in the texture are spaced by 1 pixel
|
||||||
float icon_size_px = (float)(tex_width - 1) / ((float)Num_States + (float)Num_Rendered_Highlight_States);
|
const float icon_size_px = (float)(tex_width - 1) / ((float)Num_States + (float)Num_Rendered_Highlight_States);
|
||||||
char render_state = (m_highlight_state == NotHighlighted ? m_state : Num_States + m_highlight_state);
|
const char render_state = (m_highlight_state == NotHighlighted ? m_state : Num_States + m_highlight_state);
|
||||||
float inv_tex_width = 1.0f / (float)tex_width;
|
const float inv_tex_width = 1.0f / (float)tex_width;
|
||||||
float inv_tex_height = 1.0f / (float)tex_height;
|
const float inv_tex_height = 1.0f / (float)tex_height;
|
||||||
// tiles in the texture are spaced by 1 pixel
|
// tiles in the texture are spaced by 1 pixel
|
||||||
float u_offset = 1.0f * inv_tex_width;
|
const float u_offset = 1.0f * inv_tex_width;
|
||||||
float v_offset = 1.0f * inv_tex_height;
|
const float v_offset = 1.0f * inv_tex_height;
|
||||||
float du = icon_size_px * inv_tex_width;
|
const float du = icon_size_px * inv_tex_width;
|
||||||
float dv = icon_size_px * inv_tex_height;
|
const float dv = icon_size_px * inv_tex_height;
|
||||||
float left = u_offset + (float)render_state * du;
|
const float left = u_offset + (float)render_state * du;
|
||||||
float right = left + du - u_offset;
|
const float right = left + du - u_offset;
|
||||||
float top = v_offset + (float)m_data.sprite_id * dv;
|
const float top = v_offset + (float)m_data.sprite_id * dv;
|
||||||
float bottom = top + dv - v_offset;
|
const float bottom = top + dv - v_offset;
|
||||||
ret.left_top = { left, top };
|
ret.left_top = { left, top };
|
||||||
ret.left_bottom = { left, bottom };
|
ret.left_bottom = { left, bottom };
|
||||||
ret.right_bottom = { right, bottom };
|
ret.right_bottom = { right, bottom };
|
||||||
|
@ -114,12 +117,26 @@ void GLToolbarItem::render(unsigned int tex_id, float left, float right, float b
|
||||||
|
|
||||||
GLTexture::render_sub_texture(tex_id, left, right, bottom, top, uvs(tex_width, tex_height, icon_size));
|
GLTexture::render_sub_texture(tex_id, left, right, bottom, top, uvs(tex_width, tex_height, icon_size));
|
||||||
|
|
||||||
if (is_pressed())
|
if (is_pressed()) {
|
||||||
{
|
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||||
if ((m_last_action_type == Left) && m_data.left.can_render())
|
const Size cnv_size = parent.get_canvas_size();
|
||||||
|
const float cnv_w = (float)cnv_size.get_width();
|
||||||
|
const float cnv_h = (float)cnv_size.get_height();
|
||||||
|
|
||||||
|
const float out_left = (0.5f * left + 0.5f) * cnv_w;
|
||||||
|
const float out_right = (0.5f * right + 0.5f) * cnv_w;
|
||||||
|
const float out_top = (0.5f * top + 0.5f) * cnv_h;
|
||||||
|
const float out_bottom = (0.5f * bottom + 0.5f) * cnv_h;
|
||||||
|
if (m_last_action_type == Left && m_data.left.can_render())
|
||||||
|
m_data.left.render_callback(out_left, out_right, out_bottom, out_top);
|
||||||
|
else if (m_last_action_type == Right && m_data.right.can_render())
|
||||||
|
m_data.right.render_callback(out_left, out_right, out_bottom, out_top);
|
||||||
|
#else
|
||||||
|
if (m_last_action_type == Left && m_data.left.can_render())
|
||||||
m_data.left.render_callback(left, right, bottom, top);
|
m_data.left.render_callback(left, right, bottom, top);
|
||||||
else if ((m_last_action_type == Right) && m_data.right.can_render())
|
else if (m_last_action_type == Right && m_data.right.can_render())
|
||||||
m_data.right.render_callback(left, right, bottom, top);
|
m_data.right.render_callback(left, right, bottom, top);
|
||||||
|
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1756,7 +1773,11 @@ void GLToolbar::render_horizontal(const GLCanvas3D& parent)
|
||||||
if (item->is_separator())
|
if (item->is_separator())
|
||||||
left += separator_stride;
|
left += separator_stride;
|
||||||
else {
|
else {
|
||||||
|
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||||
|
item->render(parent, tex_id, left, left + icons_size_x, top - icons_size_y, top, (unsigned int)tex_width, (unsigned int)tex_height, (unsigned int)(m_layout.icons_size * m_layout.scale));
|
||||||
|
#else
|
||||||
item->render(tex_id, left, left + icons_size_x, top - icons_size_y, top, (unsigned int)tex_width, (unsigned int)tex_height, (unsigned int)(m_layout.icons_size * m_layout.scale));
|
item->render(tex_id, left, left + icons_size_x, top - icons_size_y, top, (unsigned int)tex_width, (unsigned int)tex_height, (unsigned int)(m_layout.icons_size * m_layout.scale));
|
||||||
|
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||||
left += icon_stride;
|
left += icon_stride;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1811,7 +1832,11 @@ void GLToolbar::render_vertical(const GLCanvas3D& parent)
|
||||||
if (item->is_separator())
|
if (item->is_separator())
|
||||||
top -= separator_stride;
|
top -= separator_stride;
|
||||||
else {
|
else {
|
||||||
|
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||||
|
item->render(parent, tex_id, left, left + icons_size_x, top - icons_size_y, top, (unsigned int)tex_width, (unsigned int)tex_height, (unsigned int)(m_layout.icons_size * m_layout.scale));
|
||||||
|
#else
|
||||||
item->render(tex_id, left, left + icons_size_x, top - icons_size_y, top, (unsigned int)tex_width, (unsigned int)tex_height, (unsigned int)(m_layout.icons_size * m_layout.scale));
|
item->render(tex_id, left, left + icons_size_x, top - icons_size_y, top, (unsigned int)tex_width, (unsigned int)tex_height, (unsigned int)(m_layout.icons_size * m_layout.scale));
|
||||||
|
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||||
top -= icon_stride;
|
top -= icon_stride;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -153,7 +153,12 @@ public:
|
||||||
// returns true if the state changes
|
// returns true if the state changes
|
||||||
bool update_enabled_state();
|
bool update_enabled_state();
|
||||||
|
|
||||||
|
#if ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||||
|
void render(const GLCanvas3D& parent, unsigned int tex_id, float left, float right, float bottom, float top, unsigned int tex_width, unsigned int tex_height, unsigned int icon_size) const;
|
||||||
|
#else
|
||||||
void render(unsigned int tex_id, float left, float right, float bottom, float top, unsigned int tex_width, unsigned int tex_height, unsigned int icon_size) const;
|
void render(unsigned int tex_id, float left, float right, float bottom, float top, unsigned int tex_width, unsigned int tex_height, unsigned int icon_size) const;
|
||||||
|
#endif // ENABLE_GLBEGIN_GLEND_SHADERS_ATTRIBUTES
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void set_visible(bool visible) { m_data.visible = visible; }
|
void set_visible(bool visible) { m_data.visible = visible; }
|
||||||
|
|
||||||
|
|
|
@ -802,7 +802,7 @@ void GLGizmosManager::render_arrow(const GLCanvas3D& parent, EType highlighted_t
|
||||||
const float inv_cnv_h = 1.0f / cnv_h;
|
const float inv_cnv_h = 1.0f / cnv_h;
|
||||||
|
|
||||||
const float top_x = -1.0f;
|
const float top_x = -1.0f;
|
||||||
float top_y = 0.5f * 2.0f * get_scaled_total_height() * inv_cnv_h;
|
float top_y = get_scaled_total_height() * inv_cnv_h;
|
||||||
|
|
||||||
const float icons_size_x = 2.0f * m_layout.scaled_icons_size() * inv_cnv_w;
|
const float icons_size_x = 2.0f * m_layout.scaled_icons_size() * inv_cnv_w;
|
||||||
const float icons_size_y = 2.0f * m_layout.scaled_icons_size() * inv_cnv_h;
|
const float icons_size_y = 2.0f * m_layout.scaled_icons_size() * inv_cnv_h;
|
||||||
|
@ -936,15 +936,13 @@ void GLGizmosManager::do_render_overlay() const
|
||||||
if (idx == m_current || current_y == FLT_MAX) {
|
if (idx == m_current || current_y == FLT_MAX) {
|
||||||
// The FLT_MAX trick is here so that even non-selectable but activable
|
// The FLT_MAX trick is here so that even non-selectable but activable
|
||||||
// gizmos are passed some meaningful value.
|
// gizmos are passed some meaningful value.
|
||||||
current_y = 0.5f * cnv_h - top_y;
|
current_y = 0.5f * cnv_h - 0.5f * top_y * cnv_h;
|
||||||
}
|
}
|
||||||
top_y -= stride_y;
|
top_y -= stride_y;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_current != Undefined) {
|
if (m_current != Undefined)
|
||||||
const float toolbar_top = cnv_h - wxGetApp().plater()->get_view_toolbar().get_height();
|
m_gizmos[m_current]->render_input_window(get_scaled_total_width(), current_y, cnv_h - wxGetApp().plater()->get_view_toolbar().get_height());
|
||||||
m_gizmos[m_current]->render_input_window(width, current_y, toolbar_top);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
void GLGizmosManager::do_render_overlay() const
|
void GLGizmosManager::do_render_overlay() const
|
||||||
|
|
Loading…
Reference in a new issue