mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-10-31 04:31:15 -06:00 
			
		
		
		
	FIX: dark mode 3rd printer bed display
1.fix custom bed render grid inappropriately 2.optimize: do not init toolbar every time switch dark mode Change-Id: I354496c6c982d9f72b22629f6973a79d65189dda
This commit is contained in:
		
							parent
							
								
									daf4b4ef74
								
							
						
					
					
						commit
						a9c180df24
					
				
					 7 changed files with 107 additions and 4 deletions
				
			
		|  | @ -1268,11 +1268,10 @@ void GLCanvas3D::on_change_color_mode(bool is_dark, bool reinit) { | |||
|         m_gizmos.on_change_color_mode(is_dark); | ||||
|         if (reinit) { | ||||
|             // reset svg
 | ||||
|             _init_toolbars(); | ||||
|             m_gizmos.init(); | ||||
|             _switch_toolbars_icon_filename(); | ||||
|             m_gizmos.switch_gizmos_icon_filename(); | ||||
|             // set dirty to re-generate icon texture
 | ||||
|             m_separator_toolbar.set_icon_dirty(); | ||||
|             m_separator_toolbar.set_icon_dirty(); | ||||
|             m_main_toolbar.set_icon_dirty(); | ||||
|             wxGetApp().plater()->get_collapse_toolbar().set_icon_dirty(); | ||||
|             m_assemble_view_toolbar.set_icon_dirty(); | ||||
|  | @ -5680,6 +5679,55 @@ void GLCanvas3D::render_thumbnail_legacy(ThumbnailData& thumbnail_data, unsigned | |||
| } | ||||
| 
 | ||||
| //BBS: GUI refractor
 | ||||
| 
 | ||||
| void GLCanvas3D::_switch_toolbars_icon_filename() | ||||
| { | ||||
|     BackgroundTexture::Metadata background_data; | ||||
|     background_data.filename = m_is_dark ? "toolbar_background_dark.png" : "toolbar_background.png"; | ||||
|     background_data.left = 16; | ||||
|     background_data.top = 16; | ||||
|     background_data.right = 16; | ||||
|     background_data.bottom = 16; | ||||
|     m_main_toolbar.init(background_data); | ||||
|     m_assemble_view_toolbar.init(background_data); | ||||
|     m_separator_toolbar.init(background_data); | ||||
|     wxGetApp().plater()->get_collapse_toolbar().init(background_data); | ||||
|          | ||||
|     // main toolbar
 | ||||
|     { | ||||
|         GLToolbarItem* item; | ||||
|         item = m_main_toolbar.get_item("add"); | ||||
|         item->set_icon_filename(m_is_dark ? "toolbar_open_dark.svg" : "toolbar_open.svg"); | ||||
| 
 | ||||
|         item = m_main_toolbar.get_item("addplate"); | ||||
|         item->set_icon_filename(m_is_dark ? "toolbar_add_plate_dark.svg" : "toolbar_add_plate.svg"); | ||||
| 
 | ||||
|         item = m_main_toolbar.get_item("orient"); | ||||
|         item->set_icon_filename(m_is_dark ? "toolbar_orient_dark.svg" : "toolbar_orient.svg"); | ||||
| 
 | ||||
|         item = m_main_toolbar.get_item("addplate"); | ||||
|         item->set_icon_filename(m_is_dark ? "toolbar_add_plate_dark.svg" : "toolbar_add_plate.svg"); | ||||
| 
 | ||||
|         item = m_main_toolbar.get_item("arrange"); | ||||
|         item->set_icon_filename(m_is_dark ? "toolbar_arrange_dark.svg" : "toolbar_arrange.svg"); | ||||
| 
 | ||||
|         item = m_main_toolbar.get_item("splitobjects"); | ||||
|         item->set_icon_filename(m_is_dark ? "split_objects_dark.svg" : "split_objects.svg"); | ||||
| 
 | ||||
|         item = m_main_toolbar.get_item("splitvolumes"); | ||||
|         item->set_icon_filename(m_is_dark ? "split_parts_dark.svg" : "split_parts.svg"); | ||||
| 
 | ||||
|         item = m_main_toolbar.get_item("layersediting"); | ||||
|         item->set_icon_filename(m_is_dark ? "toolbar_variable_layer_height_dark.svg" : "toolbar_variable_layer_height.svg"); | ||||
|     } | ||||
| 
 | ||||
|     // assemble view toolbar
 | ||||
|     { | ||||
|         GLToolbarItem* item; | ||||
|         item = m_assemble_view_toolbar.get_item("assembly_view"); | ||||
|         item->set_icon_filename(m_is_dark ? "toolbar_assemble_dark.svg" : "toolbar_assemble.svg"); | ||||
|     } | ||||
| } | ||||
| bool GLCanvas3D::_init_toolbars() | ||||
| { | ||||
|     if (!_init_main_toolbar()) | ||||
|  | @ -5921,7 +5969,7 @@ bool GLCanvas3D::_init_assemble_view_toolbar() | |||
| 
 | ||||
|     GLToolbarItem::Data item; | ||||
|     item.name = "assembly_view"; | ||||
|     item.icon_filename = "toolbar_assemble.svg"; | ||||
|     item.icon_filename = m_is_dark ? "toolbar_assemble_dark.svg" : "toolbar_assemble.svg"; | ||||
|     item.tooltip = _utf8(L("Assembly View")); | ||||
|     item.sprite_id = 1; | ||||
|     item.left.toggable = false; | ||||
|  |  | |||
|  | @ -1044,6 +1044,7 @@ public: | |||
| private: | ||||
|     bool _is_shown_on_screen() const; | ||||
| 
 | ||||
|     void _switch_toolbars_icon_filename(); | ||||
|     bool _init_toolbars(); | ||||
|     bool _init_main_toolbar(); | ||||
|     bool _init_select_plate_toolbar(); | ||||
|  |  | |||
|  | @ -186,6 +186,7 @@ public: | |||
| 
 | ||||
|     const std::string& get_name() const { return m_data.name; } | ||||
|     const std::string& get_icon_filename() const { return m_data.icon_filename; } | ||||
|     void set_icon_filename(const std::string& filename) { m_data.icon_filename = filename; } | ||||
|     const std::string& get_tooltip() const { return m_data.tooltip; } | ||||
|     const std::string& get_additional_tooltip() const { return m_data.additional_tooltip; } | ||||
|     void set_additional_tooltip(const std::string& text) { m_data.additional_tooltip = text; } | ||||
|  |  | |||
|  | @ -166,6 +166,10 @@ GLGizmoBase::GLGizmoBase(GLCanvas3D& parent, const std::string& icon_filename, u | |||
|     m_cylinder.init_from(its_make_cylinder(1., 1., 2 * PI / 24.)); | ||||
| } | ||||
| 
 | ||||
| void GLGizmoBase::set_icon_filename(const std::string &filename) { | ||||
|     m_icon_filename = filename; | ||||
| } | ||||
| 
 | ||||
| void GLGizmoBase::set_hover_id(int id) | ||||
| { | ||||
|     if (m_grabbers.empty() || (id < (int)m_grabbers.size())) | ||||
|  |  | |||
|  | @ -151,6 +151,8 @@ public: | |||
| 
 | ||||
|     const std::string& get_icon_filename() const { return m_icon_filename; } | ||||
| 
 | ||||
|     void set_icon_filename(const std::string& filename); | ||||
| 
 | ||||
|     bool is_activable() const { return on_is_activable(); } | ||||
|     bool is_selectable() const { return on_is_selectable(); } | ||||
|     CommonGizmosDataID get_requirements() const { return on_get_requirements(); } | ||||
|  |  | |||
|  | @ -120,6 +120,51 @@ size_t GLGizmosManager::get_gizmo_idx_from_mouse(const Vec2d& mouse_pos) const | |||
|     return Undefined; | ||||
| } | ||||
| 
 | ||||
| void GLGizmosManager::switch_gizmos_icon_filename() | ||||
| { | ||||
|     m_background_texture.metadata.filename = m_is_dark ? "toolbar_background_dark.png" : "toolbar_background.png"; | ||||
|     m_background_texture.metadata.left = 16; | ||||
|     m_background_texture.metadata.top = 16; | ||||
|     m_background_texture.metadata.right = 16; | ||||
|     m_background_texture.metadata.bottom = 16; | ||||
|     if (!m_background_texture.metadata.filename.empty()) | ||||
|         m_background_texture.texture.load_from_file(resources_dir() + "/images/" + m_background_texture.metadata.filename, false, GLTexture::SingleThreaded, false); | ||||
| 
 | ||||
|     for (auto& gizmo : m_gizmos) { | ||||
|         gizmo->on_change_color_mode(m_is_dark); | ||||
|         switch (gizmo->get_sprite_id()) | ||||
|         { | ||||
|         case(EType::Move): | ||||
|             gizmo->set_icon_filename(m_is_dark ? "toolbar_move_dark.svg" : "toolbar_move.svg"); | ||||
|             break; | ||||
|         case(EType::Rotate): | ||||
|             gizmo->set_icon_filename(m_is_dark ? "toolbar_rotate_dark.svg" : "toolbar_rotate.svg"); | ||||
|             break; | ||||
|         case(EType::Scale): | ||||
|             gizmo->set_icon_filename(m_is_dark ? "toolbar_scale_dark.svg" : "toolbar_scale.svg"); | ||||
|             break; | ||||
|         case(EType::Flatten): | ||||
|             gizmo->set_icon_filename(m_is_dark ? "toolbar_flatten_dark.svg" : "toolbar_flatten.svg"); | ||||
|             break; | ||||
|         case(EType::Cut): | ||||
|             gizmo->set_icon_filename(m_is_dark ? "toolbar_cut_dark.svg" : "toolbar_cut.svg"); | ||||
|             break; | ||||
|         case(EType::FdmSupports): | ||||
|             gizmo->set_icon_filename(m_is_dark ? "toolbar_support_dark.svg" : "toolbar_support.svg"); | ||||
|             break; | ||||
|         case(EType::Seam): | ||||
|             gizmo->set_icon_filename(m_is_dark ? "toolbar_seam_dark.svg" : "toolbar_seam.svg"); | ||||
|             break; | ||||
|         case(EType::Text): | ||||
|             gizmo->set_icon_filename(m_is_dark ? "toolbar_text_dark.svg" : "toolbar_text.svg"); | ||||
|             break; | ||||
|         case(EType::MmuSegmentation): | ||||
|             gizmo->set_icon_filename(m_is_dark ? "mmu_segmentation_dark.svg" : "mmu_segmentation.svg"); | ||||
|             break; | ||||
|         } | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| bool GLGizmosManager::init() | ||||
| { | ||||
|     bool result = init_icon_textures(); | ||||
|  |  | |||
|  | @ -163,6 +163,8 @@ public: | |||
| 
 | ||||
|     explicit GLGizmosManager(GLCanvas3D& parent); | ||||
| 
 | ||||
|     void switch_gizmos_icon_filename(); | ||||
| 
 | ||||
|     bool init(); | ||||
| 
 | ||||
|     bool init_icon_textures(); | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 liz.li
						liz.li