Tech ENABLE_SVG_ICONS set as default

This commit is contained in:
Enrico Turri 2019-07-12 10:13:35 +02:00
parent 5cbaa7b081
commit cc70c8dff9
22 changed files with 2 additions and 608 deletions

View file

@ -41,13 +41,4 @@
#define ENABLE_TEXTURES_FROM_SVG (1 && ENABLE_1_42_0_ALPHA7)
//====================
// 1.42.0.alpha8 techs
//====================
#define ENABLE_1_42_0_ALPHA8 1
// Toolbars and Gizmos use icons imported from svg files
#define ENABLE_SVG_ICONS (1 && ENABLE_1_42_0_ALPHA8 && ENABLE_TEXTURES_FROM_SVG)
#endif // _technologies_h_

View file

@ -1199,11 +1199,7 @@ GLCanvas3D::GLCanvas3D(wxGLCanvas* canvas, Bed3D& bed, Camera& camera, GLToolbar
, m_bed(bed)
, m_camera(camera)
, m_view_toolbar(view_toolbar)
#if ENABLE_SVG_ICONS
, m_toolbar(GLToolbar::Normal, "Top")
#else
, m_toolbar(GLToolbar::Normal)
#endif // ENABLE_SVG_ICONS
, m_use_clipping_planes(false)
, m_sidebar_field("")
, m_keep_dirty(false)
@ -3422,12 +3418,6 @@ bool GLCanvas3D::_init_toolbar()
if (!m_toolbar.is_enabled())
return true;
#if !ENABLE_SVG_ICONS
ItemsIconsTexture::Metadata icons_data;
icons_data.filename = "toolbar.png";
icons_data.icon_size = 37;
#endif // !ENABLE_SVG_ICONS
BackgroundTexture::Metadata background_data;
background_data.filename = "toolbar_background.png";
background_data.left = 16;
@ -3435,11 +3425,7 @@ bool GLCanvas3D::_init_toolbar()
background_data.right = 16;
background_data.bottom = 16;
#if ENABLE_SVG_ICONS
if (!m_toolbar.init(background_data))
#else
if (!m_toolbar.init(icons_data, background_data))
#endif // ENABLE_SVG_ICONS
{
// unable to init the toolbar texture, disable it
m_toolbar.set_enabled(false);
@ -3456,9 +3442,7 @@ bool GLCanvas3D::_init_toolbar()
GLToolbarItem::Data item;
item.name = "add";
#if ENABLE_SVG_ICONS
item.icon_filename = "add.svg";
#endif // ENABLE_SVG_ICONS
item.tooltip = _utf8(L("Add...")) + " [" + GUI::shortkey_ctrl_prefix() + "I]";
item.sprite_id = 0;
item.action_callback = [this]() { if (m_canvas != nullptr) wxPostEvent(m_canvas, SimpleEvent(EVT_GLTOOLBAR_ADD)); };
@ -3466,9 +3450,7 @@ bool GLCanvas3D::_init_toolbar()
return false;
item.name = "delete";
#if ENABLE_SVG_ICONS
item.icon_filename = "remove.svg";
#endif // ENABLE_SVG_ICONS
item.tooltip = _utf8(L("Delete")) + " [Del]";
item.sprite_id = 1;
item.action_callback = [this]() { if (m_canvas != nullptr) wxPostEvent(m_canvas, SimpleEvent(EVT_GLTOOLBAR_DELETE)); };
@ -3477,9 +3459,7 @@ bool GLCanvas3D::_init_toolbar()
return false;
item.name = "deleteall";
#if ENABLE_SVG_ICONS
item.icon_filename = "delete_all.svg";
#endif // ENABLE_SVG_ICONS
item.tooltip = _utf8(L("Delete all")) + " [" + GUI::shortkey_ctrl_prefix() + "Del]";
item.sprite_id = 2;
item.action_callback = [this]() { if (m_canvas != nullptr) wxPostEvent(m_canvas, SimpleEvent(EVT_GLTOOLBAR_DELETE_ALL)); };
@ -3488,9 +3468,7 @@ bool GLCanvas3D::_init_toolbar()
return false;
item.name = "arrange";
#if ENABLE_SVG_ICONS
item.icon_filename = "arrange.svg";
#endif // ENABLE_SVG_ICONS
item.tooltip = _utf8(L("Arrange")) + " [A]";
item.sprite_id = 3;
item.action_callback = [this]() { if (m_canvas != nullptr) wxPostEvent(m_canvas, SimpleEvent(EVT_GLTOOLBAR_ARRANGE)); };
@ -3502,9 +3480,7 @@ bool GLCanvas3D::_init_toolbar()
return false;
item.name = "copy";
#if ENABLE_SVG_ICONS
item.icon_filename = "copy.svg";
#endif // ENABLE_SVG_ICONS
item.tooltip = _utf8(L("Copy")) + " [" + GUI::shortkey_ctrl_prefix() + "C]";
item.sprite_id = 4;
item.action_callback = [this]() { if (m_canvas != nullptr) wxPostEvent(m_canvas, SimpleEvent(EVT_GLTOOLBAR_COPY)); };
@ -3513,9 +3489,7 @@ bool GLCanvas3D::_init_toolbar()
return false;
item.name = "paste";
#if ENABLE_SVG_ICONS
item.icon_filename = "paste.svg";
#endif // ENABLE_SVG_ICONS
item.tooltip = _utf8(L("Paste")) + " [" + GUI::shortkey_ctrl_prefix() + "V]";
item.sprite_id = 5;
item.action_callback = [this]() { if (m_canvas != nullptr) wxPostEvent(m_canvas, SimpleEvent(EVT_GLTOOLBAR_PASTE)); };
@ -3527,9 +3501,7 @@ bool GLCanvas3D::_init_toolbar()
return false;
item.name = "more";
#if ENABLE_SVG_ICONS
item.icon_filename = "instance_add.svg";
#endif // ENABLE_SVG_ICONS
item.tooltip = _utf8(L("Add instance")) + " [+]";
item.sprite_id = 6;
item.action_callback = [this]() { if (m_canvas != nullptr) wxPostEvent(m_canvas, SimpleEvent(EVT_GLTOOLBAR_MORE)); };
@ -3539,9 +3511,7 @@ bool GLCanvas3D::_init_toolbar()
return false;
item.name = "fewer";
#if ENABLE_SVG_ICONS
item.icon_filename = "instance_remove.svg";
#endif // ENABLE_SVG_ICONS
item.tooltip = _utf8(L("Remove instance")) + " [-]";
item.sprite_id = 7;
item.action_callback = [this]() { if (m_canvas != nullptr) wxPostEvent(m_canvas, SimpleEvent(EVT_GLTOOLBAR_FEWER)); };
@ -3554,9 +3524,7 @@ bool GLCanvas3D::_init_toolbar()
return false;
item.name = "splitobjects";
#if ENABLE_SVG_ICONS
item.icon_filename = "split_objects.svg";
#endif // ENABLE_SVG_ICONS
item.tooltip = _utf8(L("Split to objects"));
item.sprite_id = 8;
item.action_callback = [this]() { if (m_canvas != nullptr) wxPostEvent(m_canvas, SimpleEvent(EVT_GLTOOLBAR_SPLIT_OBJECTS)); };
@ -3566,9 +3534,7 @@ bool GLCanvas3D::_init_toolbar()
return false;
item.name = "splitvolumes";
#if ENABLE_SVG_ICONS
item.icon_filename = "split_parts.svg";
#endif // ENABLE_SVG_ICONS
item.tooltip = _utf8(L("Split to parts"));
item.sprite_id = 9;
item.action_callback = [this]() { if (m_canvas != nullptr) wxPostEvent(m_canvas, SimpleEvent(EVT_GLTOOLBAR_SPLIT_VOLUMES)); };
@ -3581,9 +3547,7 @@ bool GLCanvas3D::_init_toolbar()
return false;
item.name = "layersediting";
#if ENABLE_SVG_ICONS
item.icon_filename = "layers_white.svg";
#endif // ENABLE_SVG_ICONS
item.tooltip = _utf8(L("Layers editing"));
item.sprite_id = 10;
item.is_toggable = true;
@ -3921,9 +3885,6 @@ void GLCanvas3D::_render_overlays() const
_render_gizmos_overlay();
_render_warning_texture();
_render_legend_texture();
#if !ENABLE_SVG_ICONS
_resize_toolbars();
#endif // !ENABLE_SVG_ICONS
_render_toolbar();
_render_view_toolbar();
@ -4000,7 +3961,6 @@ void GLCanvas3D::_render_current_gizmo() const
void GLCanvas3D::_render_gizmos_overlay() const
{
#if ENABLE_SVG_ICONS
#if ENABLE_RETINA_GL
// m_gizmos.set_overlay_scale(m_retina_helper->get_scale_factor());
const float scale = m_retina_helper->get_scale_factor()*wxGetApp().toolbar_icon_scale();
@ -4011,14 +3971,12 @@ void GLCanvas3D::_render_gizmos_overlay() const
const float size = int(GLGizmosManager::Default_Icons_Size*wxGetApp().toolbar_icon_scale());
m_gizmos.set_overlay_icon_size(size); //! #ys_FIXME_experiment
#endif /* __WXMSW__ */
#endif // ENABLE_SVG_ICONS
m_gizmos.render_overlay(*this, m_selection);
}
void GLCanvas3D::_render_toolbar() const
{
#if ENABLE_SVG_ICONS
#if ENABLE_RETINA_GL
// m_toolbar.set_scale(m_retina_helper->get_scale_factor());
const float scale = m_retina_helper->get_scale_factor() * wxGetApp().toolbar_icon_scale(true);
@ -4073,20 +4031,12 @@ void GLCanvas3D::_render_toolbar() const
}
}
m_toolbar.set_position(top, left);
#else
#if ENABLE_RETINA_GL
m_toolbar.set_icons_scale(m_retina_helper->get_scale_factor());
#else
m_toolbar.set_icons_scale(m_canvas->GetContentScaleFactor());
#endif /* __WXMSW__ */
#endif // ENABLE_SVG_ICONS
m_toolbar.render(*this);
}
void GLCanvas3D::_render_view_toolbar() const
{
#if ENABLE_SVG_ICONS
#if ENABLE_RETINA_GL
// m_view_toolbar.set_scale(m_retina_helper->get_scale_factor());
const float scale = m_retina_helper->get_scale_factor() * wxGetApp().toolbar_icon_scale();
@ -4106,13 +4056,6 @@ void GLCanvas3D::_render_view_toolbar() const
float top = (-0.5f * (float)cnv_size.get_height() + m_view_toolbar.get_height()) * inv_zoom;
float left = -0.5f * (float)cnv_size.get_width() * inv_zoom;
m_view_toolbar.set_position(top, left);
#else
#if ENABLE_RETINA_GL
m_view_toolbar.set_icons_scale(m_retina_helper->get_scale_factor());
#else
m_view_toolbar.set_icons_scale(m_canvas->GetContentScaleFactor());
#endif /* __WXMSW__ */
#endif // ENABLE_SVG_ICONS
m_view_toolbar.render(*this);
}
@ -5555,73 +5498,6 @@ bool GLCanvas3D::_is_any_volume_outside() const
return false;
}
#if !ENABLE_SVG_ICONS
void GLCanvas3D::_resize_toolbars() const
{
Size cnv_size = get_canvas_size();
float zoom = (float)m_camera.get_zoom();
float inv_zoom = (zoom != 0.0f) ? 1.0f / zoom : 0.0f;
#if ENABLE_RETINA_GL
m_toolbar.set_icons_scale(m_retina_helper->get_scale_factor());
#else
m_toolbar.set_icons_scale(m_canvas->GetContentScaleFactor());
#endif /* __WXMSW__ */
GLToolbar::Layout::EOrientation orientation = m_toolbar.get_layout_orientation();
switch (m_toolbar.get_layout_type())
{
default:
case GLToolbar::Layout::Horizontal:
{
// centers the toolbar on the top edge of the 3d scene
float top, left;
if (orientation == GLToolbar::Layout::Top)
{
top = 0.5f * (float)cnv_size.get_height() * inv_zoom;
left = -0.5f * m_toolbar.get_width() * inv_zoom;
}
else
{
top = (-0.5f * (float)cnv_size.get_height() + m_view_toolbar.get_height()) * inv_zoom;
left = -0.5f * m_toolbar.get_width() * inv_zoom;
}
m_toolbar.set_position(top, left);
break;
}
case GLToolbar::Layout::Vertical:
{
// centers the toolbar on the right edge of the 3d scene
float top, left;
if (orientation == GLToolbar::Layout::Left)
{
top = 0.5f * m_toolbar.get_height() * inv_zoom;
left = (-0.5f * (float)cnv_size.get_width()) * inv_zoom;
}
else
{
top = 0.5f * m_toolbar.get_height() * inv_zoom;
left = (0.5f * (float)cnv_size.get_width() - m_toolbar.get_width()) * inv_zoom;
}
m_toolbar.set_position(top, left);
break;
}
}
#if ENABLE_RETINA_GL
m_view_toolbar.set_icons_scale(m_retina_helper->get_scale_factor());
#else
m_view_toolbar.set_icons_scale(m_canvas->GetContentScaleFactor());
#endif /* __WXMSW__ */
// places the toolbar on the bottom-left corner of the 3d scene
float top = (-0.5f * (float)cnv_size.get_height() + m_view_toolbar.get_height()) * inv_zoom;
float left = -0.5f * (float)cnv_size.get_width() * inv_zoom;
m_view_toolbar.set_position(top, left);
}
#endif // !ENABLE_SVG_ICONS
void GLCanvas3D::_update_selection_from_hover()
{
bool ctrl_pressed = wxGetKeyState(WXK_CONTROL);

View file

@ -728,10 +728,6 @@ private:
bool _is_any_volume_outside() const;
#if !ENABLE_SVG_ICONS
void _resize_toolbars() const;
#endif // !ENABLE_SVG_ICONS
// updates the selection from the content of m_hover_volume_idxs
void _update_selection_from_hover();

View file

@ -38,9 +38,7 @@ const GLToolbarItem::EnabledStateCallback GLToolbarItem::Default_Enabled_State_C
GLToolbarItem::Data::Data()
: name("")
#if ENABLE_SVG_ICONS
, icon_filename("")
#endif // ENABLE_SVG_ICONS
, tooltip("")
, sprite_id(-1)
, is_toggable(false)
@ -105,14 +103,6 @@ GLTexture::Quad_UVs GLToolbarItem::get_uvs(unsigned int tex_width, unsigned int
return uvs;
}
#if !ENABLE_SVG_ICONS
ItemsIconsTexture::Metadata::Metadata()
: filename("")
, icon_size(0)
{
}
#endif // !ENABLE_SVG_ICONS
BackgroundTexture::Metadata::Metadata()
: filename("")
, left(0)
@ -122,9 +112,7 @@ BackgroundTexture::Metadata::Metadata()
{
}
#if ENABLE_SVG_ICONS
const float GLToolbar::Default_Icons_Size = 40.0f;
#endif // ENABLE_SVG_ICONS
GLToolbar::Layout::Layout()
: type(Horizontal)
@ -134,31 +122,19 @@ GLToolbar::Layout::Layout()
, border(0.0f)
, separator_size(0.0f)
, gap_size(0.0f)
#if ENABLE_SVG_ICONS
, icons_size(Default_Icons_Size)
, scale(1.0f)
#else
, icons_scale(1.0f)
#endif // ENABLE_SVG_ICONS
, width(0.0f)
, height(0.0f)
, dirty(true)
{
}
#if ENABLE_SVG_ICONS
GLToolbar::GLToolbar(GLToolbar::EType type, const std::string& name)
#else
GLToolbar::GLToolbar(GLToolbar::EType type)
#endif // ENABLE_SVG_ICONS
: m_type(type)
#if ENABLE_SVG_ICONS
, m_name(name)
#endif // ENABLE_SVG_ICONS
, m_enabled(false)
#if ENABLE_SVG_ICONS
, m_icons_texture_dirty(true)
#endif // ENABLE_SVG_ICONS
, m_tooltip("")
{
}
@ -171,27 +147,13 @@ GLToolbar::~GLToolbar()
}
}
#if ENABLE_SVG_ICONS
bool GLToolbar::init(const BackgroundTexture::Metadata& background_texture)
#else
bool GLToolbar::init(const ItemsIconsTexture::Metadata& icons_texture, const BackgroundTexture::Metadata& background_texture)
#endif // ENABLE_SVG_ICONS
{
#if ENABLE_SVG_ICONS
if (m_background_texture.texture.get_id() != 0)
return true;
std::string path = resources_dir() + "/icons/";
bool res = false;
#else
if (m_icons_texture.texture.get_id() != 0)
return true;
std::string path = resources_dir() + "/icons/";
bool res = !icons_texture.filename.empty() && m_icons_texture.texture.load_from_file(path + icons_texture.filename, false, true);
if (res)
m_icons_texture.metadata = icons_texture;
#endif // ENABLE_SVG_ICONS
if (!background_texture.filename.empty())
res = m_background_texture.texture.load_from_file(path + background_texture.filename, false, true);
@ -247,7 +209,6 @@ void GLToolbar::set_gap_size(float size)
m_layout.dirty = true;
}
#if ENABLE_SVG_ICONS
void GLToolbar::set_icons_size(float size)
{
if (m_layout.icons_size != size)
@ -267,13 +228,6 @@ void GLToolbar::set_scale(float scale)
m_icons_texture_dirty = true;
}
}
#else
void GLToolbar::set_icons_scale(float scale)
{
m_layout.icons_scale = scale;
m_layout.dirty = true;
}
#endif // ENABLE_SVG_ICONS
bool GLToolbar::is_enabled() const
{
@ -385,10 +339,8 @@ void GLToolbar::render(const GLCanvas3D& parent) const
if (!m_enabled || m_items.empty())
return;
#if ENABLE_SVG_ICONS
if (m_icons_texture_dirty)
generate_icons_texture();
#endif // ENABLE_SVG_ICONS
switch (m_layout.type)
{
@ -492,20 +444,12 @@ float GLToolbar::get_width_horizontal() const
float GLToolbar::get_width_vertical() const
{
#if ENABLE_SVG_ICONS
return (2.0f * m_layout.border + m_layout.icons_size) * m_layout.scale;
#else
return 2.0f * m_layout.border * m_layout.icons_scale + m_icons_texture.metadata.icon_size * m_layout.icons_scale;
#endif // ENABLE_SVG_ICONS
}
float GLToolbar::get_height_horizontal() const
{
#if ENABLE_SVG_ICONS
return (2.0f * m_layout.border + m_layout.icons_size) * m_layout.scale;
#else
return 2.0f * m_layout.border * m_layout.icons_scale + m_icons_texture.metadata.icon_size * m_layout.icons_scale;
#endif // ENABLE_SVG_ICONS
}
float GLToolbar::get_height_vertical() const
@ -515,7 +459,6 @@ float GLToolbar::get_height_vertical() const
float GLToolbar::get_main_size() const
{
#if ENABLE_SVG_ICONS
float size = 2.0f * m_layout.border;
for (unsigned int i = 0; i < (unsigned int)m_items.size(); ++i)
{
@ -531,25 +474,7 @@ float GLToolbar::get_main_size() const
if (m_items.size() > 1)
size += ((float)m_items.size() - 1.0f) * m_layout.gap_size;
size *= m_layout.scale;
#else
float size = 2.0f * m_layout.border * m_layout.icons_scale;
for (unsigned int i = 0; i < (unsigned int)m_items.size(); ++i)
{
if (!m_items[i]->is_visible())
continue;
if (m_items[i]->is_separator())
size += m_layout.separator_size * m_layout.icons_scale;
else
size += (float)m_icons_texture.metadata.icon_size * m_layout.icons_scale;
}
if (m_items.size() > 1)
size += ((float)m_items.size() - 1.0f) * m_layout.gap_size * m_layout.icons_scale;
#endif // ENABLE_SVG_ICONS
return size;
return size * m_layout.scale;
}
void GLToolbar::do_action(unsigned int item_id, GLCanvas3D& parent)
@ -609,20 +534,12 @@ std::string GLToolbar::update_hover_state_horizontal(const Vec2d& mouse_pos, GLC
float zoom = (float)parent.get_camera().get_zoom();
float inv_zoom = (zoom != 0.0f) ? 1.0f / zoom : 0.0f;
#if ENABLE_SVG_ICONS
float factor = m_layout.scale * inv_zoom;
#else
float factor = m_layout.icons_scale * inv_zoom;
#endif // ENABLE_SVG_ICONS
Size cnv_size = parent.get_canvas_size();
Vec2d scaled_mouse_pos((mouse_pos(0) - 0.5 * (double)cnv_size.get_width()) * inv_zoom, (0.5 * (double)cnv_size.get_height() - mouse_pos(1)) * inv_zoom);
#if ENABLE_SVG_ICONS
float scaled_icons_size = m_layout.icons_size * factor;
#else
float scaled_icons_size = (float)m_icons_texture.metadata.icon_size * factor;
#endif // ENABLE_SVG_ICONS
float scaled_separator_size = m_layout.separator_size * factor;
float scaled_gap_size = m_layout.gap_size * factor;
float scaled_border = m_layout.border * factor;
@ -714,20 +631,12 @@ std::string GLToolbar::update_hover_state_vertical(const Vec2d& mouse_pos, GLCan
float zoom = (float)parent.get_camera().get_zoom();
float inv_zoom = (zoom != 0.0f) ? 1.0f / zoom : 0.0f;
#if ENABLE_SVG_ICONS
float factor = m_layout.scale * inv_zoom;
#else
float factor = m_layout.icons_scale * inv_zoom;
#endif // ENABLE_SVG_ICONS
Size cnv_size = parent.get_canvas_size();
Vec2d scaled_mouse_pos((mouse_pos(0) - 0.5 * (double)cnv_size.get_width()) * inv_zoom, (0.5 * (double)cnv_size.get_height() - mouse_pos(1)) * inv_zoom);
#if ENABLE_SVG_ICONS
float scaled_icons_size = m_layout.icons_size * factor;
#else
float scaled_icons_size = (float)m_icons_texture.metadata.icon_size * factor;
#endif // ENABLE_SVG_ICONS
float scaled_separator_size = m_layout.separator_size * factor;
float scaled_gap_size = m_layout.gap_size * factor;
float scaled_border = m_layout.border * factor;
@ -831,20 +740,12 @@ int GLToolbar::contains_mouse_horizontal(const Vec2d& mouse_pos, const GLCanvas3
float zoom = (float)parent.get_camera().get_zoom();
float inv_zoom = (zoom != 0.0f) ? 1.0f / zoom : 0.0f;
#if ENABLE_SVG_ICONS
float factor = m_layout.scale * inv_zoom;
#else
float factor = m_layout.icons_scale * inv_zoom;
#endif // ENABLE_SVG_ICONS
Size cnv_size = parent.get_canvas_size();
Vec2d scaled_mouse_pos((mouse_pos(0) - 0.5 * (double)cnv_size.get_width()) * inv_zoom, (0.5 * (double)cnv_size.get_height() - mouse_pos(1)) * inv_zoom);
#if ENABLE_SVG_ICONS
float scaled_icons_size = m_layout.icons_size * factor;
#else
float scaled_icons_size = (float)m_icons_texture.metadata.icon_size * factor;
#endif // ENABLE_SVG_ICONS
float scaled_separator_size = m_layout.separator_size * factor;
float scaled_gap_size = m_layout.gap_size * factor;
float scaled_border = m_layout.border * factor;
@ -914,20 +815,12 @@ int GLToolbar::contains_mouse_vertical(const Vec2d& mouse_pos, const GLCanvas3D&
float zoom = (float)parent.get_camera().get_zoom();
float inv_zoom = (zoom != 0.0f) ? 1.0f / zoom : 0.0f;
#if ENABLE_SVG_ICONS
float factor = m_layout.scale * inv_zoom;
#else
float factor = m_layout.icons_scale * inv_zoom;
#endif // ENABLE_SVG_ICONS
Size cnv_size = parent.get_canvas_size();
Vec2d scaled_mouse_pos((mouse_pos(0) - 0.5 * (double)cnv_size.get_width()) * inv_zoom, (0.5 * (double)cnv_size.get_height() - mouse_pos(1)) * inv_zoom);
#if ENABLE_SVG_ICONS
float scaled_icons_size = m_layout.icons_size * factor;
#else
float scaled_icons_size = (float)m_icons_texture.metadata.icon_size * factor;
#endif // ENABLE_SVG_ICONS
float scaled_separator_size = m_layout.separator_size * factor;
float scaled_gap_size = m_layout.gap_size * factor;
float scaled_border = m_layout.border * factor;
@ -993,34 +886,15 @@ int GLToolbar::contains_mouse_vertical(const Vec2d& mouse_pos, const GLCanvas3D&
void GLToolbar::render_horizontal(const GLCanvas3D& parent) const
{
#if ENABLE_SVG_ICONS
unsigned int tex_id = m_icons_texture.get_id();
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_width = m_icons_texture.texture.get_width();
int tex_height = m_icons_texture.texture.get_height();
#endif // ENABLE_SVG_ICONS
#if !ENABLE_SVG_ICONS
if ((tex_id == 0) || (tex_width <= 0) || (tex_height <= 0))
return;
#endif // !ENABLE_SVG_ICONS
float zoom = (float)parent.get_camera().get_zoom();
float inv_zoom = (zoom != 0.0f) ? 1.0f / zoom : 0.0f;
#if ENABLE_SVG_ICONS
float factor = inv_zoom * m_layout.scale;
#else
float factor = inv_zoom * m_layout.icons_scale;
#endif // ENABLE_SVG_ICONS
#if ENABLE_SVG_ICONS
float scaled_icons_size = m_layout.icons_size * factor;
#else
float scaled_icons_size = (float)m_icons_texture.metadata.icon_size * factor;
#endif // ENABLE_SVG_ICONS
float scaled_separator_size = m_layout.separator_size * factor;
float scaled_gap_size = m_layout.gap_size * factor;
float scaled_border = m_layout.border * factor;
@ -1121,10 +995,8 @@ void GLToolbar::render_horizontal(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)
@ -1136,11 +1008,7 @@ void GLToolbar::render_horizontal(const GLCanvas3D& parent) const
left += separator_stride;
else
{
#if ENABLE_SVG_ICONS
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_width, (unsigned int)tex_height, m_icons_texture.metadata.icon_size);
#endif // ENABLE_SVG_ICONS
left += icon_stride;
}
}
@ -1148,34 +1016,15 @@ void GLToolbar::render_horizontal(const GLCanvas3D& parent) const
void GLToolbar::render_vertical(const GLCanvas3D& parent) const
{
#if ENABLE_SVG_ICONS
unsigned int tex_id = m_icons_texture.get_id();
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_width = m_icons_texture.texture.get_width();
int tex_height = m_icons_texture.texture.get_height();
#endif // ENABLE_SVG_ICONS
#if !ENABLE_SVG_ICONS
if ((tex_id == 0) || (tex_width <= 0) || (tex_height <= 0))
return;
#endif // !ENABLE_SVG_ICONS
float zoom = (float)parent.get_camera().get_zoom();
float inv_zoom = (zoom != 0.0f) ? 1.0f / zoom : 0.0f;
#if ENABLE_SVG_ICONS
float factor = inv_zoom * m_layout.scale;
#else
float factor = inv_zoom * m_layout.icons_scale;
#endif // ENABLE_SVG_ICONS
#if ENABLE_SVG_ICONS
float scaled_icons_size = m_layout.icons_size * factor;
#else
float scaled_icons_size = (float)m_icons_texture.metadata.icon_size * m_layout.icons_scale * factor;
#endif // ENABLE_SVG_ICONS
float scaled_separator_size = m_layout.separator_size * factor;
float scaled_gap_size = m_layout.gap_size * factor;
float scaled_border = m_layout.border * factor;
@ -1276,10 +1125,8 @@ 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)
@ -1291,17 +1138,12 @@ void GLToolbar::render_vertical(const GLCanvas3D& parent) const
top -= separator_stride;
else
{
#if ENABLE_SVG_ICONS
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_width, (unsigned int)tex_height, m_icons_texture.metadata.icon_size);
#endif // ENABLE_SVG_ICONS
top -= icon_stride;
}
}
}
#if ENABLE_SVG_ICONS
bool GLToolbar::generate_icons_texture() const
{
std::string path = resources_dir() + "/icons/";
@ -1337,7 +1179,6 @@ bool GLToolbar::generate_icons_texture() const
return res;
}
#endif // ENABLE_SVG_ICONS
bool GLToolbar::update_items_visibility()
{

View file

@ -58,9 +58,7 @@ public:
struct Data
{
std::string name;
#if ENABLE_SVG_ICONS
std::string icon_filename;
#endif // ENABLE_SVG_ICONS
std::string tooltip;
unsigned int sprite_id;
bool is_toggable;
@ -88,9 +86,7 @@ public:
void set_state(EState state) { m_state = state; }
const std::string& get_name() const { return m_data.name; }
#if ENABLE_SVG_ICONS
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; }
void do_action() { m_data.action_callback(); }
@ -118,27 +114,6 @@ private:
friend class GLToolbar;
};
#if !ENABLE_SVG_ICONS
// items icon textures are assumed to be square and all with the same size in pixels, no internal check is done
// icons are layed-out into the texture starting from the top-left corner in the same order as enum GLToolbarItem::EState
// from left to right
struct ItemsIconsTexture
{
struct Metadata
{
// path of the file containing the icons' texture
std::string filename;
// size of the square icons, in pixels
unsigned int icon_size;
Metadata();
};
GLTexture texture;
Metadata metadata;
};
#endif // !ENABLE_SVG_ICONS
struct BackgroundTexture
{
struct Metadata
@ -164,9 +139,7 @@ struct BackgroundTexture
class GLToolbar
{
public:
#if ENABLE_SVG_ICONS
static const float Default_Icons_Size;
#endif // ENABLE_SVG_ICONS
enum EType : unsigned char
{
@ -201,12 +174,8 @@ public:
float border;
float separator_size;
float gap_size;
#if ENABLE_SVG_ICONS
float icons_size;
float scale;
#else
float icons_scale;
#endif // ENABLE_SVG_ICONS
float width;
float height;
@ -219,16 +188,10 @@ private:
typedef std::vector<GLToolbarItem*> ItemsList;
EType m_type;
#if ENABLE_SVG_ICONS
std::string m_name;
#endif // ENABLE_SVG_ICONS
bool m_enabled;
#if ENABLE_SVG_ICONS
mutable GLTexture m_icons_texture;
mutable bool m_icons_texture_dirty;
#else
ItemsIconsTexture m_icons_texture;
#endif // ENABLE_SVG_ICONS
BackgroundTexture m_background_texture;
mutable Layout m_layout;
@ -251,18 +214,10 @@ private:
std::string m_tooltip;
public:
#if ENABLE_SVG_ICONS
GLToolbar(EType type, const std::string& name);
#else
explicit GLToolbar(EType type);
#endif // ENABLE_SVG_ICONS
~GLToolbar();
#if ENABLE_SVG_ICONS
bool init(const BackgroundTexture::Metadata& background_texture);
#else
bool init(const ItemsIconsTexture::Metadata& icons_texture, const BackgroundTexture::Metadata& background_texture);
#endif // ENABLE_SVG_ICONS
Layout::EType get_layout_type() const;
void set_layout_type(Layout::EType type);
@ -273,12 +228,8 @@ public:
void set_border(float border);
void set_separator_size(float size);
void set_gap_size(float size);
#if ENABLE_SVG_ICONS
void set_icons_size(float size);
void set_scale(float scale);
#else
void set_icons_scale(float scale);
#endif // ENABLE_SVG_ICONS
bool is_enabled() const;
void set_enabled(bool enable);
@ -297,7 +248,6 @@ public:
const std::string& get_tooltip() const { return m_tooltip; }
// returns true if any item changed its state
bool update_items_state();
@ -324,9 +274,7 @@ private:
void render_horizontal(const GLCanvas3D& parent) const;
void render_vertical(const GLCanvas3D& parent) const;
#if ENABLE_SVG_ICONS
bool generate_icons_texture() const;
#endif // ENABLE_SVG_ICONS
// returns true if any item changed its state
bool update_items_visibility();

View file

@ -132,18 +132,12 @@ void GLGizmoBase::Grabber::render_face(float half_size) const
glsafe(::glEnd());
}
#if ENABLE_SVG_ICONS
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
: m_parent(parent)
, m_group_id(-1)
, m_state(Off)
, m_shortcut_key(0)
#if ENABLE_SVG_ICONS
, m_icon_filename(icon_filename)
#endif // ENABLE_SVG_ICONS
, m_sprite_id(sprite_id)
, m_hover_id(-1)
, m_dragging(false)

View file

@ -89,9 +89,7 @@ protected:
int m_group_id;
EState m_state;
int m_shortcut_key;
#if ENABLE_SVG_ICONS
std::string m_icon_filename;
#endif // ENABLE_SVG_ICONS
unsigned int m_sprite_id;
int m_hover_id;
bool m_dragging;
@ -102,11 +100,7 @@ protected:
ImGuiWrapper* m_imgui;
public:
#if ENABLE_SVG_ICONS
GLGizmoBase(GLCanvas3D& parent, const std::string& icon_filename, unsigned int sprite_id);
#else
GLGizmoBase(GLCanvas3D& parent, unsigned int sprite_id);
#endif // ENABLE_SVG_ICONS
virtual ~GLGizmoBase() {}
bool init() { return on_init(); }
@ -122,9 +116,7 @@ public:
int get_shortcut_key() const { return m_shortcut_key; }
void set_shortcut_key(int key) { m_shortcut_key = key; }
#if ENABLE_SVG_ICONS
const std::string& get_icon_filename() const { return m_icon_filename; }
#endif // ENABLE_SVG_ICONS
bool is_activable(const Selection& selection) const { return on_is_activable(selection); }
bool is_selectable() const { return on_is_selectable(); }

View file

@ -19,13 +19,8 @@ const double GLGizmoCut::Offset = 10.0;
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& 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)
#endif // ENABLE_SVG_ICONS
, m_cut_z(0.0)
, m_max_z(0.0)
, m_keep_upper(true)

View file

@ -23,11 +23,7 @@ class GLGizmoCut : public GLGizmoBase
bool m_rotate_lower;
public:
#if ENABLE_SVG_ICONS
GLGizmoCut(GLCanvas3D& parent, const std::string& icon_filename, unsigned int sprite_id);
#else
GLGizmoCut(GLCanvas3D& parent, unsigned int sprite_id);
#endif // ENABLE_SVG_ICONS
protected:
virtual bool on_init();

View file

@ -9,13 +9,8 @@ namespace Slic3r {
namespace GUI {
#if ENABLE_SVG_ICONS
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)
#endif // ENABLE_SVG_ICONS
, m_normal(Vec3d::Zero())
, m_starting_center(Vec3d::Zero())
{

View file

@ -37,11 +37,7 @@ private:
bool is_plane_update_necessary() const;
public:
#if ENABLE_SVG_ICONS
GLGizmoFlatten(GLCanvas3D& parent, const std::string& icon_filename, unsigned int sprite_id);
#else
GLGizmoFlatten(GLCanvas3D& parent, unsigned int sprite_id);
#endif // ENABLE_SVG_ICONS
void set_flattening_data(const ModelObject* model_object);
Vec3d get_flattening_normal() const;

View file

@ -10,13 +10,8 @@ namespace GUI {
const double GLGizmoMove3D::Offset = 10.0;
#if ENABLE_SVG_ICONS
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)
#endif // ENABLE_SVG_ICONS
, m_displacement(Vec3d::Zero())
, m_snap_step(1.0)
, m_starting_drag_position(Vec3d::Zero())

View file

@ -22,11 +22,7 @@ class GLGizmoMove3D : public GLGizmoBase
GLUquadricObj* m_quadric;
public:
#if ENABLE_SVG_ICONS
GLGizmoMove3D(GLCanvas3D& parent, const std::string& icon_filename, unsigned int sprite_id);
#else
GLGizmoMove3D(GLCanvas3D& parent, unsigned int sprite_id);
#endif // ENABLE_SVG_ICONS
virtual ~GLGizmoMove3D();
double get_snap_step(double step) const { return m_snap_step; }

View file

@ -19,11 +19,7 @@ const unsigned int GLGizmoRotate::SnapRegionsCount = 8;
const float GLGizmoRotate::GrabberOffset = 0.15f; // in percent of radius
GLGizmoRotate::GLGizmoRotate(GLCanvas3D& parent, GLGizmoRotate::Axis axis)
#if ENABLE_SVG_ICONS
: GLGizmoBase(parent, "", -1)
#else
: GLGizmoBase(parent, -1)
#endif // ENABLE_SVG_ICONS
, m_axis(axis)
, m_angle(0.0)
, m_quadric(nullptr)
@ -40,11 +36,7 @@ GLGizmoRotate::GLGizmoRotate(GLCanvas3D& parent, GLGizmoRotate::Axis axis)
}
GLGizmoRotate::GLGizmoRotate(const GLGizmoRotate& other)
#if ENABLE_SVG_ICONS
: 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
, m_axis(other.m_axis)
, m_angle(other.m_angle)
, m_quadric(nullptr)
@ -417,13 +409,8 @@ Vec3d GLGizmoRotate::mouse_position_in_local_plane(const Linef3& mouse_ray, cons
return transform(mouse_ray, m).intersect_plane(0.0);
}
#if ENABLE_SVG_ICONS
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)
#endif // ENABLE_SVG_ICONS
{
m_gizmos.emplace_back(parent, GLGizmoRotate::X);
m_gizmos.emplace_back(parent, GLGizmoRotate::Y);

View file

@ -76,11 +76,7 @@ class GLGizmoRotate3D : public GLGizmoBase
std::vector<GLGizmoRotate> m_gizmos;
public:
#if ENABLE_SVG_ICONS
GLGizmoRotate3D(GLCanvas3D& parent, const std::string& icon_filename, unsigned int sprite_id);
#else
GLGizmoRotate3D(GLCanvas3D& parent, unsigned int sprite_id);
#endif // ENABLE_SVG_ICONS
Vec3d get_rotation() const { return Vec3d(m_gizmos[X].get_angle(), m_gizmos[Y].get_angle(), m_gizmos[Z].get_angle()); }
void set_rotation(const Vec3d& rotation) { m_gizmos[X].set_angle(rotation(0)); m_gizmos[Y].set_angle(rotation(1)); m_gizmos[Z].set_angle(rotation(2)); }

View file

@ -13,13 +13,8 @@ namespace GUI {
const float GLGizmoScale3D::Offset = 5.0f;
#if ENABLE_SVG_ICONS
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)
#endif // ENABLE_SVG_ICONS
, m_scale(Vec3d::Ones())
, m_offset(Vec3d::Zero())
, m_snap_step(0.05)

View file

@ -32,11 +32,7 @@ class GLGizmoScale3D : public GLGizmoBase
StartingData m_starting;
public:
#if ENABLE_SVG_ICONS
GLGizmoScale3D(GLCanvas3D& parent, const std::string& icon_filename, unsigned int sprite_id);
#else
GLGizmoScale3D(GLCanvas3D& parent, unsigned int sprite_id);
#endif // ENABLE_SVG_ICONS
double get_snap_step(double step) const { return m_snap_step; }
void set_snap_step(double step) { m_snap_step = step; }

View file

@ -19,13 +19,8 @@
namespace Slic3r {
namespace GUI {
#if ENABLE_SVG_ICONS
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)
#endif // ENABLE_SVG_ICONS
, m_quadric(nullptr)
, m_its(nullptr)
{

View file

@ -58,11 +58,7 @@ private:
};
public:
#if ENABLE_SVG_ICONS
GLGizmoSlaSupports(GLCanvas3D& parent, const std::string& icon_filename, unsigned int sprite_id);
#else
GLGizmoSlaSupports(GLCanvas3D& parent, unsigned int sprite_id);
#endif // ENABLE_SVG_ICONS
virtual ~GLGizmoSlaSupports();
void set_sla_support_data(ModelObject* model_object, const Selection& selection);
bool gizmo_event(SLAGizmoEventType action, const Vec2d& mouse_position, bool shift_down, bool alt_down, bool control_down);

View file

@ -12,17 +12,12 @@
namespace Slic3r {
namespace GUI {
#if ENABLE_SVG_ICONS
const float GLGizmosManager::Default_Icons_Size = 64;
#endif // ENABLE_SVG_ICONS
GLGizmosManager::GLGizmosManager()
: m_enabled(false)
#if ENABLE_SVG_ICONS
, m_icons_texture_dirty(true)
#endif // ENABLE_SVG_ICONS
, m_current(Undefined)
#if ENABLE_SVG_ICONS
, m_overlay_icons_size(Default_Icons_Size)
, m_overlay_scale(1.0f)
, m_overlay_border(5.0f)
@ -30,11 +25,6 @@ GLGizmosManager::GLGizmosManager()
, m_tooltip("")
{
}
#else
{
set_overlay_scale(1.0);
}
#endif // ENABLE_SVG_ICONS
GLGizmosManager::~GLGizmosManager()
{
@ -43,20 +33,6 @@ GLGizmosManager::~GLGizmosManager()
bool GLGizmosManager::init(GLCanvas3D& parent)
{
#if !ENABLE_SVG_ICONS
m_icons_texture.metadata.filename = "gizmos.png";
m_icons_texture.metadata.icon_size = 64;
if (!m_icons_texture.metadata.filename.empty())
{
if (!m_icons_texture.texture.load_from_file(resources_dir() + "/icons/" + m_icons_texture.metadata.filename, false, true))
{
reset();
return false;
}
}
#endif // !ENABLE_SVG_ICONS
m_background_texture.metadata.filename = "toolbar_background.png";
m_background_texture.metadata.left = 16;
m_background_texture.metadata.top = 16;
@ -72,11 +48,7 @@ bool GLGizmosManager::init(GLCanvas3D& parent)
}
}
#if ENABLE_SVG_ICONS
GLGizmoBase* gizmo = new GLGizmoMove3D(parent, "move.svg", 0);
#else
GLGizmoBase* gizmo = new GLGizmoMove3D(parent, 0);
#endif // ENABLE_SVG_ICONS
if (gizmo == nullptr)
return false;
@ -85,11 +57,7 @@ bool GLGizmosManager::init(GLCanvas3D& parent)
m_gizmos.insert(GizmosMap::value_type(Move, gizmo));
#if ENABLE_SVG_ICONS
gizmo = new GLGizmoScale3D(parent, "scale.svg", 1);
#else
gizmo = new GLGizmoScale3D(parent, 1);
#endif // ENABLE_SVG_ICONS
if (gizmo == nullptr)
return false;
@ -98,11 +66,7 @@ bool GLGizmosManager::init(GLCanvas3D& parent)
m_gizmos.insert(GizmosMap::value_type(Scale, gizmo));
#if ENABLE_SVG_ICONS
gizmo = new GLGizmoRotate3D(parent, "rotate.svg", 2);
#else
gizmo = new GLGizmoRotate3D(parent, 2);
#endif // ENABLE_SVG_ICONS
if (gizmo == nullptr)
{
reset();
@ -117,11 +81,7 @@ bool GLGizmosManager::init(GLCanvas3D& parent)
m_gizmos.insert(GizmosMap::value_type(Rotate, gizmo));
#if ENABLE_SVG_ICONS
gizmo = new GLGizmoFlatten(parent, "place.svg", 3);
#else
gizmo = new GLGizmoFlatten(parent, 3);
#endif // ENABLE_SVG_ICONS
if (gizmo == nullptr)
return false;
@ -132,11 +92,7 @@ bool GLGizmosManager::init(GLCanvas3D& parent)
m_gizmos.insert(GizmosMap::value_type(Flatten, gizmo));
#if ENABLE_SVG_ICONS
gizmo = new GLGizmoCut(parent, "cut.svg", 4);
#else
gizmo = new GLGizmoCut(parent, 4);
#endif // ENABLE_SVG_ICONS
if (gizmo == nullptr)
return false;
@ -147,11 +103,7 @@ bool GLGizmosManager::init(GLCanvas3D& parent)
m_gizmos.insert(GizmosMap::value_type(Cut, gizmo));
#if ENABLE_SVG_ICONS
gizmo = new GLGizmoSlaSupports(parent, "sla_supports.svg", 5);
#else
gizmo = new GLGizmoSlaSupports(parent, 5);
#endif // ENABLE_SVG_ICONS
if (gizmo == nullptr)
return false;
@ -165,7 +117,6 @@ bool GLGizmosManager::init(GLCanvas3D& parent)
return true;
}
#if ENABLE_SVG_ICONS
void GLGizmosManager::set_overlay_icon_size(float size)
{
if (m_overlay_icons_size != size)
@ -174,21 +125,14 @@ void GLGizmosManager::set_overlay_icon_size(float size)
m_icons_texture_dirty = true;
}
}
#endif // ENABLE_SVG_ICONS
void GLGizmosManager::set_overlay_scale(float scale)
{
#if ENABLE_SVG_ICONS
if (m_overlay_scale != scale)
{
m_overlay_scale = scale;
m_icons_texture_dirty = true;
}
#else
m_overlay_icons_scale = scale;
m_overlay_border = 5.0f * scale;
m_overlay_gap_y = 5.0f * scale;
#endif // ENABLE_SVG_ICONS
}
void GLGizmosManager::refresh_on_off_state(const Selection& selection)
@ -526,10 +470,8 @@ void GLGizmosManager::render_overlay(const GLCanvas3D& canvas, const Selection&
if (!m_enabled)
return;
#if ENABLE_SVG_ICONS
if (m_icons_texture_dirty)
generate_icons_texture();
#endif // ENABLE_SVG_ICONS
do_render_overlay(canvas, selection);
}
@ -935,11 +877,7 @@ void GLGizmosManager::do_render_overlay(const GLCanvas3D& canvas, const Selectio
float height = get_total_overlay_height();
float width = get_total_overlay_width();
#if ENABLE_SVG_ICONS
float scaled_border = m_overlay_border * m_overlay_scale * inv_zoom;
#else
float scaled_border = m_overlay_border * inv_zoom;
#endif // ENABLE_SVG_ICONS
float top_x = (-0.5f * cnv_w) * inv_zoom;
float top_y = (0.5f * height) * inv_zoom;
@ -1015,7 +953,6 @@ void GLGizmosManager::do_render_overlay(const GLCanvas3D& canvas, const Selectio
}
}
#if ENABLE_SVG_ICONS
top_x += scaled_border;
top_y -= scaled_border;
float scaled_gap_y = m_overlay_gap_y * m_overlay_scale * inv_zoom;
@ -1027,21 +964,9 @@ void GLGizmosManager::do_render_overlay(const GLCanvas3D& canvas, const Selectio
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;
float scaled_gap_y = m_overlay_gap_y * inv_zoom;
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();
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) || (tex_width <= 0) || (tex_height <= 0))
return;
#endif // ENABLE_SVG_ICONS
for (GizmosMap::const_iterator it = m_gizmos.begin(); it != m_gizmos.end(); ++it)
{
@ -1051,78 +976,44 @@ void GLGizmosManager::do_render_overlay(const GLCanvas3D& canvas, const Selectio
unsigned int sprite_id = it->second->get_sprite_id();
GLGizmoBase::EState state = it->second->get_state();
#if ENABLE_SVG_ICONS
float u_icon_size = m_overlay_icons_size * m_overlay_scale * inv_tex_width;
float v_icon_size = m_overlay_icons_size * m_overlay_scale * inv_tex_height;
float v_top = sprite_id * v_icon_size;
float u_left = state * u_icon_size;
float v_bottom = v_top + v_icon_size;
float u_right = u_left + u_icon_size;
#else
float uv_icon_size = (float)m_icons_texture.metadata.icon_size * inv_texture_size;
float v_top = sprite_id * uv_icon_size;
float u_left = state * uv_icon_size;
float v_bottom = v_top + uv_icon_size;
float u_right = u_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, { { u_left, v_bottom }, { u_right, v_bottom }, { u_right, v_top }, { u_left, v_top } });
if (it->second->get_state() == GLGizmoBase::On) {
float toolbar_top = (float)cnv_h - canvas.get_view_toolbar_height();
#if ENABLE_SVG_ICONS
it->second->render_input_window(width, 0.5f * cnv_h - top_y * zoom, toolbar_top, selection);
#else
it->second->render_input_window(2.0f * m_overlay_border + scaled_icons_size * zoom, 0.5f * cnv_h - top_y * zoom, toolbar_top, selection);
#endif // ENABLE_SVG_ICONS
}
#if ENABLE_SVG_ICONS
top_y -= scaled_stride_y;
#else
top_y -= (scaled_icons_size + scaled_gap_y);
#endif // ENABLE_SVG_ICONS
}
}
float GLGizmosManager::get_total_overlay_height() const
{
#if ENABLE_SVG_ICONS
float scaled_icons_size = m_overlay_icons_size * m_overlay_scale;
float scaled_border = m_overlay_border * m_overlay_scale;
float scaled_gap_y = m_overlay_gap_y * m_overlay_scale;
float scaled_stride_y = scaled_icons_size + scaled_gap_y;
float height = 2.0f * scaled_border;
#else
float height = 2.0f * m_overlay_border;
float scaled_icons_size = (float)m_icons_texture.metadata.icon_size * m_overlay_icons_scale;
#endif // ENABLE_SVG_ICONS
for (GizmosMap::const_iterator it = m_gizmos.begin(); it != m_gizmos.end(); ++it)
{
if ((it->second == nullptr) || !it->second->is_selectable())
continue;
#if ENABLE_SVG_ICONS
height += scaled_stride_y;
#else
height += (scaled_icons_size + m_overlay_gap_y);
#endif // ENABLE_SVG_ICONS
}
#if ENABLE_SVG_ICONS
return height - scaled_gap_y;
#else
return height - m_overlay_gap_y;
#endif // ENABLE_SVG_ICONS
}
float GLGizmosManager::get_total_overlay_width() const
{
#if ENABLE_SVG_ICONS
return (2.0f * m_overlay_border + m_overlay_icons_size) * m_overlay_scale;
#else
return (float)m_icons_texture.metadata.icon_size * m_overlay_icons_scale + 2.0f * m_overlay_border;
#endif // ENABLE_SVG_ICONS
}
GLGizmoBase* GLGizmosManager::get_current() const
@ -1131,7 +1022,6 @@ GLGizmoBase* GLGizmosManager::get_current() const
return (it != m_gizmos.end()) ? it->second : nullptr;
}
#if ENABLE_SVG_ICONS
bool GLGizmosManager::generate_icons_texture() const
{
std::string path = resources_dir() + "/icons/";
@ -1157,7 +1047,6 @@ bool GLGizmosManager::generate_icons_texture() const
return res;
}
#endif // ENABLE_SVG_ICONS
void GLGizmosManager::update_on_off_state(const GLCanvas3D& canvas, const Vec2d& mouse_pos, const Selection& selection)
{
@ -1167,27 +1056,18 @@ void GLGizmosManager::update_on_off_state(const GLCanvas3D& canvas, const Vec2d&
float cnv_h = (float)canvas.get_canvas_size().get_height();
float height = get_total_overlay_height();
#if ENABLE_SVG_ICONS
float scaled_icons_size = m_overlay_icons_size * m_overlay_scale;
float scaled_border = m_overlay_border * m_overlay_scale;
float scaled_gap_y = m_overlay_gap_y * m_overlay_scale;
float scaled_stride_y = scaled_icons_size + scaled_gap_y;
float top_y = 0.5f * (cnv_h - height) + scaled_border;
#else
float top_y = 0.5f * (cnv_h - height) + m_overlay_border;
float scaled_icons_size = (float)m_icons_texture.metadata.icon_size * m_overlay_icons_scale;
#endif // ENABLE_SVG_ICONS
for (GizmosMap::iterator it = m_gizmos.begin(); it != m_gizmos.end(); ++it)
{
if ((it->second == nullptr) || !it->second->is_selectable())
continue;
#if ENABLE_SVG_ICONS
bool inside = (scaled_border <= (float)mouse_pos(0)) && ((float)mouse_pos(0) <= scaled_border + scaled_icons_size) && (top_y <= (float)mouse_pos(1)) && ((float)mouse_pos(1) <= top_y + scaled_icons_size);
#else
bool inside = (m_overlay_border <= (float)mouse_pos(0)) && ((float)mouse_pos(0) <= m_overlay_border + scaled_icons_size) && (top_y <= (float)mouse_pos(1)) && ((float)mouse_pos(1) <= top_y + scaled_icons_size);
#endif // ENABLE_SVG_ICONS
if (it->second->is_activable(selection) && inside)
{
if ((it->second->get_state() == GLGizmoBase::On))
@ -1204,11 +1084,7 @@ void GLGizmosManager::update_on_off_state(const GLCanvas3D& canvas, const Vec2d&
else
it->second->set_state(GLGizmoBase::Off);
#if ENABLE_SVG_ICONS
top_y += scaled_stride_y;
#else
top_y += (scaled_icons_size + m_overlay_gap_y);
#endif // ENABLE_SVG_ICONS
}
GizmosMap::iterator it = m_gizmos.find(m_current);
@ -1227,38 +1103,25 @@ std::string GLGizmosManager::update_hover_state(const GLCanvas3D& canvas, const
float cnv_h = (float)canvas.get_canvas_size().get_height();
float height = get_total_overlay_height();
#if ENABLE_SVG_ICONS
float scaled_icons_size = m_overlay_icons_size * m_overlay_scale;
float scaled_border = m_overlay_border * m_overlay_scale;
float scaled_gap_y = m_overlay_gap_y * m_overlay_scale;
float scaled_stride_y = scaled_icons_size + scaled_gap_y;
float top_y = 0.5f * (cnv_h - height) + scaled_border;
#else
float top_y = 0.5f * (cnv_h - height) + m_overlay_border;
float scaled_icons_size = (float)m_icons_texture.metadata.icon_size * m_overlay_icons_scale;
#endif // ENABLE_SVG_ICONS
for (GizmosMap::iterator it = m_gizmos.begin(); it != m_gizmos.end(); ++it)
{
if ((it->second == nullptr) || !it->second->is_selectable())
continue;
#if ENABLE_SVG_ICONS
bool inside = (scaled_border <= (float)mouse_pos(0)) && ((float)mouse_pos(0) <= scaled_border + scaled_icons_size) && (top_y <= (float)mouse_pos(1)) && ((float)mouse_pos(1) <= top_y + scaled_icons_size);
#else
bool inside = (m_overlay_border <= (float)mouse_pos(0)) && ((float)mouse_pos(0) <= m_overlay_border + scaled_icons_size) && (top_y <= (float)mouse_pos(1)) && ((float)mouse_pos(1) <= top_y + scaled_icons_size);
#endif // ENABLE_SVG_ICONS
if (inside)
name = it->second->get_name();
if (it->second->is_activable(selection) && (it->second->get_state() != GLGizmoBase::On))
it->second->set_state(inside ? GLGizmoBase::Hover : GLGizmoBase::Off);
#if ENABLE_SVG_ICONS
top_y += scaled_stride_y;
#else
top_y += (scaled_icons_size + m_overlay_gap_y);
#endif // ENABLE_SVG_ICONS
}
return name;
@ -1272,34 +1135,21 @@ bool GLGizmosManager::overlay_contains_mouse(const GLCanvas3D& canvas, const Vec
float cnv_h = (float)canvas.get_canvas_size().get_height();
float height = get_total_overlay_height();
#if ENABLE_SVG_ICONS
float scaled_icons_size = m_overlay_icons_size * m_overlay_scale;
float scaled_border = m_overlay_border * m_overlay_scale;
float scaled_gap_y = m_overlay_gap_y * m_overlay_scale;
float scaled_stride_y = scaled_icons_size + scaled_gap_y;
float top_y = 0.5f * (cnv_h - height) + scaled_border;
#else
float top_y = 0.5f * (cnv_h - height) + m_overlay_border;
float scaled_icons_size = (float)m_icons_texture.metadata.icon_size * m_overlay_icons_scale;
#endif // ENABLE_SVG_ICONS
for (GizmosMap::const_iterator it = m_gizmos.begin(); it != m_gizmos.end(); ++it)
{
if ((it->second == nullptr) || !it->second->is_selectable())
continue;
#if ENABLE_SVG_ICONS
if ((scaled_border <= (float)mouse_pos(0)) && ((float)mouse_pos(0) <= scaled_border + scaled_icons_size) && (top_y <= (float)mouse_pos(1)) && ((float)mouse_pos(1) <= top_y + scaled_icons_size))
#else
if ((m_overlay_border <= (float)mouse_pos(0)) && ((float)mouse_pos(0) <= m_overlay_border + scaled_icons_size) && (top_y <= (float)mouse_pos(1)) && ((float)mouse_pos(1) <= top_y + scaled_icons_size))
#endif // ENABLE_SVG_ICONS
return true;
#if ENABLE_SVG_ICONS
top_y += scaled_stride_y;
#else
top_y += (scaled_icons_size + m_overlay_gap_y);
#endif // ENABLE_SVG_ICONS
}
return false;

View file

@ -46,9 +46,7 @@ public:
class GLGizmosManager
{
public:
#if ENABLE_SVG_ICONS
static const float Default_Icons_Size;
#endif // ENABLE_SVG_ICONS
enum EType : unsigned char
{
@ -66,21 +64,13 @@ private:
bool m_enabled;
typedef std::map<EType, GLGizmoBase*> GizmosMap;
GizmosMap m_gizmos;
#if ENABLE_SVG_ICONS
mutable GLTexture m_icons_texture;
mutable bool m_icons_texture_dirty;
#else
ItemsIconsTexture m_icons_texture;
#endif // ENABLE_SVG_ICONS
BackgroundTexture m_background_texture;
EType m_current;
#if ENABLE_SVG_ICONS
float m_overlay_icons_size;
float m_overlay_scale;
#else
float m_overlay_icons_scale;
#endif // ENABLE_SVG_ICONS
float m_overlay_border;
float m_overlay_gap_y;
@ -109,9 +99,7 @@ public:
bool is_enabled() const { return m_enabled; }
void set_enabled(bool enable) { m_enabled = enable; }
#if ENABLE_SVG_ICONS
void set_overlay_icon_size(float size);
#endif // ENABLE_SVG_ICONS
void set_overlay_scale(float scale);
void refresh_on_off_state(const Selection& selection);
@ -173,9 +161,7 @@ private:
GLGizmoBase* get_current() const;
#if ENABLE_SVG_ICONS
bool generate_icons_texture() const;
#endif // ENABLE_SVG_ICONS
void update_on_off_state(const GLCanvas3D& canvas, const Vec2d& mouse_pos, const Selection& selection);
std::string update_hover_state(const GLCanvas3D& canvas, const Vec2d& mouse_pos);

View file

@ -1736,11 +1736,7 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame)
}))
, sidebar(new Sidebar(q))
, delayed_scene_refresh(false)
#if ENABLE_SVG_ICONS
, view_toolbar(GLToolbar::Radio, "View")
#else
, view_toolbar(GLToolbar::Radio)
#endif // ENABLE_SVG_ICONS
, m_project_filename(wxEmptyString)
{
this->q->SetFont(Slic3r::GUI::wxGetApp().normal_font());
@ -3395,12 +3391,6 @@ bool Plater::priv::complit_init_part_menu()
void Plater::priv::init_view_toolbar()
{
#if !ENABLE_SVG_ICONS
ItemsIconsTexture::Metadata icons_data;
icons_data.filename = "view_toolbar.png";
icons_data.icon_size = 64;
#endif // !ENABLE_SVG_ICONS
BackgroundTexture::Metadata background_data;
background_data.filename = "toolbar_background.png";
background_data.left = 16;
@ -3408,11 +3398,7 @@ void Plater::priv::init_view_toolbar()
background_data.right = 16;
background_data.bottom = 16;
#if ENABLE_SVG_ICONS
if (!view_toolbar.init(background_data))
#else
if (!view_toolbar.init(icons_data, background_data))
#endif // ENABLE_SVG_ICONS
return;
view_toolbar.set_layout_orientation(GLToolbar::Layout::Bottom);
@ -3422,9 +3408,7 @@ void Plater::priv::init_view_toolbar()
GLToolbarItem::Data item;
item.name = "3D";
#if ENABLE_SVG_ICONS
item.icon_filename = "editor.svg";
#endif // ENABLE_SVG_ICONS
item.tooltip = _utf8(L("3D editor view")) + " [" + GUI::shortkey_ctrl_prefix() + "5]";
item.sprite_id = 0;
item.action_callback = [this]() { if (this->q != nullptr) wxPostEvent(this->q, SimpleEvent(EVT_GLVIEWTOOLBAR_3D)); };
@ -3433,9 +3417,7 @@ void Plater::priv::init_view_toolbar()
return;
item.name = "Preview";
#if ENABLE_SVG_ICONS
item.icon_filename = "preview.svg";
#endif // ENABLE_SVG_ICONS
item.tooltip = _utf8(L("Preview")) + " [" + GUI::shortkey_ctrl_prefix() + "6]";
item.sprite_id = 1;
item.action_callback = [this]() { if (this->q != nullptr) wxPostEvent(this->q, SimpleEvent(EVT_GLVIEWTOOLBAR_PREVIEW)); };