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
				
			
		|  | @ -8,4 +8,5 @@ Customized with the following commits: | |||
| 042880ba2df913916b2cc77f7bb677e07bfd2c58 | ||||
| 67c55c74901f1d337ef08f2090a87cfb4263bb0f | ||||
| a94c952b40d36b1505fb77b87c0dd739e1034659 | ||||
| 3ca3a544a87cc569b69351a77996c287763388a5 | ||||
| 3ca3a544a87cc569b69351a77996c287763388a5 | ||||
| 6586a46ea23e86d54d228c55c63ca55680d25d56 | ||||
|  |  | |||
|  | @ -113,16 +113,16 @@ namespace ImGui | |||
|     const char PrinterSlaIconMarker    = 0x6;  | ||||
|     const char FilamentIconMarker      = 0x7;  | ||||
|     const char MaterialIconMarker      = 0x8; | ||||
| 	const char CloseIconMarker         = 0xB; | ||||
| 	const char CloseIconHoverMarker    = 0xC; | ||||
| 	const char CloseNotifButton        = 0xB; | ||||
| 	const char CloseNotifHoverButton   = 0xC; | ||||
| //	const char TimerDotMarker          = 0xE;
 | ||||
| //	const char TimerDotEmptyMarker     = 0xF;
 | ||||
|     const char MinimalizeMarker        = 0xE; | ||||
|     const char MinimalizeHoverMarker   = 0xF; | ||||
|     const char MinimalizeButton        = 0xE; | ||||
|     const char MinimalizeHoverButton   = 0xF; | ||||
| 	const char WarningMarker           = 0x10; | ||||
| 	const char ErrorMarker             = 0x11; | ||||
|     const char EjectMarker             = 0x12; | ||||
|     const char EjectHoverMarker        = 0x13; | ||||
|     const char EjectButton             = 0x12; | ||||
|     const char EjectHoverButton        = 0x13; | ||||
| //    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::FilamentIconMarker    , "spool"                         }, | ||||
|     {ImGui::MaterialIconMarker    , "resin"                         }, | ||||
| 	{ImGui::CloseIconMarker       , "notification_close"            }, | ||||
| 	{ImGui::CloseIconHoverMarker  , "notification_close_hover"      }, | ||||
| 	//{ImGui::TimerDotMarker      , "timer_dot"                     },
 | ||||
|     //{ImGui::TimerDotEmptyMarker , "timer_dot_empty"               },
 | ||||
|     {ImGui::MinimalizeMarker      , "notification_minimalize"       }, | ||||
|     {ImGui::MinimalizeHoverMarker , "notification_minimalize_hover" }, | ||||
| 	{ImGui::WarningMarker         , "notification_warning"          }, | ||||
|     {ImGui::ErrorMarker           , "notification_error"            }, | ||||
|     {ImGui::EjectMarker           , "notification_eject_sd"         }, | ||||
|     {ImGui::EjectHoverMarker      , "notification_eject_sd_hover"   }, | ||||
|     {ImGui::MinimalizeButton      , "notification_minimalize"       }, | ||||
|     {ImGui::MinimalizeHoverButton , "notification_minimalize_hover" } | ||||
| }; | ||||
| static const std::map<const char, std::string> font_icons_large = { | ||||
|     {ImGui::CloseNotifButton       , "notification_close"            }, | ||||
|     {ImGui::CloseNotifHoverButton  , "notification_close_hover"      }, | ||||
|     {ImGui::EjectButton            , "notification_eject_sd"         }, | ||||
|     {ImGui::EjectHoverButton       , "notification_eject_sd_hover"   }, | ||||
|     {ImGui::WarningMarker          , "notification_warning"          }, | ||||
|     {ImGui::ErrorMarker            , "notification_error"            } | ||||
| }; | ||||
| 
 | ||||
| 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
 | ||||
|     for (auto& icon : font_icons) | ||||
|         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
 | ||||
|     unsigned char* pixels; | ||||
|  | @ -969,6 +971,20 @@ void ImGuiWrapper::init_font(bool compress) | |||
|         } | ||||
|         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
 | ||||
|     GLint last_texture; | ||||
|  |  | |||
|  | @ -27,6 +27,17 @@ wxDEFINE_EVENT(EVT_EXPORT_GCODE_NOTIFICAION_CLICKED, ExportGcodeNotificationClic | |||
| wxDEFINE_EVENT(EVT_PRESET_UPDATE_AVAILABLE_CLICKED, PresetUpdateAvailableClickedEvent); | ||||
| 
 | ||||
| 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) | ||||
| 	{ | ||||
| 		if (fading_out) | ||||
|  | @ -487,24 +498,25 @@ void NotificationManager::PopNotification::render_close_button(ImGuiWrapper& img | |||
| 
 | ||||
| 	//button - if part if treggered
 | ||||
| 	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), | ||||
| 		                           ImVec2(win_pos.x, win_pos.y + win_size.y - ( m_minimize_b_visible ? 2 * m_line_height : 0)), | ||||
| 		                           true)) | ||||
| 	{ | ||||
| 		button_text = ImGui::CloseIconHoverMarker; | ||||
| 		button_text = ImGui::CloseNotifHoverButton; | ||||
| 	} | ||||
| 	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); | ||||
| 	ImGui::SetCursorPosX(win_size.x - m_line_height * 2.25f); | ||||
| 	ImGui::SetCursorPosY(win_size.y / 2 - button_size.y/2); | ||||
| 	ImGui::SetCursorPosX(win_size.x - m_line_height * 2.75f); | ||||
| 	ImGui::SetCursorPosY(win_size.y / 2 - button_size.y); | ||||
| 	if (imgui.button(button_text.c_str(), button_size.x, button_size.y)) | ||||
| 	{ | ||||
| 		m_close_pending = true; | ||||
| 	} | ||||
| 
 | ||||
| 	//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); | ||||
| 	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; | ||||
| 		text = (m_data.level == NotificationLevel::ErrorNotification ? ImGui::ErrorMarker : ImGui::WarningMarker); | ||||
| 		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()); | ||||
| 	}  | ||||
| } | ||||
|  | @ -586,16 +598,16 @@ void NotificationManager::PopNotification::render_minimize_button(ImGuiWrapper& | |||
| 	 | ||||
| 	//button - if part if treggered
 | ||||
| 	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), | ||||
| 		ImVec2(win_pos_x, win_pos_y + m_window_height), | ||||
| 		true))  | ||||
| 	{ | ||||
| 		button_text = ImGui::MinimalizeHoverMarker; | ||||
| 		button_text = ImGui::MinimalizeHoverButton; | ||||
| 	} | ||||
| 	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); | ||||
| 	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); | ||||
| 	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; | ||||
| 	} | ||||
| 	//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; | ||||
| } | ||||
| 
 | ||||
|  | @ -765,13 +777,13 @@ void NotificationManager::ExportFinishedNotification::render_eject_button(ImGuiW | |||
| 	ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4(.0f, .0f, .0f, .0f)); | ||||
| 
 | ||||
| 	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), | ||||
| 		true)) | ||||
| 	{ | ||||
| 		button_text = ImGui::EjectHoverMarker; | ||||
| 		button_text = ImGui::EjectHoverButton; | ||||
| 		// tooltip
 | ||||
| 		long time_now = wxGetLocalTime(); | ||||
| 		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_size(button_pic_size.x * 1.25f, button_pic_size.y * 1.25f); | ||||
| 	ImGui::SetCursorPosX(win_size.x - m_line_height * 4.f); | ||||
| 	ImGui::SetCursorPosY(win_size.y / 2 - button_size.y / 2); | ||||
| 	ImGui::SetCursorPosX(win_size.x - m_line_height * 5.0f); | ||||
| 	ImGui::SetCursorPosY(win_size.y / 2 - button_size.y); | ||||
| 	if (imgui.button(button_text.c_str(), button_size.x, button_size.y)) | ||||
| 	{ | ||||
| 		assert(m_evt_handler != nullptr); | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 David Kocik
						David Kocik