From 2adce6264378275abf2764a970a39e1576fd6bc0 Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Wed, 2 Jan 2019 16:26:22 +0100 Subject: [PATCH] Background texture for toolbars set as default --- src/libslic3r/Technologies.hpp | 2 - src/slic3r/GUI/GLCanvas3D.cpp | 51 --- src/slic3r/GUI/GLCanvas3D.hpp | 13 +- src/slic3r/GUI/GLToolbar.cpp | 651 --------------------------------- src/slic3r/GUI/GLToolbar.hpp | 172 +-------- src/slic3r/GUI/GUI_Preview.cpp | 8 - src/slic3r/GUI/GUI_Preview.hpp | 14 - src/slic3r/GUI/Plater.cpp | 33 -- 8 files changed, 3 insertions(+), 941 deletions(-) diff --git a/src/libslic3r/Technologies.hpp b/src/libslic3r/Technologies.hpp index 84bd7fc99..681259996 100644 --- a/src/libslic3r/Technologies.hpp +++ b/src/libslic3r/Technologies.hpp @@ -32,8 +32,6 @@ #define ENABLE_REMOVE_TABS_FROM_PLATER (1 && ENABLE_1_42_0) // Use wxDataViewRender instead of wxDataViewCustomRenderer #define ENABLE_NONCUSTOM_DATA_VIEW_RENDERING (0 && ENABLE_1_42_0) -// Adds background texture to toolbars -#define ENABLE_TOOLBAR_BACKGROUND_TEXTURE (1 && ENABLE_1_42_0) // Renders a small sphere in the center of the bounding box of the current selection when no gizmo is active #define ENABLE_RENDER_SELECTION_CENTER (0 && ENABLE_1_42_0) // Show visual hints in the 3D scene when sidebar matrix fields have focus diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index feaf14f98..1d6c3b117 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -2706,7 +2706,6 @@ bool GLCanvas3D::Gizmos::init(GLCanvas3D& parent) m_gizmos.insert(GizmosMap::value_type(SlaSupports, gizmo)); -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE m_background_texture.metadata.filename = "toolbar_background.png"; m_background_texture.metadata.left = 16; m_background_texture.metadata.top = 16; @@ -2721,7 +2720,6 @@ bool GLCanvas3D::Gizmos::init(GLCanvas3D& parent) return false; } } -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE return true; } @@ -3154,7 +3152,6 @@ void GLCanvas3D::Gizmos::_render_overlay(const GLCanvas3D& canvas, const GLCanva float inv_zoom = (zoom != 0.0f) ? 1.0f / zoom : 0.0f; float height = _get_total_overlay_height(); -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE float scaled_border = OverlayBorder * inv_zoom; float top_x = (-0.5f * cnv_w) * inv_zoom; @@ -3233,10 +3230,6 @@ void GLCanvas3D::Gizmos::_render_overlay(const GLCanvas3D& canvas, const GLCanva top_x += OverlayBorder * inv_zoom; top_y -= OverlayBorder * inv_zoom; -#else - float top_x = (OverlayBorder - 0.5f * cnv_w) * inv_zoom; - float top_y = (0.5f * height - OverlayBorder) * inv_zoom; -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE float scaled_gap_y = OverlayGapY * inv_zoom; for (GizmosMap::const_iterator it = m_gizmos.begin(); it != m_gizmos.end(); ++it) { @@ -3275,7 +3268,6 @@ float GLCanvas3D::Gizmos::_get_total_overlay_height() const return height - OverlayGapY; } -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE float GLCanvas3D::Gizmos::_get_total_overlay_width() const { float max_icon_width = 0.0f; @@ -3289,7 +3281,6 @@ float GLCanvas3D::Gizmos::_get_total_overlay_width() const return max_icon_width + 2.0f * OverlayBorder; } -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE GLGizmoBase* GLCanvas3D::Gizmos::_get_current() const { @@ -3666,11 +3657,7 @@ GLCanvas3D::GLCanvas3D(wxGLCanvas* canvas) : m_canvas(canvas) , m_context(nullptr) , m_in_render(false) -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE , m_toolbar(GLToolbar::Normal) -#else - , m_toolbar(*this) -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE #if ENABLE_REMOVE_TABS_FROM_PLATER , m_view_toolbar(nullptr) #endif // ENABLE_REMOVE_TABS_FROM_PLATER @@ -4910,11 +4897,7 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt) int layer_editing_object_idx = is_layers_editing_enabled() ? selected_object_idx : -1; m_layers_editing.last_object_id = layer_editing_object_idx; bool gizmos_overlay_contains_mouse = m_gizmos.overlay_contains_mouse(*this, m_mouse.position); -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE int toolbar_contains_mouse = m_toolbar.contains_mouse(m_mouse.position, *this); -#else - int toolbar_contains_mouse = m_toolbar.contains_mouse(m_mouse.position); -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE #if ENABLE_REMOVE_TABS_FROM_PLATER int view_toolbar_contains_mouse = (m_view_toolbar != nullptr) ? m_view_toolbar->contains_mouse(m_mouse.position, *this) : -1; #endif // ENABLE_REMOVE_TABS_FROM_PLATER @@ -4938,11 +4921,7 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt) else if (evt.LeftDClick() && (toolbar_contains_mouse != -1)) { m_toolbar_action_running = true; -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE m_toolbar.do_action((unsigned int)toolbar_contains_mouse, *this); -#else - m_toolbar.do_action((unsigned int)toolbar_contains_mouse); -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE } else if (evt.LeftDClick() && (m_gizmos.get_current_type() != Gizmos::Undefined)) { @@ -5021,11 +5000,7 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt) else if (toolbar_contains_mouse != -1) { m_toolbar_action_running = true; -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE m_toolbar.do_action((unsigned int)toolbar_contains_mouse, *this); -#else - m_toolbar.do_action((unsigned int)toolbar_contains_mouse); -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE m_mouse.left_down = false; } else @@ -5303,11 +5278,7 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt) // updates toolbar overlay if (tooltip.empty()) -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE tooltip = m_toolbar.update_hover_state(m_mouse.position, *this); -#else - tooltip = m_toolbar.update_hover_state(m_mouse.position); -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE // updates view toolbar overlay if (tooltip.empty() && (m_view_toolbar != nullptr)) @@ -5664,7 +5635,6 @@ bool GLCanvas3D::_init_toolbar() if (!m_toolbar.is_enabled()) return true; -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE ItemsIconsTexture::Metadata icons_data; icons_data.filename = "toolbar.png"; icons_data.icon_size = 36; @@ -5684,9 +5654,6 @@ bool GLCanvas3D::_init_toolbar() background_data.bottom = 16; if (!m_toolbar.init(icons_data, background_data)) -#else - if (!m_toolbar.init("toolbar.png", 36, 1, 1)) -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE { // unable to init the toolbar texture, disable it m_toolbar.set_enabled(false); @@ -5695,10 +5662,8 @@ bool GLCanvas3D::_init_toolbar() // m_toolbar.set_layout_type(GLToolbar::Layout::Vertical); m_toolbar.set_layout_type(GLToolbar::Layout::Horizontal); -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE m_toolbar.set_layout_orientation(GLToolbar::Layout::Top); m_toolbar.set_border(5.0f); -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE m_toolbar.set_separator_size(5); m_toolbar.set_gap_size(2); @@ -6339,11 +6304,7 @@ void GLCanvas3D::_render_toolbar() const #if !ENABLE_REMOVE_TABS_FROM_PLATER _resize_toolbar(); #endif // !ENABLE_REMOVE_TABS_FROM_PLATER -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE m_toolbar.render(*this); -#else - m_toolbar.render(); -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE } #if ENABLE_REMOVE_TABS_FROM_PLATER @@ -7976,9 +7937,7 @@ void GLCanvas3D::_resize_toolbar() const float zoom = get_camera_zoom(); float inv_zoom = (zoom != 0.0f) ? 1.0f / zoom : 0.0f; -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE GLToolbar::Layout::EOrientation orientation = m_toolbar.get_layout_orientation(); -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE switch (m_toolbar.get_layout_type()) { @@ -7986,7 +7945,6 @@ void GLCanvas3D::_resize_toolbar() const case GLToolbar::Layout::Horizontal: { // centers the toolbar on the top edge of the 3d scene -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE float top, left; if (orientation == GLToolbar::Layout::Top) { @@ -7998,17 +7956,12 @@ void GLCanvas3D::_resize_toolbar() const top = (-0.5f * (float)cnv_size.get_height() + m_view_toolbar->get_height()) * inv_zoom; left = -0.5f * m_toolbar.get_width() * inv_zoom; } -#else - float top = 0.5f * (float)cnv_size.get_height() * inv_zoom; - float left = -0.5f * m_toolbar.get_width() * inv_zoom; -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE m_toolbar.set_position(top, left); break; } case GLToolbar::Layout::Vertical: { // centers the toolbar on the right edge of the 3d scene -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE float top, left; if (orientation == GLToolbar::Layout::Left) { @@ -8020,10 +7973,6 @@ void GLCanvas3D::_resize_toolbar() const top = 0.5f * m_toolbar.get_height() * inv_zoom; left = (0.5f * (float)cnv_size.get_width() - m_toolbar.get_width()) * inv_zoom; } -#else - float top = 0.5f * m_toolbar.get_height() * inv_zoom; - float left = (0.5f * (float)cnv_size.get_width() - m_toolbar.get_width()) * inv_zoom; -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE m_toolbar.set_position(top, left); break; } diff --git a/src/slic3r/GUI/GLCanvas3D.hpp b/src/slic3r/GUI/GLCanvas3D.hpp index 6a1ccc45e..3c963f8be 100644 --- a/src/slic3r/GUI/GLCanvas3D.hpp +++ b/src/slic3r/GUI/GLCanvas3D.hpp @@ -640,9 +640,7 @@ private: bool m_enabled; typedef std::map GizmosMap; GizmosMap m_gizmos; -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE BackgroundTexture m_background_texture; -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE EType m_current; public: @@ -711,9 +709,8 @@ private: void _render_current_gizmo(const Selection& selection) const; float _get_total_overlay_height() const; -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE float _get_total_overlay_width() const; -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE + GLGizmoBase* _get_current() const; }; @@ -787,11 +784,7 @@ private: mutable Gizmos m_gizmos; mutable GLToolbar m_toolbar; #if ENABLE_REMOVE_TABS_FROM_PLATER -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE GLToolbar* m_view_toolbar; -#else - GLRadioToolbar* m_view_toolbar; -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE #endif // ENABLE_REMOVE_TABS_FROM_PLATER ClippingPlane m_clipping_planes[2]; bool m_use_clipping_planes; @@ -842,11 +835,7 @@ public: wxGLCanvas* get_wxglcanvas() { return m_canvas; } #if ENABLE_REMOVE_TABS_FROM_PLATER -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE void set_view_toolbar(GLToolbar* toolbar) { m_view_toolbar = toolbar; } -#else - void set_view_toolbar(GLRadioToolbar* toolbar) { m_view_toolbar = toolbar; } -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE #endif // ENABLE_REMOVE_TABS_FROM_PLATER bool init(bool useVBOs, bool use_legacy_opengl); diff --git a/src/slic3r/GUI/GLToolbar.cpp b/src/slic3r/GUI/GLToolbar.cpp index 43da81809..9bd2358bd 100644 --- a/src/slic3r/GUI/GLToolbar.cpp +++ b/src/slic3r/GUI/GLToolbar.cpp @@ -75,12 +75,10 @@ bool GLToolbarItem::is_enabled() const return m_state != Disabled; } -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE bool GLToolbarItem::is_disabled() const { return m_state == Disabled; } -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE bool GLToolbarItem::is_hovered() const { @@ -131,7 +129,6 @@ GLTexture::Quad_UVs GLToolbarItem::get_uvs(unsigned int texture_size, unsigned i return uvs; } -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE ItemsIconsTexture::Metadata::Metadata() : filename("") , icon_size(0) @@ -139,18 +136,7 @@ ItemsIconsTexture::Metadata::Metadata() , icon_gap_size(0) { } -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE -#if !ENABLE_TOOLBAR_BACKGROUND_TEXTURE -ItemsIconsTexture::ItemsIconsTexture() - : items_icon_size(0) - , items_icon_border_size(0) - , items_icon_gap_size(0) -{ -} -#endif // !ENABLE_TOOLBAR_BACKGROUND_TEXTURE - -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE BackgroundTexture::Metadata::Metadata() : filename("") , left(0) @@ -159,36 +145,24 @@ BackgroundTexture::Metadata::Metadata() , bottom(0) { } -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE GLToolbar::Layout::Layout() : type(Horizontal) -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE , orientation(Center) -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE , top(0.0f) , left(0.0f) -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE , border(0.0f) -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE , separator_size(0.0f) , gap_size(0.0f) , icons_scale(1.0f) -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE , width(0.0f) , height(0.0f) , dirty(true) -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE { } -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE GLToolbar::GLToolbar(GLToolbar::EType type) : m_type(type) -#else -GLToolbar::GLToolbar(GLCanvas3D& parent) - : m_parent(parent) -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE , m_enabled(false) { } @@ -201,7 +175,6 @@ GLToolbar::~GLToolbar() } } -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE bool GLToolbar::init(const ItemsIconsTexture::Metadata& icons_texture, const BackgroundTexture::Metadata& background_texture) { if (m_icons_texture.texture.get_id() != 0) @@ -220,21 +193,6 @@ bool GLToolbar::init(const ItemsIconsTexture::Metadata& icons_texture, const Bac return res; } -#else -bool GLToolbar::init(const std::string& icons_texture_filename, unsigned int items_icon_size, unsigned int items_icon_border_size, unsigned int items_icon_gap_size) -{ - std::string path = resources_dir() + "/icons/"; - bool res = !icons_texture_filename.empty() && m_icons_texture.texture.load_from_file(path + icons_texture_filename, false); - if (res) - { - m_icons_texture.items_icon_size = items_icon_size; - m_icons_texture.items_icon_border_size = items_icon_border_size; - m_icons_texture.items_icon_gap_size = items_icon_gap_size; - } - - return res; -} -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE GLToolbar::Layout::EType GLToolbar::get_layout_type() const { @@ -244,12 +202,9 @@ GLToolbar::Layout::EType GLToolbar::get_layout_type() const void GLToolbar::set_layout_type(GLToolbar::Layout::EType type) { m_layout.type = type; -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE m_layout.dirty = true; -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE } -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE GLToolbar::Layout::EOrientation GLToolbar::get_layout_orientation() const { return m_layout.orientation; @@ -259,7 +214,6 @@ void GLToolbar::set_layout_orientation(GLToolbar::Layout::EOrientation orientati { m_layout.orientation = orientation; } -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE void GLToolbar::set_position(float top, float left) { @@ -267,36 +221,28 @@ void GLToolbar::set_position(float top, float left) m_layout.left = left; } -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE void GLToolbar::set_border(float border) { m_layout.border = border; m_layout.dirty = true; } -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE void GLToolbar::set_separator_size(float size) { m_layout.separator_size = size; -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE m_layout.dirty = true; -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE } void GLToolbar::set_gap_size(float size) { m_layout.gap_size = size; -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE m_layout.dirty = true; -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE } void GLToolbar::set_icons_scale(float scale) { m_layout.icons_scale = scale; -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE m_layout.dirty = true; -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE } bool GLToolbar::is_enabled() const @@ -316,9 +262,7 @@ bool GLToolbar::add_item(const GLToolbarItem::Data& data) return false; m_items.push_back(item); -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE m_layout.dirty = true; -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE return true; } @@ -330,56 +274,24 @@ bool GLToolbar::add_separator() return false; m_items.push_back(item); -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE m_layout.dirty = true; -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE return true; } float GLToolbar::get_width() const { -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE if (m_layout.dirty) calc_layout(); return m_layout.width; -#else - switch (m_layout.type) - { - default: - case Layout::Horizontal: - { - return get_width_horizontal(); - } - case Layout::Vertical: - { - return get_width_vertical(); - } - } -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE } float GLToolbar::get_height() const { -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE if (m_layout.dirty) calc_layout(); return m_layout.height; -#else - switch (m_layout.type) - { - default: - case Layout::Horizontal: - { - return get_height_horizontal(); - } - case Layout::Vertical: - { - return get_height_vertical(); - } - } -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE } void GLToolbar::enable_item(const std::string& name) @@ -406,7 +318,6 @@ void GLToolbar::disable_item(const std::string& name) } } -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE void GLToolbar::select_item(const std::string& name) { if (is_item_disabled(name)) @@ -421,7 +332,6 @@ void GLToolbar::select_item(const std::string& name) } } } -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE bool GLToolbar::is_item_pressed(const std::string& name) const { @@ -434,7 +344,6 @@ bool GLToolbar::is_item_pressed(const std::string& name) const return false; } -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE bool GLToolbar::is_item_disabled(const std::string& name) const { for (GLToolbarItem* item : m_items) @@ -445,20 +354,11 @@ bool GLToolbar::is_item_disabled(const std::string& name) const return false; } -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE #if ENABLE_REMOVE_TABS_FROM_PLATER -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE std::string GLToolbar::update_hover_state(const Vec2d& mouse_pos, GLCanvas3D& parent) #else -std::string GLToolbar::update_hover_state(const Vec2d& mouse_pos) -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE -#else -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE void GLToolbar::update_hover_state(const Vec2d& mouse_pos, GLCanvas3D& parent) -#else -void GLToolbar::update_hover_state(const Vec2d& mouse_pos) -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE #endif // ENABLE_REMOVE_TABS_FROM_PLATER { #if ENABLE_REMOVE_TABS_FROM_PLATER @@ -473,30 +373,16 @@ void GLToolbar::update_hover_state(const Vec2d& mouse_pos) { default: #if ENABLE_REMOVE_TABS_FROM_PLATER -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE case Layout::Horizontal: { return update_hover_state_horizontal(mouse_pos, parent); } case Layout::Vertical: { return update_hover_state_vertical(mouse_pos, parent); } #else - case Layout::Horizontal: { return update_hover_state_horizontal(mouse_pos); } - case Layout::Vertical: { return update_hover_state_vertical(mouse_pos); } -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE -#else -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE case Layout::Horizontal: { update_hover_state_horizontal(mouse_pos, parent); break; } case Layout::Vertical: { update_hover_state_vertical(mouse_pos, parent); break; } -#else - case Layout::Horizontal: { update_hover_state_horizontal(mouse_pos); break; } - case Layout::Vertical: { update_hover_state_vertical(mouse_pos); break; } -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE #endif // ENABLE_REMOVE_TABS_FROM_PLATER } } -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE int GLToolbar::contains_mouse(const Vec2d& mouse_pos, const GLCanvas3D& parent) const -#else -int GLToolbar::contains_mouse(const Vec2d& mouse_pos) const -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE { if (!m_enabled) return -1; @@ -504,21 +390,12 @@ int GLToolbar::contains_mouse(const Vec2d& mouse_pos) const switch (m_layout.type) { default: -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE case Layout::Horizontal: { return contains_mouse_horizontal(mouse_pos, parent); } case Layout::Vertical: { return contains_mouse_vertical(mouse_pos, parent); } -#else - case Layout::Horizontal: { return contains_mouse_horizontal(mouse_pos); } - case Layout::Vertical: { return contains_mouse_vertical(mouse_pos); } -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE } } -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE void GLToolbar::do_action(unsigned int item_id, GLCanvas3D& parent) -#else -void GLToolbar::do_action(unsigned int item_id) -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE { if (item_id < (unsigned int)m_items.size()) { @@ -533,51 +410,30 @@ void GLToolbar::do_action(unsigned int item_id) else if (state == GLToolbarItem::HoverPressed) item->set_state(GLToolbarItem::Hover); -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE parent.render(); item->do_action(parent.get_wxglcanvas()); -#else - m_parent.render(); - item->do_action(m_parent.get_wxglcanvas()); -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE } else { -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE if (m_type == Radio) select_item(item->get_name()); else -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE item->set_state(GLToolbarItem::HoverPressed); -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE parent.render(); item->do_action(parent.get_wxglcanvas()); if ((m_type == Normal) && (item->get_state() != GLToolbarItem::Disabled)) -#else - m_parent.render(); - item->do_action(m_parent.get_wxglcanvas()); - if (item->get_state() != GLToolbarItem::Disabled) -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE { // the item may get disabled during the action, if not, set it back to hover state item->set_state(GLToolbarItem::Hover); -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE parent.render(); -#else - m_parent.render(); -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE } } } } } -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE void GLToolbar::render(const GLCanvas3D& parent) const -#else -void GLToolbar::render() const -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE { if (!m_enabled || m_items.empty()) return; @@ -590,19 +446,13 @@ void GLToolbar::render() const switch (m_layout.type) { default: -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE case Layout::Horizontal: { render_horizontal(parent); break; } case Layout::Vertical: { render_vertical(parent); break; } -#else - case Layout::Horizontal: { render_horizontal(); break; } - case Layout::Vertical: { render_vertical(); break; } -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE } ::glPopMatrix(); } -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE void GLToolbar::calc_layout() const { switch (m_layout.type) @@ -624,7 +474,6 @@ void GLToolbar::calc_layout() const m_layout.dirty = false; } -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE float GLToolbar::get_width_horizontal() const { @@ -633,20 +482,12 @@ float GLToolbar::get_width_horizontal() const float GLToolbar::get_width_vertical() const { -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE return 2.0f * m_layout.border + m_icons_texture.metadata.icon_size * m_layout.icons_scale; -#else - return m_icons_texture.items_icon_size * m_layout.icons_scale; -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE } float GLToolbar::get_height_horizontal() const { -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE return 2.0f * m_layout.border + m_icons_texture.metadata.icon_size * m_layout.icons_scale; -#else - return m_icons_texture.items_icon_size * m_layout.icons_scale; -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE } float GLToolbar::get_height_vertical() const @@ -656,21 +497,13 @@ float GLToolbar::get_height_vertical() const float GLToolbar::get_main_size() const { -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE float size = 2.0f * m_layout.border; -#else - float size = 0.0f; -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE for (unsigned int i = 0; i < (unsigned int)m_items.size(); ++i) { if (m_items[i]->is_separator()) size += m_layout.separator_size; else -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE size += (float)m_icons_texture.metadata.icon_size * m_layout.icons_scale; -#else - size += (float)m_icons_texture.items_icon_size * m_layout.icons_scale; -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE } if (m_items.size() > 1) @@ -680,54 +513,27 @@ float GLToolbar::get_main_size() const } #if ENABLE_REMOVE_TABS_FROM_PLATER -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE std::string GLToolbar::update_hover_state_horizontal(const Vec2d& mouse_pos, GLCanvas3D& parent) #else -std::string GLToolbar::update_hover_state_horizontal(const Vec2d& mouse_pos) -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE -#else -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE void GLToolbar::update_hover_state_horizontal(const Vec2d& mouse_pos, GLCanvas3D& parent) -#else -void GLToolbar::update_hover_state_horizontal(const Vec2d& mouse_pos) -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE #endif // ENABLE_REMOVE_TABS_FROM_PLATER { -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE float zoom = parent.get_camera_zoom(); -#else - float zoom = m_parent.get_camera_zoom(); -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE float inv_zoom = (zoom != 0.0f) ? 1.0f / zoom : 0.0f; -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE Size cnv_size = parent.get_canvas_size(); -#else - Size cnv_size = m_parent.get_canvas_size(); -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE 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_TOOLBAR_BACKGROUND_TEXTURE float scaled_icons_size = (float)m_icons_texture.metadata.icon_size * m_layout.icons_scale * inv_zoom; -#else - float scaled_icons_size = (float)m_icons_texture.items_icon_size * m_layout.icons_scale * inv_zoom; -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE float scaled_separator_size = m_layout.separator_size * inv_zoom; float scaled_gap_size = m_layout.gap_size * inv_zoom; -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE float scaled_border = m_layout.border * inv_zoom; -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE float separator_stride = scaled_separator_size + scaled_gap_size; float icon_stride = scaled_icons_size + scaled_gap_size; -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE float left = m_layout.left + scaled_border; float top = m_layout.top - scaled_border; -#else - float left = m_layout.left; - float top = m_layout.top; -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE std::string tooltip = ""; @@ -748,14 +554,10 @@ void GLToolbar::update_hover_state_horizontal(const Vec2d& mouse_pos) case GLToolbarItem::Normal: { if (inside) -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE { -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE item->set_state(GLToolbarItem::Hover); -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE parent.set_as_dirty(); } -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE break; } @@ -764,28 +566,20 @@ void GLToolbar::update_hover_state_horizontal(const Vec2d& mouse_pos) if (inside) tooltip = item->get_tooltip(); else -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE { -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE item->set_state(GLToolbarItem::Normal); -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE parent.set_as_dirty(); } -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE break; } case GLToolbarItem::Pressed: { if (inside) -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE { -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE item->set_state(GLToolbarItem::HoverPressed); -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE parent.set_as_dirty(); } -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE break; } @@ -794,14 +588,10 @@ void GLToolbar::update_hover_state_horizontal(const Vec2d& mouse_pos) if (inside) tooltip = item->get_tooltip(); else -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE { -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE item->set_state(GLToolbarItem::Pressed); -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE parent.set_as_dirty(); } -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE break; } @@ -825,54 +615,27 @@ void GLToolbar::update_hover_state_horizontal(const Vec2d& mouse_pos) } #if ENABLE_REMOVE_TABS_FROM_PLATER -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE std::string GLToolbar::update_hover_state_vertical(const Vec2d& mouse_pos, GLCanvas3D& parent) #else -std::string GLToolbar::update_hover_state_vertical(const Vec2d& mouse_pos) -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE -#else -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE void GLToolbar::update_hover_state_vertical(const Vec2d& mouse_pos, GLCanvas3D& parent) -#else -void GLToolbar::update_hover_state_vertical(const Vec2d& mouse_pos) -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE #endif // ENABLE_REMOVE_TABS_FROM_PLATER { -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE float zoom = parent.get_camera_zoom(); -#else - float zoom = m_parent.get_camera_zoom(); -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE float inv_zoom = (zoom != 0.0f) ? 1.0f / zoom : 0.0f; -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE Size cnv_size = parent.get_canvas_size(); -#else - Size cnv_size = m_parent.get_canvas_size(); -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE 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_TOOLBAR_BACKGROUND_TEXTURE float scaled_icons_size = (float)m_icons_texture.metadata.icon_size * m_layout.icons_scale * inv_zoom; -#else - float scaled_icons_size = (float)m_icons_texture.items_icon_size * m_layout.icons_scale * inv_zoom; -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE float scaled_separator_size = m_layout.separator_size * inv_zoom; float scaled_gap_size = m_layout.gap_size * inv_zoom; -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE float scaled_border = m_layout.border * inv_zoom; -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE float separator_stride = scaled_separator_size + scaled_gap_size; float icon_stride = scaled_icons_size + scaled_gap_size; -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE float left = m_layout.left + scaled_border; float top = m_layout.top - scaled_border; -#else - float left = m_layout.left; - float top = m_layout.top; -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE std::string tooltip = ""; @@ -893,14 +656,10 @@ void GLToolbar::update_hover_state_vertical(const Vec2d& mouse_pos) case GLToolbarItem::Normal: { if (inside) -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE { -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE item->set_state(GLToolbarItem::Hover); -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE parent.set_as_dirty(); } -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE break; } @@ -909,28 +668,20 @@ void GLToolbar::update_hover_state_vertical(const Vec2d& mouse_pos) if (inside) tooltip = item->get_tooltip(); else -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE { -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE item->set_state(GLToolbarItem::Normal); -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE parent.set_as_dirty(); } -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE break; } case GLToolbarItem::Pressed: { if (inside) -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE { -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE item->set_state(GLToolbarItem::HoverPressed); -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE parent.set_as_dirty(); } -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE break; } @@ -939,14 +690,10 @@ void GLToolbar::update_hover_state_vertical(const Vec2d& mouse_pos) if (inside) tooltip = item->get_tooltip(); else -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE { -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE item->set_state(GLToolbarItem::Pressed); -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE parent.set_as_dirty(); } -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE break; } @@ -968,47 +715,24 @@ void GLToolbar::update_hover_state_vertical(const Vec2d& mouse_pos) #endif // ENABLE_REMOVE_TABS_FROM_PLATER } -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE int GLToolbar::contains_mouse_horizontal(const Vec2d& mouse_pos, const GLCanvas3D& parent) const -#else -int GLToolbar::contains_mouse_horizontal(const Vec2d& mouse_pos) const -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE { -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE float zoom = parent.get_camera_zoom(); -#else - float zoom = m_parent.get_camera_zoom(); -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE float inv_zoom = (zoom != 0.0f) ? 1.0f / zoom : 0.0f; -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE Size cnv_size = parent.get_canvas_size(); -#else - Size cnv_size = m_parent.get_canvas_size(); -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE 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_TOOLBAR_BACKGROUND_TEXTURE float scaled_icons_size = (float)m_icons_texture.metadata.icon_size * m_layout.icons_scale * inv_zoom; -#else - float scaled_icons_size = (float)m_icons_texture.items_icon_size * m_layout.icons_scale * inv_zoom; -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE float scaled_separator_size = m_layout.separator_size * inv_zoom; float scaled_gap_size = m_layout.gap_size * inv_zoom; -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE float scaled_border = m_layout.border * inv_zoom; -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE float separator_stride = scaled_separator_size + scaled_gap_size; float icon_stride = scaled_icons_size + scaled_gap_size; -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE float left = m_layout.left + scaled_border; float top = m_layout.top - scaled_border; -#else - float left = m_layout.left; - float top = m_layout.top; -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE int id = -1; @@ -1033,47 +757,24 @@ int GLToolbar::contains_mouse_horizontal(const Vec2d& mouse_pos) const return -1; } -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE int GLToolbar::contains_mouse_vertical(const Vec2d& mouse_pos, const GLCanvas3D& parent) const -#else -int GLToolbar::contains_mouse_vertical(const Vec2d& mouse_pos) const -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE { -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE float zoom = parent.get_camera_zoom(); -#else - float zoom = m_parent.get_camera_zoom(); -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE float inv_zoom = (zoom != 0.0f) ? 1.0f / zoom : 0.0f; -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE Size cnv_size = parent.get_canvas_size(); -#else - Size cnv_size = m_parent.get_canvas_size(); -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE 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_TOOLBAR_BACKGROUND_TEXTURE float scaled_icons_size = (float)m_icons_texture.metadata.icon_size * m_layout.icons_scale * inv_zoom; -#else - float scaled_icons_size = (float)m_icons_texture.items_icon_size * m_layout.icons_scale * inv_zoom; -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE float scaled_separator_size = m_layout.separator_size * inv_zoom; float scaled_gap_size = m_layout.gap_size * inv_zoom; -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE float scaled_border = m_layout.border * inv_zoom; -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE float separator_stride = scaled_separator_size + scaled_gap_size; float icon_stride = scaled_icons_size + scaled_gap_size; -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE float left = m_layout.left + scaled_border; float top = m_layout.top - scaled_border; -#else - float left = m_layout.left; - float top = m_layout.top; -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE int id = -1; @@ -1098,11 +799,7 @@ int GLToolbar::contains_mouse_vertical(const Vec2d& mouse_pos) const return -1; } -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE void GLToolbar::render_horizontal(const GLCanvas3D& parent) const -#else -void GLToolbar::render_horizontal() const -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE { unsigned int tex_id = m_icons_texture.texture.get_id(); int tex_size = m_icons_texture.texture.get_width(); @@ -1110,30 +807,19 @@ void GLToolbar::render_horizontal() const if ((tex_id == 0) || (tex_size <= 0)) return; -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE float zoom = parent.get_camera_zoom(); -#else - float zoom = m_parent.get_camera_zoom(); -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE float inv_zoom = (zoom != 0.0f) ? 1.0f / zoom : 0.0f; -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE float scaled_icons_size = (float)m_icons_texture.metadata.icon_size * m_layout.icons_scale * inv_zoom; -#else - float scaled_icons_size = (float)m_icons_texture.items_icon_size * m_layout.icons_scale * inv_zoom; -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE float scaled_separator_size = m_layout.separator_size * inv_zoom; float scaled_gap_size = m_layout.gap_size * inv_zoom; -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE float scaled_border = m_layout.border * inv_zoom; float scaled_width = get_width() * inv_zoom; float scaled_height = get_height() * inv_zoom; -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE float separator_stride = scaled_separator_size + scaled_gap_size; float icon_stride = scaled_icons_size + scaled_gap_size; -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE float left = m_layout.left; float top = m_layout.top; float right = left + scaled_width; @@ -1224,10 +910,6 @@ void GLToolbar::render_horizontal() const left += scaled_border; top -= scaled_border; -#else - float left = m_layout.left; - float top = m_layout.top; -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE // renders icons for (const GLToolbarItem* item : m_items) @@ -1236,21 +918,13 @@ void GLToolbar::render_horizontal() const left += separator_stride; else { -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE item->render(tex_id, left, left + scaled_icons_size, top - scaled_icons_size, top, (unsigned int)tex_size, m_icons_texture.metadata.icon_border_size, m_icons_texture.metadata.icon_size, m_icons_texture.metadata.icon_gap_size); -#else - item->render(tex_id, left, left + scaled_icons_size, top - scaled_icons_size, top, (unsigned int)tex_size, m_icons_texture.items_icon_border_size, m_icons_texture.items_icon_size, m_icons_texture.items_icon_gap_size); -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE left += icon_stride; } } } -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE void GLToolbar::render_vertical(const GLCanvas3D& parent) const -#else -void GLToolbar::render_vertical() const -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE { unsigned int tex_id = m_icons_texture.texture.get_id(); int tex_size = m_icons_texture.texture.get_width(); @@ -1258,30 +932,19 @@ void GLToolbar::render_vertical() const if ((tex_id == 0) || (tex_size <= 0)) return; -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE float zoom = parent.get_camera_zoom(); -#else - float zoom = m_parent.get_camera_zoom(); -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE float inv_zoom = (zoom != 0.0f) ? 1.0f / zoom : 0.0f; -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE float scaled_icons_size = (float)m_icons_texture.metadata.icon_size * m_layout.icons_scale * inv_zoom; -#else - float scaled_icons_size = (float)m_icons_texture.items_icon_size * m_layout.icons_scale * inv_zoom; -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE float scaled_separator_size = m_layout.separator_size * inv_zoom; float scaled_gap_size = m_layout.gap_size * inv_zoom; -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE float scaled_border = m_layout.border * inv_zoom; float scaled_width = get_width() * inv_zoom; float scaled_height = get_height() * inv_zoom; -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE float separator_stride = scaled_separator_size + scaled_gap_size; float icon_stride = scaled_icons_size + scaled_gap_size; -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE float left = m_layout.left; float top = m_layout.top; float right = left + scaled_width; @@ -1372,10 +1035,6 @@ void GLToolbar::render_vertical() const left += scaled_border; top -= scaled_border; -#else - float left = m_layout.left; - float top = m_layout.top; -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE // renders icons for (const GLToolbarItem* item : m_items) @@ -1384,321 +1043,11 @@ void GLToolbar::render_vertical() const top -= separator_stride; else { -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE item->render(tex_id, left, left + scaled_icons_size, top - scaled_icons_size, top, (unsigned int)tex_size, m_icons_texture.metadata.icon_border_size, m_icons_texture.metadata.icon_size, m_icons_texture.metadata.icon_gap_size); -#else - item->render(tex_id, left, left + scaled_icons_size, top - scaled_icons_size, top, (unsigned int)tex_size, m_icons_texture.items_icon_border_size, m_icons_texture.items_icon_size, m_icons_texture.items_icon_gap_size); -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE top -= icon_stride; } } } -#if !ENABLE_TOOLBAR_BACKGROUND_TEXTURE -GLRadioToolbarItem::Data::Data() - : name("") - , tooltip("") - , sprite_id(-1) -{ -} - -GLRadioToolbarItem::GLRadioToolbarItem(const GLRadioToolbarItem::Data& data) - : m_state(Normal) - , m_data(data) -{ -} - -GLRadioToolbarItem::EState GLRadioToolbarItem::get_state() const -{ - return m_state; -} - -void GLRadioToolbarItem::set_state(GLRadioToolbarItem::EState state) -{ - m_state = state; -} - -const std::string& GLRadioToolbarItem::get_name() const -{ - return m_data.name; -} - -const std::string& GLRadioToolbarItem::get_tooltip() const -{ - return m_data.tooltip; -} - -bool GLRadioToolbarItem::is_hovered() const -{ - return (m_state == Hover) || (m_state == HoverPressed); -} - -bool GLRadioToolbarItem::is_pressed() const -{ - return (m_state == Pressed) || (m_state == HoverPressed); -} - -void GLRadioToolbarItem::do_action(wxEvtHandler *target) -{ - wxPostEvent(target, SimpleEvent(m_data.action_event)); -} - -void GLRadioToolbarItem::render(unsigned int tex_id, float left, float right, float bottom, float top, unsigned int texture_size, unsigned int border_size, unsigned int icon_size, unsigned int gap_size) const -{ - GLTexture::render_sub_texture(tex_id, left, right, bottom, top, get_uvs(texture_size, border_size, icon_size, gap_size)); -} - -GLTexture::Quad_UVs GLRadioToolbarItem::get_uvs(unsigned int texture_size, unsigned int border_size, unsigned int icon_size, unsigned int gap_size) const -{ - GLTexture::Quad_UVs uvs; - - float inv_texture_size = (texture_size != 0) ? 1.0f / (float)texture_size : 0.0f; - - float scaled_icon_size = (float)icon_size * inv_texture_size; - float scaled_border_size = (float)border_size * inv_texture_size; - float scaled_gap_size = (float)gap_size * inv_texture_size; - float stride = scaled_icon_size + scaled_gap_size; - - float left = scaled_border_size + (float)m_state * stride; - float right = left + scaled_icon_size; - float top = scaled_border_size + (float)m_data.sprite_id * stride; - float bottom = top + scaled_icon_size; - - uvs.left_top = { left, top }; - uvs.left_bottom = { left, bottom }; - uvs.right_bottom = { right, bottom }; - uvs.right_top = { right, top }; - - return uvs; -} - -GLRadioToolbar::GLRadioToolbar() - : m_top(0.0f) - , m_left(0.0f) -{ -} - -GLRadioToolbar::~GLRadioToolbar() -{ - for (GLRadioToolbarItem* item : m_items) - { - delete item; - } -} - -bool GLRadioToolbar::init(const std::string& icons_texture_filename, unsigned int items_icon_size, unsigned int items_icon_border_size, unsigned int items_icon_gap_size) -{ - 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); - if (res) - { - m_icons_texture.items_icon_size = items_icon_size; - m_icons_texture.items_icon_border_size = items_icon_border_size; - m_icons_texture.items_icon_gap_size = items_icon_gap_size; - } - - return res; -} - -bool GLRadioToolbar::add_item(const GLRadioToolbarItem::Data& data) -{ - GLRadioToolbarItem* item = new GLRadioToolbarItem(data); - if (item == nullptr) - return false; - - m_items.push_back(item); - return true; -} - -float GLRadioToolbar::get_height() const -{ - return m_icons_texture.items_icon_size; -} - -void GLRadioToolbar::set_position(float top, float left) -{ - m_top = top; - m_left = left; -} - -void GLRadioToolbar::set_selection(const std::string& name) -{ - for (GLRadioToolbarItem* item : m_items) - { - item->set_state((item->get_name() == name) ? GLRadioToolbarItem::Pressed : GLRadioToolbarItem::Normal); - } -} - -int GLRadioToolbar::contains_mouse(const Vec2d& mouse_pos, const GLCanvas3D& parent) const -{ - float zoom = parent.get_camera_zoom(); - float inv_zoom = (zoom != 0.0f) ? 1.0f / zoom : 0.0f; - - 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); - - float scaled_icons_size = (float)m_icons_texture.items_icon_size * inv_zoom; - - float left = m_left; - float top = m_top; - - int id = -1; - - for (GLRadioToolbarItem* item : m_items) - { - ++id; - - float right = left + scaled_icons_size; - float bottom = top - scaled_icons_size; - - if ((left <= (float)scaled_mouse_pos(0)) && ((float)scaled_mouse_pos(0) <= right) && (bottom <= (float)scaled_mouse_pos(1)) && ((float)scaled_mouse_pos(1) <= top)) - return id; - - left += scaled_icons_size; - } - - return -1; -} - -std::string GLRadioToolbar::update_hover_state(const Vec2d& mouse_pos, GLCanvas3D& parent) -{ - float zoom = parent.get_camera_zoom(); - float inv_zoom = (zoom != 0.0f) ? 1.0f / zoom : 0.0f; - - 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); - - float scaled_icons_size = (float)m_icons_texture.items_icon_size * inv_zoom; - - float left = m_left; - float top = m_top; - - std::string tooltip = ""; - - for (GLRadioToolbarItem* item : m_items) - { - float right = left + scaled_icons_size; - float bottom = top - scaled_icons_size; - - GLRadioToolbarItem::EState state = item->get_state(); - bool inside = (left <= (float)scaled_mouse_pos(0)) && ((float)scaled_mouse_pos(0) <= right) && (bottom <= (float)scaled_mouse_pos(1)) && ((float)scaled_mouse_pos(1) <= top); - - switch (state) - { - case GLRadioToolbarItem::Normal: - { - if (inside) - { - item->set_state(GLRadioToolbarItem::Hover); - parent.set_as_dirty(); - } - - break; - } - case GLRadioToolbarItem::Hover: - { - if (inside) - tooltip = item->get_tooltip(); - else - { - item->set_state(GLRadioToolbarItem::Normal); - parent.set_as_dirty(); - } - - break; - } - case GLRadioToolbarItem::Pressed: - { - if (inside) - { - item->set_state(GLRadioToolbarItem::HoverPressed); - parent.set_as_dirty(); - } - - break; - } - case GLRadioToolbarItem::HoverPressed: - { - if (inside) - tooltip = item->get_tooltip(); - else - { - item->set_state(GLRadioToolbarItem::Pressed); - parent.set_as_dirty(); - } - - break; - } - default: - { - break; - } - } - - left += scaled_icons_size; - } - - return tooltip; -} - -void GLRadioToolbar::do_action(unsigned int item_id, GLCanvas3D& parent) -{ - for (unsigned int i = 0; i < (unsigned int)m_items.size(); ++i) - { - if (i != item_id) - m_items[i]->set_state(GLRadioToolbarItem::Normal); - } - - if (item_id < (unsigned int)m_items.size()) - { - GLRadioToolbarItem* item = m_items[item_id]; - if ((item != nullptr) && item->is_hovered() && !item->is_pressed()) - { - item->set_state(GLRadioToolbarItem::HoverPressed); - item->do_action(parent.get_wxglcanvas()); - } - } - - parent.set_as_dirty(); -} - -void GLRadioToolbar::render(const GLCanvas3D& parent) const -{ - if (m_items.empty()) - return; - - ::glDisable(GL_DEPTH_TEST); - - ::glPushMatrix(); - ::glLoadIdentity(); - - unsigned int tex_id = m_icons_texture.texture.get_id(); - int tex_size = m_icons_texture.texture.get_width(); - - if ((tex_id == 0) || (tex_size <= 0)) - return; - - float zoom = parent.get_camera_zoom(); - float inv_zoom = (zoom != 0.0f) ? 1.0f / zoom : 0.0f; - - float scaled_icons_size = (float)m_icons_texture.items_icon_size * inv_zoom; - - float left = m_left; - float top = m_top; - - // renders icons - for (const GLRadioToolbarItem* item : m_items) - { - item->render(tex_id, left, left + scaled_icons_size, top - scaled_icons_size, top, (unsigned int)tex_size, m_icons_texture.items_icon_border_size, m_icons_texture.items_icon_size, m_icons_texture.items_icon_gap_size); - left += scaled_icons_size; - } - - ::glPopMatrix(); -} -#endif // !ENABLE_TOOLBAR_BACKGROUND_TEXTURE - } // namespace GUI } // namespace Slic3r diff --git a/src/slic3r/GUI/GLToolbar.hpp b/src/slic3r/GUI/GLToolbar.hpp index 430d4a844..49296796d 100644 --- a/src/slic3r/GUI/GLToolbar.hpp +++ b/src/slic3r/GUI/GLToolbar.hpp @@ -77,9 +77,7 @@ public: void do_action(wxEvtHandler *target); bool is_enabled() const; -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE bool is_disabled() const; -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE bool is_hovered() const; bool is_pressed() const; @@ -97,7 +95,6 @@ private: // from left to right struct ItemsIconsTexture { -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE struct Metadata { // path of the file containing the icons' texture @@ -111,23 +108,11 @@ struct ItemsIconsTexture Metadata(); }; -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE - GLTexture texture; -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE - Metadata metadata; -#else - // size of the square icons, in pixels - unsigned int items_icon_size; - // distance from the border, in pixels - unsigned int items_icon_border_size; - // distance between two adjacent icons (to avoid filtering artifacts), in pixels - unsigned int items_icon_gap_size; - ItemsIconsTexture(); -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE + GLTexture texture; + Metadata metadata; }; -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE struct BackgroundTexture { struct Metadata @@ -149,19 +134,16 @@ struct BackgroundTexture GLTexture texture; Metadata metadata; }; -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE class GLToolbar { public: -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE enum EType : unsigned char { Normal, Radio, Num_Types }; -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE struct Layout { @@ -183,23 +165,17 @@ public: }; EType type; -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE EOrientation orientation; -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE float top; float left; -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE float border; -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE float separator_size; float gap_size; float icons_scale; -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE float width; float height; bool dirty; -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE Layout(); }; @@ -207,47 +183,27 @@ public: private: typedef std::vector ItemsList; -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE EType m_type; -#else - GLCanvas3D& m_parent; -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE bool m_enabled; ItemsIconsTexture m_icons_texture; -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE BackgroundTexture m_background_texture; mutable Layout m_layout; -#else - Layout m_layout; -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE ItemsList m_items; public: -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE explicit GLToolbar(EType type); -#else - explicit GLToolbar(GLCanvas3D& parent); -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE ~GLToolbar(); -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE bool init(const ItemsIconsTexture::Metadata& icons_texture, const BackgroundTexture::Metadata& background_texture); -#else - bool init(const std::string& icons_texture_filename, unsigned int items_icon_size, unsigned int items_icon_border_size, unsigned int items_icon_gap_size); -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE Layout::EType get_layout_type() const; void set_layout_type(Layout::EType type); -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE Layout::EOrientation get_layout_orientation() const; void set_layout_orientation(Layout::EOrientation orientation); -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE void set_position(float top, float left); -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE void set_border(float border); -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE void set_separator_size(float size); void set_gap_size(float size); void set_icons_scale(float scale); @@ -263,169 +219,45 @@ public: void enable_item(const std::string& name); void disable_item(const std::string& name); -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE void select_item(const std::string& name); -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE bool is_item_pressed(const std::string& name) const; -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE bool is_item_disabled(const std::string& name) const; -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE #if ENABLE_REMOVE_TABS_FROM_PLATER -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE std::string update_hover_state(const Vec2d& mouse_pos, GLCanvas3D& parent); #else - std::string update_hover_state(const Vec2d& mouse_pos); -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE -#else -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE void update_hover_state(const Vec2d& mouse_pos, GLCanvas3D& parent); -#else - void update_hover_state(const Vec2d& mouse_pos); -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE #endif // ENABLE_REMOVE_TABS_FROM_PLATER -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE // returns the id of the item under the given mouse position or -1 if none int contains_mouse(const Vec2d& mouse_pos, const GLCanvas3D& parent) const; void do_action(unsigned int item_id, GLCanvas3D& parent); -#else - // returns the id of the item under the given mouse position or -1 if none - int contains_mouse(const Vec2d& mouse_pos) const; - void do_action(unsigned int item_id); -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE - -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE void render(const GLCanvas3D& parent) const; -#else - void render() const; -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE private: -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE void calc_layout() const; -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE float get_width_horizontal() const; float get_width_vertical() const; float get_height_horizontal() const; float get_height_vertical() const; float get_main_size() const; #if ENABLE_REMOVE_TABS_FROM_PLATER -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE std::string update_hover_state_horizontal(const Vec2d& mouse_pos, GLCanvas3D& parent); std::string update_hover_state_vertical(const Vec2d& mouse_pos, GLCanvas3D& parent); #else - std::string update_hover_state_horizontal(const Vec2d& mouse_pos); - std::string update_hover_state_vertical(const Vec2d& mouse_pos); -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE -#else -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE void update_hover_state_horizontal(const Vec2d& mouse_pos, GLCanvas3D& parent); void update_hover_state_vertical(const Vec2d& mouse_pos, GLCanvas3D& parent); -#else - void update_hover_state_horizontal(const Vec2d& mouse_pos); - void update_hover_state_vertical(const Vec2d& mouse_pos); -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE #endif // ENABLE_REMOVE_TABS_FROM_PLATER -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE 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_horizontal(const GLCanvas3D& parent) const; void render_vertical(const GLCanvas3D& parent) const; -#else - int contains_mouse_horizontal(const Vec2d& mouse_pos) const; - int contains_mouse_vertical(const Vec2d& mouse_pos) const; - - void render_horizontal() const; - void render_vertical() const; -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE }; -#if !ENABLE_TOOLBAR_BACKGROUND_TEXTURE -class GLRadioToolbarItem -{ -public: - struct Data - { - std::string name; - std::string tooltip; - unsigned int sprite_id; - wxEventType action_event; - - Data(); - }; - - enum EState : unsigned char - { - Normal, - Pressed, - Hover, - HoverPressed, - Num_States - }; - -private: - EState m_state; - Data m_data; - -public: - GLRadioToolbarItem(const Data& data); - - EState get_state() const; - void set_state(EState state); - - const std::string& get_name() const; - const std::string& get_tooltip() const; - - bool is_hovered() const; - bool is_pressed() const; - - void do_action(wxEvtHandler *target); - - void render(unsigned int tex_id, float left, float right, float bottom, float top, unsigned int texture_size, unsigned int border_size, unsigned int icon_size, unsigned int gap_size) const; - -private: - GLTexture::Quad_UVs get_uvs(unsigned int texture_size, unsigned int border_size, unsigned int icon_size, unsigned int gap_size) const; -}; - -class GLRadioToolbar -{ - typedef std::vector ItemsList; - - ItemsIconsTexture m_icons_texture; - - ItemsList m_items; - float m_top; - float m_left; - -public: - GLRadioToolbar(); - ~GLRadioToolbar(); - - bool init(const std::string& icons_texture_filename, unsigned int items_icon_size, unsigned int items_icon_border_size, unsigned int items_icon_gap_size); - - bool add_item(const GLRadioToolbarItem::Data& data); - - float get_height() const; - - void set_position(float top, float left); - void set_selection(const std::string& name); - - // returns the id of the item under the given mouse position or -1 if none - int contains_mouse(const Vec2d& mouse_pos, const GLCanvas3D& parent) const; - - std::string update_hover_state(const Vec2d& mouse_pos, GLCanvas3D& parent); - - void do_action(unsigned int item_id, GLCanvas3D& parent); - - void render(const GLCanvas3D& parent) const; -}; -#endif // !ENABLE_TOOLBAR_BACKGROUND_TEXTURE - } // namespace GUI } // namespace Slic3r diff --git a/src/slic3r/GUI/GUI_Preview.cpp b/src/slic3r/GUI/GUI_Preview.cpp index 459bd9e5b..59b4a727d 100644 --- a/src/slic3r/GUI/GUI_Preview.cpp +++ b/src/slic3r/GUI/GUI_Preview.cpp @@ -91,11 +91,7 @@ bool View3D::init(wxWindow* parent, Model* model, DynamicPrintConfig* config, Ba return true; } -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE void View3D::set_view_toolbar(GLToolbar* toolbar) -#else -void View3D::set_view_toolbar(GLRadioToolbar* toolbar) -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE { if (m_canvas != nullptr) m_canvas->set_view_toolbar(toolbar); @@ -366,11 +362,7 @@ Preview::~Preview() } #if ENABLE_REMOVE_TABS_FROM_PLATER -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE void Preview::set_view_toolbar(GLToolbar* toolbar) -#else -void Preview::set_view_toolbar(GLRadioToolbar* toolbar) -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE { if (m_canvas != nullptr) m_canvas->set_view_toolbar(toolbar); diff --git a/src/slic3r/GUI/GUI_Preview.hpp b/src/slic3r/GUI/GUI_Preview.hpp index bd71adcb5..e04946255 100644 --- a/src/slic3r/GUI/GUI_Preview.hpp +++ b/src/slic3r/GUI/GUI_Preview.hpp @@ -28,15 +28,9 @@ class Model; namespace GUI { class GLCanvas3D; -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE #if ENABLE_REMOVE_TABS_FROM_PLATER class GLToolbar; #endif // ENABLE_REMOVE_TABS_FROM_PLATER -#else -#if ENABLE_REMOVE_TABS_FROM_PLATER -class GLRadioToolbar; -#endif // ENABLE_REMOVE_TABS_FROM_PLATER -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE #if ENABLE_REMOVE_TABS_FROM_PLATER class View3D : public wxPanel @@ -59,11 +53,7 @@ public: wxGLCanvas* get_wxglcanvas() { return m_canvas_widget; } GLCanvas3D* get_canvas3d() { return m_canvas; } -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE void set_view_toolbar(GLToolbar* toolbar); -#else - void set_view_toolbar(GLRadioToolbar* toolbar); -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE void set_as_dirty(); void set_bed_shape(const Pointfs& shape); @@ -131,11 +121,7 @@ public: wxGLCanvas* get_wxglcanvas() { return m_canvas_widget; } #if ENABLE_REMOVE_TABS_FROM_PLATER -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE void set_view_toolbar(GLToolbar* toolbar); -#else - void set_view_toolbar(GLRadioToolbar* toolbar); -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE #endif // ENABLE_REMOVE_TABS_FROM_PLATER void set_number_extruders(unsigned int number_extruders); diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 92c408670..5dd3d0ee0 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -913,11 +913,7 @@ struct Plater::priv Sidebar *sidebar; #if ENABLE_REMOVE_TABS_FROM_PLATER View3D* view3D; -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE GLToolbar view_toolbar; -#else - GLRadioToolbar view_toolbar; -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE #else #if !ENABLE_IMGUI wxPanel *panel3d; @@ -1080,9 +1076,7 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame) #endif // !ENABLE_REMOVE_TABS_FROM_PLATER , delayed_scene_refresh(false) , project_filename(wxEmptyString) -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE , view_toolbar(GLToolbar::Radio) -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE { arranging.store(false); rotoptimizing.store(false); @@ -2674,7 +2668,6 @@ bool Plater::priv::complit_init_part_menu() #if ENABLE_REMOVE_TABS_FROM_PLATER void Plater::priv::init_view_toolbar() { -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE ItemsIconsTexture::Metadata icons_data; icons_data.filename = "view_toolbar.png"; icons_data.icon_size = 64; @@ -2689,12 +2682,8 @@ void Plater::priv::init_view_toolbar() background_data.bottom = 16; if (!view_toolbar.init(icons_data, background_data)) -#else - if (!view_toolbar.init("view_toolbar.png", 64, 0, 0)) -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE return; -#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE view_toolbar.set_layout_orientation(GLToolbar::Layout::Bottom); view_toolbar.set_border(5.0f); view_toolbar.set_gap_size(1.0f); @@ -2725,28 +2714,6 @@ void Plater::priv::init_view_toolbar() view3D->set_view_toolbar(&view_toolbar); preview->set_view_toolbar(&view_toolbar); -#else - GLRadioToolbarItem::Data item; - - item.name = "3D"; - item.tooltip = GUI::L_str("3D editor view"); - item.sprite_id = 0; - item.action_event = EVT_GLVIEWTOOLBAR_3D; - if (!view_toolbar.add_item(item)) - return; - - item.name = "Preview"; - item.tooltip = GUI::L_str("Preview"); - item.sprite_id = 1; - item.action_event = EVT_GLVIEWTOOLBAR_PREVIEW; - if (!view_toolbar.add_item(item)) - return; - - view3D->set_view_toolbar(&view_toolbar); - preview->set_view_toolbar(&view_toolbar); - - view_toolbar.set_selection("3D"); -#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE } #endif // ENABLE_REMOVE_TABS_FROM_PLATER