mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-20 13:17:54 -06:00
Added background texture to toolbars
This commit is contained in:
parent
49202b0698
commit
083c626770
10 changed files with 976 additions and 49 deletions
|
@ -77,6 +77,9 @@ 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;
|
||||
|
||||
|
@ -94,7 +97,25 @@ private:
|
|||
// from left to right
|
||||
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;
|
||||
#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
|
||||
|
@ -103,49 +124,129 @@ struct ItemsIconsTexture
|
|||
unsigned int items_icon_gap_size;
|
||||
|
||||
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
|
||||
{
|
||||
public:
|
||||
#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE
|
||||
enum EType : unsigned char
|
||||
{
|
||||
Normal,
|
||||
Radio,
|
||||
Num_Types
|
||||
};
|
||||
#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE
|
||||
|
||||
struct Layout
|
||||
{
|
||||
enum Type : unsigned char
|
||||
enum EType : unsigned char
|
||||
{
|
||||
Horizontal,
|
||||
Vertical,
|
||||
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 left;
|
||||
#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE
|
||||
float border;
|
||||
#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE
|
||||
float separator_size;
|
||||
float gap_size;
|
||||
|
||||
#if ENABLE_TOOLBAR_BACKGROUND_TEXTURE
|
||||
float width;
|
||||
float height;
|
||||
bool dirty;
|
||||
#endif // ENABLE_TOOLBAR_BACKGROUND_TEXTURE
|
||||
|
||||
Layout();
|
||||
};
|
||||
|
||||
private:
|
||||
typedef std::vector<GLToolbarItem*> 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);
|
||||
|
||||
Layout::Type get_layout_type() const;
|
||||
void set_layout_type(Layout::Type type);
|
||||
#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);
|
||||
|
||||
|
@ -160,42 +261,89 @@ 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:
|
||||
|
@ -274,6 +422,7 @@ public:
|
|||
|
||||
void render(const GLCanvas3D& parent) const;
|
||||
};
|
||||
#endif // !ENABLE_TOOLBAR_BACKGROUND_TEXTURE
|
||||
|
||||
} // namespace GUI
|
||||
} // namespace Slic3r
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue