Fixed set of sprite_id for items inside toolbars

This commit is contained in:
YuSanka 2024-05-02 13:28:45 +02:00 committed by Lukas Matena
parent dc78fc5a77
commit dfcddc25e7
2 changed files with 22 additions and 16 deletions

View File

@ -5028,10 +5028,12 @@ bool GLCanvas3D::_init_main_toolbar()
GLToolbarItem::Data item;
unsigned int sprite_id = 0;
item.name = "add";
item.icon_filename = "add.svg";
item.tooltip = _u8L("Add...") + " [" + GUI::shortkey_ctrl_prefix() + "I]";
item.sprite_id = 0;
item.sprite_id = sprite_id++;
item.left.action_callback = [this]() { if (m_canvas != nullptr) wxPostEvent(m_canvas, SimpleEvent(EVT_GLTOOLBAR_ADD)); };
if (!m_main_toolbar.add_item(item))
return false;
@ -5039,7 +5041,7 @@ bool GLCanvas3D::_init_main_toolbar()
item.name = "delete";
item.icon_filename = "remove.svg";
item.tooltip = _u8L("Delete") + " [Del]";
item.sprite_id = 1;
item.sprite_id = sprite_id++;
item.left.action_callback = [this]() { if (m_canvas != nullptr) wxPostEvent(m_canvas, SimpleEvent(EVT_GLTOOLBAR_DELETE)); };
item.enabling_callback = []()->bool { return wxGetApp().plater()->can_delete(); };
if (!m_main_toolbar.add_item(item))
@ -5048,7 +5050,7 @@ bool GLCanvas3D::_init_main_toolbar()
item.name = "deleteall";
item.icon_filename = "delete_all.svg";
item.tooltip = _u8L("Delete all") + " [" + GUI::shortkey_ctrl_prefix() + "Del]";
item.sprite_id = 2;
item.sprite_id = sprite_id++;
item.left.action_callback = [this]() { if (m_canvas != nullptr) wxPostEvent(m_canvas, SimpleEvent(EVT_GLTOOLBAR_DELETE_ALL)); };
item.enabling_callback = []()->bool { return wxGetApp().plater()->can_delete_all(); };
if (!m_main_toolbar.add_item(item))
@ -5057,7 +5059,7 @@ bool GLCanvas3D::_init_main_toolbar()
item.name = "arrange";
item.icon_filename = "arrange.svg";
item.tooltip = _u8L("Arrange") + " [A]\n" + _u8L("Arrange selection") + " [Shift+A]\n" + _u8L("Click right mouse button to show arrangement options");
item.sprite_id = 3;
item.sprite_id = sprite_id++;
item.left.action_callback = [this]() { if (m_canvas != nullptr) wxPostEvent(m_canvas, SimpleEvent(EVT_GLTOOLBAR_ARRANGE)); };
item.enabling_callback = []()->bool { return wxGetApp().plater()->can_arrange(); };
item.right.toggable = true;
@ -5077,7 +5079,7 @@ bool GLCanvas3D::_init_main_toolbar()
item.name = "copy";
item.icon_filename = "copy.svg";
item.tooltip = _u8L("Copy") + " [" + GUI::shortkey_ctrl_prefix() + "C]";
item.sprite_id = 4;
item.sprite_id = sprite_id++;
item.left.action_callback = [this]() { if (m_canvas != nullptr) wxPostEvent(m_canvas, SimpleEvent(EVT_GLTOOLBAR_COPY)); };
item.enabling_callback = []()->bool { return wxGetApp().plater()->can_copy_to_clipboard(); };
if (!m_main_toolbar.add_item(item))
@ -5086,7 +5088,7 @@ bool GLCanvas3D::_init_main_toolbar()
item.name = "paste";
item.icon_filename = "paste.svg";
item.tooltip = _u8L("Paste") + " [" + GUI::shortkey_ctrl_prefix() + "V]";
item.sprite_id = 5;
item.sprite_id = sprite_id++;
item.left.action_callback = [this]() { if (m_canvas != nullptr) wxPostEvent(m_canvas, SimpleEvent(EVT_GLTOOLBAR_PASTE)); };
item.enabling_callback = []()->bool { return wxGetApp().plater()->can_paste_from_clipboard(); };
if (!m_main_toolbar.add_item(item))
@ -5098,7 +5100,7 @@ bool GLCanvas3D::_init_main_toolbar()
item.name = "more";
item.icon_filename = "instance_add.svg";
item.tooltip = _u8L("Add instance") + " [+]";
item.sprite_id = 6;
item.sprite_id = sprite_id++;
item.left.action_callback = [this]() { if (m_canvas != nullptr) wxPostEvent(m_canvas, SimpleEvent(EVT_GLTOOLBAR_MORE)); };
item.visibility_callback = []()->bool { return wxGetApp().get_mode() != comSimple; };
item.enabling_callback = []()->bool { return wxGetApp().plater()->can_increase_instances(); };
@ -5109,7 +5111,7 @@ bool GLCanvas3D::_init_main_toolbar()
item.name = "fewer";
item.icon_filename = "instance_remove.svg";
item.tooltip = _u8L("Remove instance") + " [-]";
item.sprite_id = 7;
item.sprite_id = sprite_id++;
item.left.action_callback = [this]() { if (m_canvas != nullptr) wxPostEvent(m_canvas, SimpleEvent(EVT_GLTOOLBAR_FEWER)); };
item.visibility_callback = []()->bool { return wxGetApp().get_mode() != comSimple; };
item.enabling_callback = []()->bool { return wxGetApp().plater()->can_decrease_instances(); };
@ -5122,7 +5124,7 @@ bool GLCanvas3D::_init_main_toolbar()
item.name = "splitobjects";
item.icon_filename = "split_objects.svg";
item.tooltip = _u8L("Split to objects");
item.sprite_id = 8;
item.sprite_id = sprite_id++;
item.left.action_callback = [this]() { if (m_canvas != nullptr) wxPostEvent(m_canvas, SimpleEvent(EVT_GLTOOLBAR_SPLIT_OBJECTS)); };
item.visibility_callback = GLToolbarItem::Default_Visibility_Callback;
item.enabling_callback = []()->bool { return wxGetApp().plater()->can_split_to_objects(); };
@ -5132,7 +5134,7 @@ bool GLCanvas3D::_init_main_toolbar()
item.name = "splitvolumes";
item.icon_filename = "split_parts.svg";
item.tooltip = _u8L("Split to parts");
item.sprite_id = 9;
item.sprite_id = sprite_id++;
item.left.action_callback = [this]() { if (m_canvas != nullptr) wxPostEvent(m_canvas, SimpleEvent(EVT_GLTOOLBAR_SPLIT_VOLUMES)); };
item.visibility_callback = []()->bool { return wxGetApp().get_mode() != comSimple; };
item.enabling_callback = []()->bool { return wxGetApp().plater()->can_split_to_volumes(); };
@ -5147,7 +5149,7 @@ bool GLCanvas3D::_init_main_toolbar()
item.tooltip = _u8L("Switch to Settings") + "\n" + "[" + GUI::shortkey_ctrl_prefix() + "2] - " + _u8L("Print Settings Tab") +
"\n" + "[" + GUI::shortkey_ctrl_prefix() + "3] - " + (current_printer_technology() == ptFFF ? _u8L("Filament Settings Tab") : _u8L("Material Settings Tab") +
"\n" + "[" + GUI::shortkey_ctrl_prefix() + "4] - " + _u8L("Printer Settings Tab")) ;
item.sprite_id = 10;
item.sprite_id = sprite_id++;
item.enabling_callback = GLToolbarItem::Default_Enabling_Callback;
item.visibility_callback = []() { return wxGetApp().app_config->get_bool("dlg_settings_layout_mode"); };
item.left.action_callback = []() { wxGetApp().mainframe->select_tab(); };
@ -5160,7 +5162,7 @@ bool GLCanvas3D::_init_main_toolbar()
item.name = "layersediting";
item.icon_filename = "layers_white.svg";
item.tooltip = _u8L("Variable layer height");
item.sprite_id = 12;
item.sprite_id = sprite_id++;
item.left.action_callback = [this]() { if (m_canvas != nullptr) wxPostEvent(m_canvas, SimpleEvent(EVT_GLTOOLBAR_LAYERSEDITING)); };
item.visibility_callback = [this]()->bool {
bool res = current_printer_technology() == ptFFF;
@ -5210,10 +5212,12 @@ bool GLCanvas3D::_init_undoredo_toolbar()
GLToolbarItem::Data item;
unsigned int sprite_id = 0;
item.name = "undo";
item.icon_filename = "undo_toolbar.svg";
item.tooltip = _u8L("Undo") + " [" + GUI::shortkey_ctrl_prefix() + "Z]\n" + _u8L("Click right mouse button to open/close History");
item.sprite_id = 0;
item.sprite_id = sprite_id++;
item.left.action_callback = [this]() { post_event(SimpleEvent(EVT_GLCANVAS_UNDO)); };
item.right.toggable = true;
item.right.action_callback = [this]() { m_imgui_undo_redo_hovered_pos = -1; };
@ -5250,7 +5254,7 @@ bool GLCanvas3D::_init_undoredo_toolbar()
item.name = "redo";
item.icon_filename = "redo_toolbar.svg";
item.tooltip = _u8L("Redo") + " [" + GUI::shortkey_ctrl_prefix() + "Y]\n" + _u8L("Click right mouse button to open/close History");
item.sprite_id = 1;
item.sprite_id = sprite_id++;
item.left.action_callback = [this]() { post_event(SimpleEvent(EVT_GLCANVAS_REDO)); };
item.right.action_callback = [this]() { m_imgui_undo_redo_hovered_pos = -1; };
item.right.render_callback = [this](float left, float right, float, float) {

View File

@ -3253,10 +3253,12 @@ bool Plater::priv::init_view_toolbar()
GLToolbarItem::Data item;
unsigned int sprite_id = 0;
item.name = "3D";
item.icon_filename = "editor.svg";
item.tooltip = _u8L("3D editor view") + " [" + GUI::shortkey_ctrl_prefix() + "5]";
item.sprite_id = 0;
item.sprite_id = sprite_id++;
item.left.action_callback = [this]() { if (this->q != nullptr) wxPostEvent(this->q, SimpleEvent(EVT_GLVIEWTOOLBAR_3D)); };
if (!view_toolbar.add_item(item))
return false;
@ -3264,7 +3266,7 @@ bool Plater::priv::init_view_toolbar()
item.name = "Preview";
item.icon_filename = "preview.svg";
item.tooltip = _u8L("Preview") + " [" + GUI::shortkey_ctrl_prefix() + "6]";
item.sprite_id = 1;
item.sprite_id = sprite_id++;
item.left.action_callback = [this]() { if (this->q != nullptr) wxPostEvent(this->q, SimpleEvent(EVT_GLVIEWTOOLBAR_PREVIEW)); };
if (!view_toolbar.add_item(item))
return false;