mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-10-30 20:21:12 -06:00 
			
		
		
		
	Undo/Redo buttons moved into their own toolbar
This commit is contained in:
		
							parent
							
								
									2de6d95322
								
							
						
					
					
						commit
						81d3669a25
					
				
					 5 changed files with 163 additions and 105 deletions
				
			
		|  | @ -1202,7 +1202,8 @@ GLCanvas3D::GLCanvas3D(wxGLCanvas* canvas, Bed3D& bed, Camera& camera, GLToolbar | |||
|     , m_bed(bed) | ||||
|     , m_camera(camera) | ||||
|     , m_view_toolbar(view_toolbar) | ||||
|     , m_toolbar(GLToolbar::Normal, "Top") | ||||
|     , m_main_toolbar(GLToolbar::Normal, "Top") | ||||
|     , m_undoredo_toolbar(GLToolbar::Normal, "Top") | ||||
|     , m_gizmos(*this) | ||||
|     , m_use_clipping_planes(false) | ||||
|     , m_sidebar_field("") | ||||
|  | @ -1309,7 +1310,7 @@ bool GLCanvas3D::init() | |||
|         return false; | ||||
|     } | ||||
| 
 | ||||
|     if (m_toolbar.is_enabled() && !m_layers_editing.init("variable_layer_height.vs", "variable_layer_height.fs")) | ||||
|     if (m_main_toolbar.is_enabled() && !m_layers_editing.init("variable_layer_height.vs", "variable_layer_height.fs")) | ||||
|     { | ||||
|         std::cout << "Unable to initialize variable_layer_height shader: please, check that the files variable_layer_height.vs and variable_layer_height.fs are available" << std::endl; | ||||
|         return false; | ||||
|  | @ -1323,7 +1324,7 @@ bool GLCanvas3D::init() | |||
|     if (m_gizmos.is_enabled() && !m_gizmos.init()) | ||||
|         std::cout << "Unable to initialize gizmos: please, check that all the required textures are available" << std::endl; | ||||
| 
 | ||||
|     if (!_init_toolbar()) | ||||
|     if (!_init_toolbars()) | ||||
|         return false; | ||||
| 
 | ||||
|     if (m_selection.is_enabled() && !m_selection.init()) | ||||
|  | @ -1514,9 +1515,14 @@ void GLCanvas3D::enable_selection(bool enable) | |||
|     m_selection.set_enabled(enable); | ||||
| } | ||||
| 
 | ||||
| void GLCanvas3D::enable_toolbar(bool enable) | ||||
| void GLCanvas3D::enable_main_toolbar(bool enable) | ||||
| { | ||||
|     m_toolbar.set_enabled(enable); | ||||
|     m_main_toolbar.set_enabled(enable); | ||||
| } | ||||
| 
 | ||||
| void GLCanvas3D::enable_undoredo_toolbar(bool enable) | ||||
| { | ||||
|     m_undoredo_toolbar.set_enabled(enable); | ||||
| } | ||||
| 
 | ||||
| void GLCanvas3D::enable_dynamic_background(bool enable) | ||||
|  | @ -2295,7 +2301,8 @@ void GLCanvas3D::on_idle(wxIdleEvent& evt) | |||
|     if (!m_initialized) | ||||
|         return; | ||||
| 
 | ||||
|     m_dirty |= m_toolbar.update_items_state(); | ||||
|     m_dirty |= m_main_toolbar.update_items_state(); | ||||
|     m_dirty |= m_undoredo_toolbar.update_items_state(); | ||||
|     m_dirty |= m_view_toolbar.update_items_state(); | ||||
| 
 | ||||
|     if (!m_dirty) | ||||
|  | @ -2674,7 +2681,15 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt) | |||
| #endif /* SLIC3R_DEBUG_MOUSE_EVENTS */ | ||||
| 	} | ||||
| 
 | ||||
|     if (m_toolbar.on_mouse(evt, *this)) | ||||
|     if (m_main_toolbar.on_mouse(evt, *this)) | ||||
|     { | ||||
|         if (evt.LeftUp() || evt.MiddleUp() || evt.RightUp()) | ||||
|             mouse_up_cleanup(); | ||||
|         m_mouse.set_start_position_3D_as_invalid(); | ||||
|         return; | ||||
|     } | ||||
| 
 | ||||
|     if (m_undoredo_toolbar.on_mouse(evt, *this)) | ||||
|     { | ||||
|         if (evt.LeftUp() || evt.MiddleUp() || evt.RightUp()) | ||||
|             mouse_up_cleanup(); | ||||
|  | @ -3015,7 +3030,10 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt) | |||
|             tooltip = m_gizmos.get_tooltip(); | ||||
| 
 | ||||
|         if (tooltip.empty()) | ||||
|             tooltip = m_toolbar.get_tooltip(); | ||||
|             tooltip = m_main_toolbar.get_tooltip(); | ||||
| 
 | ||||
|         if (tooltip.empty()) | ||||
|             tooltip = m_undoredo_toolbar.get_tooltip(); | ||||
| 
 | ||||
|         if (tooltip.empty()) | ||||
|             tooltip = m_view_toolbar.get_tooltip(); | ||||
|  | @ -3480,7 +3498,7 @@ void GLCanvas3D::_render_undo_redo_stack(const bool is_undo, float pos_x) | |||
|     ImGuiWrapper* imgui = wxGetApp().imgui(); | ||||
| 
 | ||||
|     const float x = pos_x * (float)get_camera().get_zoom() + 0.5f * (float)get_canvas_size().get_width(); | ||||
|     imgui->set_next_window_pos(x, m_toolbar.get_height(), ImGuiCond_Always, 0.5f, 0.0f); | ||||
|     imgui->set_next_window_pos(x, m_undoredo_toolbar.get_height(), ImGuiCond_Always, 0.5f, 0.0f); | ||||
|     imgui->set_next_window_bg_alpha(0.5f); | ||||
|     imgui->begin(wxString::Format(_(L("%s Stack")), stack_name), | ||||
|                  ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse); | ||||
|  | @ -3502,9 +3520,20 @@ void GLCanvas3D::_render_undo_redo_stack(const bool is_undo, float pos_x) | |||
|     imgui->end(); | ||||
| } | ||||
| 
 | ||||
| bool GLCanvas3D::_init_toolbar() | ||||
| bool GLCanvas3D::_init_toolbars() | ||||
| { | ||||
|     if (!m_toolbar.is_enabled()) | ||||
|     if (!_init_main_toolbar()) | ||||
|         return false; | ||||
| 
 | ||||
|     if (!_init_undoredo_toolbar()) | ||||
|         return false; | ||||
| 
 | ||||
|     return true; | ||||
| } | ||||
| 
 | ||||
| bool GLCanvas3D::_init_main_toolbar() | ||||
| { | ||||
|     if (!m_main_toolbar.is_enabled()) | ||||
|         return true; | ||||
| 
 | ||||
|     BackgroundTexture::Metadata background_data; | ||||
|  | @ -3514,19 +3543,19 @@ bool GLCanvas3D::_init_toolbar() | |||
|     background_data.right = 16; | ||||
|     background_data.bottom = 16; | ||||
| 
 | ||||
|     if (!m_toolbar.init(background_data)) | ||||
|     if (!m_main_toolbar.init(background_data)) | ||||
|     { | ||||
|         // unable to init the toolbar texture, disable it
 | ||||
|         m_toolbar.set_enabled(false); | ||||
|         m_main_toolbar.set_enabled(false); | ||||
|         return true; | ||||
|     } | ||||
| 
 | ||||
| //    m_toolbar.set_layout_type(GLToolbar::Layout::Vertical);
 | ||||
|     m_toolbar.set_layout_type(GLToolbar::Layout::Horizontal); | ||||
|     m_toolbar.set_layout_orientation(GLToolbar::Layout::Top); | ||||
|     m_toolbar.set_border(5.0f); | ||||
|     m_toolbar.set_separator_size(5); | ||||
|     m_toolbar.set_gap_size(2); | ||||
| //    m_main_toolbar.set_layout_type(GLToolbar::Layout::Vertical);
 | ||||
|     m_main_toolbar.set_layout_type(GLToolbar::Layout::Horizontal); | ||||
|     m_main_toolbar.set_layout_orientation(GLToolbar::Layout::Top); | ||||
|     m_main_toolbar.set_border(5.0f); | ||||
|     m_main_toolbar.set_separator_size(5); | ||||
|     m_main_toolbar.set_gap_size(2); | ||||
| 
 | ||||
|     GLToolbarItem::Data item; | ||||
| 
 | ||||
|  | @ -3535,7 +3564,7 @@ bool GLCanvas3D::_init_toolbar() | |||
|     item.tooltip = _utf8(L("Add...")) + " [" + GUI::shortkey_ctrl_prefix() + "I]"; | ||||
|     item.sprite_id = 0; | ||||
|     item.left.action_callback = [this]() { if (m_canvas != nullptr) wxPostEvent(m_canvas, SimpleEvent(EVT_GLTOOLBAR_ADD)); }; | ||||
|     if (!m_toolbar.add_item(item)) | ||||
|     if (!m_main_toolbar.add_item(item)) | ||||
|         return false; | ||||
| 
 | ||||
|     item.name = "delete"; | ||||
|  | @ -3544,7 +3573,7 @@ bool GLCanvas3D::_init_toolbar() | |||
|     item.sprite_id = 1; | ||||
|     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_toolbar.add_item(item)) | ||||
|     if (!m_main_toolbar.add_item(item)) | ||||
|         return false; | ||||
| 
 | ||||
|     item.name = "deleteall"; | ||||
|  | @ -3553,7 +3582,7 @@ bool GLCanvas3D::_init_toolbar() | |||
|     item.sprite_id = 2; | ||||
|     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_toolbar.add_item(item)) | ||||
|     if (!m_main_toolbar.add_item(item)) | ||||
|         return false; | ||||
| 
 | ||||
|     item.name = "arrange"; | ||||
|  | @ -3562,10 +3591,10 @@ bool GLCanvas3D::_init_toolbar() | |||
|     item.sprite_id = 3; | ||||
|     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(); }; | ||||
|     if (!m_toolbar.add_item(item)) | ||||
|     if (!m_main_toolbar.add_item(item)) | ||||
|         return false; | ||||
| 
 | ||||
|     if (!m_toolbar.add_separator()) | ||||
|     if (!m_main_toolbar.add_separator()) | ||||
|         return false; | ||||
| 
 | ||||
|     item.name = "copy"; | ||||
|  | @ -3574,7 +3603,7 @@ bool GLCanvas3D::_init_toolbar() | |||
|     item.sprite_id = 4; | ||||
|     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_toolbar.add_item(item)) | ||||
|     if (!m_main_toolbar.add_item(item)) | ||||
|         return false; | ||||
| 
 | ||||
|     item.name = "paste"; | ||||
|  | @ -3583,10 +3612,10 @@ bool GLCanvas3D::_init_toolbar() | |||
|     item.sprite_id = 5; | ||||
|     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_toolbar.add_item(item)) | ||||
|     if (!m_main_toolbar.add_item(item)) | ||||
|         return false; | ||||
| 
 | ||||
|     if (!m_toolbar.add_separator()) | ||||
|     if (!m_main_toolbar.add_separator()) | ||||
|         return false; | ||||
| 
 | ||||
|     item.name = "more"; | ||||
|  | @ -3597,7 +3626,7 @@ bool GLCanvas3D::_init_toolbar() | |||
|     item.visibility_callback = []()->bool { return wxGetApp().get_mode() != comSimple; }; | ||||
|     item.enabling_callback = []()->bool { return wxGetApp().plater()->can_increase_instances(); }; | ||||
| 
 | ||||
|     if (!m_toolbar.add_item(item)) | ||||
|     if (!m_main_toolbar.add_item(item)) | ||||
|         return false; | ||||
| 
 | ||||
|     item.name = "fewer"; | ||||
|  | @ -3607,10 +3636,10 @@ bool GLCanvas3D::_init_toolbar() | |||
|     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(); }; | ||||
|     if (!m_toolbar.add_item(item)) | ||||
|     if (!m_main_toolbar.add_item(item)) | ||||
|         return false; | ||||
| 
 | ||||
|     if (!m_toolbar.add_separator()) | ||||
|     if (!m_main_toolbar.add_separator()) | ||||
|         return false; | ||||
| 
 | ||||
|     item.name = "splitobjects"; | ||||
|  | @ -3620,7 +3649,7 @@ bool GLCanvas3D::_init_toolbar() | |||
|     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(); }; | ||||
|     if (!m_toolbar.add_item(item)) | ||||
|     if (!m_main_toolbar.add_item(item)) | ||||
|         return false; | ||||
| 
 | ||||
|     item.name = "splitvolumes"; | ||||
|  | @ -3630,10 +3659,10 @@ bool GLCanvas3D::_init_toolbar() | |||
|     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(); }; | ||||
|     if (!m_toolbar.add_item(item)) | ||||
|     if (!m_main_toolbar.add_item(item)) | ||||
|         return false; | ||||
| 
 | ||||
|     if (!m_toolbar.add_separator()) | ||||
|     if (!m_main_toolbar.add_separator()) | ||||
|         return false; | ||||
| 
 | ||||
|     item.name = "layersediting"; | ||||
|  | @ -3644,16 +3673,44 @@ bool GLCanvas3D::_init_toolbar() | |||
|     item.left.action_callback = [this]() { if (m_canvas != nullptr) wxPostEvent(m_canvas, SimpleEvent(EVT_GLTOOLBAR_LAYERSEDITING)); }; | ||||
|     item.visibility_callback = [this]()->bool { return m_process->current_printer_technology() == ptFFF; }; | ||||
|     item.enabling_callback = []()->bool { return wxGetApp().plater()->can_layers_editing(); }; | ||||
|     if (!m_toolbar.add_item(item)) | ||||
|     if (!m_main_toolbar.add_item(item)) | ||||
|         return false; | ||||
| 
 | ||||
|     if (!m_toolbar.add_separator()) | ||||
|         return false; | ||||
|     return true; | ||||
| } | ||||
| 
 | ||||
| bool GLCanvas3D::_init_undoredo_toolbar() | ||||
| { | ||||
|     if (!m_undoredo_toolbar.is_enabled()) | ||||
|         return true; | ||||
| 
 | ||||
|     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_undoredo_toolbar.init(background_data)) | ||||
|     { | ||||
|         // unable to init the toolbar texture, disable it
 | ||||
|         m_undoredo_toolbar.set_enabled(false); | ||||
|         return true; | ||||
|     } | ||||
| 
 | ||||
| //    m_undoredo_toolbar.set_layout_type(GLToolbar::Layout::Vertical);
 | ||||
|     m_undoredo_toolbar.set_layout_type(GLToolbar::Layout::Horizontal); | ||||
|     m_undoredo_toolbar.set_layout_orientation(GLToolbar::Layout::Top); | ||||
|     m_undoredo_toolbar.set_border(5.0f); | ||||
|     m_undoredo_toolbar.set_separator_size(5); | ||||
|     m_undoredo_toolbar.set_gap_size(2); | ||||
| 
 | ||||
|     GLToolbarItem::Data item; | ||||
| 
 | ||||
|     item.name = "undo"; | ||||
|     item.icon_filename = "undo_toolbar.svg"; | ||||
|     item.tooltip = _utf8(L("Undo")) + " [" + GUI::shortkey_ctrl_prefix() + "Z]"; | ||||
|     item.sprite_id = 11; | ||||
|     item.sprite_id = 0; | ||||
|     item.left.toggable = false; | ||||
|     item.left.action_callback = [this]() { post_event(SimpleEvent(EVT_GLCANVAS_UNDO)); }; | ||||
|     item.right.toggable = true; | ||||
|  | @ -3661,18 +3718,18 @@ bool GLCanvas3D::_init_toolbar() | |||
|     item.right.render_callback = [this](float left, float right, float, float) { if (m_canvas != nullptr) _render_undo_redo_stack(true, 0.5f * (left + right)); }; | ||||
|     item.visibility_callback = []()->bool { return true; }; | ||||
|     item.enabling_callback = [this]()->bool { return wxGetApp().plater()->can_undo(); }; | ||||
|     if (!m_toolbar.add_item(item)) | ||||
|     if (!m_undoredo_toolbar.add_item(item)) | ||||
|         return false; | ||||
| 
 | ||||
|     item.name = "redo"; | ||||
|     item.icon_filename = "redo_toolbar.svg"; | ||||
|     item.tooltip = _utf8(L("Redo")) + " [" + GUI::shortkey_ctrl_prefix() + "Y]"; | ||||
|     item.sprite_id = 12; | ||||
|     item.sprite_id = 1; | ||||
|     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) { if (m_canvas != nullptr) _render_undo_redo_stack(false, 0.5f * (left + right)); }; | ||||
|     item.enabling_callback = [this]()->bool { return wxGetApp().plater()->can_redo(); }; | ||||
|     if (!m_toolbar.add_item(item)) | ||||
|     if (!m_undoredo_toolbar.add_item(item)) | ||||
|         return false; | ||||
| 
 | ||||
|     return true; | ||||
|  | @ -4003,7 +4060,8 @@ void GLCanvas3D::_render_overlays() const | |||
|     _render_gizmos_overlay(); | ||||
|     _render_warning_texture(); | ||||
|     _render_legend_texture(); | ||||
|     _render_toolbar(); | ||||
|     _render_main_toolbar(); | ||||
|     _render_undoredo_toolbar(); | ||||
|     _render_view_toolbar(); | ||||
| 
 | ||||
|     if ((m_layers_editing.last_object_id >= 0) && (m_layers_editing.object_max_z() > 0.0f)) | ||||
|  | @ -4093,64 +4151,57 @@ void GLCanvas3D::_render_gizmos_overlay() const | |||
|     m_gizmos.render_overlay(); | ||||
| } | ||||
| 
 | ||||
| void GLCanvas3D::_render_toolbar() const | ||||
| void GLCanvas3D::_render_main_toolbar() const | ||||
| { | ||||
|     if (!m_main_toolbar.is_enabled()) | ||||
|         return; | ||||
| 
 | ||||
| #if ENABLE_RETINA_GL | ||||
| //     m_toolbar.set_scale(m_retina_helper->get_scale_factor());
 | ||||
| //     m_main_toolbar.set_scale(m_retina_helper->get_scale_factor());
 | ||||
|     const float scale = m_retina_helper->get_scale_factor() * wxGetApp().toolbar_icon_scale(true); | ||||
|     m_toolbar.set_scale(scale); //! #ys_FIXME_experiment
 | ||||
|     m_main_toolbar.set_scale(scale); //! #ys_FIXME_experiment
 | ||||
| #else | ||||
| //     m_toolbar.set_scale(m_canvas->GetContentScaleFactor());
 | ||||
| //     m_toolbar.set_scale(wxGetApp().em_unit()*0.1f);
 | ||||
| //     m_main_toolbar.set_scale(m_canvas->GetContentScaleFactor());
 | ||||
| //     m_main_toolbar.set_scale(wxGetApp().em_unit()*0.1f);
 | ||||
|     const float size = int(GLToolbar::Default_Icons_Size * wxGetApp().toolbar_icon_scale(true)); | ||||
|     m_toolbar.set_icons_size(size); //! #ys_FIXME_experiment
 | ||||
|     m_main_toolbar.set_icons_size(size); //! #ys_FIXME_experiment
 | ||||
| #endif // ENABLE_RETINA_GL
 | ||||
| 
 | ||||
|     Size cnv_size = get_canvas_size(); | ||||
|     float zoom = (float)m_camera.get_zoom(); | ||||
|     float inv_zoom = (zoom != 0.0f) ? 1.0f / zoom : 0.0f; | ||||
| 
 | ||||
|     GLToolbar::Layout::EOrientation orientation = m_toolbar.get_layout_orientation(); | ||||
|     float top = 0.5f * (float)cnv_size.get_height() * inv_zoom; | ||||
|     float left = -0.5f * (m_main_toolbar.get_width() + m_undoredo_toolbar.get_width()) * inv_zoom; | ||||
| 
 | ||||
|     float top = 0.0f; | ||||
|     float left = 0.0f; | ||||
|     switch (m_toolbar.get_layout_type()) | ||||
|     { | ||||
|     default: | ||||
|     case GLToolbar::Layout::Horizontal: | ||||
|     { | ||||
|         // centers the toolbar on the top edge of the 3d scene
 | ||||
|         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; | ||||
|         } | ||||
|         break; | ||||
|     } | ||||
|     case GLToolbar::Layout::Vertical: | ||||
|     { | ||||
|         // centers the toolbar on the right edge of the 3d scene
 | ||||
|         if (orientation == GLToolbar::Layout::Left) | ||||
|         { | ||||
|             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; | ||||
|         } | ||||
|         break; | ||||
|     } | ||||
|     } | ||||
|     m_toolbar.set_position(top, left); | ||||
|     m_main_toolbar.set_position(top, left); | ||||
|     m_main_toolbar.render(*this); | ||||
| } | ||||
| 
 | ||||
|     m_toolbar.render(*this); | ||||
| void GLCanvas3D::_render_undoredo_toolbar() const | ||||
| { | ||||
|     if (!m_undoredo_toolbar.is_enabled()) | ||||
|         return; | ||||
| 
 | ||||
| #if ENABLE_RETINA_GL | ||||
| //     m_undoredo_toolbar.set_scale(m_retina_helper->get_scale_factor());
 | ||||
|     const float scale = m_retina_helper->get_scale_factor() * wxGetApp().toolbar_icon_scale(true); | ||||
|     m_undoredo_toolbar.set_scale(scale); //! #ys_FIXME_experiment
 | ||||
| #else | ||||
| //     m_undoredo_toolbar.set_scale(m_canvas->GetContentScaleFactor());
 | ||||
| //     m_undoredo_toolbar.set_scale(wxGetApp().em_unit()*0.1f);
 | ||||
|     const float size = int(GLToolbar::Default_Icons_Size * wxGetApp().toolbar_icon_scale(true)); | ||||
|     m_undoredo_toolbar.set_icons_size(size); //! #ys_FIXME_experiment
 | ||||
| #endif // ENABLE_RETINA_GL
 | ||||
| 
 | ||||
|     Size cnv_size = get_canvas_size(); | ||||
|     float zoom = (float)m_camera.get_zoom(); | ||||
|     float inv_zoom = (zoom != 0.0f) ? 1.0f / zoom : 0.0f; | ||||
| 
 | ||||
|     float top = 0.5f * (float)cnv_size.get_height() * inv_zoom; | ||||
|     float left = (m_main_toolbar.get_width() - 0.5f * (m_main_toolbar.get_width() + m_undoredo_toolbar.get_width())) * inv_zoom; | ||||
|     m_undoredo_toolbar.set_position(top, left); | ||||
|     m_undoredo_toolbar.render(*this); | ||||
| } | ||||
| 
 | ||||
| void GLCanvas3D::_render_view_toolbar() const | ||||
|  | @ -5672,14 +5723,14 @@ void GLCanvas3D::_update_selection_from_hover() | |||
| 
 | ||||
| bool GLCanvas3D::_deactivate_undo_redo_toolbar_items() | ||||
| { | ||||
|     if (m_toolbar.is_item_pressed("undo")) | ||||
|     if (m_undoredo_toolbar.is_item_pressed("undo")) | ||||
|     { | ||||
|         m_toolbar.force_right_action(m_toolbar.get_item_id("undo"), *this); | ||||
|         m_undoredo_toolbar.force_right_action(m_undoredo_toolbar.get_item_id("undo"), *this); | ||||
|         return true; | ||||
|     } | ||||
|     else if (m_toolbar.is_item_pressed("redo")) | ||||
|     else if (m_undoredo_toolbar.is_item_pressed("redo")) | ||||
|     { | ||||
|         m_toolbar.force_right_action(m_toolbar.get_item_id("redo"), *this); | ||||
|         m_undoredo_toolbar.force_right_action(m_undoredo_toolbar.get_item_id("redo"), *this); | ||||
|         return true; | ||||
|     } | ||||
| 
 | ||||
|  |  | |||
|  | @ -438,7 +438,8 @@ private: | |||
|     Shader m_shader; | ||||
|     Mouse m_mouse; | ||||
|     mutable GLGizmosManager m_gizmos; | ||||
|     mutable GLToolbar m_toolbar; | ||||
|     mutable GLToolbar m_main_toolbar; | ||||
|     mutable GLToolbar m_undoredo_toolbar; | ||||
|     ClippingPlane m_clipping_planes[2]; | ||||
|     mutable ClippingPlane m_camera_clipping_plane; | ||||
|     bool m_use_clipping_planes; | ||||
|  | @ -551,7 +552,8 @@ public: | |||
|     void enable_moving(bool enable); | ||||
|     void enable_gizmos(bool enable); | ||||
|     void enable_selection(bool enable); | ||||
|     void enable_toolbar(bool enable); | ||||
|     void enable_main_toolbar(bool enable); | ||||
|     void enable_undoredo_toolbar(bool enable); | ||||
|     void enable_dynamic_background(bool enable); | ||||
|     void allow_multisample(bool allow); | ||||
| 
 | ||||
|  | @ -644,10 +646,16 @@ public: | |||
|     void start_keeping_dirty() { m_keep_dirty = true; } | ||||
|     void stop_keeping_dirty() { m_keep_dirty = false; } | ||||
| 
 | ||||
|     unsigned int get_main_toolbar_item_id(const std::string& name) const { return m_main_toolbar.get_item_id(name); } | ||||
|     void force_main_toolbar_left_action(unsigned int item_id) { m_main_toolbar.force_left_action(item_id, *this); } | ||||
|     void force_main_toolbar_right_action(unsigned int item_id) { m_main_toolbar.force_right_action(item_id, *this); } | ||||
| 
 | ||||
| private: | ||||
|     bool _is_shown_on_screen() const; | ||||
| 
 | ||||
|     bool _init_toolbar(); | ||||
|     bool _init_toolbars(); | ||||
|     bool _init_main_toolbar(); | ||||
|     bool _init_undoredo_toolbar(); | ||||
| 
 | ||||
|     bool _set_current(); | ||||
|     void _resize(unsigned int w, unsigned int h); | ||||
|  | @ -674,7 +682,8 @@ private: | |||
|     void _render_volumes_for_picking() const; | ||||
|     void _render_current_gizmo() const; | ||||
|     void _render_gizmos_overlay() const; | ||||
|     void _render_toolbar() const; | ||||
|     void _render_main_toolbar() const; | ||||
|     void _render_undoredo_toolbar() const; | ||||
|     void _render_view_toolbar() const; | ||||
| #if ENABLE_SHOW_CAMERA_TARGET | ||||
|     void _render_camera_target() const; | ||||
|  |  | |||
|  | @ -403,6 +403,9 @@ void GLToolbar::render(const GLCanvas3D& parent) const | |||
| 
 | ||||
| bool GLToolbar::on_mouse(wxMouseEvent& evt, GLCanvas3D& parent) | ||||
| { | ||||
|     if (!m_enabled) | ||||
|         return false; | ||||
| 
 | ||||
|     Vec2d mouse_pos((double)evt.GetX(), (double)evt.GetY()); | ||||
|     bool processed = false; | ||||
| 
 | ||||
|  | @ -1009,9 +1012,6 @@ void GLToolbar::render_horizontal(const GLCanvas3D& parent) const | |||
|         float bg_right = right; | ||||
|         float bg_top = top; | ||||
|         float bg_bottom = bottom; | ||||
|         float bg_width = right - left; | ||||
|         float bg_height = top - bottom; | ||||
|         float bg_min_size = std::min(bg_width, bg_height); | ||||
| 
 | ||||
|         float bg_uv_i_left = (float)m_background_texture.metadata.left * inv_bg_tex_width; | ||||
|         float bg_uv_i_right = 1.0f - (float)m_background_texture.metadata.right * inv_bg_tex_width; | ||||
|  | @ -1139,9 +1139,6 @@ void GLToolbar::render_vertical(const GLCanvas3D& parent) const | |||
|         float bg_right = right; | ||||
|         float bg_top = top; | ||||
|         float bg_bottom = bottom; | ||||
|         float bg_width = right - left; | ||||
|         float bg_height = top - bottom; | ||||
|         float bg_min_size = std::min(bg_width, bg_height); | ||||
| 
 | ||||
|         float bg_uv_i_left = (float)m_background_texture.metadata.left * inv_bg_tex_width; | ||||
|         float bg_uv_i_right = 1.0f - (float)m_background_texture.metadata.right * inv_bg_tex_width; | ||||
|  |  | |||
|  | @ -63,7 +63,8 @@ bool View3D::init(wxWindow* parent, Bed3D& bed, Camera& camera, GLToolbar& view_ | |||
|     m_canvas->set_config(config); | ||||
|     m_canvas->enable_gizmos(true); | ||||
|     m_canvas->enable_selection(true); | ||||
|     m_canvas->enable_toolbar(true); | ||||
|     m_canvas->enable_main_toolbar(true); | ||||
|     m_canvas->enable_undoredo_toolbar(true); | ||||
| 
 | ||||
|     wxBoxSizer* main_sizer = new wxBoxSizer(wxVERTICAL); | ||||
|     main_sizer->Add(m_canvas_widget, 1, wxALL | wxEXPAND, 0); | ||||
|  |  | |||
|  | @ -3639,8 +3639,8 @@ void Plater::priv::undo_redo_to(std::vector<UndoRedo::Snapshot>::const_iterator | |||
|     	top_snapshot_flags |= UndoRedo::Snapshot::VARIABLE_LAYER_EDITING_ACTIVE; | ||||
| 	bool   		 new_variable_layer_editing_active = (new_flags & UndoRedo::Snapshot::VARIABLE_LAYER_EDITING_ACTIVE) != 0; | ||||
| 	// Disable layer editing before the Undo / Redo jump.
 | ||||
|     if (! new_variable_layer_editing_active && view3D->is_layers_editing_enabled()) | ||||
|     	view3D->enable_layers_editing(false); | ||||
|     if (!new_variable_layer_editing_active && view3D->is_layers_editing_enabled()) | ||||
|         view3D->get_canvas3d()->force_main_toolbar_left_action(view3D->get_canvas3d()->get_main_toolbar_item_id("layersediting")); | ||||
|     // Do the jump in time.
 | ||||
|     if (it_snapshot->timestamp < this->undo_redo_stack.active_snapshot_time() ? | ||||
| 		this->undo_redo_stack.undo(model, this->view3D->get_canvas3d()->get_selection(), this->view3D->get_canvas3d()->get_gizmos_manager(), this->printer_technology, top_snapshot_flags, it_snapshot->timestamp) : | ||||
|  | @ -3657,8 +3657,8 @@ void Plater::priv::undo_redo_to(std::vector<UndoRedo::Snapshot>::const_iterator | |||
| 		this->update_after_undo_redo(temp_snapshot_was_taken); | ||||
| 		// Enable layer editing after the Undo / Redo jump.
 | ||||
| 		if (! view3D->is_layers_editing_enabled() && this->layers_height_allowed() && new_variable_layer_editing_active) | ||||
| 			view3D->enable_layers_editing(true); | ||||
| 	} | ||||
|             view3D->get_canvas3d()->force_main_toolbar_left_action(view3D->get_canvas3d()->get_main_toolbar_item_id("layersediting")); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| void Plater::priv::update_after_undo_redo(bool /* temp_snapshot_was_taken */) | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Enrico Turri
						Enrico Turri