This commit is contained in:
Enrico Turri 2018-12-17 10:55:48 +01:00
commit 082f7f4924
10 changed files with 976 additions and 49 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 22 KiB

View File

@ -38,6 +38,8 @@
#define ENABLE_CONSTRAINED_CAMERA_TARGET (1 && ENABLE_1_42_0) #define ENABLE_CONSTRAINED_CAMERA_TARGET (1 && ENABLE_1_42_0)
// Use wxDataViewRender instead of wxDataViewCustomRenderer // Use wxDataViewRender instead of wxDataViewCustomRenderer
#define ENABLE_NONCUSTOM_DATA_VIEW_RENDERING (0 && ENABLE_1_42_0) #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)
#endif // _technologies_h_ #endif // _technologies_h_

View File

@ -3434,7 +3434,11 @@ GLCanvas3D::GLCanvas3D(wxGLCanvas* canvas)
: m_canvas(canvas) : m_canvas(canvas)
, m_context(nullptr) , m_context(nullptr)
, m_in_render(false) , m_in_render(false)
#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE
, m_toolbar(GLToolbar::Normal)
#else
, m_toolbar(*this) , m_toolbar(*this)
#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE
#if ENABLE_REMOVE_TABS_FROM_PLATER #if ENABLE_REMOVE_TABS_FROM_PLATER
, m_view_toolbar(nullptr) , m_view_toolbar(nullptr)
#endif // ENABLE_REMOVE_TABS_FROM_PLATER #endif // ENABLE_REMOVE_TABS_FROM_PLATER
@ -4675,7 +4679,11 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
int layer_editing_object_idx = is_layers_editing_enabled() ? selected_object_idx : -1; int layer_editing_object_idx = is_layers_editing_enabled() ? selected_object_idx : -1;
m_layers_editing.last_object_id = layer_editing_object_idx; m_layers_editing.last_object_id = layer_editing_object_idx;
bool gizmos_overlay_contains_mouse = m_gizmos.overlay_contains_mouse(*this, m_mouse.position); 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); int toolbar_contains_mouse = m_toolbar.contains_mouse(m_mouse.position);
#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE
#if ENABLE_REMOVE_TABS_FROM_PLATER #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; 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 #endif // ENABLE_REMOVE_TABS_FROM_PLATER
@ -4699,7 +4707,11 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
else if (evt.LeftDClick() && (toolbar_contains_mouse != -1)) else if (evt.LeftDClick() && (toolbar_contains_mouse != -1))
{ {
m_toolbar_action_running = true; 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); 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)) else if (evt.LeftDClick() && (m_gizmos.get_current_type() != Gizmos::Undefined))
{ {
@ -4778,7 +4790,11 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
else if (toolbar_contains_mouse != -1) else if (toolbar_contains_mouse != -1)
{ {
m_toolbar_action_running = true; 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); m_toolbar.do_action((unsigned int)toolbar_contains_mouse);
#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE
m_mouse.left_down = false; m_mouse.left_down = false;
} }
else else
@ -5061,7 +5077,11 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
// updates toolbar overlay // updates toolbar overlay
if (tooltip.empty()) 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); tooltip = m_toolbar.update_hover_state(m_mouse.position);
#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE
// updates view toolbar overlay // updates view toolbar overlay
if (tooltip.empty() && (m_view_toolbar != nullptr)) if (tooltip.empty() && (m_view_toolbar != nullptr))
@ -5429,7 +5449,24 @@ bool GLCanvas3D::_init_toolbar()
if (!m_toolbar.is_enabled()) if (!m_toolbar.is_enabled())
return true; return true;
#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE
ItemsIconsTexture::Metadata icons_data;
icons_data.filename = "toolbar.png";
icons_data.icon_size = 36;
icons_data.icon_border_size = 1;
icons_data.icon_gap_size = 1;
BackgroundTexture::Metadata background_data;
background_data.filename = "toolbar_background.png";
background_data.left = 16;
background_data.top = 16;
background_data.right = 16;
background_data.bottom = 16;
if (!m_toolbar.init(icons_data, background_data))
#else
if (!m_toolbar.init("toolbar.png", 36, 1, 1)) if (!m_toolbar.init("toolbar.png", 36, 1, 1))
#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE
{ {
// unable to init the toolbar texture, disable it // unable to init the toolbar texture, disable it
m_toolbar.set_enabled(false); m_toolbar.set_enabled(false);
@ -5438,6 +5475,10 @@ bool GLCanvas3D::_init_toolbar()
// m_toolbar.set_layout_type(GLToolbar::Layout::Vertical); // m_toolbar.set_layout_type(GLToolbar::Layout::Vertical);
m_toolbar.set_layout_type(GLToolbar::Layout::Horizontal); 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_separator_size(5);
m_toolbar.set_gap_size(2); m_toolbar.set_gap_size(2);
@ -5524,9 +5565,6 @@ bool GLCanvas3D::_init_toolbar()
if (!m_toolbar.add_item(item)) if (!m_toolbar.add_item(item))
return false; return false;
if (!m_toolbar.add_separator())
return false;
enable_toolbar_item("add", true); enable_toolbar_item("add", true);
return true; return true;
@ -6063,7 +6101,11 @@ void GLCanvas3D::_render_toolbar() const
#if !ENABLE_REMOVE_TABS_FROM_PLATER #if !ENABLE_REMOVE_TABS_FROM_PLATER
_resize_toolbar(); _resize_toolbar();
#endif // !ENABLE_REMOVE_TABS_FROM_PLATER #endif // !ENABLE_REMOVE_TABS_FROM_PLATER
#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE
m_toolbar.render(*this);
#else
m_toolbar.render(); m_toolbar.render();
#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE
} }
#if ENABLE_REMOVE_TABS_FROM_PLATER #if ENABLE_REMOVE_TABS_FROM_PLATER
@ -7721,25 +7763,54 @@ void GLCanvas3D::_resize_toolbar() const
float zoom = get_camera_zoom(); float zoom = get_camera_zoom();
float inv_zoom = (zoom != 0.0f) ? 1.0f / zoom : 0.0f; 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()) switch (m_toolbar.get_layout_type())
{ {
default: default:
case GLToolbar::Layout::Horizontal: case GLToolbar::Layout::Horizontal:
{ {
// centers the toolbar on the top edge of the 3d scene // centers the toolbar on the top edge of the 3d scene
unsigned int toolbar_width = m_toolbar.get_width(); #if ENABLE_TOOLBAR_BACKGROUND_TEXTURE
float top = (0.5f * (float)cnv_size.get_height() - 2.0f) * inv_zoom; float top, left;
float left = -0.5f * (float)toolbar_width * inv_zoom; 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;
}
#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); m_toolbar.set_position(top, left);
break; break;
} }
case GLToolbar::Layout::Vertical: case GLToolbar::Layout::Vertical:
{ {
// centers the toolbar on the right edge of the 3d scene // centers the toolbar on the right edge of the 3d scene
unsigned int toolbar_width = m_toolbar.get_width(); #if ENABLE_TOOLBAR_BACKGROUND_TEXTURE
unsigned int toolbar_height = m_toolbar.get_height(); float top, left;
float top = 0.5f * (float)toolbar_height * inv_zoom; if (orientation == GLToolbar::Layout::Left)
float left = (0.5f * (float)cnv_size.get_width() - toolbar_width - 2.0f) * inv_zoom; {
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;
}
#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); m_toolbar.set_position(top, left);
break; break;
} }
@ -7748,6 +7819,7 @@ void GLCanvas3D::_resize_toolbar() const
#if ENABLE_REMOVE_TABS_FROM_PLATER #if ENABLE_REMOVE_TABS_FROM_PLATER
if (m_view_toolbar != nullptr) if (m_view_toolbar != nullptr)
{ {
// 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 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; float left = -0.5f * (float)cnv_size.get_width() * inv_zoom;
m_view_toolbar->set_position(top, left); m_view_toolbar->set_position(top, left);

View File

@ -769,7 +769,11 @@ private:
mutable Gizmos m_gizmos; mutable Gizmos m_gizmos;
mutable GLToolbar m_toolbar; mutable GLToolbar m_toolbar;
#if ENABLE_REMOVE_TABS_FROM_PLATER #if ENABLE_REMOVE_TABS_FROM_PLATER
#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE
GLToolbar* m_view_toolbar;
#else
GLRadioToolbar* m_view_toolbar; GLRadioToolbar* m_view_toolbar;
#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE
#endif // ENABLE_REMOVE_TABS_FROM_PLATER #endif // ENABLE_REMOVE_TABS_FROM_PLATER
ClippingPlane m_clipping_planes[2]; ClippingPlane m_clipping_planes[2];
bool m_use_clipping_planes; bool m_use_clipping_planes;
@ -824,7 +828,11 @@ public:
wxGLCanvas* get_wxglcanvas() { return m_canvas; } wxGLCanvas* get_wxglcanvas() { return m_canvas; }
#if ENABLE_REMOVE_TABS_FROM_PLATER #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; } void set_view_toolbar(GLRadioToolbar* toolbar) { m_view_toolbar = toolbar; }
#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE
#endif // ENABLE_REMOVE_TABS_FROM_PLATER #endif // ENABLE_REMOVE_TABS_FROM_PLATER
bool init(bool useVBOs, bool use_legacy_opengl); bool init(bool useVBOs, bool use_legacy_opengl);

File diff suppressed because it is too large Load Diff

View File

@ -77,6 +77,9 @@ public:
void do_action(wxEvtHandler *target); void do_action(wxEvtHandler *target);
bool is_enabled() const; bool is_enabled() const;
#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE
bool is_disabled() const;
#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE
bool is_hovered() const; bool is_hovered() const;
bool is_pressed() const; bool is_pressed() const;
@ -94,7 +97,25 @@ private:
// from left to right // from left to right
struct ItemsIconsTexture struct ItemsIconsTexture
{ {
#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE
struct Metadata
{
// path of the file containing the icons' texture
std::string filename;
// size of the square icons, in pixels
unsigned int icon_size;
// size of the border, in pixels
unsigned int icon_border_size;
// distance between two adjacent icons (to avoid filtering artifacts), in pixels
unsigned int icon_gap_size;
Metadata();
};
#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE
GLTexture texture; GLTexture texture;
#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE
Metadata metadata;
#else
// size of the square icons, in pixels // size of the square icons, in pixels
unsigned int items_icon_size; unsigned int items_icon_size;
// distance from the border, in pixels // distance from the border, in pixels
@ -103,49 +124,129 @@ struct ItemsIconsTexture
unsigned int items_icon_gap_size; unsigned int items_icon_gap_size;
ItemsIconsTexture(); ItemsIconsTexture();
#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE
}; };
#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE
struct BackgroundTexture
{
struct Metadata
{
// path of the file containing the background texture
std::string filename;
// size of the left edge, in pixels
unsigned int left;
// size of the right edge, in pixels
unsigned int right;
// size of the top edge, in pixels
unsigned int top;
// size of the bottom edge, in pixels
unsigned int bottom;
Metadata();
};
GLTexture texture;
Metadata metadata;
};
#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE
class GLToolbar class GLToolbar
{ {
public: public:
#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE
enum EType : unsigned char
{
Normal,
Radio,
Num_Types
};
#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE
struct Layout struct Layout
{ {
enum Type : unsigned char enum EType : unsigned char
{ {
Horizontal, Horizontal,
Vertical, Vertical,
Num_Types Num_Types
}; };
Type type; enum EOrientation : unsigned int
{
Top,
Bottom,
Left,
Right,
Center,
Num_Locations
};
EType type;
#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE
EOrientation orientation;
#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE
float top; float top;
float left; float left;
#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE
float border;
#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE
float separator_size; float separator_size;
float gap_size; float gap_size;
#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE
float width;
float height;
bool dirty;
#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE
Layout(); Layout();
}; };
private: private:
typedef std::vector<GLToolbarItem*> ItemsList; typedef std::vector<GLToolbarItem*> ItemsList;
#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE
EType m_type;
#else
GLCanvas3D& m_parent; GLCanvas3D& m_parent;
#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE
bool m_enabled; bool m_enabled;
ItemsIconsTexture m_icons_texture; ItemsIconsTexture m_icons_texture;
#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE
BackgroundTexture m_background_texture;
mutable Layout m_layout;
#else
Layout m_layout; Layout m_layout;
#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE
ItemsList m_items; ItemsList m_items;
public: public:
#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE
explicit GLToolbar(EType type);
#else
explicit GLToolbar(GLCanvas3D& parent); explicit GLToolbar(GLCanvas3D& parent);
#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE
~GLToolbar(); ~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); 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::Type get_layout_type() const;
void set_layout_type(Layout::Type type); 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); 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_separator_size(float size);
void set_gap_size(float size); void set_gap_size(float size);
@ -160,42 +261,89 @@ public:
void enable_item(const std::string& name); void enable_item(const std::string& name);
void disable_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; 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_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); 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 #else
void update_hover_state(const Vec2d& mouse_pos); void update_hover_state(const Vec2d& mouse_pos);
#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE
#endif // ENABLE_REMOVE_TABS_FROM_PLATER #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 // returns the id of the item under the given mouse position or -1 if none
int contains_mouse(const Vec2d& mouse_pos) const; int contains_mouse(const Vec2d& mouse_pos) const;
void do_action(unsigned int item_id); 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; void render() const;
#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE
private: private:
#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE
void calc_layout() const;
#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE
float get_width_horizontal() const; float get_width_horizontal() const;
float get_width_vertical() const; float get_width_vertical() const;
float get_height_horizontal() const; float get_height_horizontal() const;
float get_height_vertical() const; float get_height_vertical() const;
float get_main_size() const; float get_main_size() const;
#if ENABLE_REMOVE_TABS_FROM_PLATER #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_horizontal(const Vec2d& mouse_pos);
std::string update_hover_state_vertical(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 #else
void update_hover_state_horizontal(const Vec2d& mouse_pos); void update_hover_state_horizontal(const Vec2d& mouse_pos);
void update_hover_state_vertical(const Vec2d& mouse_pos); void update_hover_state_vertical(const Vec2d& mouse_pos);
#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE
#endif // ENABLE_REMOVE_TABS_FROM_PLATER #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_horizontal(const Vec2d& mouse_pos) const;
int contains_mouse_vertical(const Vec2d& mouse_pos) const; int contains_mouse_vertical(const Vec2d& mouse_pos) const;
void render_horizontal() const; void render_horizontal() const;
void render_vertical() const; void render_vertical() const;
#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE
}; };
#if !ENABLE_TOOLBAR_BACKGROUND_TEXTURE
class GLRadioToolbarItem class GLRadioToolbarItem
{ {
public: public:
@ -274,6 +422,7 @@ public:
void render(const GLCanvas3D& parent) const; void render(const GLCanvas3D& parent) const;
}; };
#endif // !ENABLE_TOOLBAR_BACKGROUND_TEXTURE
} // namespace GUI } // namespace GUI
} // namespace Slic3r } // namespace Slic3r

View File

@ -92,7 +92,11 @@ bool View3D::init(wxWindow* parent, Model* model, DynamicPrintConfig* config, Ba
return true; return true;
} }
#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE
void View3D::set_view_toolbar(GLToolbar* toolbar)
#else
void View3D::set_view_toolbar(GLRadioToolbar* toolbar) void View3D::set_view_toolbar(GLRadioToolbar* toolbar)
#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE
{ {
if (m_canvas != nullptr) if (m_canvas != nullptr)
m_canvas->set_view_toolbar(toolbar); m_canvas->set_view_toolbar(toolbar);
@ -365,7 +369,11 @@ Preview::~Preview()
} }
#if ENABLE_REMOVE_TABS_FROM_PLATER #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) void Preview::set_view_toolbar(GLRadioToolbar* toolbar)
#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE
{ {
if (m_canvas != nullptr) if (m_canvas != nullptr)
m_canvas->set_view_toolbar(toolbar); m_canvas->set_view_toolbar(toolbar);

View File

@ -28,9 +28,15 @@ class Model;
namespace GUI { namespace GUI {
class GLCanvas3D; 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 #if ENABLE_REMOVE_TABS_FROM_PLATER
class GLRadioToolbar; class GLRadioToolbar;
#endif // ENABLE_REMOVE_TABS_FROM_PLATER #endif // ENABLE_REMOVE_TABS_FROM_PLATER
#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE
#if ENABLE_REMOVE_TABS_FROM_PLATER #if ENABLE_REMOVE_TABS_FROM_PLATER
class View3D : public wxPanel class View3D : public wxPanel
@ -53,7 +59,11 @@ public:
wxGLCanvas* get_wxglcanvas() { return m_canvas_widget; } wxGLCanvas* get_wxglcanvas() { return m_canvas_widget; }
GLCanvas3D* get_canvas3d() { return m_canvas; } GLCanvas3D* get_canvas3d() { return m_canvas; }
#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE
void set_view_toolbar(GLToolbar* toolbar);
#else
void set_view_toolbar(GLRadioToolbar* toolbar); void set_view_toolbar(GLRadioToolbar* toolbar);
#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE
void set_as_dirty(); void set_as_dirty();
void set_bed_shape(const Pointfs& shape); void set_bed_shape(const Pointfs& shape);
@ -122,7 +132,11 @@ public:
wxGLCanvas* get_wxglcanvas() { return m_canvas_widget; } wxGLCanvas* get_wxglcanvas() { return m_canvas_widget; }
#if ENABLE_REMOVE_TABS_FROM_PLATER #if ENABLE_REMOVE_TABS_FROM_PLATER
#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE
void set_view_toolbar(GLToolbar* toolbar);
#else
void set_view_toolbar(GLRadioToolbar* toolbar); void set_view_toolbar(GLRadioToolbar* toolbar);
#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE
#endif // ENABLE_REMOVE_TABS_FROM_PLATER #endif // ENABLE_REMOVE_TABS_FROM_PLATER
void set_number_extruders(unsigned int number_extruders); void set_number_extruders(unsigned int number_extruders);

View File

@ -913,7 +913,11 @@ struct Plater::priv
Sidebar *sidebar; Sidebar *sidebar;
#if ENABLE_REMOVE_TABS_FROM_PLATER #if ENABLE_REMOVE_TABS_FROM_PLATER
View3D* view3D; View3D* view3D;
#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE
GLToolbar view_toolbar;
#else
GLRadioToolbar view_toolbar; GLRadioToolbar view_toolbar;
#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE
#else #else
#if !ENABLE_IMGUI #if !ENABLE_IMGUI
wxPanel *panel3d; wxPanel *panel3d;
@ -1068,6 +1072,9 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame)
#endif // !ENABLE_REMOVE_TABS_FROM_PLATER #endif // !ENABLE_REMOVE_TABS_FROM_PLATER
, delayed_scene_refresh(false) , delayed_scene_refresh(false)
, project_filename(wxEmptyString) , project_filename(wxEmptyString)
#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE
, view_toolbar(GLToolbar::Radio)
#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE
{ {
arranging.store(false); arranging.store(false);
rotoptimizing.store(false); rotoptimizing.store(false);
@ -1286,7 +1293,9 @@ void Plater::priv::select_view_3D(const std::string& name)
else if (name == "Preview") else if (name == "Preview")
set_current_panel(preview); set_current_panel(preview);
#if !ENABLE_TOOLBAR_BACKGROUND_TEXTURE
view_toolbar.set_selection(name); view_toolbar.set_selection(name);
#endif // !ENABLE_TOOLBAR_BACKGROUND_TEXTURE
} }
#else #else
void Plater::priv::select_view(const std::string& direction) void Plater::priv::select_view(const std::string& direction)
@ -2646,9 +2655,58 @@ bool Plater::priv::complit_init_part_menu()
#if ENABLE_REMOVE_TABS_FROM_PLATER #if ENABLE_REMOVE_TABS_FROM_PLATER
void Plater::priv::init_view_toolbar() 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;
icons_data.icon_border_size = 0;
icons_data.icon_gap_size = 0;
BackgroundTexture::Metadata background_data;
background_data.filename = "toolbar_background.png";
background_data.left = 16;
background_data.top = 16;
background_data.right = 16;
background_data.bottom = 16;
if (!view_toolbar.init(icons_data, background_data))
#else
if (!view_toolbar.init("view_toolbar.png", 64, 0, 0)) if (!view_toolbar.init("view_toolbar.png", 64, 0, 0))
#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE
return; 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);
GLToolbarItem::Data item;
item.name = "3D";
item.tooltip = GUI::L_str("3D editor view");
item.sprite_id = 0;
item.action_event = EVT_GLVIEWTOOLBAR_3D;
item.is_toggable = false;
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;
item.is_toggable = false;
if (!view_toolbar.add_item(item))
return;
view_toolbar.enable_item("3D");
view_toolbar.enable_item("Preview");
view_toolbar.select_item("3D");
view_toolbar.set_enabled(true);
view3D->set_view_toolbar(&view_toolbar);
preview->set_view_toolbar(&view_toolbar);
#else
GLRadioToolbarItem::Data item; GLRadioToolbarItem::Data item;
item.name = "3D"; item.name = "3D";
@ -2669,6 +2727,7 @@ void Plater::priv::init_view_toolbar()
preview->set_view_toolbar(&view_toolbar); preview->set_view_toolbar(&view_toolbar);
view_toolbar.set_selection("3D"); view_toolbar.set_selection("3D");
#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE
} }
#endif // ENABLE_REMOVE_TABS_FROM_PLATER #endif // ENABLE_REMOVE_TABS_FROM_PLATER