mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-10-30 20:21:12 -06:00 
			
		
		
		
	Merge branch 'dk_eject' into master
This commit is contained in:
		
						commit
						560aef05c7
					
				
					 4 changed files with 61 additions and 32 deletions
				
			
		|  | @ -9,3 +9,4 @@ Customized with the following commits: | ||||||
| 67c55c74901f1d337ef08f2090a87cfb4263bb0f | 67c55c74901f1d337ef08f2090a87cfb4263bb0f | ||||||
| a94c952b40d36b1505fb77b87c0dd739e1034659 | a94c952b40d36b1505fb77b87c0dd739e1034659 | ||||||
| 3ca3a544a87cc569b69351a77996c287763388a5 | 3ca3a544a87cc569b69351a77996c287763388a5 | ||||||
|  | 6586a46ea23e86d54d228c55c63ca55680d25d56 | ||||||
|  |  | ||||||
|  | @ -113,16 +113,16 @@ namespace ImGui | ||||||
|     const char PrinterSlaIconMarker    = 0x6;  |     const char PrinterSlaIconMarker    = 0x6;  | ||||||
|     const char FilamentIconMarker      = 0x7;  |     const char FilamentIconMarker      = 0x7;  | ||||||
|     const char MaterialIconMarker      = 0x8; |     const char MaterialIconMarker      = 0x8; | ||||||
| 	const char CloseIconMarker         = 0xB; | 	const char CloseNotifButton        = 0xB; | ||||||
| 	const char CloseIconHoverMarker    = 0xC; | 	const char CloseNotifHoverButton   = 0xC; | ||||||
| //	const char TimerDotMarker          = 0xE;
 | //	const char TimerDotMarker          = 0xE;
 | ||||||
| //	const char TimerDotEmptyMarker     = 0xF;
 | //	const char TimerDotEmptyMarker     = 0xF;
 | ||||||
|     const char MinimalizeMarker        = 0xE; |     const char MinimalizeButton        = 0xE; | ||||||
|     const char MinimalizeHoverMarker   = 0xF; |     const char MinimalizeHoverButton   = 0xF; | ||||||
| 	const char WarningMarker           = 0x10; | 	const char WarningMarker           = 0x10; | ||||||
| 	const char ErrorMarker             = 0x11; | 	const char ErrorMarker             = 0x11; | ||||||
|     const char EjectMarker             = 0x12; |     const char EjectButton             = 0x12; | ||||||
|     const char EjectHoverMarker        = 0x13; |     const char EjectHoverButton        = 0x13; | ||||||
| //    void MyFunction(const char* name, const MyMatrix44& v);
 | //    void MyFunction(const char* name, const MyMatrix44& v);
 | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -42,16 +42,16 @@ static const std::map<const char, std::string> font_icons = { | ||||||
|     {ImGui::PrinterSlaIconMarker  , "sla_printer"                   }, |     {ImGui::PrinterSlaIconMarker  , "sla_printer"                   }, | ||||||
|     {ImGui::FilamentIconMarker    , "spool"                         }, |     {ImGui::FilamentIconMarker    , "spool"                         }, | ||||||
|     {ImGui::MaterialIconMarker    , "resin"                         }, |     {ImGui::MaterialIconMarker    , "resin"                         }, | ||||||
| 	{ImGui::CloseIconMarker       , "notification_close"            }, |     {ImGui::MinimalizeButton      , "notification_minimalize"       }, | ||||||
| 	{ImGui::CloseIconHoverMarker  , "notification_close_hover"      }, |     {ImGui::MinimalizeHoverButton , "notification_minimalize_hover" } | ||||||
| 	//{ImGui::TimerDotMarker      , "timer_dot"                     },
 | }; | ||||||
|     //{ImGui::TimerDotEmptyMarker , "timer_dot_empty"               },
 | static const std::map<const char, std::string> font_icons_large = { | ||||||
|     {ImGui::MinimalizeMarker      , "notification_minimalize"       }, |     {ImGui::CloseNotifButton       , "notification_close"            }, | ||||||
|     {ImGui::MinimalizeHoverMarker , "notification_minimalize_hover" }, |     {ImGui::CloseNotifHoverButton  , "notification_close_hover"      }, | ||||||
|  |     {ImGui::EjectButton            , "notification_eject_sd"         }, | ||||||
|  |     {ImGui::EjectHoverButton       , "notification_eject_sd_hover"   }, | ||||||
|     {ImGui::WarningMarker          , "notification_warning"          }, |     {ImGui::WarningMarker          , "notification_warning"          }, | ||||||
|     {ImGui::ErrorMarker           , "notification_error"            }, |     {ImGui::ErrorMarker            , "notification_error"            } | ||||||
|     {ImGui::EjectMarker           , "notification_eject_sd"         }, |  | ||||||
|     {ImGui::EjectHoverMarker      , "notification_eject_sd_hover"   }, |  | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| const ImVec4 ImGuiWrapper::COL_GREY_DARK         = { 0.333f, 0.333f, 0.333f, 1.0f }; | const ImVec4 ImGuiWrapper::COL_GREY_DARK         = { 0.333f, 0.333f, 0.333f, 1.0f }; | ||||||
|  | @ -950,6 +950,8 @@ void ImGuiWrapper::init_font(bool compress) | ||||||
|     // add rectangles for the icons to the font atlas
 |     // add rectangles for the icons to the font atlas
 | ||||||
|     for (auto& icon : font_icons) |     for (auto& icon : font_icons) | ||||||
|         io.Fonts->AddCustomRectFontGlyph(font, icon.first, icon_sz, icon_sz, 3.0 * font_scale + icon_sz); |         io.Fonts->AddCustomRectFontGlyph(font, icon.first, icon_sz, icon_sz, 3.0 * font_scale + icon_sz); | ||||||
|  |     for (auto& icon : font_icons_large) | ||||||
|  |         io.Fonts->AddCustomRectFontGlyph(font, icon.first, icon_sz * 2, icon_sz * 2, 3.0 * font_scale + icon_sz * 2); | ||||||
| 
 | 
 | ||||||
|     // Build texture atlas
 |     // Build texture atlas
 | ||||||
|     unsigned char* pixels; |     unsigned char* pixels; | ||||||
|  | @ -969,6 +971,20 @@ void ImGuiWrapper::init_font(bool compress) | ||||||
|         } |         } | ||||||
|         rect_id++; |         rect_id++; | ||||||
|     } |     } | ||||||
|  |     icon_sz = lround(32 * font_scale); // default size of large icon is 32 px
 | ||||||
|  |      | ||||||
|  |     for (auto icon : font_icons_large) { | ||||||
|  |         if (const ImFontAtlas::CustomRect* rect = io.Fonts->GetCustomRectByIndex(rect_id)) { | ||||||
|  |             std::vector<unsigned char> raw_data = load_svg(icon.second, icon_sz, icon_sz); | ||||||
|  |             const ImU32* pIn = (ImU32*)raw_data.data(); | ||||||
|  |             for (int y = 0; y < icon_sz; y++) { | ||||||
|  |                 ImU32* pOut = (ImU32*)pixels + (rect->Y + y) * width + (rect->X); | ||||||
|  |                 for (int x = 0; x < icon_sz; x++) | ||||||
|  |                     *pOut++ = *pIn++; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |         rect_id++; | ||||||
|  |     } | ||||||
| 
 | 
 | ||||||
|     // Upload texture to graphics system
 |     // Upload texture to graphics system
 | ||||||
|     GLint last_texture; |     GLint last_texture; | ||||||
|  |  | ||||||
|  | @ -27,6 +27,17 @@ wxDEFINE_EVENT(EVT_EXPORT_GCODE_NOTIFICAION_CLICKED, ExportGcodeNotificationClic | ||||||
| wxDEFINE_EVENT(EVT_PRESET_UPDATE_AVAILABLE_CLICKED, PresetUpdateAvailableClickedEvent); | wxDEFINE_EVENT(EVT_PRESET_UPDATE_AVAILABLE_CLICKED, PresetUpdateAvailableClickedEvent); | ||||||
| 
 | 
 | ||||||
| namespace Notifications_Internal{ | namespace Notifications_Internal{ | ||||||
|  | 	ImFont* add_default_font(float pixel_size) | ||||||
|  | 	{ | ||||||
|  | 		ImGuiIO& io = ImGui::GetIO(); | ||||||
|  | 		ImFontConfig config; | ||||||
|  | 		config.SizePixels = pixel_size; | ||||||
|  | 		config.OversampleH = config.OversampleV = 1; | ||||||
|  | 		config.PixelSnapH = true; | ||||||
|  | 		ImFont* font = io.Fonts->AddFontDefault(&config); | ||||||
|  | 		return font; | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
| 	static inline void push_style_color(ImGuiCol idx, const ImVec4& col, bool fading_out, float current_fade_opacity) | 	static inline void push_style_color(ImGuiCol idx, const ImVec4& col, bool fading_out, float current_fade_opacity) | ||||||
| 	{ | 	{ | ||||||
| 		if (fading_out) | 		if (fading_out) | ||||||
|  | @ -487,24 +498,25 @@ void NotificationManager::PopNotification::render_close_button(ImGuiWrapper& img | ||||||
| 
 | 
 | ||||||
| 	//button - if part if treggered
 | 	//button - if part if treggered
 | ||||||
| 	std::string button_text; | 	std::string button_text; | ||||||
| 	button_text = ImGui::CloseIconMarker; | 	button_text = ImGui::CloseNotifButton; | ||||||
| 	 | 	 | ||||||
| 	if (ImGui::IsMouseHoveringRect(ImVec2(win_pos.x - win_size.x / 10.f, win_pos.y), | 	if (ImGui::IsMouseHoveringRect(ImVec2(win_pos.x - win_size.x / 10.f, win_pos.y), | ||||||
| 		                           ImVec2(win_pos.x, win_pos.y + win_size.y - ( m_minimize_b_visible ? 2 * m_line_height : 0)), | 		                           ImVec2(win_pos.x, win_pos.y + win_size.y - ( m_minimize_b_visible ? 2 * m_line_height : 0)), | ||||||
| 		                           true)) | 		                           true)) | ||||||
| 	{ | 	{ | ||||||
| 		button_text = ImGui::CloseIconHoverMarker; | 		button_text = ImGui::CloseNotifHoverButton; | ||||||
| 	} | 	} | ||||||
| 	ImVec2 button_pic_size = ImGui::CalcTextSize(button_text.c_str()); | 	ImVec2 button_pic_size = ImGui::CalcTextSize(button_text.c_str()); | ||||||
| 	ImVec2 button_size(button_pic_size.x * 1.25f, button_pic_size.y * 1.25f); | 	ImVec2 button_size(button_pic_size.x * 1.25f, button_pic_size.y * 1.25f); | ||||||
| 	ImGui::SetCursorPosX(win_size.x - m_line_height * 2.25f); | 	ImGui::SetCursorPosX(win_size.x - m_line_height * 2.75f); | ||||||
| 	ImGui::SetCursorPosY(win_size.y / 2 - button_size.y/2); | 	ImGui::SetCursorPosY(win_size.y / 2 - button_size.y); | ||||||
| 	if (imgui.button(button_text.c_str(), button_size.x, button_size.y)) | 	if (imgui.button(button_text.c_str(), button_size.x, button_size.y)) | ||||||
| 	{ | 	{ | ||||||
| 		m_close_pending = true; | 		m_close_pending = true; | ||||||
| 	} | 	} | ||||||
|  | 
 | ||||||
| 	//invisible large button
 | 	//invisible large button
 | ||||||
| 	ImGui::SetCursorPosX(win_size.x - m_line_height * 2.125); | 	ImGui::SetCursorPosX(win_size.x - m_line_height * 2.35f); | ||||||
| 	ImGui::SetCursorPosY(0); | 	ImGui::SetCursorPosY(0); | ||||||
| 	if (imgui.button(" ", m_line_height * 2.125, win_size.y - ( m_minimize_b_visible ? 2 * m_line_height : 0))) | 	if (imgui.button(" ", m_line_height * 2.125, win_size.y - ( m_minimize_b_visible ? 2 * m_line_height : 0))) | ||||||
| 	{ | 	{ | ||||||
|  | @ -569,7 +581,7 @@ void NotificationManager::PopNotification::render_left_sign(ImGuiWrapper& imgui) | ||||||
| 		std::string text; | 		std::string text; | ||||||
| 		text = (m_data.level == NotificationLevel::ErrorNotification ? ImGui::ErrorMarker : ImGui::WarningMarker); | 		text = (m_data.level == NotificationLevel::ErrorNotification ? ImGui::ErrorMarker : ImGui::WarningMarker); | ||||||
| 		ImGui::SetCursorPosX(m_line_height / 3); | 		ImGui::SetCursorPosX(m_line_height / 3); | ||||||
| 		ImGui::SetCursorPosY(m_window_height / 2 - m_line_height / 2); | 		ImGui::SetCursorPosY(m_window_height / 2 - m_line_height); | ||||||
| 		imgui.text(text.c_str()); | 		imgui.text(text.c_str()); | ||||||
| 	}  | 	}  | ||||||
| } | } | ||||||
|  | @ -586,16 +598,16 @@ void NotificationManager::PopNotification::render_minimize_button(ImGuiWrapper& | ||||||
| 	 | 	 | ||||||
| 	//button - if part if treggered
 | 	//button - if part if treggered
 | ||||||
| 	std::string button_text; | 	std::string button_text; | ||||||
| 	button_text = ImGui::MinimalizeMarker; | 	button_text = ImGui::MinimalizeButton; | ||||||
| 	if (ImGui::IsMouseHoveringRect(ImVec2(win_pos_x - m_window_width / 10.f, win_pos_y + m_window_height - 2 * m_line_height + 1), | 	if (ImGui::IsMouseHoveringRect(ImVec2(win_pos_x - m_window_width / 10.f, win_pos_y + m_window_height - 2 * m_line_height + 1), | ||||||
| 		ImVec2(win_pos_x, win_pos_y + m_window_height), | 		ImVec2(win_pos_x, win_pos_y + m_window_height), | ||||||
| 		true))  | 		true))  | ||||||
| 	{ | 	{ | ||||||
| 		button_text = ImGui::MinimalizeHoverMarker; | 		button_text = ImGui::MinimalizeHoverButton; | ||||||
| 	} | 	} | ||||||
| 	ImVec2 button_pic_size = ImGui::CalcTextSize(button_text.c_str()); | 	ImVec2 button_pic_size = ImGui::CalcTextSize(button_text.c_str()); | ||||||
| 	ImVec2 button_size(button_pic_size.x * 1.25f, button_pic_size.y * 1.25f); | 	ImVec2 button_size(button_pic_size.x * 1.25f, button_pic_size.y * 1.25f); | ||||||
| 	ImGui::SetCursorPosX(m_window_width - m_line_height * 2.25f); | 	ImGui::SetCursorPosX(m_window_width - m_line_height * 1.8f); | ||||||
| 	ImGui::SetCursorPosY(m_window_height - button_size.y - 5); | 	ImGui::SetCursorPosY(m_window_height - button_size.y - 5); | ||||||
| 	if (imgui.button(button_text.c_str(), button_size.x, button_size.y)) | 	if (imgui.button(button_text.c_str(), button_size.x, button_size.y)) | ||||||
| 	{ | 	{ | ||||||
|  | @ -712,7 +724,7 @@ void NotificationManager::ExportFinishedNotification::count_spaces() | ||||||
| 		m_left_indentation = picture_width + m_line_height / 2; | 		m_left_indentation = picture_width + m_line_height / 2; | ||||||
| 	} | 	} | ||||||
| 	//TODO count this properly
 | 	//TODO count this properly
 | ||||||
| 	m_window_width_offset = m_left_indentation + m_line_height * (m_to_removable ? 5.f : 3.f); | 	m_window_width_offset = m_left_indentation + m_line_height * (m_to_removable ? 6.f : 3.f); | ||||||
| 	m_window_width = m_line_height * 25; | 	m_window_width = m_line_height * 25; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | @ -765,13 +777,13 @@ void NotificationManager::ExportFinishedNotification::render_eject_button(ImGuiW | ||||||
| 	ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4(.0f, .0f, .0f, .0f)); | 	ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4(.0f, .0f, .0f, .0f)); | ||||||
| 
 | 
 | ||||||
| 	std::string button_text; | 	std::string button_text; | ||||||
| 	button_text = ImGui::EjectMarker; | 	button_text = ImGui::EjectButton; | ||||||
| 	 | 	 | ||||||
|     if (ImGui::IsMouseHoveringRect(ImVec2(win_pos.x - m_line_height * 4.5f, win_pos.y), |     if (ImGui::IsMouseHoveringRect(ImVec2(win_pos.x - m_line_height * 5.f, win_pos.y), | ||||||
| 		ImVec2(win_pos.x - m_line_height * 2.5f, win_pos.y + win_size.y), | 		ImVec2(win_pos.x - m_line_height * 2.5f, win_pos.y + win_size.y), | ||||||
| 		true)) | 		true)) | ||||||
| 	{ | 	{ | ||||||
| 		button_text = ImGui::EjectHoverMarker; | 		button_text = ImGui::EjectHoverButton; | ||||||
| 		// tooltip
 | 		// tooltip
 | ||||||
| 		long time_now = wxGetLocalTime(); | 		long time_now = wxGetLocalTime(); | ||||||
| 		if (m_hover_time > 0 && m_hover_time < time_now) { | 		if (m_hover_time > 0 && m_hover_time < time_now) { | ||||||
|  | @ -788,8 +800,8 @@ void NotificationManager::ExportFinishedNotification::render_eject_button(ImGuiW | ||||||
| 
 | 
 | ||||||
| 	ImVec2 button_pic_size = ImGui::CalcTextSize(button_text.c_str()); | 	ImVec2 button_pic_size = ImGui::CalcTextSize(button_text.c_str()); | ||||||
| 	ImVec2 button_size(button_pic_size.x * 1.25f, button_pic_size.y * 1.25f); | 	ImVec2 button_size(button_pic_size.x * 1.25f, button_pic_size.y * 1.25f); | ||||||
| 	ImGui::SetCursorPosX(win_size.x - m_line_height * 4.f); | 	ImGui::SetCursorPosX(win_size.x - m_line_height * 5.0f); | ||||||
| 	ImGui::SetCursorPosY(win_size.y / 2 - button_size.y / 2); | 	ImGui::SetCursorPosY(win_size.y / 2 - button_size.y); | ||||||
| 	if (imgui.button(button_text.c_str(), button_size.x, button_size.y)) | 	if (imgui.button(button_text.c_str(), button_size.x, button_size.y)) | ||||||
| 	{ | 	{ | ||||||
| 		assert(m_evt_handler != nullptr); | 		assert(m_evt_handler != nullptr); | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 David Kocik
						David Kocik