OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::GUI::GLToolbar Class Reference

#include </home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/GUI/GLToolbar.hpp>

Collaboration diagram for Slic3r::GUI::GLToolbar:

Classes

struct  Layout
struct  MouseCapture

Public Types

enum  EType : unsigned char { Normal , Radio , Num_Types }

Public Member Functions

 GLToolbar (EType type, const std::string &name)
 ~GLToolbar ()
bool init (const BackgroundTexture::Metadata &background_texture)
bool init_arrow (const std::string &filename)
Layout::EType get_layout_type () const
void set_layout_type (Layout::EType type)
void set_icon_dirty ()
Layout::EHorizontalOrientation get_horizontal_orientation () const
void set_horizontal_orientation (Layout::EHorizontalOrientation orientation)
Layout::EVerticalOrientation get_vertical_orientation () const
void set_vertical_orientation (Layout::EVerticalOrientation orientation)
void set_position (float top, float left)
void set_border (float border)
void set_separator_size (float size)
void set_gap_size (float size)
void set_icons_size (float size)
void set_text_size (float size)
void set_scale (float scale)
bool is_enabled () const
void set_enabled (bool enable)
bool add_item (const GLToolbarItem::Data &data, GLToolbarItem::EType type=GLToolbarItem::Action)
bool add_separator ()
bool del_all_item ()
float get_icons_size ()
float get_width ()
float get_height ()
void select_item (const std::string &name)
bool is_item_pressed (const std::string &name) const
bool is_item_disabled (const std::string &name) const
bool is_item_visible (const std::string &name) const
bool is_any_item_pressed () const
unsigned int get_items_count () const
int get_item_id (const std::string &name) const
void force_left_action (int item_id, GLCanvas3D &parent)
void force_right_action (int item_id, GLCanvas3D &parent)
std::string get_tooltip () const
void get_additional_tooltip (int item_id, std::string &text)
void set_additional_tooltip (int item_id, const std::string &text)
void set_tooltip (int item_id, const std::string &text)
int get_visible_items_cnt () const
bool update_items_state ()
void render (const GLCanvas3D &parent, GLToolbarItem::EType type=GLToolbarItem::Action)
void render_item_windows (const GLCanvas3D &parent)
size_t get_state_hash () const
void render_arrow (const GLCanvas3D &parent, GLToolbarItem *highlighted_item)
bool on_mouse (wxMouseEvent &evt, GLCanvas3D &parent)
GLToolbarItem * get_item (const std::string &item_name)
int generate_button_text_textures (wxFont &font)
int generate_image_textures ()
float get_scaled_icon_size ()

Static Public Attributes

static const float Default_Icons_Size = 40.0f

Private Types

typedef std::vector< GLToolbarItem * > ItemsList

Private Member Functions

void calc_layout ()
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
void do_action (GLToolbarItem::EActionType type, int item_id, GLCanvas3D &parent, bool check_hover)
void update_hover_state (const Vec2d &mouse_pos, GLCanvas3D &parent)
void update_hover_state_horizontal (const Vec2d &mouse_pos, GLCanvas3D &parent)
void update_hover_state_vertical (const Vec2d &mouse_pos, GLCanvas3D &parent)
int contains_mouse (const Vec2d &mouse_pos, const GLCanvas3D &parent) const
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_background (float left, float top, float right, float bottom, float border_w, float border_h) const
void render_horizontal (const GLCanvas3D &parent, GLToolbarItem::EType type, bool draw_icons)
void render_vertical (const GLCanvas3D &parent, bool draw_icons)
bool generate_icons_texture ()
bool update_items_visibility ()
bool update_items_enabled_state ()

Private Attributes

EType m_type
std::string m_name
bool m_enabled
GLTexture m_icons_texture
bool m_icons_texture_dirty
GLTexture m_images_texture
BackgroundTexture m_background_texture
GLTexture m_arrow_texture
Layout m_layout
ItemsList m_items
MouseCapture m_mouse_capture
int m_pressed_toggable_id

Detailed Description

Member Typedef Documentation

◆ ItemsList

typedef std::vector<GLToolbarItem*> Slic3r::GUI::GLToolbar::ItemsList
private

Member Enumeration Documentation

◆ EType

enum Slic3r::GUI::GLToolbar::EType : unsigned char
Enumerator
Normal 
Radio 
Num_Types 
273 {
274 Normal,
275 Radio,
277 };
@ Normal
Definition GLToolbar.hpp:274
@ Num_Types
Definition GLToolbar.hpp:276
@ Radio
Definition GLToolbar.hpp:275

Constructor & Destructor Documentation

◆ GLToolbar()

Slic3r::GUI::GLToolbar::GLToolbar ( GLToolbar::EType type,
const std::string & name )
265 : m_type(type)
266 , m_name(name)
267 , m_enabled(false)
270{
271}
int m_pressed_toggable_id
Definition GLToolbar.hpp:354
EType m_type
Definition GLToolbar.hpp:328
bool m_icons_texture_dirty
Definition GLToolbar.hpp:332
std::string m_name
Definition GLToolbar.hpp:329
bool m_enabled
Definition GLToolbar.hpp:330

References m_enabled, m_icons_texture_dirty, m_name, m_pressed_toggable_id, and m_type.

◆ ~GLToolbar()

Slic3r::GUI::GLToolbar::~GLToolbar ( )
274{
275 for (GLToolbarItem* item : m_items)
276 {
277 delete item;
278 }
279}
ItemsList m_items
Definition GLToolbar.hpp:338

References m_items.

Member Function Documentation

◆ add_item()

bool Slic3r::GUI::GLToolbar::add_item ( const GLToolbarItem::Data & data,
GLToolbarItem::EType type = GLToolbarItem::Action )
369{
370 GLToolbarItem* item = new GLToolbarItem(type, data);
371 if (item == nullptr)
372 return false;
373
374 m_items.push_back(item);
375 m_layout.dirty = true;
376 return true;
377}
Layout m_layout
Definition GLToolbar.hpp:336

References m_items, and m_layout.

Referenced by Slic3r::GUI::setup_collapse_toolbar().

Here is the caller graph for this function:

◆ add_separator()

bool Slic3r::GUI::GLToolbar::add_separator ( )
391{
392 GLToolbarItem::Data data;
393 GLToolbarItem* item = new GLToolbarItem(GLToolbarItem::Separator, data);
394 if (item == nullptr)
395 return false;
396
397 m_items.push_back(item);
398 m_layout.dirty = true;
399 return true;
400}
@ Separator
Definition GLToolbar.hpp:76

References m_items, m_layout, and Slic3r::GUI::GLToolbarItem::Separator.

◆ calc_layout()

void Slic3r::GUI::GLToolbar::calc_layout ( )
private
673{
674 switch (m_layout.type)
675 {
676 default:
678 {
681 break;
682 }
683 case Layout::Vertical:
684 {
686 m_layout.height = get_height_vertical();
687 break;
688 }
689 }
690
691 m_layout.dirty = false;
692}
float get_height_vertical() const
Definition GLToolbar.cpp:748
float get_width_vertical() const
Definition GLToolbar.cpp:722
float get_height_horizontal() const
Definition GLToolbar.cpp:743
float get_width_horizontal() const
Definition GLToolbar.cpp:695
@ Vertical
Definition GLToolbar.hpp:284
@ Horizontal
Definition GLToolbar.hpp:283

References get_height_horizontal(), get_height_vertical(), get_width_horizontal(), get_width_vertical(), Slic3r::GUI::GLToolbar::Layout::Horizontal, m_layout, and Slic3r::GUI::GLToolbar::Layout::Vertical.

Referenced by get_height(), and get_width().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ contains_mouse()

int Slic3r::GUI::GLToolbar::contains_mouse ( const Vec2d & mouse_pos,
const GLCanvas3D & parent ) const
private
1079{
1080 if (!m_enabled)
1081 return -1;
1082
1083 switch (m_layout.type)
1084 {
1085 default:
1086 case Layout::Horizontal: { return contains_mouse_horizontal(mouse_pos, parent); }
1087 case Layout::Vertical: { return contains_mouse_vertical(mouse_pos, parent); }
1088 }
1089}
int contains_mouse_horizontal(const Vec2d &mouse_pos, const GLCanvas3D &parent) const
Definition GLToolbar.cpp:1091
int contains_mouse_vertical(const Vec2d &mouse_pos, const GLCanvas3D &parent) const
Definition GLToolbar.cpp:1169

References contains_mouse_horizontal(), contains_mouse_vertical(), Slic3r::GUI::GLToolbar::Layout::Horizontal, m_enabled, m_layout, and Slic3r::GUI::GLToolbar::Layout::Vertical.

Referenced by on_mouse().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ contains_mouse_horizontal()

int Slic3r::GUI::GLToolbar::contains_mouse_horizontal ( const Vec2d & mouse_pos,
const GLCanvas3D & parent ) const
private
1092{
1093 const Size cnv_size = parent.get_canvas_size();
1094 const Vec2d scaled_mouse_pos((mouse_pos.x() - 0.5 * (double)cnv_size.get_width()), (0.5 * (double)cnv_size.get_height() - mouse_pos.y()));
1095
1096 const float icons_size = m_layout.icons_size * m_layout.scale;
1097 const float separator_size = m_layout.separator_size * m_layout.scale;
1098 const float gap_size = m_layout.gap_size * m_layout.scale;
1099 const float border = m_layout.border * m_layout.scale;
1100
1101 float left = m_layout.left + border;
1102 const float top = m_layout.top - border;
1103
1104 for (size_t id = 0; id < m_items.size(); ++id) {
1105 GLToolbarItem* item = m_items[id];
1106
1107 if (!item->is_visible())
1108 continue;
1109
1110 if (item->is_separator()) {
1111 float right = left + separator_size;
1112 const float bottom = top - icons_size;
1113
1114 // mouse inside the separator
1115 if (left <= (float)scaled_mouse_pos.x() &&
1116 (float)scaled_mouse_pos.x() <= right &&
1117 bottom <= (float)scaled_mouse_pos.y() &&
1118 (float)scaled_mouse_pos.y() <= top)
1119 return id;
1120
1121 left = right;
1122 right += gap_size;
1123
1124 if (id < m_items.size() - 1) {
1125 // mouse inside the gap
1126 if (left <= (float)scaled_mouse_pos.x() &&
1127 (float)scaled_mouse_pos.x() <= right &&
1128 bottom <= (float)scaled_mouse_pos.y() &&
1129 (float)scaled_mouse_pos.y() <= top)
1130 return -2;
1131 }
1132
1133 left = right;
1134 }
1135 else {
1136 float right = left + icons_size;
1137 const float bottom = top - icons_size;
1138
1139 //BBS: GUI refactor: GLToolbar
1140 if (item->is_action_with_text())
1141 right += icons_size * item->get_extra_size_ratio();
1142
1143 // mouse inside the icon
1144 if (left <= (float)scaled_mouse_pos.x() &&
1145 (float)scaled_mouse_pos.x() <= right &&
1146 bottom <= (float)scaled_mouse_pos.y() &&
1147 (float)scaled_mouse_pos.y() <= top)
1148 return id;
1149
1150 left = right;
1151 right += gap_size;
1152
1153 if (id < m_items.size() - 1) {
1154 // mouse inside the gap
1155 if (left <= (float)scaled_mouse_pos.x() &&
1156 (float)scaled_mouse_pos.x() <= right &&
1157 bottom <= (float)scaled_mouse_pos.y() &&
1158 (float)scaled_mouse_pos.y() <= top)
1159 return -2;
1160 }
1161
1162 left = right;
1163 }
1164 }
1165
1166 return -1;
1167}
Eigen::Matrix< double, 2, 1, Eigen::DontAlign > Vec2d
Definition Point.hpp:67
@ right
Definition MarchingSquares.hpp:190
@ left
Definition MarchingSquares.hpp:188

References Slic3r::GUI::GLCanvas3D::get_canvas_size(), Slic3r::GUI::GLToolbarItem::get_extra_size_ratio(), Slic3r::GUI::Size::get_height(), Slic3r::GUI::Size::get_width(), Slic3r::GUI::GLToolbarItem::is_action_with_text(), Slic3r::GUI::GLToolbarItem::is_separator(), Slic3r::GUI::GLToolbarItem::is_visible(), m_items, and m_layout.

Referenced by contains_mouse().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ contains_mouse_vertical()

int Slic3r::GUI::GLToolbar::contains_mouse_vertical ( const Vec2d & mouse_pos,
const GLCanvas3D & parent ) const
private
1170{
1171 const Size cnv_size = parent.get_canvas_size();
1172 const Vec2d scaled_mouse_pos((mouse_pos.x() - 0.5 * (double)cnv_size.get_width()), (0.5 * (double)cnv_size.get_height() - mouse_pos.y()));
1173
1174 const float icons_size = m_layout.icons_size * m_layout.scale;
1175 const float separator_size = m_layout.separator_size * m_layout.scale;
1176 const float gap_size = m_layout.gap_size * m_layout.scale;
1177 const float border = m_layout.border * m_layout.scale;
1178
1179 const float left = m_layout.left + border;
1180 float top = m_layout.top - border;
1181
1182 for (size_t id = 0; id < m_items.size(); ++id) {
1183 GLToolbarItem* item = m_items[id];
1184
1185 if (!item->is_visible())
1186 continue;
1187
1188 if (item->is_separator()) {
1189 const float right = left + icons_size;
1190 float bottom = top - separator_size;
1191
1192 // mouse inside the separator
1193 if (left <= (float)scaled_mouse_pos.x() &&
1194 (float)scaled_mouse_pos.x() <= right &&
1195 bottom <= (float)scaled_mouse_pos.y() &&
1196 (float)scaled_mouse_pos.y() <= top)
1197 return id;
1198
1199 top = bottom;
1200 bottom -= gap_size;
1201
1202 if (id < m_items.size() - 1) {
1203 // mouse inside the gap
1204 if (left <= (float)scaled_mouse_pos.x() &&
1205 (float)scaled_mouse_pos.x() <= right &&
1206 bottom <= (float)scaled_mouse_pos.y() &&
1207 (float)scaled_mouse_pos.y() <= top)
1208 return -2;
1209 }
1210
1211 top = bottom;
1212 }
1213 else {
1214 float right = left + icons_size;
1215 float bottom = top - icons_size;
1216
1217 if (item->is_action_with_text_image())
1218 right += m_layout.text_size * m_layout.scale;
1219
1220 //BBS: GUI refactor: GLToolbar
1221 if (item->is_action_with_text())
1222 right += icons_size * item->get_extra_size_ratio();
1223
1224 // mouse inside the icon
1225 if (left <= (float)scaled_mouse_pos.x() &&
1226 (float)scaled_mouse_pos.x() <= right &&
1227 bottom <= (float)scaled_mouse_pos.y() &&
1228 (float)scaled_mouse_pos.y() <= top)
1229 return id;
1230
1231 top = bottom;
1232 bottom -= gap_size;
1233
1234 if (id < m_items.size() - 1) {
1235 // mouse inside the gap
1236 if (left <= (float)scaled_mouse_pos.x() &&
1237 (float)scaled_mouse_pos.x() <= right &&
1238 bottom <= (float)scaled_mouse_pos.y() &&
1239 (float)scaled_mouse_pos.y() <= top)
1240 return -2;
1241 }
1242
1243 top = bottom;
1244 }
1245 }
1246
1247 return -1;
1248}

References Slic3r::GUI::GLCanvas3D::get_canvas_size(), Slic3r::GUI::GLToolbarItem::get_extra_size_ratio(), Slic3r::GUI::Size::get_height(), Slic3r::GUI::Size::get_width(), Slic3r::GUI::GLToolbarItem::is_action_with_text(), Slic3r::GUI::GLToolbarItem::is_action_with_text_image(), Slic3r::GUI::GLToolbarItem::is_separator(), Slic3r::GUI::GLToolbarItem::is_visible(), m_items, and m_layout.

Referenced by contains_mouse().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ del_all_item()

bool Slic3r::GUI::GLToolbar::del_all_item ( )
380{
381 for (int i = 0; i < m_items.size(); i++) {
382 delete m_items[i];
383 m_items[i] = nullptr;
384 }
385 m_items.clear();
386 m_layout.dirty = true;
387 return true;
388}

References m_items, and m_layout.

Referenced by Slic3r::GUI::setup_collapse_toolbar().

Here is the caller graph for this function:

◆ do_action()

void Slic3r::GUI::GLToolbar::do_action ( GLToolbarItem::EActionType type,
int item_id,
GLCanvas3D & parent,
bool check_hover )
private
784{
785 if (m_pressed_toggable_id == -1 || m_pressed_toggable_id == item_id) {
786 if (0 <= item_id && item_id < (int)m_items.size()) {
787 GLToolbarItem* item = m_items[item_id];
788 if (item != nullptr && !item->is_separator() && !item->is_disabled() && (!check_hover || item->is_hovered())) {
789 if ((type == GLToolbarItem::Right && item->is_right_toggable()) ||
790 (type == GLToolbarItem::Left && item->is_left_toggable())) {
791 GLToolbarItem::EState state = item->get_state();
792 if (state == GLToolbarItem::Hover)
793 item->set_state(GLToolbarItem::HoverPressed);
794 else if (state == GLToolbarItem::HoverPressed)
795 item->set_state(GLToolbarItem::Hover);
796 else if (state == GLToolbarItem::Pressed)
797 item->set_state(GLToolbarItem::Normal);
798 else if (state == GLToolbarItem::Normal)
799 item->set_state(GLToolbarItem::Pressed);
800
801 m_pressed_toggable_id = item->is_pressed() ? item_id : -1;
802 item->reset_last_action_type();
803
804 parent.render();
805 switch (type)
806 {
807 default:
808 case GLToolbarItem::Left: { item->do_left_action(); break; }
809 case GLToolbarItem::Right: { item->do_right_action(); break; }
810 }
811 }
812 else {
813 if (m_type == Radio)
814 select_item(item->get_name());
815 else
816 item->set_state(item->is_hovered() ? GLToolbarItem::HoverPressed : GLToolbarItem::Pressed);
817
818 item->reset_last_action_type();
819 parent.render();
820 switch (type)
821 {
822 default:
823 case GLToolbarItem::Left: { item->do_left_action(); break; }
824 case GLToolbarItem::Right: { item->do_right_action(); break; }
825 }
826
827 if (m_type == Normal && item->get_state() != GLToolbarItem::Disabled) {
828 // the item may get disabled during the action, if not, set it back to hover state
829 item->set_state(GLToolbarItem::Hover);
830 parent.render();
831 }
832 }
833 }
834 }
835 }
836}
EState
Definition GLToolbar.hpp:93
@ Pressed
Definition GLToolbar.hpp:95
@ Disabled
Definition GLToolbar.hpp:96
@ HoverPressed
Definition GLToolbar.hpp:98
@ Normal
Definition GLToolbar.hpp:94
@ Hover
Definition GLToolbar.hpp:97
@ Left
Definition GLToolbar.hpp:87
@ Right
Definition GLToolbar.hpp:88
void select_item(const std::string &name)
Definition GLToolbar.cpp:418

References Slic3r::GUI::GLToolbarItem::Disabled, Slic3r::GUI::GLToolbarItem::do_left_action(), Slic3r::GUI::GLToolbarItem::do_right_action(), Slic3r::GUI::GLToolbarItem::get_name(), Slic3r::GUI::GLToolbarItem::get_state(), Slic3r::GUI::GLToolbarItem::Hover, Slic3r::GUI::GLToolbarItem::HoverPressed, Slic3r::GUI::GLToolbarItem::is_disabled(), Slic3r::GUI::GLToolbarItem::is_hovered(), Slic3r::GUI::GLToolbarItem::is_left_toggable(), Slic3r::GUI::GLToolbarItem::is_pressed(), Slic3r::GUI::GLToolbarItem::is_right_toggable(), Slic3r::GUI::GLToolbarItem::is_separator(), Slic3r::GUI::GLToolbarItem::Left, m_items, m_pressed_toggable_id, m_type, Normal, Slic3r::GUI::GLToolbarItem::Normal, Slic3r::GUI::GLToolbarItem::Pressed, Radio, Slic3r::GUI::GLCanvas3D::render(), Slic3r::GUI::GLToolbarItem::reset_last_action_type(), Slic3r::GUI::GLToolbarItem::Right, select_item(), and Slic3r::GUI::GLToolbarItem::set_state().

Referenced by force_left_action(), force_right_action(), and on_mouse().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ force_left_action()

void Slic3r::GUI::GLToolbar::force_left_action ( int item_id,
GLCanvas3D & parent )
inline
403{ do_action(GLToolbarItem::Left, item_id, parent, false); }
void do_action(GLToolbarItem::EActionType type, int item_id, GLCanvas3D &parent, bool check_hover)
Definition GLToolbar.cpp:783

References do_action(), and Slic3r::GUI::GLToolbarItem::Left.

Here is the call graph for this function:

◆ force_right_action()

void Slic3r::GUI::GLToolbar::force_right_action ( int item_id,
GLCanvas3D & parent )
inline
404{ do_action(GLToolbarItem::Right, item_id, parent, false); }

References do_action(), and Slic3r::GUI::GLToolbarItem::Right.

Here is the call graph for this function:

◆ generate_button_text_textures()

int Slic3r::GUI::GLToolbar::generate_button_text_textures ( wxFont & font)
1639{
1640 int ret = 0;
1641
1642 for (int i = 0; i < (int)m_items.size(); ++i)
1643 {
1644 GLToolbarItem* item = m_items[i];
1645
1646 if (item->is_action_with_text())
1647 {
1648 ret |= item->generate_texture(font);
1649 }
1650
1651 if (item->is_action_with_text_image())
1652 {
1653 ret |= item->generate_texture(font);
1654 }
1655 }
1656
1657 return ret;
1658}

References Slic3r::GUI::GLToolbarItem::generate_texture(), Slic3r::GUI::GLToolbarItem::is_action_with_text(), Slic3r::GUI::GLToolbarItem::is_action_with_text_image(), and m_items.

Here is the call graph for this function:

◆ generate_icons_texture()

bool Slic3r::GUI::GLToolbar::generate_icons_texture ( )
private
1546{
1547 std::string path = resources_dir() + "/images/";
1548 std::vector<std::string> filenames;
1549 for (GLToolbarItem* item : m_items) {
1550 const std::string& icon_filename = item->get_icon_filename();
1551 if (!icon_filename.empty())
1552 filenames.push_back(path + icon_filename);
1553 }
1554
1555 std::vector<std::pair<int, bool>> states;
1556 //1: white only, 2: gray only, 0 : normal
1557 //true/false: apply background or not
1558 if (m_type == Normal) {
1559 states.push_back({ 1, false }); // Normal
1560 states.push_back({ 0, false }); // Pressed
1561 states.push_back({ 2, false }); // Disabled
1562 states.push_back({ 0, false }); // Hover
1563 states.push_back({ 0, false }); // HoverPressed
1564 states.push_back({ 2, false }); // HoverDisabled
1565 states.push_back({ 0, false }); // HighlightedShown
1566 states.push_back({ 2, false }); // HighlightedHidden
1567 }
1568 else {
1569 states.push_back({ 1, false }); // Normal
1570 states.push_back({ 0, true }); // Pressed
1571 states.push_back({ 2, false }); // Disabled
1572 states.push_back({ 0, false }); // Hover
1573 states.push_back({ 1, true }); // HoverPressed
1574 states.push_back({ 1, false }); // HoverDisabled
1575 states.push_back({ 0, false }); // HighlightedShown
1576 states.push_back({ 1, false }); // HighlightedHidden
1577 }
1578
1579 unsigned int sprite_size_px = (unsigned int)(m_layout.icons_size * m_layout.scale);
1580// // force even size
1581// if (sprite_size_px % 2 != 0)
1582// sprite_size_px += 1;
1583
1584 bool res = m_icons_texture.load_from_svg_files_as_sprites_array(filenames, states, sprite_size_px, false);
1585 if (res)
1586 m_icons_texture_dirty = false;
1587
1588 return res;
1589}
GLTexture m_icons_texture
Definition GLToolbar.hpp:331
const std::string & resources_dir()
Definition utils.cpp:296

References m_icons_texture, m_icons_texture_dirty, m_items, m_layout, m_type, Normal, and Slic3r::resources_dir().

Referenced by render().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ generate_image_textures()

int Slic3r::GUI::GLToolbar::generate_image_textures ( )
1661{
1662 int ret = 0;
1663 for (int i = 0; i < (int)m_items.size(); ++i)
1664 {
1665 GLToolbarItem* item = m_items[i];
1666 if (item->is_action_with_text_image()) {
1667 ret |= item->generate_image_texture();
1668 }
1669 }
1670 return ret;
1671}

References Slic3r::GUI::GLToolbarItem::generate_image_texture(), Slic3r::GUI::GLToolbarItem::is_action_with_text_image(), and m_items.

Here is the call graph for this function:

◆ get_additional_tooltip()

void Slic3r::GUI::GLToolbar::get_additional_tooltip ( int item_id,
std::string & text )
512{
513 if (0 <= item_id && item_id < (int)m_items.size())
514 {
515 text = m_items[item_id]->get_additional_tooltip();
516 return;
517 }
518
519 text.clear();
520}

References m_items.

◆ get_height()

float Slic3r::GUI::GLToolbar::get_height ( )
411{
412 if (m_layout.dirty)
413 calc_layout();
414
415 return m_layout.height;
416}
void calc_layout()
Definition GLToolbar.cpp:672

References calc_layout(), and m_layout.

Referenced by Slic3r::GUI::GLCanvas3D::get_collapse_toolbar_height(), render_horizontal(), Slic3r::GUI::GLCanvas3D::LayersEditing::render_variable_layer_height_dialog(), and render_vertical().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_height_horizontal()

float Slic3r::GUI::GLToolbar::get_height_horizontal ( ) const
private
744{
745 return (2.0f * m_layout.border + m_layout.icons_size) * m_layout.scale;
746}

References m_layout.

Referenced by calc_layout().

Here is the caller graph for this function:

◆ get_height_vertical()

float Slic3r::GUI::GLToolbar::get_height_vertical ( ) const
private
749{
750 return get_main_size();
751}
float get_main_size() const
Definition GLToolbar.cpp:753

References get_main_size().

Referenced by calc_layout().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_horizontal_orientation()

Layout::EHorizontalOrientation Slic3r::GUI::GLToolbar::get_horizontal_orientation ( ) const
inline
367{ return m_layout.horizontal_orientation; }

References m_layout.

◆ get_icons_size()

float Slic3r::GUI::GLToolbar::get_icons_size ( )
inline
388{ return m_layout.icons_size; }

References m_layout.

◆ get_item()

GLToolbarItem * Slic3r::GUI::GLToolbar::get_item ( const std::string & item_name)
1064{
1065 if (!m_enabled)
1066 return nullptr;
1067
1068 for (GLToolbarItem* item : m_items)
1069 {
1070 if (item->get_name() == item_name)
1071 {
1072 return item;
1073 }
1074 }
1075 return nullptr;
1076}

References m_enabled, and m_items.

Referenced by Slic3r::GUI::GLCanvas3D::LayersEditing::render_variable_layer_height_dialog().

Here is the caller graph for this function:

◆ get_item_id()

int Slic3r::GUI::GLToolbar::get_item_id ( const std::string & name) const
478{
479 for (int i = 0; i < (int)m_items.size(); ++i)
480 {
481 if (m_items[i]->get_name() == name)
482 return i;
483 }
484
485 return -1;
486}

References m_items.

◆ get_items_count()

unsigned int Slic3r::GUI::GLToolbar::get_items_count ( ) const
inline
400{ return (unsigned int)m_items.size(); }

References m_items.

◆ get_layout_type()

GLToolbar::Layout::EType Slic3r::GUI::GLToolbar::get_layout_type ( ) const
305{
306 return m_layout.type;
307}

References m_layout.

◆ get_main_size()

float Slic3r::GUI::GLToolbar::get_main_size ( ) const
private
754{
755 float size = 2.0f * m_layout.border;
756 for (unsigned int i = 0; i < (unsigned int)m_items.size(); ++i)
757 {
758 if (!m_items[i]->is_visible())
759 continue;
760
761 if (m_items[i]->is_separator())
762 size += m_layout.separator_size;
763 else
764 size += (float)m_layout.icons_size;
765 }
766
767 if (m_items.size() > 1)
768 size += ((float)m_items.size() - 1.0f) * m_layout.gap_size;
769
770 return size * m_layout.scale;
771}

References m_items, and m_layout.

Referenced by get_height_vertical().

Here is the caller graph for this function:

◆ get_scaled_icon_size()

float Slic3r::GUI::GLToolbar::get_scaled_icon_size ( )
1675{
1676 return m_layout.icons_size * m_layout.scale;
1677}

References m_layout.

◆ get_state_hash()

size_t Slic3r::GUI::GLToolbar::get_state_hash ( ) const
575{
576 size_t hash = 0;
577 boost::hash_combine(hash, m_enabled);
578 for (const GLToolbarItem* item : m_items) {
579 boost::hash_combine(hash, (int)item->get_state());
580 boost::hash_combine(hash, item->is_visible());
581 }
582 return hash;
583}

References m_enabled, and m_items.

◆ get_tooltip()

std::string Slic3r::GUI::GLToolbar::get_tooltip ( ) const
489{
490 std::string tooltip;
491
492 for (GLToolbarItem* item : m_items)
493 {
494 if (item->is_hovered())
495 {
496 tooltip = item->get_tooltip();
497 if (!item->is_pressed())
498 {
499 const std::string& additional_tooltip = item->get_additional_tooltip();
500 if (!additional_tooltip.empty())
501 tooltip += "\n" + additional_tooltip;
502
503 break;
504 }
505 }
506 }
507
508 return tooltip;
509}

References m_items.

Referenced by Slic3r::GUI::GLCanvas3D::_render_frame().

Here is the caller graph for this function:

◆ get_vertical_orientation()

Layout::EVerticalOrientation Slic3r::GUI::GLToolbar::get_vertical_orientation ( ) const
inline
369{ return m_layout.vertical_orientation; }

References m_layout.

◆ get_visible_items_cnt()

int Slic3r::GUI::GLToolbar::get_visible_items_cnt ( ) const
774{
775 int cnt = 0;
776 for (unsigned int i = 0; i < (unsigned int)m_items.size(); ++i)
777 if (m_items[i]->is_visible() && !m_items[i]->is_separator())
778 cnt++;
779
780 return cnt;
781}

References m_items.

◆ get_width()

float Slic3r::GUI::GLToolbar::get_width ( )
403{
404 if (m_layout.dirty)
405 calc_layout();
406
407 return m_layout.width;
408}

References calc_layout(), and m_layout.

Referenced by Slic3r::GUI::GLCanvas3D::get_collapse_toolbar_width(), render_horizontal(), and render_vertical().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_width_horizontal()

float Slic3r::GUI::GLToolbar::get_width_horizontal ( ) const
private
696{
697 float size = 2.0f * m_layout.border;
698 for (unsigned int i = 0; i < (unsigned int)m_items.size(); ++i)
699 {
700 if (!m_items[i]->is_visible())
701 continue;
702
703 if (m_items[i]->is_separator())
704 size += m_layout.separator_size;
705 else
706 {
707 size += (float)m_layout.icons_size;
708 if (m_items[i]->is_action_with_text())
709 size += m_items[i]->get_extra_size_ratio() * m_layout.icons_size;
710 if (m_items[i]->is_action_with_text_image())
711 size += m_layout.text_size;
712 }
713 }
714
715 if (m_items.size() > 1)
716 size += ((float)m_items.size() - 1.0f) * m_layout.gap_size;
717
718 return size * m_layout.scale;
719}

References m_items, and m_layout.

Referenced by calc_layout().

Here is the caller graph for this function:

◆ get_width_vertical()

float Slic3r::GUI::GLToolbar::get_width_vertical ( ) const
private
723{
724 float max_extra_text_size = 0.0;
725 for (unsigned int i = 0; i < (unsigned int)m_items.size(); ++i)
726 {
727 if (m_items[i]->is_action_with_text())
728 {
729 float temp_size = m_items[i]->get_extra_size_ratio() * m_layout.icons_size;
730
731 max_extra_text_size = (temp_size > max_extra_text_size) ? temp_size : max_extra_text_size;
732 }
733
734 if (m_items[i]->is_action_with_text_image())
735 {
736 max_extra_text_size = m_layout.text_size;
737 }
738 }
739
740 return (2.0f * m_layout.border + m_layout.icons_size + max_extra_text_size) * m_layout.scale;
741}

References m_items, and m_layout.

Referenced by calc_layout().

Here is the caller graph for this function:

◆ init()

bool Slic3r::GUI::GLToolbar::init ( const BackgroundTexture::Metadata & background_texture)
282{
283 std::string path = resources_dir() + "/images/";
284 bool res = false;
285
286 if (!background_texture.filename.empty())
287 res = m_background_texture.texture.load_from_file(path + background_texture.filename, false, GLTexture::SingleThreaded, false);
288
289 if (res)
290 m_background_texture.metadata = background_texture;
291
292 return res;
293}
@ SingleThreaded
Definition GLTexture.hpp:73
BackgroundTexture m_background_texture
Definition GLToolbar.hpp:334

References Slic3r::GUI::BackgroundTexture::Metadata::filename, m_background_texture, Slic3r::resources_dir(), and Slic3r::GUI::GLTexture::SingleThreaded.

Referenced by Slic3r::GUI::GLCanvas3D::_switch_toolbars_icon_filename().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ init_arrow()

bool Slic3r::GUI::GLToolbar::init_arrow ( const std::string & filename)
296{
297 if (m_arrow_texture.get_id() != 0)
298 return true;
299
300 const std::string path = resources_dir() + "/images/";
301 return (!filename.empty()) ? m_arrow_texture.load_from_svg_file(path + filename, false, false, false, 1000) : false;
302}
GLTexture m_arrow_texture
Definition GLToolbar.hpp:335

References m_arrow_texture, and Slic3r::resources_dir().

Here is the call graph for this function:

◆ is_any_item_pressed()

bool Slic3r::GUI::GLToolbar::is_any_item_pressed ( ) const
467{
468 for (const GLToolbarItem* item : m_items)
469 {
470 if (item->is_pressed())
471 return true;
472 }
473
474 return false;
475}

References m_items.

Referenced by update_items_state().

Here is the caller graph for this function:

◆ is_enabled()

bool Slic3r::GUI::GLToolbar::is_enabled ( ) const
inline
380{ return m_enabled; }

References m_enabled.

◆ is_item_disabled()

bool Slic3r::GUI::GLToolbar::is_item_disabled ( const std::string & name) const
445{
446 for (const GLToolbarItem* item : m_items)
447 {
448 if (item->get_name() == name)
449 return item->is_disabled();
450 }
451
452 return false;
453}

References m_items.

Referenced by select_item().

Here is the caller graph for this function:

◆ is_item_pressed()

bool Slic3r::GUI::GLToolbar::is_item_pressed ( const std::string & name) const
434{
435 for (const GLToolbarItem* item : m_items)
436 {
437 if (item->get_name() == name)
438 return item->is_pressed();
439 }
440
441 return false;
442}

References m_items.

◆ is_item_visible()

bool Slic3r::GUI::GLToolbar::is_item_visible ( const std::string & name) const
456{
457 for (const GLToolbarItem* item : m_items)
458 {
459 if (item->get_name() == name)
460 return item->is_visible();
461 }
462
463 return false;
464}

References m_items.

◆ on_mouse()

bool Slic3r::GUI::GLToolbar::on_mouse ( wxMouseEvent & evt,
GLCanvas3D & parent )
586{
587 if (!m_enabled)
588 return false;
589
590 const Vec2d mouse_pos((double)evt.GetX(), (double)evt.GetY());
591 bool processed = false;
592
593 // mouse anywhere
594 if (!evt.Dragging() && !evt.Leaving() && !evt.Entering() && m_mouse_capture.parent != nullptr) {
595 if (m_mouse_capture.any() && (evt.LeftUp() || evt.MiddleUp() || evt.RightUp())) {
596 // prevents loosing selection into the scene if mouse down was done inside the toolbar and mouse up was down outside it,
597 // as when switching between views
598 m_mouse_capture.reset();
599 return true;
600 }
601 m_mouse_capture.reset();
602 }
603
604 if (evt.Moving())
605 update_hover_state(mouse_pos, parent);
606 else if (evt.LeftUp()) {
607 if (m_mouse_capture.left) {
608 processed = true;
609 m_mouse_capture.left = false;
610 }
611 else
612 return false;
613 }
614 else if (evt.MiddleUp()) {
615 if (m_mouse_capture.middle) {
616 processed = true;
617 m_mouse_capture.middle = false;
618 }
619 else
620 return false;
621 }
622 else if (evt.RightUp()) {
623 if (m_mouse_capture.right) {
624 processed = true;
625 m_mouse_capture.right = false;
626 }
627 else
628 return false;
629 }
630 else if (evt.Dragging()) {
631 if (m_mouse_capture.any())
632 // if the button down was done on this toolbar, prevent from dragging into the scene
633 processed = true;
634 else
635 return false;
636 }
637
638 const int item_id = contains_mouse(mouse_pos, parent);
639 if (item_id != -1) {
640 // mouse inside toolbar
641 if (evt.LeftDown() || evt.LeftDClick()) {
642 m_mouse_capture.left = true;
643 m_mouse_capture.parent = &parent;
644 processed = true;
645 if (item_id != -2 && !m_items[item_id]->is_separator() && !m_items[item_id]->is_disabled() &&
646 (m_pressed_toggable_id == -1 || m_items[item_id]->get_last_action_type() == GLToolbarItem::Left)) {
647 // mouse is inside an icon
648 do_action(GLToolbarItem::Left, item_id, parent, true);
649 parent.set_as_dirty();
650 }
651 }
652 else if (evt.MiddleDown()) {
653 m_mouse_capture.middle = true;
654 m_mouse_capture.parent = &parent;
655 }
656 else if (evt.RightDown()) {
657 m_mouse_capture.right = true;
658 m_mouse_capture.parent = &parent;
659 processed = true;
660 if (item_id != -2 && !m_items[item_id]->is_separator() && !m_items[item_id]->is_disabled() &&
661 (m_pressed_toggable_id == -1 || m_items[item_id]->get_last_action_type() == GLToolbarItem::Right)) {
662 // mouse is inside an icon
663 do_action(GLToolbarItem::Right, item_id, parent, true);
664 parent.set_as_dirty();
665 }
666 }
667 }
668
669 return processed;
670}
int contains_mouse(const Vec2d &mouse_pos, const GLCanvas3D &parent) const
Definition GLToolbar.cpp:1078
void update_hover_state(const Vec2d &mouse_pos, GLCanvas3D &parent)
Definition GLToolbar.cpp:838
MouseCapture m_mouse_capture
Definition GLToolbar.hpp:353

References contains_mouse(), do_action(), Slic3r::GUI::GLToolbarItem::Left, m_enabled, m_items, m_mouse_capture, m_pressed_toggable_id, Slic3r::GUI::GLToolbarItem::Right, Slic3r::GUI::GLCanvas3D::set_as_dirty(), update_hover_state(), and Slic3r::GUI::wxMouseEvent.

Here is the call graph for this function:

◆ render()

void Slic3r::GUI::GLToolbar::render ( const GLCanvas3D & parent,
GLToolbarItem::EType type = GLToolbarItem::Action )
546{
547 if (!m_enabled || m_items.empty())
548 return;
549
552
553 switch (m_layout.type)
554 {
555 default:
556 case Layout::Horizontal: { render_horizontal(parent, type, true); break; }
557 case Layout::Vertical: { render_vertical(parent, true); break; }
558 }
559}
void render_vertical(const GLCanvas3D &parent, bool draw_icons)
Definition GLToolbar.cpp:1460
void render_horizontal(const GLCanvas3D &parent, GLToolbarItem::EType type, bool draw_icons)
Definition GLToolbar.cpp:1390
bool generate_icons_texture()
Definition GLToolbar.cpp:1545

References generate_icons_texture(), Slic3r::GUI::GLToolbar::Layout::Horizontal, m_enabled, m_icons_texture_dirty, m_items, m_layout, render_horizontal(), render_vertical(), and Slic3r::GUI::GLToolbar::Layout::Vertical.

Here is the call graph for this function:

◆ render_arrow()

void Slic3r::GUI::GLToolbar::render_arrow ( const GLCanvas3D & parent,
GLToolbarItem * highlighted_item )
1328{
1329 // arrow texture not initialized
1330 if (m_arrow_texture.get_id() == 0)
1331 return;
1332
1333 float inv_zoom = (float)wxGetApp().plater()->get_camera().get_inv_zoom();
1334 float factor = inv_zoom * m_layout.scale;
1335
1336 float scaled_icons_size = m_layout.icons_size * factor;
1337 float scaled_separator_size = m_layout.separator_size * factor;
1338 float scaled_gap_size = m_layout.gap_size * factor;
1339 float border = m_layout.border * factor;
1340
1341 float separator_stride = scaled_separator_size + scaled_gap_size;
1342 float icon_stride = scaled_icons_size + scaled_gap_size;
1343
1344 float left = m_layout.left;
1345 float top = m_layout.top - icon_stride;
1346
1347 bool found = false;
1348 for (const GLToolbarItem* item : m_items) {
1349 if (!item->is_visible())
1350 continue;
1351
1352 if (item->is_separator())
1353 left += separator_stride;
1354 else {
1355 if (item->get_name() == highlighted_item->get_name()) {
1356 found = true;
1357 break;
1358 }
1359 left += icon_stride;
1360 }
1361 }
1362 if (!found)
1363 return;
1364
1365 left += border;
1366 top -= separator_stride;
1367 float right = left + scaled_icons_size;
1368
1369 const unsigned int tex_id = m_arrow_texture.get_id();
1370 // arrow width and height
1371 const float arr_tex_width = (float)m_arrow_texture.get_width();
1372 const float arr_tex_height = (float)m_arrow_texture.get_height();
1373 if (tex_id != 0 && arr_tex_width > 0.0f && arr_tex_height > 0.0f) {
1374 float internal_left = left + border - scaled_icons_size * 1.5f; // add scaled_icons_size for huge arrow
1375 float internal_right = right - border + scaled_icons_size * 1.5f;
1376 float internal_top = top - border;
1377 // bottom is not moving and should be calculated from arrow texture sides ratio
1378 float arrow_sides_ratio = (float)m_arrow_texture.get_height() / (float)m_arrow_texture.get_width();
1379 float internal_bottom = internal_top - (internal_right - internal_left) * arrow_sides_ratio ;
1380
1381 const float left_uv = 0.0f;
1382 const float right_uv = 1.0f;
1383 const float top_uv = 1.0f;
1384 const float bottom_uv = 0.0f;
1385
1386 GLTexture::render_sub_texture(tex_id, internal_left, internal_right, internal_bottom, internal_top, { { left_uv, top_uv }, { right_uv, top_uv }, { right_uv, bottom_uv }, { left_uv, bottom_uv } });
1387 }
1388}
static void render_sub_texture(unsigned int tex_id, float left, float right, float bottom, float top, const Quad_UVs &uvs)
Definition GLTexture.cpp:715

References Slic3r::GUI::GLToolbarItem::get_name(), m_arrow_texture, m_items, m_layout, and Slic3r::GUI::GLTexture::render_sub_texture().

Here is the call graph for this function:

◆ render_background()

void Slic3r::GUI::GLToolbar::render_background ( float left,
float top,
float right,
float bottom,
float border_w,
float border_h ) const
private
1251{
1252 const unsigned int tex_id = m_background_texture.texture.get_id();
1253 const float tex_width = (float)m_background_texture.texture.get_width();
1254 const float tex_height = (float)m_background_texture.texture.get_height();
1255 if (tex_id != 0 && tex_width > 0.0f && tex_height > 0.0f) {
1256 const float inv_tex_width = 1.0f / tex_width;
1257 const float inv_tex_height = 1.0f / tex_height;
1258
1259 const float internal_left = left + border_w;
1260 const float internal_right = right - border_w;
1261 const float internal_top = top - border_h;
1262 const float internal_bottom = bottom + border_w;
1263
1264 const float left_uv = 0.0f;
1265 const float right_uv = 1.0f;
1266 const float top_uv = 1.0f;
1267 const float bottom_uv = 0.0f;
1268
1269 const float internal_left_uv = (float)m_background_texture.metadata.left * inv_tex_width;
1270 const float internal_right_uv = 1.0f - (float)m_background_texture.metadata.right * inv_tex_width;
1271 const float internal_top_uv = 1.0f - (float)m_background_texture.metadata.top * inv_tex_height;
1272 const float internal_bottom_uv = (float)m_background_texture.metadata.bottom * inv_tex_height;
1273
1274 // top-left corner
1275 if (m_layout.horizontal_orientation == Layout::HO_Left || m_layout.vertical_orientation == Layout::VO_Top)
1276 GLTexture::render_sub_texture(tex_id, left, internal_left, internal_top, top, { { internal_left_uv, internal_bottom_uv }, { internal_right_uv, internal_bottom_uv }, { internal_right_uv, internal_top_uv }, { internal_left_uv, internal_top_uv } });
1277 else
1278 GLTexture::render_sub_texture(tex_id, left, internal_left, internal_top, top, { { left_uv, internal_top_uv }, { internal_left_uv, internal_top_uv }, { internal_left_uv, top_uv }, { left_uv, top_uv } });
1279
1280 // top edge
1281 if (m_layout.vertical_orientation == Layout::VO_Top)
1282 GLTexture::render_sub_texture(tex_id, internal_left, internal_right, internal_top, top, { { internal_left_uv, internal_bottom_uv }, { internal_right_uv, internal_bottom_uv }, { internal_right_uv, internal_top_uv }, { internal_left_uv, internal_top_uv } });
1283 else
1284 GLTexture::render_sub_texture(tex_id, internal_left, internal_right, internal_top, top, { { internal_left_uv, internal_top_uv }, { internal_right_uv, internal_top_uv }, { internal_right_uv, top_uv }, { internal_left_uv, top_uv } });
1285
1286 // top-right corner
1287 if (m_layout.horizontal_orientation == Layout::HO_Right || m_layout.vertical_orientation == Layout::VO_Top)
1288 GLTexture::render_sub_texture(tex_id, internal_right, right, internal_top, top, { { internal_left_uv, internal_bottom_uv }, { internal_right_uv, internal_bottom_uv }, { internal_right_uv, internal_top_uv }, { internal_left_uv, internal_top_uv } });
1289 else
1290 GLTexture::render_sub_texture(tex_id, internal_right, right, internal_top, top, { { internal_right_uv, internal_top_uv }, { right_uv, internal_top_uv }, { right_uv, top_uv }, { internal_right_uv, top_uv } });
1291
1292 // center-left edge
1293 if (m_layout.horizontal_orientation == Layout::HO_Left)
1294 GLTexture::render_sub_texture(tex_id, left, internal_left, internal_bottom, internal_top, { { internal_left_uv, internal_bottom_uv }, { internal_right_uv, internal_bottom_uv }, { internal_right_uv, internal_top_uv }, { internal_left_uv, internal_top_uv } });
1295 else
1296 GLTexture::render_sub_texture(tex_id, left, internal_left, internal_bottom, internal_top, { { left_uv, internal_bottom_uv }, { internal_left_uv, internal_bottom_uv }, { internal_left_uv, internal_top_uv }, { left_uv, internal_top_uv } });
1297
1298 // center
1299 GLTexture::render_sub_texture(tex_id, internal_left, internal_right, internal_bottom, internal_top, { { internal_left_uv, internal_bottom_uv }, { internal_right_uv, internal_bottom_uv }, { internal_right_uv, internal_top_uv }, { internal_left_uv, internal_top_uv } });
1300
1301 // center-right edge
1302 if (m_layout.horizontal_orientation == Layout::HO_Right)
1303 GLTexture::render_sub_texture(tex_id, internal_right, right, internal_bottom, internal_top, { { internal_left_uv, internal_bottom_uv }, { internal_right_uv, internal_bottom_uv }, { internal_right_uv, internal_top_uv }, { internal_left_uv, internal_top_uv } });
1304 else
1305 GLTexture::render_sub_texture(tex_id, internal_right, right, internal_bottom, internal_top, { { internal_right_uv, internal_bottom_uv }, { right_uv, internal_bottom_uv }, { right_uv, internal_top_uv }, { internal_right_uv, internal_top_uv } });
1306
1307 // bottom-left corner
1308 if (m_layout.horizontal_orientation == Layout::HO_Left || m_layout.vertical_orientation == Layout::VO_Bottom)
1309 GLTexture::render_sub_texture(tex_id, left, internal_left, bottom, internal_bottom, { { internal_left_uv, internal_bottom_uv }, { internal_right_uv, internal_bottom_uv }, { internal_right_uv, internal_top_uv }, { internal_left_uv, internal_top_uv } });
1310 else
1311 GLTexture::render_sub_texture(tex_id, left, internal_left, bottom, internal_bottom, { { left_uv, bottom_uv }, { internal_left_uv, bottom_uv }, { internal_left_uv, internal_bottom_uv }, { left_uv, internal_bottom_uv } });
1312
1313 // bottom edge
1314 if (m_layout.vertical_orientation == Layout::VO_Bottom)
1315 GLTexture::render_sub_texture(tex_id, internal_left, internal_right, bottom, internal_bottom, { { internal_left_uv, internal_bottom_uv }, { internal_right_uv, internal_bottom_uv }, { internal_right_uv, internal_top_uv }, { internal_left_uv, internal_top_uv } });
1316 else
1317 GLTexture::render_sub_texture(tex_id, internal_left, internal_right, bottom, internal_bottom, { { internal_left_uv, bottom_uv }, { internal_right_uv, bottom_uv }, { internal_right_uv, internal_bottom_uv }, { internal_left_uv, internal_bottom_uv } });
1318
1319 // bottom-right corner
1320 if (m_layout.horizontal_orientation == Layout::HO_Right || m_layout.vertical_orientation == Layout::VO_Bottom)
1321 GLTexture::render_sub_texture(tex_id, internal_right, right, bottom, internal_bottom, { { internal_left_uv, internal_bottom_uv }, { internal_right_uv, internal_bottom_uv }, { internal_right_uv, internal_top_uv }, { internal_left_uv, internal_top_uv } });
1322 else
1323 GLTexture::render_sub_texture(tex_id, internal_right, right, bottom, internal_bottom, { { internal_right_uv, bottom_uv }, { right_uv, bottom_uv }, { right_uv, internal_bottom_uv }, { internal_right_uv, internal_bottom_uv } });
1324 }
1325}
@ VO_Bottom
Definition GLToolbar.hpp:300
@ VO_Top
Definition GLToolbar.hpp:298
@ HO_Right
Definition GLToolbar.hpp:292
@ HO_Left
Definition GLToolbar.hpp:290

References Slic3r::GUI::GLToolbar::Layout::HO_Left, Slic3r::GUI::GLToolbar::Layout::HO_Right, m_background_texture, m_layout, Slic3r::GUI::GLTexture::render_sub_texture(), Slic3r::GUI::GLToolbar::Layout::VO_Bottom, and Slic3r::GUI::GLToolbar::Layout::VO_Top.

Referenced by render_horizontal(), and render_vertical().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ render_horizontal()

void Slic3r::GUI::GLToolbar::render_horizontal ( const GLCanvas3D & parent,
GLToolbarItem::EType type,
bool draw_icons )
private
1391{
1392 const Size cnv_size = parent.get_canvas_size();
1393 const float cnv_w = (float)cnv_size.get_width();
1394 const float cnv_h = (float)cnv_size.get_height();
1395
1396 if (cnv_w == 0 || cnv_h == 0)
1397 return;
1398
1399 const float inv_cnv_w = 1.0f / cnv_w;
1400 const float inv_cnv_h = 1.0f / cnv_h;
1401
1402 const float icons_size_x = 2.0f * m_layout.icons_size * m_layout.scale * inv_cnv_w;
1403 const float icons_size_y = 2.0f * m_layout.icons_size * m_layout.scale * inv_cnv_h;
1404 const float separator_size = 2.0f * m_layout.separator_size * m_layout.scale * inv_cnv_w;
1405 const float gap_size = 2.0f * m_layout.gap_size * m_layout.scale * inv_cnv_w;
1406 const float border_w = 2.0f * m_layout.border * m_layout.scale * inv_cnv_w;
1407 const float border_h = 2.0f * m_layout.border * m_layout.scale * inv_cnv_h;
1408 const float width = 2.0f * get_width() * inv_cnv_w;
1409 const float height = 2.0f * get_height() * inv_cnv_h;
1410
1411 const float separator_stride = separator_size + gap_size;
1412 const float icon_stride = icons_size_x + gap_size;
1413
1414 float left = 2.0f * m_layout.left * inv_cnv_w;
1415 float top = 2.0f * m_layout.top * inv_cnv_h;
1416 float right = left + width;
1417 if (type == GLToolbarItem::SeparatorLine)
1418 right = left + width * 0.5;
1419 const float bottom = top - height;
1420
1421 if (draw_icons)
1422 render_background(left, top, right, bottom, border_w, border_h);
1423
1424 left += border_w;
1425 top -= border_h;
1426
1427 // renders icons
1428 for (const GLToolbarItem* item : m_items) {
1429 if (!item->is_visible())
1430 continue;
1431
1432 if (item->is_separator())
1433 left += separator_stride;
1434 else {
1435 //BBS GUI refactor
1436 item->render_left_pos = left;
1437 if (!draw_icons)
1438 item->render_window(left, left + icons_size_x, top - icons_size_y, top);
1439 else if (!item->is_action_with_text_image()) {
1440 unsigned int tex_id = m_icons_texture.get_id();
1441 int tex_width = m_icons_texture.get_width();
1442 int tex_height = m_icons_texture.get_height();
1443 if ((tex_id == 0) || (tex_width <= 0) || (tex_height <= 0))
1444 return;
1445 item->render(tex_id, left, left + icons_size_x, top - icons_size_y, top, (unsigned int)tex_width, (unsigned int)tex_height, (unsigned int)(m_layout.icons_size * m_layout.scale));
1446 }
1447 //BBS: GUI refactor: GLToolbar
1448 if (item->is_action_with_text())
1449 {
1450 float scaled_text_size = item->get_extra_size_ratio() * icons_size_x;
1451 if (draw_icons)
1452 item->render_text(left + icons_size_x, left + icons_size_x + scaled_text_size, top - icons_size_y, top);
1453 left += scaled_text_size;
1454 }
1455 left += icon_stride;
1456 }
1457 }
1458}
@ SeparatorLine
Definition GLToolbar.hpp:80
float get_width()
Definition GLToolbar.cpp:402
void render_background(float left, float top, float right, float bottom, float border_w, float border_h) const
Definition GLToolbar.cpp:1250
float get_height()
Definition GLToolbar.cpp:410
coord_t width(const BoundingBox &box)
Definition Arrange.cpp:1184
coord_t height(const BoundingBox &box)
Definition Arrange.cpp:1185

References Slic3r::GUI::GLCanvas3D::get_canvas_size(), get_height(), Slic3r::GUI::Size::get_height(), get_width(), Slic3r::GUI::Size::get_width(), m_icons_texture, m_items, m_layout, render_background(), and Slic3r::GUI::GLToolbarItem::SeparatorLine.

Referenced by render(), and render_item_windows().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ render_item_windows()

void Slic3r::GUI::GLToolbar::render_item_windows ( const GLCanvas3D & parent)
562{
563 if (!m_enabled || m_items.empty())
564 return;
565
566 switch (m_layout.type)
567 {
568 default:
569 case Layout::Horizontal: { render_horizontal(parent, GLToolbarItem::Action, false); break; }
570 case Layout::Vertical: { render_vertical(parent, false); break; }
571 }
572}
@ Action
Definition GLToolbar.hpp:75

References Slic3r::GUI::GLToolbarItem::Action, Slic3r::GUI::GLToolbar::Layout::Horizontal, m_enabled, m_items, m_layout, render_horizontal(), render_vertical(), and Slic3r::GUI::GLToolbar::Layout::Vertical.

Here is the call graph for this function:

◆ render_vertical()

void Slic3r::GUI::GLToolbar::render_vertical ( const GLCanvas3D & parent,
bool draw_icons )
private
1461{
1462 const Size cnv_size = parent.get_canvas_size();
1463 const float cnv_w = (float)cnv_size.get_width();
1464 const float cnv_h = (float)cnv_size.get_height();
1465
1466 if (cnv_w == 0 || cnv_h == 0)
1467 return;
1468
1469 const float inv_cnv_w = 1.0f / cnv_w;
1470 const float inv_cnv_h = 1.0f / cnv_h;
1471
1472 const float icons_size_x = 2.0f * m_layout.icons_size * m_layout.scale * inv_cnv_w;
1473 const float icons_size_y = 2.0f * m_layout.icons_size * m_layout.scale * inv_cnv_h;
1474 const float separator_size = 2.0f * m_layout.separator_size * m_layout.scale * inv_cnv_h;
1475 const float gap_size = 2.0f * m_layout.gap_size * m_layout.scale * inv_cnv_h;
1476 const float border_w = 2.0f * m_layout.border * m_layout.scale * inv_cnv_w;
1477 const float border_h = 2.0f * m_layout.border * m_layout.scale * inv_cnv_h;
1478 const float width = 2.0f * get_width() * inv_cnv_w;
1479 const float height = 2.0f * get_height() * inv_cnv_h;
1480
1481 const float separator_stride = separator_size + gap_size;
1482 const float icon_stride = icons_size_y + gap_size;
1483
1484 float left = 2.0f * m_layout.left * inv_cnv_w;
1485 float top = 2.0f * m_layout.top * inv_cnv_h;
1486 const float right = left + width;
1487 const float bottom = top - height;
1488
1489 if (draw_icons)
1490 render_background(left, top, right, bottom, border_w, border_h);
1491
1492 left += border_w;
1493 top -= border_h;
1494
1495 // renders icons
1496 for (const GLToolbarItem* item : m_items) {
1497 if (!item->is_visible())
1498 continue;
1499
1500 if (item->is_separator())
1501 top -= separator_stride;
1502 else {
1503 if (!draw_icons) {
1504 item->render_window(left, left + icons_size_x, top - icons_size_y, top);
1505 top -= icon_stride;
1506 continue;
1507 }
1508 unsigned int tex_id;
1509 int tex_width, tex_height;
1510 if (item->is_action_with_text_image()) {
1511 float scaled_text_size = m_layout.text_size * m_layout.scale * inv_cnv_w;
1512 float scaled_text_width = item->get_extra_size_ratio() * icons_size_x;
1513 float scaled_text_border = 2.5 * m_layout.scale * inv_cnv_h;
1514 float scaled_text_height = icons_size_y / 2.0f;
1515 item->render_text(left, left + scaled_text_size, top - scaled_text_border - scaled_text_height, top - scaled_text_border);
1516
1517 float image_left = left + scaled_text_size;
1518 tex_id = item->m_data.image_texture.get_id();
1519 tex_width = item->m_data.image_texture.get_width();
1520 tex_height = item->m_data.image_texture.get_height();
1521 if ((tex_id == 0) || (tex_width <= 0) || (tex_height <= 0))
1522 return;
1523 item->render_image(tex_id, image_left, image_left + icons_size_x, top - icons_size_y, top, (unsigned int)tex_width, (unsigned int)tex_height, (unsigned int)(m_layout.icons_size * m_layout.scale));
1524 }
1525 else {
1526 tex_id = m_icons_texture.get_id();
1527 tex_width = m_icons_texture.get_width();
1528 tex_height = m_icons_texture.get_height();
1529 if ((tex_id == 0) || (tex_width <= 0) || (tex_height <= 0))
1530 return;
1531 item->render(tex_id, left, left + icons_size_x, top - icons_size_y, top, (unsigned int)tex_width, (unsigned int)tex_height, (unsigned int)(m_layout.icons_size * m_layout.scale));
1532 //BBS: GUI refactor: GLToolbar
1533 }
1534 if (item->is_action_with_text())
1535 {
1536 float scaled_text_width = item->get_extra_size_ratio() * icons_size_x;
1537 float scaled_text_height = icons_size_y;
1538 item->render_text(left + icons_size_x, left + icons_size_x + scaled_text_width, top - scaled_text_height, top);
1539 }
1540 top -= icon_stride;
1541 }
1542 }
1543}

References Slic3r::GUI::GLCanvas3D::get_canvas_size(), get_height(), Slic3r::GUI::Size::get_height(), get_width(), Slic3r::GUI::Size::get_width(), m_icons_texture, m_items, m_layout, and render_background().

Referenced by render(), and render_item_windows().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ select_item()

void Slic3r::GUI::GLToolbar::select_item ( const std::string & name)
419{
420 if (is_item_disabled(name))
421 return;
422
423 for (GLToolbarItem* item : m_items)
424 {
425 if (!item->is_disabled())
426 {
427 bool hover = item->is_hovered();
428 item->set_state((item->get_name() == name) ? (hover ? GLToolbarItem::HoverPressed : GLToolbarItem::Pressed) : (hover ? GLToolbarItem::Hover : GLToolbarItem::Normal));
429 }
430 }
431}
bool is_item_disabled(const std::string &name) const
Definition GLToolbar.cpp:444

References Slic3r::GUI::GLToolbarItem::Hover, Slic3r::GUI::GLToolbarItem::HoverPressed, is_item_disabled(), m_items, Slic3r::GUI::GLToolbarItem::Normal, and Slic3r::GUI::GLToolbarItem::Pressed.

Referenced by do_action().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_additional_tooltip()

void Slic3r::GUI::GLToolbar::set_additional_tooltip ( int item_id,
const std::string & text )
523{
524 if (0 <= item_id && item_id < (int)m_items.size())
525 m_items[item_id]->set_additional_tooltip(text);
526}

References m_items.

◆ set_border()

void Slic3r::GUI::GLToolbar::set_border ( float border)
322{
323 m_layout.border = border;
324 m_layout.dirty = true;
325}

References m_layout.

Referenced by Slic3r::GUI::setup_collapse_toolbar().

Here is the caller graph for this function:

◆ set_enabled()

void Slic3r::GUI::GLToolbar::set_enabled ( bool enable)
inline
381{ m_enabled = enable; }

References m_enabled.

◆ set_gap_size()

void Slic3r::GUI::GLToolbar::set_gap_size ( float size)
334{
335 m_layout.gap_size = size;
336 m_layout.dirty = true;
337}

References m_layout.

Referenced by Slic3r::GUI::setup_collapse_toolbar().

Here is the caller graph for this function:

◆ set_horizontal_orientation()

void Slic3r::GUI::GLToolbar::set_horizontal_orientation ( Layout::EHorizontalOrientation orientation)
inline
368{ m_layout.horizontal_orientation = orientation; }

References m_layout.

Referenced by Slic3r::GUI::setup_collapse_toolbar().

Here is the caller graph for this function:

◆ set_icon_dirty()

void Slic3r::GUI::GLToolbar::set_icon_dirty ( )
inline
366{ m_icons_texture_dirty = true; }

References m_icons_texture_dirty.

Referenced by Slic3r::GUI::GLCanvas3D::on_change_color_mode().

Here is the caller graph for this function:

◆ set_icons_size()

void Slic3r::GUI::GLToolbar::set_icons_size ( float size)
340{
341 if (m_layout.icons_size != size)
342 {
343 m_layout.icons_size = size;
344 m_layout.dirty = true;
346 }
347}

References m_icons_texture_dirty, and m_layout.

◆ set_layout_type()

void Slic3r::GUI::GLToolbar::set_layout_type ( Layout::EType type)
310{
311 m_layout.type = type;
312 m_layout.dirty = true;
313}

References m_layout.

Referenced by Slic3r::GUI::setup_collapse_toolbar().

Here is the caller graph for this function:

◆ set_position()

void Slic3r::GUI::GLToolbar::set_position ( float top,
float left )
316{
317 m_layout.top = top;
318 m_layout.left = left;
319}

References m_layout.

◆ set_scale()

void Slic3r::GUI::GLToolbar::set_scale ( float scale)
359{
360 if (m_layout.scale != scale) {
361 m_layout.scale = scale;
362 m_layout.dirty = true;
364 }
365}
int scale(const int val)
Definition WipeTowerDialog.cpp:58

References m_icons_texture_dirty, m_layout, and scale().

Here is the call graph for this function:

◆ set_separator_size()

void Slic3r::GUI::GLToolbar::set_separator_size ( float size)
328{
329 m_layout.separator_size = size;
330 m_layout.dirty = true;
331}

References m_layout.

Referenced by Slic3r::GUI::setup_collapse_toolbar().

Here is the caller graph for this function:

◆ set_text_size()

void Slic3r::GUI::GLToolbar::set_text_size ( float size)
350{
351 if (m_layout.text_size != size)
352 {
353 m_layout.text_size = size;
354 m_layout.dirty = true;
355 }
356}

References m_layout.

◆ set_tooltip()

void Slic3r::GUI::GLToolbar::set_tooltip ( int item_id,
const std::string & text )
529{
530 if (0 <= item_id && item_id < (int)m_items.size())
531 m_items[item_id]->set_tooltip(text);
532}

References m_items.

◆ set_vertical_orientation()

void Slic3r::GUI::GLToolbar::set_vertical_orientation ( Layout::EVerticalOrientation orientation)
inline
370{ m_layout.vertical_orientation = orientation; }

References m_layout.

Referenced by Slic3r::GUI::setup_collapse_toolbar().

Here is the caller graph for this function:

◆ update_hover_state()

void Slic3r::GUI::GLToolbar::update_hover_state ( const Vec2d & mouse_pos,
GLCanvas3D & parent )
private
839{
840 if (!m_enabled)
841 return;
842
843 switch (m_layout.type)
844 {
845 default:
846 case Layout::Horizontal: { update_hover_state_horizontal(mouse_pos, parent); break; }
847 case Layout::Vertical: { update_hover_state_vertical(mouse_pos, parent); break; }
848 }
849}
void update_hover_state_vertical(const Vec2d &mouse_pos, GLCanvas3D &parent)
Definition GLToolbar.cpp:957
void update_hover_state_horizontal(const Vec2d &mouse_pos, GLCanvas3D &parent)
Definition GLToolbar.cpp:851

References Slic3r::GUI::GLToolbar::Layout::Horizontal, m_enabled, m_layout, update_hover_state_horizontal(), update_hover_state_vertical(), and Slic3r::GUI::GLToolbar::Layout::Vertical.

Referenced by on_mouse().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ update_hover_state_horizontal()

void Slic3r::GUI::GLToolbar::update_hover_state_horizontal ( const Vec2d & mouse_pos,
GLCanvas3D & parent )
private
852{
853 const Size cnv_size = parent.get_canvas_size();
854 const Vec2d scaled_mouse_pos((mouse_pos.x() - 0.5 * (double)cnv_size.get_width()), (0.5 * (double)cnv_size.get_height() - mouse_pos.y()));
855
856 const float icons_size = m_layout.icons_size * m_layout.scale;
857 const float separator_size = m_layout.separator_size * m_layout.scale;
858 const float gap_size = m_layout.gap_size * m_layout.scale;
859 const float border = m_layout.border * m_layout.scale;
860
861 const float separator_stride = separator_size + gap_size;
862 const float icon_stride = icons_size + gap_size;
863
864 float left = m_layout.left + border;
865 float top = m_layout.top - border;
866
867 for (GLToolbarItem* item : m_items) {
868 if (!item->is_visible())
869 continue;
870
871 if (item->is_separator())
872 left += separator_stride;
873 else {
874 float right = left + icons_size;
875 const float bottom = top - icons_size;
876
877 //BBS: GUI refactor: GLToolbar
878 if (item->is_action_with_text())
879 right += icons_size * item->get_extra_size_ratio();
880
881 const GLToolbarItem::EState state = item->get_state();
882 bool inside = (left <= (float)scaled_mouse_pos.x()) &&
883 ((float)scaled_mouse_pos.x() <= right) &&
884 (bottom <= (float)scaled_mouse_pos.y()) &&
885 ((float)scaled_mouse_pos.y() <= top);
886
887 switch (state)
888 {
890 {
891 if (inside) {
892 item->set_state(GLToolbarItem::Hover);
893 parent.set_as_dirty();
894 }
895
896 break;
897 }
899 {
900 if (!inside) {
901 item->set_state(GLToolbarItem::Normal);
902 parent.set_as_dirty();
903 }
904
905 break;
906 }
908 {
909 if (inside) {
910 item->set_state(GLToolbarItem::HoverPressed);
911 parent.set_as_dirty();
912 }
913
914 break;
915 }
917 {
918 if (!inside) {
919 item->set_state(GLToolbarItem::Pressed);
920 parent.set_as_dirty();
921 }
922
923 break;
924 }
926 {
927 if (inside) {
928 item->set_state(GLToolbarItem::HoverDisabled);
929 parent.set_as_dirty();
930 }
931
932 break;
933 }
935 {
936 if (!inside) {
937 item->set_state(GLToolbarItem::Disabled);
938 parent.set_as_dirty();
939 }
940
941 break;
942 }
943 default:
944 {
945 break;
946 }
947 }
948
949 left += icon_stride;
950 //BBS: GUI refactor: GLToolbar
951 if (item->is_action_with_text())
952 left += icons_size * item->get_extra_size_ratio();
953 }
954 }
955}
@ HoverDisabled
Definition GLToolbar.hpp:99
bool inside(const Polygons &polygons, const Point &p)
Definition TreeNode.cpp:160

References Slic3r::GUI::GLToolbarItem::Disabled, Slic3r::GUI::GLCanvas3D::get_canvas_size(), Slic3r::GUI::Size::get_height(), Slic3r::GUI::Size::get_width(), Slic3r::GUI::GLToolbarItem::Hover, Slic3r::GUI::GLToolbarItem::HoverDisabled, Slic3r::GUI::GLToolbarItem::HoverPressed, m_items, m_layout, Slic3r::GUI::GLToolbarItem::Normal, Slic3r::GUI::GLToolbarItem::Pressed, and Slic3r::GUI::GLCanvas3D::set_as_dirty().

Referenced by update_hover_state().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ update_hover_state_vertical()

void Slic3r::GUI::GLToolbar::update_hover_state_vertical ( const Vec2d & mouse_pos,
GLCanvas3D & parent )
private
958{
959 const Size cnv_size = parent.get_canvas_size();
960 const Vec2d scaled_mouse_pos((mouse_pos.x() - 0.5 * (double)cnv_size.get_width()), (0.5 * (double)cnv_size.get_height() - mouse_pos.y()));
961
962 const float icons_size = m_layout.icons_size * m_layout.scale;
963 const float separator_size = m_layout.separator_size * m_layout.scale;
964 const float gap_size = m_layout.gap_size * m_layout.scale;
965 const float border = m_layout.border * m_layout.scale;
966
967 const float separator_stride = separator_size + gap_size;
968 const float icon_stride = icons_size + gap_size;
969
970 float left = m_layout.left + border;
971 float top = m_layout.top - border;
972
973 for (GLToolbarItem* item : m_items) {
974 if (!item->is_visible())
975 continue;
976
977 if (item->is_separator())
978 top -= separator_stride;
979 else {
980 float right = left + icons_size;
981 const float bottom = top - icons_size;
982
983 if (item->is_action_with_text_image())
984 right += m_layout.text_size * m_layout.scale;
985
986 //BBS: GUI refactor: GLToolbar
987 if (item->is_action_with_text())
988 right += icons_size * item->get_extra_size_ratio();
989
990 GLToolbarItem::EState state = item->get_state();
991 const bool inside = (left <= (float)scaled_mouse_pos.x()) &&
992 ((float)scaled_mouse_pos.x() <= right) &&
993 (bottom <= (float)scaled_mouse_pos.y()) &&
994 ((float)scaled_mouse_pos.y() <= top);
995
996 switch (state)
997 {
999 {
1000 if (inside) {
1001 item->set_state(GLToolbarItem::Hover);
1002 parent.set_as_dirty();
1003 }
1004
1005 break;
1006 }
1008 {
1009 if (!inside) {
1010 item->set_state(GLToolbarItem::Normal);
1011 parent.set_as_dirty();
1012 }
1013
1014 break;
1015 }
1017 {
1018 if (inside) {
1019 item->set_state(GLToolbarItem::HoverPressed);
1020 parent.set_as_dirty();
1021 }
1022
1023 break;
1024 }
1026 {
1027 if (!inside) {
1028 item->set_state(GLToolbarItem::Pressed);
1029 parent.set_as_dirty();
1030 }
1031
1032 break;
1033 }
1035 {
1036 if (inside) {
1037 item->set_state(GLToolbarItem::HoverDisabled);
1038 parent.set_as_dirty();
1039 }
1040
1041 break;
1042 }
1044 {
1045 if (!inside) {
1046 item->set_state(GLToolbarItem::Disabled);
1047 parent.set_as_dirty();
1048 }
1049
1050 break;
1051 }
1052 default:
1053 {
1054 break;
1055 }
1056 }
1057
1058 top -= icon_stride;
1059 }
1060 }
1061}

References Slic3r::GUI::GLToolbarItem::Disabled, Slic3r::GUI::GLCanvas3D::get_canvas_size(), Slic3r::GUI::Size::get_height(), Slic3r::GUI::Size::get_width(), Slic3r::GUI::GLToolbarItem::Hover, Slic3r::GUI::GLToolbarItem::HoverDisabled, Slic3r::GUI::GLToolbarItem::HoverPressed, m_items, m_layout, Slic3r::GUI::GLToolbarItem::Normal, Slic3r::GUI::GLToolbarItem::Pressed, and Slic3r::GUI::GLCanvas3D::set_as_dirty().

Referenced by update_hover_state().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ update_items_enabled_state()

bool Slic3r::GUI::GLToolbar::update_items_enabled_state ( )
private
1617{
1618 bool ret = false;
1619
1620 for (int i = 0; i < (int)m_items.size(); ++i)
1621 {
1622 GLToolbarItem* item = m_items[i];
1623 ret |= item->update_enabled_state();
1624 if (item->is_enabled() && (m_pressed_toggable_id != -1) && (m_pressed_toggable_id != i))
1625 {
1626 ret = true;
1627 item->set_state(GLToolbarItem::Disabled);
1628 }
1629 }
1630
1631 if (ret)
1632 m_layout.dirty = true;
1633
1634 return ret;
1635}

References Slic3r::GUI::GLToolbarItem::Disabled, Slic3r::GUI::GLToolbarItem::is_enabled(), m_items, m_layout, m_pressed_toggable_id, Slic3r::GUI::GLToolbarItem::set_state(), and Slic3r::GUI::GLToolbarItem::update_enabled_state().

Referenced by update_items_state().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ update_items_state()

bool Slic3r::GUI::GLToolbar::update_items_state ( )
535{
536 bool ret = false;
539 if (!is_any_item_pressed())
541
542 return ret;
543}
bool update_items_visibility()
Definition GLToolbar.cpp:1591
bool update_items_enabled_state()
Definition GLToolbar.cpp:1616
bool is_any_item_pressed() const
Definition GLToolbar.cpp:466

References is_any_item_pressed(), m_pressed_toggable_id, update_items_enabled_state(), and update_items_visibility().

Referenced by Slic3r::GUI::GLCanvas3D::on_idle().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ update_items_visibility()

bool Slic3r::GUI::GLToolbar::update_items_visibility ( )
private
1592{
1593 bool ret = false;
1594
1595 for (GLToolbarItem* item : m_items) {
1596 ret |= item->update_visibility();
1597 }
1598
1599 if (ret)
1600 m_layout.dirty = true;
1601
1602 // updates separators visibility to avoid having two of them consecutive
1603 bool any_item_visible = false;
1604 for (GLToolbarItem* item : m_items) {
1605 if (!item->is_separator())
1606 any_item_visible |= item->is_visible();
1607 else {
1608 item->set_visible(any_item_visible);
1609 any_item_visible = false;
1610 }
1611 }
1612
1613 return ret;
1614}

References m_items, and m_layout.

Referenced by update_items_state().

Here is the caller graph for this function:

Member Data Documentation

◆ Default_Icons_Size

◆ m_arrow_texture

GLTexture Slic3r::GUI::GLToolbar::m_arrow_texture
private

Referenced by init_arrow(), and render_arrow().

◆ m_background_texture

BackgroundTexture Slic3r::GUI::GLToolbar::m_background_texture
private

Referenced by init(), and render_background().

◆ m_enabled

◆ m_icons_texture

GLTexture Slic3r::GUI::GLToolbar::m_icons_texture
private

◆ m_icons_texture_dirty

bool Slic3r::GUI::GLToolbar::m_icons_texture_dirty
private

◆ m_images_texture

GLTexture Slic3r::GUI::GLToolbar::m_images_texture
mutableprivate

◆ m_items

◆ m_layout

◆ m_mouse_capture

MouseCapture Slic3r::GUI::GLToolbar::m_mouse_capture
private

Referenced by on_mouse().

◆ m_name

std::string Slic3r::GUI::GLToolbar::m_name
private

Referenced by GLToolbar().

◆ m_pressed_toggable_id

int Slic3r::GUI::GLToolbar::m_pressed_toggable_id
private

◆ m_type

EType Slic3r::GUI::GLToolbar::m_type
private

The documentation for this class was generated from the following files:
  • /home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/GUI/GLToolbar.hpp
  • /home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/GUI/GLToolbar.cpp