Reworked rendering of toolbars background texture
This commit is contained in:
parent
99e2fe20a5
commit
33c0683d11
@ -3564,7 +3564,8 @@ bool GLCanvas3D::_init_main_toolbar()
|
||||
|
||||
// m_main_toolbar.set_layout_type(GLToolbar::Layout::Vertical);
|
||||
m_main_toolbar.set_layout_type(GLToolbar::Layout::Horizontal);
|
||||
m_main_toolbar.set_layout_orientation(GLToolbar::Layout::Top);
|
||||
m_main_toolbar.set_horizontal_orientation(GLToolbar::Layout::HO_Right);
|
||||
m_main_toolbar.set_vertical_orientation(GLToolbar::Layout::VO_Top);
|
||||
m_main_toolbar.set_border(5.0f);
|
||||
m_main_toolbar.set_separator_size(5);
|
||||
m_main_toolbar.set_gap_size(2);
|
||||
@ -3712,7 +3713,8 @@ bool GLCanvas3D::_init_undoredo_toolbar()
|
||||
|
||||
// m_undoredo_toolbar.set_layout_type(GLToolbar::Layout::Vertical);
|
||||
m_undoredo_toolbar.set_layout_type(GLToolbar::Layout::Horizontal);
|
||||
m_undoredo_toolbar.set_layout_orientation(GLToolbar::Layout::Top);
|
||||
m_undoredo_toolbar.set_horizontal_orientation(GLToolbar::Layout::HO_Left);
|
||||
m_undoredo_toolbar.set_vertical_orientation(GLToolbar::Layout::VO_Top);
|
||||
m_undoredo_toolbar.set_border(5.0f);
|
||||
m_undoredo_toolbar.set_separator_size(5);
|
||||
m_undoredo_toolbar.set_gap_size(2);
|
||||
|
@ -131,7 +131,8 @@ const float GLToolbar::Default_Icons_Size = 40.0f;
|
||||
|
||||
GLToolbar::Layout::Layout()
|
||||
: type(Horizontal)
|
||||
, orientation(Center)
|
||||
, horizontal_orientation(HO_Center)
|
||||
, vertical_orientation(VO_Center)
|
||||
, top(0.0f)
|
||||
, left(0.0f)
|
||||
, border(0.0f)
|
||||
@ -191,16 +192,6 @@ void GLToolbar::set_layout_type(GLToolbar::Layout::EType type)
|
||||
m_layout.dirty = true;
|
||||
}
|
||||
|
||||
GLToolbar::Layout::EOrientation GLToolbar::get_layout_orientation() const
|
||||
{
|
||||
return m_layout.orientation;
|
||||
}
|
||||
|
||||
void GLToolbar::set_layout_orientation(GLToolbar::Layout::EOrientation orientation)
|
||||
{
|
||||
m_layout.orientation = orientation;
|
||||
}
|
||||
|
||||
void GLToolbar::set_position(float top, float left)
|
||||
{
|
||||
m_layout.top = top;
|
||||
@ -969,6 +960,84 @@ int GLToolbar::contains_mouse_vertical(const Vec2d& mouse_pos, const GLCanvas3D&
|
||||
return -1;
|
||||
}
|
||||
|
||||
void GLToolbar::render_background(float left, float top, float right, float bottom, float border) const
|
||||
{
|
||||
unsigned int tex_id = m_background_texture.texture.get_id();
|
||||
float tex_width = (float)m_background_texture.texture.get_width();
|
||||
float tex_height = (float)m_background_texture.texture.get_height();
|
||||
if ((tex_id != 0) && (tex_width > 0) && (tex_height > 0))
|
||||
{
|
||||
float inv_tex_width = (tex_width != 0.0f) ? 1.0f / tex_width : 0.0f;
|
||||
float inv_tex_height = (tex_height != 0.0f) ? 1.0f / tex_height : 0.0f;
|
||||
|
||||
float internal_left = left + border;
|
||||
float internal_right = right - border;
|
||||
float internal_top = top - border;
|
||||
float internal_bottom = bottom + border;
|
||||
|
||||
float left_uv = 0.0f;
|
||||
float right_uv = 1.0f;
|
||||
float top_uv = 1.0f;
|
||||
float bottom_uv = 0.0f;
|
||||
|
||||
float internal_left_uv = (float)m_background_texture.metadata.left * inv_tex_width;
|
||||
float internal_right_uv = 1.0f - (float)m_background_texture.metadata.right * inv_tex_width;
|
||||
float internal_top_uv = 1.0f - (float)m_background_texture.metadata.top * inv_tex_height;
|
||||
float internal_bottom_uv = (float)m_background_texture.metadata.bottom * inv_tex_height;
|
||||
|
||||
// top-left corner
|
||||
if ((m_layout.horizontal_orientation == Layout::HO_Left) || (m_layout.vertical_orientation == Layout::VO_Top))
|
||||
GLTexture::render_sub_texture(tex_id, left, internal_left, internal_top, top, { { internal_left_uv, internal_bottom_uv }, { internal_right_uv, internal_bottom_uv }, { internal_right_uv, internal_top_uv }, { internal_left_uv, internal_top_uv } });
|
||||
else
|
||||
GLTexture::render_sub_texture(tex_id, left, internal_left, internal_top, top, { { left_uv, internal_top_uv }, { internal_left_uv, internal_top_uv }, { internal_left_uv, top_uv }, { left_uv, top_uv } });
|
||||
|
||||
// top edge
|
||||
if (m_layout.vertical_orientation == Layout::VO_Top)
|
||||
GLTexture::render_sub_texture(tex_id, internal_left, internal_right, internal_top, top, { { internal_left_uv, internal_bottom_uv }, { internal_right_uv, internal_bottom_uv }, { internal_right_uv, internal_top_uv }, { internal_left_uv, internal_top_uv } });
|
||||
else
|
||||
GLTexture::render_sub_texture(tex_id, internal_left, internal_right, internal_top, top, { { internal_left_uv, internal_top_uv }, { internal_right_uv, internal_top_uv }, { internal_right_uv, top_uv }, { internal_left_uv, top_uv } });
|
||||
|
||||
// top-right corner
|
||||
if ((m_layout.horizontal_orientation == Layout::HO_Right) || (m_layout.vertical_orientation == Layout::VO_Top))
|
||||
GLTexture::render_sub_texture(tex_id, internal_right, right, internal_top, top, { { internal_left_uv, internal_bottom_uv }, { internal_right_uv, internal_bottom_uv }, { internal_right_uv, internal_top_uv }, { internal_left_uv, internal_top_uv } });
|
||||
else
|
||||
GLTexture::render_sub_texture(tex_id, internal_right, right, internal_top, top, { { internal_right_uv, internal_top_uv }, { right_uv, internal_top_uv }, { right_uv, top_uv }, { internal_right_uv, top_uv } });
|
||||
|
||||
// center-left edge
|
||||
if (m_layout.horizontal_orientation == Layout::HO_Left)
|
||||
GLTexture::render_sub_texture(tex_id, left, internal_left, internal_bottom, internal_top, { { internal_left_uv, internal_bottom_uv }, { internal_right_uv, internal_bottom_uv }, { internal_right_uv, internal_top_uv }, { internal_left_uv, internal_top_uv } });
|
||||
else
|
||||
GLTexture::render_sub_texture(tex_id, left, internal_left, internal_bottom, internal_top, { { left_uv, internal_bottom_uv }, { internal_left_uv, internal_bottom_uv }, { internal_left_uv, internal_top_uv }, { left_uv, internal_top_uv } });
|
||||
|
||||
// center
|
||||
GLTexture::render_sub_texture(tex_id, internal_left, internal_right, internal_bottom, internal_top, { { internal_left_uv, internal_bottom_uv }, { internal_right_uv, internal_bottom_uv }, { internal_right_uv, internal_top_uv }, { internal_left_uv, internal_top_uv } });
|
||||
|
||||
// center-right edge
|
||||
if (m_layout.horizontal_orientation == Layout::HO_Right)
|
||||
GLTexture::render_sub_texture(tex_id, internal_right, right, internal_bottom, internal_top, { { internal_left_uv, internal_bottom_uv }, { internal_right_uv, internal_bottom_uv }, { internal_right_uv, internal_top_uv }, { internal_left_uv, internal_top_uv } });
|
||||
else
|
||||
GLTexture::render_sub_texture(tex_id, internal_right, right, internal_bottom, internal_top, { { internal_right_uv, internal_bottom_uv }, { right_uv, internal_bottom_uv }, { right_uv, internal_top_uv }, { internal_right_uv, internal_top_uv } });
|
||||
|
||||
// bottom-left corner
|
||||
if ((m_layout.horizontal_orientation == Layout::HO_Left) || (m_layout.vertical_orientation == Layout::VO_Bottom))
|
||||
GLTexture::render_sub_texture(tex_id, left, internal_left, bottom, internal_bottom, { { internal_left_uv, internal_bottom_uv }, { internal_right_uv, internal_bottom_uv }, { internal_right_uv, internal_top_uv }, { internal_left_uv, internal_top_uv } });
|
||||
else
|
||||
GLTexture::render_sub_texture(tex_id, left, internal_left, bottom, internal_bottom, { { left_uv, bottom_uv }, { internal_left_uv, bottom_uv }, { internal_left_uv, internal_bottom_uv }, { left_uv, internal_bottom_uv } });
|
||||
|
||||
// bottom edge
|
||||
if (m_layout.vertical_orientation == Layout::VO_Bottom)
|
||||
GLTexture::render_sub_texture(tex_id, internal_left, internal_right, bottom, internal_bottom, { { internal_left_uv, internal_bottom_uv }, { internal_right_uv, internal_bottom_uv }, { internal_right_uv, internal_top_uv }, { internal_left_uv, internal_top_uv } });
|
||||
else
|
||||
GLTexture::render_sub_texture(tex_id, internal_left, internal_right, bottom, internal_bottom, { { internal_left_uv, bottom_uv }, { internal_right_uv, bottom_uv }, { internal_right_uv, internal_bottom_uv }, { internal_left_uv, internal_bottom_uv } });
|
||||
|
||||
// bottom-right corner
|
||||
if ((m_layout.horizontal_orientation == Layout::HO_Right) || (m_layout.vertical_orientation == Layout::VO_Bottom))
|
||||
GLTexture::render_sub_texture(tex_id, internal_right, right, bottom, internal_bottom, { { internal_left_uv, internal_bottom_uv }, { internal_right_uv, internal_bottom_uv }, { internal_right_uv, internal_top_uv }, { internal_left_uv, internal_top_uv } });
|
||||
else
|
||||
GLTexture::render_sub_texture(tex_id, internal_right, right, bottom, internal_bottom, { { internal_right_uv, bottom_uv }, { right_uv, bottom_uv }, { right_uv, internal_bottom_uv }, { internal_right_uv, internal_bottom_uv } });
|
||||
}
|
||||
}
|
||||
|
||||
void GLToolbar::render_horizontal(const GLCanvas3D& parent) const
|
||||
{
|
||||
unsigned int tex_id = m_icons_texture.get_id();
|
||||
@ -994,85 +1063,7 @@ void GLToolbar::render_horizontal(const GLCanvas3D& parent) const
|
||||
float right = left + scaled_width;
|
||||
float bottom = top - scaled_height;
|
||||
|
||||
// renders background
|
||||
unsigned int bg_tex_id = m_background_texture.texture.get_id();
|
||||
float bg_tex_width = (float)m_background_texture.texture.get_width();
|
||||
float bg_tex_height = (float)m_background_texture.texture.get_height();
|
||||
if ((bg_tex_id != 0) && (bg_tex_width > 0) && (bg_tex_height > 0))
|
||||
{
|
||||
float inv_bg_tex_width = (bg_tex_width != 0.0f) ? 1.0f / bg_tex_width : 0.0f;
|
||||
float inv_bg_tex_height = (bg_tex_height != 0.0f) ? 1.0f / bg_tex_height : 0.0f;
|
||||
|
||||
float bg_uv_left = 0.0f;
|
||||
float bg_uv_right = 1.0f;
|
||||
float bg_uv_top = 1.0f;
|
||||
float bg_uv_bottom = 0.0f;
|
||||
|
||||
float bg_left = left;
|
||||
float bg_right = right;
|
||||
float bg_top = top;
|
||||
float bg_bottom = bottom;
|
||||
|
||||
float bg_uv_i_left = (float)m_background_texture.metadata.left * inv_bg_tex_width;
|
||||
float bg_uv_i_right = 1.0f - (float)m_background_texture.metadata.right * inv_bg_tex_width;
|
||||
float bg_uv_i_top = 1.0f - (float)m_background_texture.metadata.top * inv_bg_tex_height;
|
||||
float bg_uv_i_bottom = (float)m_background_texture.metadata.bottom * inv_bg_tex_height;
|
||||
|
||||
float bg_i_left = bg_left + scaled_border;
|
||||
float bg_i_right = bg_right - scaled_border;
|
||||
float bg_i_top = bg_top - scaled_border;
|
||||
float bg_i_bottom = bg_bottom + scaled_border;
|
||||
|
||||
switch (m_layout.orientation)
|
||||
{
|
||||
case Layout::Top:
|
||||
{
|
||||
bg_uv_top = bg_uv_i_top;
|
||||
bg_i_top = bg_top;
|
||||
break;
|
||||
}
|
||||
case Layout::Bottom:
|
||||
{
|
||||
bg_uv_bottom = bg_uv_i_bottom;
|
||||
bg_i_bottom = bg_bottom;
|
||||
break;
|
||||
}
|
||||
case Layout::Center:
|
||||
{
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
if ((m_layout.border > 0) && (bg_uv_top != bg_uv_i_top))
|
||||
{
|
||||
if (bg_uv_left != bg_uv_i_left)
|
||||
GLTexture::render_sub_texture(bg_tex_id, bg_left, bg_i_left, bg_i_top, bg_top, { { bg_uv_left, bg_uv_i_top }, { bg_uv_i_left, bg_uv_i_top }, { bg_uv_i_left, bg_uv_top }, { bg_uv_left, bg_uv_top } });
|
||||
|
||||
GLTexture::render_sub_texture(bg_tex_id, bg_i_left, bg_i_right, bg_i_top, bg_top, { { bg_uv_i_left, bg_uv_i_top }, { bg_uv_i_right, bg_uv_i_top }, { bg_uv_i_right, bg_uv_top }, { bg_uv_i_left, bg_uv_top } });
|
||||
|
||||
if (bg_uv_right != bg_uv_i_right)
|
||||
GLTexture::render_sub_texture(bg_tex_id, bg_i_right, bg_right, bg_i_top, bg_top, { { bg_uv_i_right, bg_uv_i_top }, { bg_uv_right, bg_uv_i_top }, { bg_uv_right, bg_uv_top }, { bg_uv_i_right, bg_uv_top } });
|
||||
}
|
||||
|
||||
if ((m_layout.border > 0) && (bg_uv_left != bg_uv_i_left))
|
||||
GLTexture::render_sub_texture(bg_tex_id, bg_left, bg_i_left, bg_i_bottom, bg_i_top, { { bg_uv_left, bg_uv_i_bottom }, { bg_uv_i_left, bg_uv_i_bottom }, { bg_uv_i_left, bg_uv_i_top }, { bg_uv_left, bg_uv_i_top } });
|
||||
|
||||
GLTexture::render_sub_texture(bg_tex_id, bg_i_left, bg_i_right, bg_i_bottom, bg_i_top, { { bg_uv_i_left, bg_uv_i_bottom }, { bg_uv_i_right, bg_uv_i_bottom }, { bg_uv_i_right, bg_uv_i_top }, { bg_uv_i_left, bg_uv_i_top } });
|
||||
|
||||
if ((m_layout.border > 0) && (bg_uv_right != bg_uv_i_right))
|
||||
GLTexture::render_sub_texture(bg_tex_id, bg_i_right, bg_right, bg_i_bottom, bg_i_top, { { bg_uv_i_right, bg_uv_i_bottom }, { bg_uv_right, bg_uv_i_bottom }, { bg_uv_right, bg_uv_i_top }, { bg_uv_i_right, bg_uv_i_top } });
|
||||
|
||||
if ((m_layout.border > 0) && (bg_uv_bottom != bg_uv_i_bottom))
|
||||
{
|
||||
if (bg_uv_left != bg_uv_i_left)
|
||||
GLTexture::render_sub_texture(bg_tex_id, bg_left, bg_i_left, bg_bottom, bg_i_bottom, { { bg_uv_left, bg_uv_bottom }, { bg_uv_i_left, bg_uv_bottom }, { bg_uv_i_left, bg_uv_i_bottom }, { bg_uv_left, bg_uv_i_bottom } });
|
||||
|
||||
GLTexture::render_sub_texture(bg_tex_id, bg_i_left, bg_i_right, bg_bottom, bg_i_bottom, { { bg_uv_i_left, bg_uv_bottom }, { bg_uv_i_right, bg_uv_bottom }, { bg_uv_i_right, bg_uv_i_bottom }, { bg_uv_i_left, bg_uv_i_bottom } });
|
||||
|
||||
if (bg_uv_right != bg_uv_i_right)
|
||||
GLTexture::render_sub_texture(bg_tex_id, bg_i_right, bg_right, bg_bottom, bg_i_bottom, { { bg_uv_i_right, bg_uv_bottom }, { bg_uv_right, bg_uv_bottom }, { bg_uv_right, bg_uv_i_bottom }, { bg_uv_i_right, bg_uv_i_bottom } });
|
||||
}
|
||||
}
|
||||
render_background(left, top, right, bottom, scaled_border);
|
||||
|
||||
left += scaled_border;
|
||||
top -= scaled_border;
|
||||
@ -1121,85 +1112,7 @@ void GLToolbar::render_vertical(const GLCanvas3D& parent) const
|
||||
float right = left + scaled_width;
|
||||
float bottom = top - scaled_height;
|
||||
|
||||
// renders background
|
||||
unsigned int bg_tex_id = m_background_texture.texture.get_id();
|
||||
float bg_tex_width = (float)m_background_texture.texture.get_width();
|
||||
float bg_tex_height = (float)m_background_texture.texture.get_height();
|
||||
if ((bg_tex_id != 0) && (bg_tex_width > 0) && (bg_tex_height > 0))
|
||||
{
|
||||
float inv_bg_tex_width = (bg_tex_width != 0.0f) ? 1.0f / bg_tex_width : 0.0f;
|
||||
float inv_bg_tex_height = (bg_tex_height != 0.0f) ? 1.0f / bg_tex_height : 0.0f;
|
||||
|
||||
float bg_uv_left = 0.0f;
|
||||
float bg_uv_right = 1.0f;
|
||||
float bg_uv_top = 1.0f;
|
||||
float bg_uv_bottom = 0.0f;
|
||||
|
||||
float bg_left = left;
|
||||
float bg_right = right;
|
||||
float bg_top = top;
|
||||
float bg_bottom = bottom;
|
||||
|
||||
float bg_uv_i_left = (float)m_background_texture.metadata.left * inv_bg_tex_width;
|
||||
float bg_uv_i_right = 1.0f - (float)m_background_texture.metadata.right * inv_bg_tex_width;
|
||||
float bg_uv_i_top = 1.0f - (float)m_background_texture.metadata.top * inv_bg_tex_height;
|
||||
float bg_uv_i_bottom = (float)m_background_texture.metadata.bottom * inv_bg_tex_height;
|
||||
|
||||
float bg_i_left = bg_left + scaled_border;
|
||||
float bg_i_right = bg_right - scaled_border;
|
||||
float bg_i_top = bg_top - scaled_border;
|
||||
float bg_i_bottom = bg_bottom + scaled_border;
|
||||
|
||||
switch (m_layout.orientation)
|
||||
{
|
||||
case Layout::Left:
|
||||
{
|
||||
bg_uv_left = bg_uv_i_left;
|
||||
bg_i_left = bg_left;
|
||||
break;
|
||||
}
|
||||
case Layout::Right:
|
||||
{
|
||||
bg_uv_right = bg_uv_i_right;
|
||||
bg_i_right = bg_right;
|
||||
break;
|
||||
}
|
||||
case Layout::Center:
|
||||
{
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
if ((m_layout.border > 0) && (bg_uv_top != bg_uv_i_top))
|
||||
{
|
||||
if (bg_uv_left != bg_uv_i_left)
|
||||
GLTexture::render_sub_texture(bg_tex_id, bg_left, bg_i_left, bg_i_top, bg_top, { { bg_uv_left, bg_uv_i_top }, { bg_uv_i_left, bg_uv_i_top }, { bg_uv_i_left, bg_uv_top }, { bg_uv_left, bg_uv_top } });
|
||||
|
||||
GLTexture::render_sub_texture(bg_tex_id, bg_i_left, bg_i_right, bg_i_top, bg_top, { { bg_uv_i_left, bg_uv_i_top }, { bg_uv_i_right, bg_uv_i_top }, { bg_uv_i_right, bg_uv_top }, { bg_uv_i_left, bg_uv_top } });
|
||||
|
||||
if (bg_uv_right != bg_uv_i_right)
|
||||
GLTexture::render_sub_texture(bg_tex_id, bg_i_right, bg_right, bg_i_top, bg_top, { { bg_uv_i_right, bg_uv_i_top }, { bg_uv_right, bg_uv_i_top }, { bg_uv_right, bg_uv_top }, { bg_uv_i_right, bg_uv_top } });
|
||||
}
|
||||
|
||||
if ((m_layout.border > 0) && (bg_uv_left != bg_uv_i_left))
|
||||
GLTexture::render_sub_texture(bg_tex_id, bg_left, bg_i_left, bg_i_bottom, bg_i_top, { { bg_uv_left, bg_uv_i_bottom }, { bg_uv_i_left, bg_uv_i_bottom }, { bg_uv_i_left, bg_uv_i_top }, { bg_uv_left, bg_uv_i_top } });
|
||||
|
||||
GLTexture::render_sub_texture(bg_tex_id, bg_i_left, bg_i_right, bg_i_bottom, bg_i_top, { { bg_uv_i_left, bg_uv_i_bottom }, { bg_uv_i_right, bg_uv_i_bottom }, { bg_uv_i_right, bg_uv_i_top }, { bg_uv_i_left, bg_uv_i_top } });
|
||||
|
||||
if ((m_layout.border > 0) && (bg_uv_right != bg_uv_i_right))
|
||||
GLTexture::render_sub_texture(bg_tex_id, bg_i_right, bg_right, bg_i_bottom, bg_i_top, { { bg_uv_i_right, bg_uv_i_bottom }, { bg_uv_right, bg_uv_i_bottom }, { bg_uv_right, bg_uv_i_top }, { bg_uv_i_right, bg_uv_i_top } });
|
||||
|
||||
if ((m_layout.border > 0) && (bg_uv_bottom != bg_uv_i_bottom))
|
||||
{
|
||||
if (bg_uv_left != bg_uv_i_left)
|
||||
GLTexture::render_sub_texture(bg_tex_id, bg_left, bg_i_left, bg_bottom, bg_i_bottom, { { bg_uv_left, bg_uv_bottom }, { bg_uv_i_left, bg_uv_bottom }, { bg_uv_i_left, bg_uv_i_bottom }, { bg_uv_left, bg_uv_i_bottom } });
|
||||
|
||||
GLTexture::render_sub_texture(bg_tex_id, bg_i_left, bg_i_right, bg_bottom, bg_i_bottom, { { bg_uv_i_left, bg_uv_bottom }, { bg_uv_i_right, bg_uv_bottom }, { bg_uv_i_right, bg_uv_i_bottom }, { bg_uv_i_left, bg_uv_i_bottom } });
|
||||
|
||||
if (bg_uv_right != bg_uv_i_right)
|
||||
GLTexture::render_sub_texture(bg_tex_id, bg_i_right, bg_right, bg_bottom, bg_i_bottom, { { bg_uv_i_right, bg_uv_bottom }, { bg_uv_right, bg_uv_bottom }, { bg_uv_right, bg_uv_i_bottom }, { bg_uv_i_right, bg_uv_i_bottom } });
|
||||
}
|
||||
}
|
||||
render_background(left, top, right, bottom, scaled_border);
|
||||
|
||||
left += scaled_border;
|
||||
top -= scaled_border;
|
||||
|
@ -189,18 +189,25 @@ public:
|
||||
Num_Types
|
||||
};
|
||||
|
||||
enum EOrientation : unsigned int
|
||||
enum EHorizontalOrientation : unsigned char
|
||||
{
|
||||
Top,
|
||||
Bottom,
|
||||
Left,
|
||||
Right,
|
||||
Center,
|
||||
Num_Locations
|
||||
HO_Left,
|
||||
HO_Center,
|
||||
HO_Right,
|
||||
Num_Horizontal_Orientations
|
||||
};
|
||||
|
||||
enum EVerticalOrientation : unsigned char
|
||||
{
|
||||
VO_Top,
|
||||
VO_Center,
|
||||
VO_Bottom,
|
||||
Num_Vertical_Orientations
|
||||
};
|
||||
|
||||
EType type;
|
||||
EOrientation orientation;
|
||||
EHorizontalOrientation horizontal_orientation;
|
||||
EVerticalOrientation vertical_orientation;
|
||||
float top;
|
||||
float left;
|
||||
float border;
|
||||
@ -254,8 +261,10 @@ public:
|
||||
|
||||
Layout::EType get_layout_type() const;
|
||||
void set_layout_type(Layout::EType type);
|
||||
Layout::EOrientation get_layout_orientation() const;
|
||||
void set_layout_orientation(Layout::EOrientation orientation);
|
||||
Layout::EHorizontalOrientation get_horizontal_orientation() const { return m_layout.horizontal_orientation; }
|
||||
void set_horizontal_orientation(Layout::EHorizontalOrientation orientation) { m_layout.horizontal_orientation = orientation; }
|
||||
Layout::EVerticalOrientation get_vertical_orientation() const { return m_layout.vertical_orientation; }
|
||||
void set_vertical_orientation(Layout::EVerticalOrientation orientation) { m_layout.vertical_orientation = orientation; }
|
||||
|
||||
void set_position(float top, float left);
|
||||
void set_border(float border);
|
||||
@ -311,6 +320,7 @@ private:
|
||||
int contains_mouse_horizontal(const Vec2d& mouse_pos, const GLCanvas3D& parent) const;
|
||||
int contains_mouse_vertical(const Vec2d& mouse_pos, const GLCanvas3D& parent) const;
|
||||
|
||||
void render_background(float left, float top, float right, float bottom, float border) const;
|
||||
void render_horizontal(const GLCanvas3D& parent) const;
|
||||
void render_vertical(const GLCanvas3D& parent) const;
|
||||
|
||||
|
@ -879,6 +879,60 @@ void GLGizmosManager::reset()
|
||||
m_gizmos.clear();
|
||||
}
|
||||
|
||||
void GLGizmosManager::render_background(float left, float top, float right, float bottom, float border) const
|
||||
{
|
||||
unsigned int tex_id = m_background_texture.texture.get_id();
|
||||
float tex_width = (float)m_background_texture.texture.get_width();
|
||||
float tex_height = (float)m_background_texture.texture.get_height();
|
||||
if ((tex_id != 0) && (tex_width > 0) && (tex_height > 0))
|
||||
{
|
||||
float inv_tex_width = (tex_width != 0.0f) ? 1.0f / tex_width : 0.0f;
|
||||
float inv_tex_height = (tex_height != 0.0f) ? 1.0f / tex_height : 0.0f;
|
||||
|
||||
float internal_left = left + border;
|
||||
float internal_right = right - border;
|
||||
float internal_top = top - border;
|
||||
float internal_bottom = bottom + border;
|
||||
|
||||
float left_uv = 0.0f;
|
||||
float right_uv = 1.0f;
|
||||
float top_uv = 1.0f;
|
||||
float bottom_uv = 0.0f;
|
||||
|
||||
float internal_left_uv = (float)m_background_texture.metadata.left * inv_tex_width;
|
||||
float internal_right_uv = 1.0f - (float)m_background_texture.metadata.right * inv_tex_width;
|
||||
float internal_top_uv = 1.0f - (float)m_background_texture.metadata.top * inv_tex_height;
|
||||
float internal_bottom_uv = (float)m_background_texture.metadata.bottom * inv_tex_height;
|
||||
|
||||
// top-left corner
|
||||
GLTexture::render_sub_texture(tex_id, left, internal_left, internal_top, top, { { internal_left_uv, internal_bottom_uv }, { internal_right_uv, internal_bottom_uv }, { internal_right_uv, internal_top_uv }, { internal_left_uv, internal_top_uv } });
|
||||
|
||||
// top edge
|
||||
GLTexture::render_sub_texture(tex_id, internal_left, internal_right, internal_top, top, { { internal_left_uv, internal_top_uv }, { internal_right_uv, internal_top_uv }, { internal_right_uv, top_uv }, { internal_left_uv, top_uv } });
|
||||
|
||||
// top-right corner
|
||||
GLTexture::render_sub_texture(tex_id, internal_right, right, internal_top, top, { { internal_right_uv, internal_top_uv }, { right_uv, internal_top_uv }, { right_uv, top_uv }, { internal_right_uv, top_uv } });
|
||||
|
||||
// center-left edge
|
||||
GLTexture::render_sub_texture(tex_id, left, internal_left, internal_bottom, internal_top, { { internal_left_uv, internal_bottom_uv }, { internal_right_uv, internal_bottom_uv }, { internal_right_uv, internal_top_uv }, { internal_left_uv, internal_top_uv } });
|
||||
|
||||
// center
|
||||
GLTexture::render_sub_texture(tex_id, internal_left, internal_right, internal_bottom, internal_top, { { internal_left_uv, internal_bottom_uv }, { internal_right_uv, internal_bottom_uv }, { internal_right_uv, internal_top_uv }, { internal_left_uv, internal_top_uv } });
|
||||
|
||||
// center-right edge
|
||||
GLTexture::render_sub_texture(tex_id, internal_right, right, internal_bottom, internal_top, { { internal_right_uv, internal_bottom_uv }, { right_uv, internal_bottom_uv }, { right_uv, internal_top_uv }, { internal_right_uv, internal_top_uv } });
|
||||
|
||||
// bottom-left corner
|
||||
GLTexture::render_sub_texture(tex_id, left, internal_left, bottom, internal_bottom, { { internal_left_uv, internal_bottom_uv }, { internal_right_uv, internal_bottom_uv }, { internal_right_uv, internal_top_uv }, { internal_left_uv, internal_top_uv } });
|
||||
|
||||
// bottom edge
|
||||
GLTexture::render_sub_texture(tex_id, internal_left, internal_right, bottom, internal_bottom, { { internal_left_uv, bottom_uv }, { internal_right_uv, bottom_uv }, { internal_right_uv, internal_bottom_uv }, { internal_left_uv, internal_bottom_uv } });
|
||||
|
||||
// bottom-right corner
|
||||
GLTexture::render_sub_texture(tex_id, internal_right, right, bottom, internal_bottom, { { internal_right_uv, bottom_uv }, { right_uv, bottom_uv }, { right_uv, internal_bottom_uv }, { internal_right_uv, internal_bottom_uv } });
|
||||
}
|
||||
}
|
||||
|
||||
void GLGizmosManager::do_render_overlay() const
|
||||
{
|
||||
if (m_gizmos.empty())
|
||||
@ -901,71 +955,7 @@ void GLGizmosManager::do_render_overlay() const
|
||||
float right = left + width * inv_zoom;
|
||||
float bottom = top - height * inv_zoom;
|
||||
|
||||
// renders background
|
||||
unsigned int bg_tex_id = m_background_texture.texture.get_id();
|
||||
float bg_tex_width = (float)m_background_texture.texture.get_width();
|
||||
float bg_tex_height = (float)m_background_texture.texture.get_height();
|
||||
if ((bg_tex_id != 0) && (bg_tex_width > 0) && (bg_tex_height > 0))
|
||||
{
|
||||
float inv_bg_tex_width = (bg_tex_width != 0.0f) ? 1.0f / bg_tex_width : 0.0f;
|
||||
float inv_bg_tex_height = (bg_tex_height != 0.0f) ? 1.0f / bg_tex_height : 0.0f;
|
||||
|
||||
float bg_uv_left = 0.0f;
|
||||
float bg_uv_right = 1.0f;
|
||||
float bg_uv_top = 1.0f;
|
||||
float bg_uv_bottom = 0.0f;
|
||||
|
||||
float bg_left = left;
|
||||
float bg_right = right;
|
||||
float bg_top = top;
|
||||
float bg_bottom = bottom;
|
||||
float bg_width = right - left;
|
||||
float bg_height = top - bottom;
|
||||
float bg_min_size = std::min(bg_width, bg_height);
|
||||
|
||||
float bg_uv_i_left = (float)m_background_texture.metadata.left * inv_bg_tex_width;
|
||||
float bg_uv_i_right = 1.0f - (float)m_background_texture.metadata.right * inv_bg_tex_width;
|
||||
float bg_uv_i_top = 1.0f - (float)m_background_texture.metadata.top * inv_bg_tex_height;
|
||||
float bg_uv_i_bottom = (float)m_background_texture.metadata.bottom * inv_bg_tex_height;
|
||||
|
||||
float bg_i_left = bg_left + scaled_border;
|
||||
float bg_i_right = bg_right - scaled_border;
|
||||
float bg_i_top = bg_top - scaled_border;
|
||||
float bg_i_bottom = bg_bottom + scaled_border;
|
||||
|
||||
bg_uv_left = bg_uv_i_left;
|
||||
bg_i_left = bg_left;
|
||||
|
||||
if ((m_overlay_border > 0) && (bg_uv_top != bg_uv_i_top))
|
||||
{
|
||||
if (bg_uv_left != bg_uv_i_left)
|
||||
GLTexture::render_sub_texture(bg_tex_id, bg_left, bg_i_left, bg_i_top, bg_top, { { bg_uv_left, bg_uv_i_top }, { bg_uv_i_left, bg_uv_i_top }, { bg_uv_i_left, bg_uv_top }, { bg_uv_left, bg_uv_top } });
|
||||
|
||||
GLTexture::render_sub_texture(bg_tex_id, bg_i_left, bg_i_right, bg_i_top, bg_top, { { bg_uv_i_left, bg_uv_i_top }, { bg_uv_i_right, bg_uv_i_top }, { bg_uv_i_right, bg_uv_top }, { bg_uv_i_left, bg_uv_top } });
|
||||
|
||||
if (bg_uv_right != bg_uv_i_right)
|
||||
GLTexture::render_sub_texture(bg_tex_id, bg_i_right, bg_right, bg_i_top, bg_top, { { bg_uv_i_right, bg_uv_i_top }, { bg_uv_right, bg_uv_i_top }, { bg_uv_right, bg_uv_top }, { bg_uv_i_right, bg_uv_top } });
|
||||
}
|
||||
|
||||
if ((m_overlay_border > 0) && (bg_uv_left != bg_uv_i_left))
|
||||
GLTexture::render_sub_texture(bg_tex_id, bg_left, bg_i_left, bg_i_bottom, bg_i_top, { { bg_uv_left, bg_uv_i_bottom }, { bg_uv_i_left, bg_uv_i_bottom }, { bg_uv_i_left, bg_uv_i_top }, { bg_uv_left, bg_uv_i_top } });
|
||||
|
||||
GLTexture::render_sub_texture(bg_tex_id, bg_i_left, bg_i_right, bg_i_bottom, bg_i_top, { { bg_uv_i_left, bg_uv_i_bottom }, { bg_uv_i_right, bg_uv_i_bottom }, { bg_uv_i_right, bg_uv_i_top }, { bg_uv_i_left, bg_uv_i_top } });
|
||||
|
||||
if ((m_overlay_border > 0) && (bg_uv_right != bg_uv_i_right))
|
||||
GLTexture::render_sub_texture(bg_tex_id, bg_i_right, bg_right, bg_i_bottom, bg_i_top, { { bg_uv_i_right, bg_uv_i_bottom }, { bg_uv_right, bg_uv_i_bottom }, { bg_uv_right, bg_uv_i_top }, { bg_uv_i_right, bg_uv_i_top } });
|
||||
|
||||
if ((m_overlay_border > 0) && (bg_uv_bottom != bg_uv_i_bottom))
|
||||
{
|
||||
if (bg_uv_left != bg_uv_i_left)
|
||||
GLTexture::render_sub_texture(bg_tex_id, bg_left, bg_i_left, bg_bottom, bg_i_bottom, { { bg_uv_left, bg_uv_bottom }, { bg_uv_i_left, bg_uv_bottom }, { bg_uv_i_left, bg_uv_i_bottom }, { bg_uv_left, bg_uv_i_bottom } });
|
||||
|
||||
GLTexture::render_sub_texture(bg_tex_id, bg_i_left, bg_i_right, bg_bottom, bg_i_bottom, { { bg_uv_i_left, bg_uv_bottom }, { bg_uv_i_right, bg_uv_bottom }, { bg_uv_i_right, bg_uv_i_bottom }, { bg_uv_i_left, bg_uv_i_bottom } });
|
||||
|
||||
if (bg_uv_right != bg_uv_i_right)
|
||||
GLTexture::render_sub_texture(bg_tex_id, bg_i_right, bg_right, bg_bottom, bg_i_bottom, { { bg_uv_i_right, bg_uv_bottom }, { bg_uv_right, bg_uv_bottom }, { bg_uv_right, bg_uv_i_bottom }, { bg_uv_i_right, bg_uv_i_bottom } });
|
||||
}
|
||||
}
|
||||
render_background(left, top, right, bottom, scaled_border);
|
||||
|
||||
top_x += scaled_border;
|
||||
top_y -= scaled_border;
|
||||
|
@ -187,6 +187,7 @@ public:
|
||||
private:
|
||||
void reset();
|
||||
|
||||
void render_background(float left, float top, float right, float bottom, float border) const;
|
||||
void do_render_overlay() const;
|
||||
|
||||
float get_total_overlay_height() const;
|
||||
|
@ -3422,7 +3422,8 @@ void Plater::priv::init_view_toolbar()
|
||||
if (!view_toolbar.init(background_data))
|
||||
return;
|
||||
|
||||
view_toolbar.set_layout_orientation(GLToolbar::Layout::Bottom);
|
||||
view_toolbar.set_horizontal_orientation(GLToolbar::Layout::HO_Left);
|
||||
view_toolbar.set_vertical_orientation(GLToolbar::Layout::VO_Bottom);
|
||||
view_toolbar.set_border(5.0f);
|
||||
view_toolbar.set_gap_size(1.0f);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user