Allow non-squared textures for toolbars and gizmo icons
This commit is contained in:
parent
0f683a6a1e
commit
f47fe861ac
@ -3146,7 +3146,10 @@ void GLCanvas3D::Gizmos::do_render_overlay(const GLCanvas3D& canvas, const GLCan
|
||||
float scaled_icons_size = m_overlay_icons_size * m_overlay_scale * inv_zoom;
|
||||
float scaled_stride_y = scaled_icons_size + scaled_gap_y;
|
||||
unsigned int icons_texture_id = m_icons_texture.get_id();
|
||||
unsigned int texture_size = m_icons_texture.get_width();
|
||||
unsigned int tex_width = m_icons_texture.get_width();
|
||||
unsigned int tex_height = m_icons_texture.get_height();
|
||||
float inv_tex_width = (tex_width != 0) ? 1.0f / (float)tex_width : 0.0f;
|
||||
float inv_tex_height = (tex_height != 0) ? 1.0f / (float)tex_height : 0.0f;
|
||||
#else
|
||||
top_x += m_overlay_border * inv_zoom;
|
||||
top_y -= m_overlay_border * inv_zoom;
|
||||
@ -3155,11 +3158,11 @@ void GLCanvas3D::Gizmos::do_render_overlay(const GLCanvas3D& canvas, const GLCan
|
||||
float scaled_icons_size = (float)m_icons_texture.metadata.icon_size * m_overlay_icons_scale * inv_zoom;
|
||||
unsigned int icons_texture_id = m_icons_texture.texture.get_id();
|
||||
unsigned int texture_size = m_icons_texture.texture.get_width();
|
||||
#endif // ENABLE_SVG_ICONS
|
||||
float inv_texture_size = (texture_size != 0) ? 1.0f / (float)texture_size : 0.0f;
|
||||
#endif // ENABLE_SVG_ICONS
|
||||
|
||||
#if ENABLE_SVG_ICONS
|
||||
if ((icons_texture_id == 0) || (texture_size <= 0))
|
||||
if ((icons_texture_id == 0) || (tex_width <= 0) || (tex_height <= 0))
|
||||
return;
|
||||
#endif // ENABLE_SVG_ICONS
|
||||
|
||||
@ -3172,14 +3175,19 @@ void GLCanvas3D::Gizmos::do_render_overlay(const GLCanvas3D& canvas, const GLCan
|
||||
GLGizmoBase::EState state = it->second->get_state();
|
||||
|
||||
#if ENABLE_SVG_ICONS
|
||||
float uv_icon_size = m_overlay_icons_size * inv_texture_size;
|
||||
float u_icon_size = m_overlay_icons_size * inv_tex_width;
|
||||
float v_icon_size = m_overlay_icons_size * inv_tex_height;
|
||||
float top = sprite_id * v_icon_size;
|
||||
float left = state * u_icon_size;
|
||||
float bottom = top + v_icon_size;
|
||||
float right = left + u_icon_size;
|
||||
#else
|
||||
float uv_icon_size = (float)m_icons_texture.metadata.icon_size * inv_texture_size;
|
||||
#endif // ENABLE_SVG_ICONS
|
||||
float top = sprite_id * uv_icon_size;
|
||||
float left = state * uv_icon_size;
|
||||
float bottom = top + uv_icon_size;
|
||||
float right = left + uv_icon_size;
|
||||
#endif // ENABLE_SVG_ICONS
|
||||
|
||||
GLTexture::render_sub_texture(icons_texture_id, top_x, top_x + scaled_icons_size, top_y - scaled_icons_size, top_y, { { left, bottom }, { right, bottom }, { right, top }, { left, top } });
|
||||
#if ENABLE_IMGUI
|
||||
@ -3262,9 +3270,9 @@ bool GLCanvas3D::Gizmos::generate_icons_texture() const
|
||||
{
|
||||
if (it->second != nullptr)
|
||||
{
|
||||
const std::string& svg_file = it->second->get_svg_file();
|
||||
if (!svg_file.empty())
|
||||
filenames.push_back(path + svg_file);
|
||||
const std::string& icon_filename = it->second->get_icon_filename();
|
||||
if (!icon_filename.empty())
|
||||
filenames.push_back(path + icon_filename);
|
||||
}
|
||||
}
|
||||
|
||||
@ -5901,7 +5909,7 @@ bool GLCanvas3D::_init_toolbar()
|
||||
|
||||
item.name = "add";
|
||||
#if ENABLE_SVG_ICONS
|
||||
item.svg_file = "add.svg";
|
||||
item.icon_filename = "add.svg";
|
||||
#endif // ENABLE_SVG_ICONS
|
||||
item.tooltip = GUI::L_str("Add...") + " [" + GUI::shortkey_ctrl_prefix() + "I]";
|
||||
item.sprite_id = 0;
|
||||
@ -5911,7 +5919,7 @@ bool GLCanvas3D::_init_toolbar()
|
||||
|
||||
item.name = "delete";
|
||||
#if ENABLE_SVG_ICONS
|
||||
item.svg_file = "remove.svg";
|
||||
item.icon_filename = "remove.svg";
|
||||
#endif // ENABLE_SVG_ICONS
|
||||
item.tooltip = GUI::L_str("Delete") + " [Del]";
|
||||
item.sprite_id = 1;
|
||||
@ -5921,7 +5929,7 @@ bool GLCanvas3D::_init_toolbar()
|
||||
|
||||
item.name = "deleteall";
|
||||
#if ENABLE_SVG_ICONS
|
||||
item.svg_file = "delete_all.svg";
|
||||
item.icon_filename = "delete_all.svg";
|
||||
#endif // ENABLE_SVG_ICONS
|
||||
item.tooltip = GUI::L_str("Delete all") + " [" + GUI::shortkey_ctrl_prefix() + "Del]";
|
||||
item.sprite_id = 2;
|
||||
@ -5931,7 +5939,7 @@ bool GLCanvas3D::_init_toolbar()
|
||||
|
||||
item.name = "arrange";
|
||||
#if ENABLE_SVG_ICONS
|
||||
item.svg_file = "arrange.svg";
|
||||
item.icon_filename = "arrange.svg";
|
||||
#endif // ENABLE_SVG_ICONS
|
||||
item.tooltip = GUI::L_str("Arrange [A]");
|
||||
item.sprite_id = 3;
|
||||
@ -5944,7 +5952,7 @@ bool GLCanvas3D::_init_toolbar()
|
||||
|
||||
item.name = "more";
|
||||
#if ENABLE_SVG_ICONS
|
||||
item.svg_file = "instance_add.svg";
|
||||
item.icon_filename = "instance_add.svg";
|
||||
#endif // ENABLE_SVG_ICONS
|
||||
item.tooltip = GUI::L_str("Add instance [+]");
|
||||
item.sprite_id = 4;
|
||||
@ -5954,7 +5962,7 @@ bool GLCanvas3D::_init_toolbar()
|
||||
|
||||
item.name = "fewer";
|
||||
#if ENABLE_SVG_ICONS
|
||||
item.svg_file = "instance_remove.svg";
|
||||
item.icon_filename = "instance_remove.svg";
|
||||
#endif // ENABLE_SVG_ICONS
|
||||
item.tooltip = GUI::L_str("Remove instance [-]");
|
||||
item.sprite_id = 5;
|
||||
@ -5967,7 +5975,7 @@ bool GLCanvas3D::_init_toolbar()
|
||||
|
||||
item.name = "splitobjects";
|
||||
#if ENABLE_SVG_ICONS
|
||||
item.svg_file = "split_objects.svg";
|
||||
item.icon_filename = "split_objects.svg";
|
||||
#endif // ENABLE_SVG_ICONS
|
||||
item.tooltip = GUI::L_str("Split to objects");
|
||||
item.sprite_id = 6;
|
||||
@ -5977,7 +5985,7 @@ bool GLCanvas3D::_init_toolbar()
|
||||
|
||||
item.name = "splitvolumes";
|
||||
#if ENABLE_SVG_ICONS
|
||||
item.svg_file = "split_parts.svg";
|
||||
item.icon_filename = "split_parts.svg";
|
||||
#endif // ENABLE_SVG_ICONS
|
||||
item.tooltip = GUI::L_str("Split to parts");
|
||||
item.sprite_id = 8;
|
||||
@ -5990,7 +5998,7 @@ bool GLCanvas3D::_init_toolbar()
|
||||
|
||||
item.name = "layersediting";
|
||||
#if ENABLE_SVG_ICONS
|
||||
item.svg_file = "layers.svg";
|
||||
item.icon_filename = "layers.svg";
|
||||
#endif // ENABLE_SVG_ICONS
|
||||
item.tooltip = GUI::L_str("Layers editing");
|
||||
item.sprite_id = 7;
|
||||
|
@ -158,7 +158,7 @@ void GLGizmoBase::Grabber::render_face(float half_size) const
|
||||
}
|
||||
|
||||
#if ENABLE_SVG_ICONS
|
||||
GLGizmoBase::GLGizmoBase(GLCanvas3D& parent, const std::string& svg_file, unsigned int sprite_id)
|
||||
GLGizmoBase::GLGizmoBase(GLCanvas3D& parent, const std::string& icon_filename, unsigned int sprite_id)
|
||||
#else
|
||||
GLGizmoBase::GLGizmoBase(GLCanvas3D& parent, unsigned int sprite_id)
|
||||
#endif // ENABLE_SVG_ICONS
|
||||
@ -167,7 +167,7 @@ GLGizmoBase::GLGizmoBase(GLCanvas3D& parent, unsigned int sprite_id)
|
||||
, m_state(Off)
|
||||
, m_shortcut_key(0)
|
||||
#if ENABLE_SVG_ICONS
|
||||
, m_svg_file(svg_file)
|
||||
, m_icon_filename(icon_filename)
|
||||
#endif // ENABLE_SVG_ICONS
|
||||
, m_sprite_id(sprite_id)
|
||||
, m_hover_id(-1)
|
||||
@ -334,7 +334,7 @@ GLGizmoRotate::GLGizmoRotate(GLCanvas3D& parent, GLGizmoRotate::Axis axis)
|
||||
|
||||
GLGizmoRotate::GLGizmoRotate(const GLGizmoRotate& other)
|
||||
#if ENABLE_SVG_ICONS
|
||||
: GLGizmoBase(other.m_parent, other.m_svg_file, other.m_sprite_id)
|
||||
: GLGizmoBase(other.m_parent, other.m_icon_filename, other.m_sprite_id)
|
||||
#else
|
||||
: GLGizmoBase(other.m_parent, other.m_sprite_id)
|
||||
#endif // ENABLE_SVG_ICONS
|
||||
@ -710,8 +710,8 @@ Vec3d GLGizmoRotate::mouse_position_in_local_plane(const Linef3& mouse_ray, cons
|
||||
}
|
||||
|
||||
#if ENABLE_SVG_ICONS
|
||||
GLGizmoRotate3D::GLGizmoRotate3D(GLCanvas3D& parent, const std::string& svg_file, unsigned int sprite_id)
|
||||
: GLGizmoBase(parent, svg_file, sprite_id)
|
||||
GLGizmoRotate3D::GLGizmoRotate3D(GLCanvas3D& parent, const std::string& icon_filename, unsigned int sprite_id)
|
||||
: GLGizmoBase(parent, icon_filename, sprite_id)
|
||||
#else
|
||||
GLGizmoRotate3D::GLGizmoRotate3D(GLCanvas3D& parent, unsigned int sprite_id)
|
||||
: GLGizmoBase(parent, sprite_id)
|
||||
@ -795,8 +795,8 @@ void GLGizmoRotate3D::on_render_input_window(float x, float y, const GLCanvas3D:
|
||||
const float GLGizmoScale3D::Offset = 5.0f;
|
||||
|
||||
#if ENABLE_SVG_ICONS
|
||||
GLGizmoScale3D::GLGizmoScale3D(GLCanvas3D& parent, const std::string& svg_file, unsigned int sprite_id)
|
||||
: GLGizmoBase(parent, svg_file, sprite_id)
|
||||
GLGizmoScale3D::GLGizmoScale3D(GLCanvas3D& parent, const std::string& icon_filename, unsigned int sprite_id)
|
||||
: GLGizmoBase(parent, icon_filename, sprite_id)
|
||||
#else
|
||||
GLGizmoScale3D::GLGizmoScale3D(GLCanvas3D& parent, unsigned int sprite_id)
|
||||
: GLGizmoBase(parent, sprite_id)
|
||||
@ -1146,8 +1146,8 @@ double GLGizmoScale3D::calc_ratio(const UpdateData& data) const
|
||||
const double GLGizmoMove3D::Offset = 10.0;
|
||||
|
||||
#if ENABLE_SVG_ICONS
|
||||
GLGizmoMove3D::GLGizmoMove3D(GLCanvas3D& parent, const std::string& svg_file, unsigned int sprite_id)
|
||||
: GLGizmoBase(parent, svg_file, sprite_id)
|
||||
GLGizmoMove3D::GLGizmoMove3D(GLCanvas3D& parent, const std::string& icon_filename, unsigned int sprite_id)
|
||||
: GLGizmoBase(parent, icon_filename, sprite_id)
|
||||
#else
|
||||
GLGizmoMove3D::GLGizmoMove3D(GLCanvas3D& parent, unsigned int sprite_id)
|
||||
: GLGizmoBase(parent, sprite_id)
|
||||
@ -1388,8 +1388,8 @@ void GLGizmoMove3D::render_grabber_extension(Axis axis, const BoundingBoxf3& box
|
||||
}
|
||||
|
||||
#if ENABLE_SVG_ICONS
|
||||
GLGizmoFlatten::GLGizmoFlatten(GLCanvas3D& parent, const std::string& svg_file, unsigned int sprite_id)
|
||||
: GLGizmoBase(parent, svg_file, sprite_id)
|
||||
GLGizmoFlatten::GLGizmoFlatten(GLCanvas3D& parent, const std::string& icon_filename, unsigned int sprite_id)
|
||||
: GLGizmoBase(parent, icon_filename, sprite_id)
|
||||
#else
|
||||
GLGizmoFlatten::GLGizmoFlatten(GLCanvas3D& parent, unsigned int sprite_id)
|
||||
: GLGizmoBase(parent, sprite_id)
|
||||
@ -1732,8 +1732,8 @@ Vec3d GLGizmoFlatten::get_flattening_normal() const
|
||||
}
|
||||
|
||||
#if ENABLE_SVG_ICONS
|
||||
GLGizmoSlaSupports::GLGizmoSlaSupports(GLCanvas3D& parent, const std::string& svg_file, unsigned int sprite_id)
|
||||
: GLGizmoBase(parent, svg_file, sprite_id)
|
||||
GLGizmoSlaSupports::GLGizmoSlaSupports(GLCanvas3D& parent, const std::string& icon_filename, unsigned int sprite_id)
|
||||
: GLGizmoBase(parent, icon_filename, sprite_id)
|
||||
#else
|
||||
GLGizmoSlaSupports::GLGizmoSlaSupports(GLCanvas3D& parent, unsigned int sprite_id)
|
||||
: GLGizmoBase(parent, sprite_id)
|
||||
@ -2550,8 +2550,8 @@ const double GLGizmoCut::Margin = 20.0;
|
||||
const std::array<float, 3> GLGizmoCut::GrabberColor = { 1.0, 0.5, 0.0 };
|
||||
|
||||
#if ENABLE_SVG_ICONS
|
||||
GLGizmoCut::GLGizmoCut(GLCanvas3D& parent, const std::string& svg_file, unsigned int sprite_id)
|
||||
: GLGizmoBase(parent, svg_file, sprite_id)
|
||||
GLGizmoCut::GLGizmoCut(GLCanvas3D& parent, const std::string& icon_filename, unsigned int sprite_id)
|
||||
: GLGizmoBase(parent, icon_filename, sprite_id)
|
||||
#else
|
||||
GLGizmoCut::GLGizmoCut(GLCanvas3D& parent, unsigned int sprite_id)
|
||||
: GLGizmoBase(parent, sprite_id)
|
||||
|
@ -88,7 +88,7 @@ protected:
|
||||
EState m_state;
|
||||
int m_shortcut_key;
|
||||
#if ENABLE_SVG_ICONS
|
||||
std::string m_svg_file;
|
||||
std::string m_icon_filename;
|
||||
#endif // ENABLE_SVG_ICONS
|
||||
unsigned int m_sprite_id;
|
||||
int m_hover_id;
|
||||
@ -103,7 +103,7 @@ protected:
|
||||
|
||||
public:
|
||||
#if ENABLE_SVG_ICONS
|
||||
GLGizmoBase(GLCanvas3D& parent, const std::string& svg_file, unsigned int sprite_id);
|
||||
GLGizmoBase(GLCanvas3D& parent, const std::string& icon_filename, unsigned int sprite_id);
|
||||
#else
|
||||
GLGizmoBase(GLCanvas3D& parent, unsigned int sprite_id);
|
||||
#endif // ENABLE_SVG_ICONS
|
||||
@ -123,7 +123,7 @@ public:
|
||||
void set_shortcut_key(int key) { m_shortcut_key = key; }
|
||||
|
||||
#if ENABLE_SVG_ICONS
|
||||
const std::string& get_svg_file() const { return m_svg_file; }
|
||||
const std::string& get_icon_filename() const { return m_icon_filename; }
|
||||
#endif // ENABLE_SVG_ICONS
|
||||
|
||||
bool is_activable(const GLCanvas3D::Selection& selection) const { return on_is_activable(selection); }
|
||||
@ -254,7 +254,7 @@ class GLGizmoRotate3D : public GLGizmoBase
|
||||
|
||||
public:
|
||||
#if ENABLE_SVG_ICONS
|
||||
GLGizmoRotate3D(GLCanvas3D& parent, const std::string& svg_file, unsigned int sprite_id);
|
||||
GLGizmoRotate3D(GLCanvas3D& parent, const std::string& icon_filename, unsigned int sprite_id);
|
||||
#else
|
||||
GLGizmoRotate3D(GLCanvas3D& parent, unsigned int sprite_id);
|
||||
#endif // ENABLE_SVG_ICONS
|
||||
@ -329,7 +329,7 @@ class GLGizmoScale3D : public GLGizmoBase
|
||||
|
||||
public:
|
||||
#if ENABLE_SVG_ICONS
|
||||
GLGizmoScale3D(GLCanvas3D& parent, const std::string& svg_file, unsigned int sprite_id);
|
||||
GLGizmoScale3D(GLCanvas3D& parent, const std::string& icon_filename, unsigned int sprite_id);
|
||||
#else
|
||||
GLGizmoScale3D(GLCanvas3D& parent, unsigned int sprite_id);
|
||||
#endif // ENABLE_SVG_ICONS
|
||||
@ -380,7 +380,7 @@ class GLGizmoMove3D : public GLGizmoBase
|
||||
|
||||
public:
|
||||
#if ENABLE_SVG_ICONS
|
||||
GLGizmoMove3D(GLCanvas3D& parent, const std::string& svg_file, unsigned int sprite_id);
|
||||
GLGizmoMove3D(GLCanvas3D& parent, const std::string& icon_filename, unsigned int sprite_id);
|
||||
#else
|
||||
GLGizmoMove3D(GLCanvas3D& parent, unsigned int sprite_id);
|
||||
#endif // ENABLE_SVG_ICONS
|
||||
@ -439,7 +439,7 @@ private:
|
||||
|
||||
public:
|
||||
#if ENABLE_SVG_ICONS
|
||||
GLGizmoFlatten(GLCanvas3D& parent, const std::string& svg_file, unsigned int sprite_id);
|
||||
GLGizmoFlatten(GLCanvas3D& parent, const std::string& icon_filename, unsigned int sprite_id);
|
||||
#else
|
||||
GLGizmoFlatten(GLCanvas3D& parent, unsigned int sprite_id);
|
||||
#endif // ENABLE_SVG_ICONS
|
||||
@ -491,7 +491,7 @@ private:
|
||||
|
||||
public:
|
||||
#if ENABLE_SVG_ICONS
|
||||
GLGizmoSlaSupports(GLCanvas3D& parent, const std::string& svg_file, unsigned int sprite_id);
|
||||
GLGizmoSlaSupports(GLCanvas3D& parent, const std::string& icon_filename, unsigned int sprite_id);
|
||||
#else
|
||||
GLGizmoSlaSupports(GLCanvas3D& parent, unsigned int sprite_id);
|
||||
#endif // ENABLE_SVG_ICONS
|
||||
@ -588,7 +588,7 @@ class GLGizmoCut : public GLGizmoBase
|
||||
|
||||
public:
|
||||
#if ENABLE_SVG_ICONS
|
||||
GLGizmoCut(GLCanvas3D& parent, const std::string& svg_file, unsigned int sprite_id);
|
||||
GLGizmoCut(GLCanvas3D& parent, const std::string& icon_filename, unsigned int sprite_id);
|
||||
#else
|
||||
GLGizmoCut(GLCanvas3D& parent, unsigned int sprite_id);
|
||||
#endif // ENABLE_SVG_ICONS
|
||||
|
@ -148,8 +148,8 @@ bool GLTexture::load_from_svg_files_as_sprites_array(const std::vector<std::stri
|
||||
if (filenames.empty() || (num_states == 0) || (sprite_size_px == 0))
|
||||
return false;
|
||||
|
||||
m_width = (int)sprite_size_px * std::max((int)(num_states), (int)(filenames.size()));
|
||||
m_height = m_width;
|
||||
m_width = (int)(sprite_size_px * num_states);
|
||||
m_height = (int)(sprite_size_px * filenames.size());
|
||||
int n_pixels = m_width * m_height;
|
||||
|
||||
if (n_pixels <= 0)
|
||||
|
@ -33,7 +33,7 @@ wxDEFINE_EVENT(EVT_GLVIEWTOOLBAR_PREVIEW, SimpleEvent);
|
||||
GLToolbarItem::Data::Data()
|
||||
: name("")
|
||||
#if ENABLE_SVG_ICONS
|
||||
, svg_file("")
|
||||
, icon_filename("")
|
||||
#endif // ENABLE_SVG_ICONS
|
||||
, tooltip("")
|
||||
, sprite_id(-1)
|
||||
@ -56,22 +56,24 @@ void GLToolbarItem::do_action(wxEvtHandler *target)
|
||||
wxPostEvent(target, SimpleEvent(m_data.action_event));
|
||||
}
|
||||
|
||||
void GLToolbarItem::render(unsigned int tex_id, float left, float right, float bottom, float top, unsigned int texture_size, 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
|
||||
{
|
||||
GLTexture::render_sub_texture(tex_id, left, right, bottom, top, get_uvs(texture_size, icon_size));
|
||||
GLTexture::render_sub_texture(tex_id, left, right, bottom, top, get_uvs(tex_width, tex_height, icon_size));
|
||||
}
|
||||
|
||||
GLTexture::Quad_UVs GLToolbarItem::get_uvs(unsigned int texture_size, unsigned int icon_size) const
|
||||
GLTexture::Quad_UVs GLToolbarItem::get_uvs(unsigned int tex_width, unsigned int tex_height, unsigned int icon_size) const
|
||||
{
|
||||
GLTexture::Quad_UVs uvs;
|
||||
|
||||
float inv_texture_size = (texture_size != 0) ? 1.0f / (float)texture_size : 0.0f;
|
||||
float inv_tex_width = (tex_width != 0) ? 1.0f / (float)tex_width : 0.0f;
|
||||
float inv_tex_height = (tex_height != 0) ? 1.0f / (float)tex_height : 0.0f;
|
||||
|
||||
float scaled_icon_size = (float)icon_size * inv_texture_size;
|
||||
float left = (float)m_state * scaled_icon_size;
|
||||
float right = left + scaled_icon_size;
|
||||
float top = (float)m_data.sprite_id * scaled_icon_size;
|
||||
float bottom = top + scaled_icon_size;
|
||||
float scaled_icon_width = (float)icon_size * inv_tex_width;
|
||||
float scaled_icon_height = (float)icon_size * inv_tex_height;
|
||||
float left = (float)m_state * scaled_icon_width;
|
||||
float right = left + scaled_icon_width;
|
||||
float top = (float)m_data.sprite_id * scaled_icon_height;
|
||||
float bottom = top + scaled_icon_height;
|
||||
|
||||
uvs.left_top = { left, top };
|
||||
uvs.left_bottom = { left, bottom };
|
||||
@ -907,7 +909,8 @@ void GLToolbar::render_horizontal(const GLCanvas3D& parent) const
|
||||
{
|
||||
#if ENABLE_SVG_ICONS
|
||||
unsigned int tex_id = m_icons_texture.get_id();
|
||||
int tex_size = m_icons_texture.get_width();
|
||||
int tex_width = m_icons_texture.get_width();
|
||||
int tex_height = m_icons_texture.get_height();
|
||||
#else
|
||||
unsigned int tex_id = m_icons_texture.texture.get_id();
|
||||
int tex_size = m_icons_texture.texture.get_width();
|
||||
@ -1032,7 +1035,7 @@ void GLToolbar::render_horizontal(const GLCanvas3D& parent) const
|
||||
top -= scaled_border;
|
||||
|
||||
#if ENABLE_SVG_ICONS
|
||||
if ((tex_id == 0) || (tex_size <= 0))
|
||||
if ((tex_id == 0) || (tex_width <= 0) || (tex_height <= 0))
|
||||
return;
|
||||
#endif // ENABLE_SVG_ICONS
|
||||
|
||||
@ -1049,7 +1052,7 @@ void GLToolbar::render_horizontal(const GLCanvas3D& parent) const
|
||||
else
|
||||
{
|
||||
#if ENABLE_SVG_ICONS
|
||||
item->render(tex_id, left, left + scaled_icons_size, top - scaled_icons_size, top, (unsigned int)tex_size, (unsigned int)m_layout.icons_size);
|
||||
item->render(tex_id, left, left + scaled_icons_size, top - scaled_icons_size, 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 + scaled_icons_size, top - scaled_icons_size, top, (unsigned int)tex_size, m_icons_texture.metadata.icon_size);
|
||||
#endif // ENABLE_SVG_ICONS
|
||||
@ -1062,14 +1065,17 @@ void GLToolbar::render_vertical(const GLCanvas3D& parent) const
|
||||
{
|
||||
#if ENABLE_SVG_ICONS
|
||||
unsigned int tex_id = m_icons_texture.get_id();
|
||||
int tex_size = m_icons_texture.get_width();
|
||||
int tex_width = m_icons_texture.get_width();
|
||||
int tex_height = m_icons_texture.get_height();
|
||||
#else
|
||||
unsigned int tex_id = m_icons_texture.texture.get_id();
|
||||
int tex_size = m_icons_texture.texture.get_width();
|
||||
#endif // ENABLE_SVG_ICONS
|
||||
|
||||
#if !ENABLE_SVG_ICONS
|
||||
if ((tex_id == 0) || (tex_size <= 0))
|
||||
return;
|
||||
#endif // !ENABLE_SVG_ICONS
|
||||
|
||||
float zoom = parent.get_camera_zoom();
|
||||
float inv_zoom = (zoom != 0.0f) ? 1.0f / zoom : 0.0f;
|
||||
@ -1184,6 +1190,11 @@ void GLToolbar::render_vertical(const GLCanvas3D& parent) const
|
||||
left += scaled_border;
|
||||
top -= scaled_border;
|
||||
|
||||
#if ENABLE_SVG_ICONS
|
||||
if ((tex_id == 0) || (tex_width <= 0) || (tex_height <= 0))
|
||||
return;
|
||||
#endif // ENABLE_SVG_ICONS
|
||||
|
||||
// renders icons
|
||||
for (const GLToolbarItem* item : m_items)
|
||||
{
|
||||
@ -1197,7 +1208,7 @@ void GLToolbar::render_vertical(const GLCanvas3D& parent) const
|
||||
else
|
||||
{
|
||||
#if ENABLE_SVG_ICONS
|
||||
item->render(tex_id, left, left + scaled_icons_size, top - scaled_icons_size, top, (unsigned int)tex_size, (unsigned int)(m_layout.icons_size * m_layout.scale));
|
||||
item->render(tex_id, left, left + scaled_icons_size, top - scaled_icons_size, 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 + scaled_icons_size, top - scaled_icons_size, top, (unsigned int)tex_size, m_icons_texture.metadata.icon_size);
|
||||
#endif // ENABLE_SVG_ICONS
|
||||
@ -1213,9 +1224,9 @@ bool GLToolbar::generate_icons_texture() const
|
||||
std::vector<std::string> filenames;
|
||||
for (GLToolbarItem* item : m_items)
|
||||
{
|
||||
const std::string& svg_file = item->get_svg_file();
|
||||
if (!svg_file.empty())
|
||||
filenames.push_back(path + svg_file);
|
||||
const std::string& icon_filename = item->get_icon_filename();
|
||||
if (!icon_filename.empty())
|
||||
filenames.push_back(path + icon_filename);
|
||||
}
|
||||
|
||||
bool res = m_icons_texture.load_from_svg_files_as_sprites_array(filenames, GLToolbarItem::Num_States, (unsigned int)(m_layout.icons_size * m_layout.scale));
|
||||
|
@ -52,7 +52,7 @@ public:
|
||||
{
|
||||
std::string name;
|
||||
#if ENABLE_SVG_ICONS
|
||||
std::string svg_file;
|
||||
std::string icon_filename;
|
||||
#endif // ENABLE_SVG_ICONS
|
||||
std::string tooltip;
|
||||
unsigned int sprite_id;
|
||||
@ -78,7 +78,7 @@ public:
|
||||
|
||||
const std::string& get_name() const { return m_data.name; }
|
||||
#if ENABLE_SVG_ICONS
|
||||
const std::string& get_svg_file() const { return m_data.svg_file; }
|
||||
const std::string& get_icon_filename() const { return m_data.icon_filename; }
|
||||
#endif // ENABLE_SVG_ICONS
|
||||
const std::string& get_tooltip() const { return m_data.tooltip; }
|
||||
|
||||
@ -96,10 +96,10 @@ public:
|
||||
#endif // ENABLE_MODE_AWARE_TOOLBAR_ITEMS
|
||||
bool is_separator() const { return m_type == Separator; }
|
||||
|
||||
void render(unsigned int tex_id, float left, float right, float bottom, float top, unsigned int texture_size, 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;
|
||||
|
||||
private:
|
||||
GLTexture::Quad_UVs get_uvs(unsigned int texture_size, unsigned int icon_size) const;
|
||||
GLTexture::Quad_UVs get_uvs(unsigned int tex_width, unsigned int tex_height, unsigned int icon_size) const;
|
||||
};
|
||||
|
||||
#if !ENABLE_SVG_ICONS
|
||||
|
@ -2651,7 +2651,7 @@ void Plater::priv::init_view_toolbar()
|
||||
|
||||
item.name = "3D";
|
||||
#if ENABLE_SVG_ICONS
|
||||
item.svg_file = "add.svg";
|
||||
item.icon_filename = "add.svg";
|
||||
#endif // ENABLE_SVG_ICONS
|
||||
item.tooltip = GUI::L_str("3D editor view") + " [" + GUI::shortkey_ctrl_prefix() + "5]";
|
||||
item.sprite_id = 0;
|
||||
@ -2662,7 +2662,7 @@ void Plater::priv::init_view_toolbar()
|
||||
|
||||
item.name = "Preview";
|
||||
#if ENABLE_SVG_ICONS
|
||||
item.svg_file = "remove.svg";
|
||||
item.icon_filename = "remove.svg";
|
||||
#endif // ENABLE_SVG_ICONS
|
||||
item.tooltip = GUI::L_str("Preview") + " [" + GUI::shortkey_ctrl_prefix() + "6]";
|
||||
item.sprite_id = 1;
|
||||
|
Loading…
Reference in New Issue
Block a user