mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-10-31 12:41:20 -06:00 
			
		
		
		
	FIX:fixed crash when creat projecy in full screen mode on mac
Change-Id: I029bf52e805d699a5d6de4e3a049954b09e58255
This commit is contained in:
		
							parent
							
								
									fd0f22b771
								
							
						
					
					
						commit
						e325214cb6
					
				
					 4 changed files with 47 additions and 7 deletions
				
			
		|  | @ -198,6 +198,25 @@ DPIFrame(NULL, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, BORDERLESS_FRAME_ | |||
|     // Font is already set in DPIFrame constructor
 | ||||
| */ | ||||
| 
 | ||||
| #ifdef __APPLE__ | ||||
| 	m_reset_title_text_colour_timer = new wxTimer(); | ||||
| 	m_reset_title_text_colour_timer->SetOwner(this); | ||||
| 	Bind(wxEVT_TIMER, [this](auto& e) { | ||||
| 		set_title_colour_after_set_title(GetHandle()); | ||||
| 		m_reset_title_text_colour_timer->Stop(); | ||||
| 	}); | ||||
| 	this->Bind(wxEVT_FULLSCREEN, [this](wxFullScreenEvent& e) { | ||||
| 		set_tag_when_enter_full_screen(e.IsFullScreen()); | ||||
| 		if (!e.IsFullScreen()) { | ||||
|             if (m_reset_title_text_colour_timer) { | ||||
|                 m_reset_title_text_colour_timer->Stop(); | ||||
|                 m_reset_title_text_colour_timer->Start(500); | ||||
|             } | ||||
| 		} | ||||
| 		e.Skip(); | ||||
| 	}); | ||||
| #endif | ||||
| 
 | ||||
| #ifdef __APPLE__ | ||||
|     // Initialize the docker task bar icon.
 | ||||
|     switch (wxGetApp().get_app_mode()) { | ||||
|  | @ -766,8 +785,8 @@ void MainFrame::update_title() | |||
| 
 | ||||
| void MainFrame::update_title_colour_after_set_title()  | ||||
| { | ||||
| #ifdef __WXOSX__ | ||||
|     set_title_colour_after_set_title(); | ||||
| #ifdef __APPLE__ | ||||
|     set_title_colour_after_set_title(GetHandle()); | ||||
| #endif | ||||
| } | ||||
| 
 | ||||
|  |  | |||
|  | @ -83,6 +83,7 @@ protected: | |||
| class MainFrame : public DPIFrame | ||||
| { | ||||
|     bool        m_loaded {false}; | ||||
|     wxTimer* m_reset_title_text_colour_timer{ nullptr }; | ||||
| 
 | ||||
|     wxString    m_qs_last_input_file = wxEmptyString; | ||||
|     wxString    m_qs_last_output_file = wxEmptyString; | ||||
|  |  | |||
|  | @ -11,7 +11,8 @@ extern bool mac_dark_mode(); | |||
| extern double mac_max_scaling_factor(); | ||||
| extern void set_miniaturizable(void * window); | ||||
| void WKWebView_evaluateJavaScript(void * web, wxString const & script, void (*callback)(wxString const &)); | ||||
| void set_title_colour_after_set_title(); | ||||
| void set_tag_when_enter_full_screen(bool isfullscreen); | ||||
| void set_title_colour_after_set_title(void * window); | ||||
| void initGestures(void * view,  wxEvtHandler * handler); | ||||
| #endif | ||||
| 
 | ||||
|  |  | |||
|  | @ -20,6 +20,7 @@ namespace Slic3r { | |||
| namespace GUI { | ||||
| 
 | ||||
| NSTextField* mainframe_text_field = nil; | ||||
| bool is_in_full_screen_mode = false; | ||||
| 
 | ||||
| bool mac_dark_mode() | ||||
| { | ||||
|  | @ -60,11 +61,25 @@ void set_miniaturizable(void * window) | |||
|     } | ||||
| } | ||||
| 
 | ||||
| void set_title_colour_after_set_title() | ||||
| void set_tag_when_enter_full_screen(bool isfullscreen) | ||||
| { | ||||
|     if(mainframe_text_field){ | ||||
|         [(NSTextField*)mainframe_text_field setTextColor :  NSColor.whiteColor]; | ||||
|   is_in_full_screen_mode = isfullscreen; | ||||
| } | ||||
| 
 | ||||
| void set_title_colour_after_set_title(void * window) | ||||
| { | ||||
|   NSEnumerator *viewEnum = [[[[[[[(NSView*) window window] contentView] superview] titlebarViewController] view] subviews] objectEnumerator]; | ||||
|   NSView *viewObject; | ||||
|   while(viewObject = (NSView *)[viewEnum nextObject]) { | ||||
|     if([viewObject class] == [NSTextField self]) { | ||||
|       [(NSTextField*)viewObject setTextColor : NSColor.whiteColor]; | ||||
|       mainframe_text_field = viewObject; | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|   if (mainframe_text_field) { | ||||
|     [(NSTextField*)mainframe_text_field setTextColor : NSColor.whiteColor]; | ||||
|   } | ||||
| } | ||||
| 
 | ||||
| void WKWebView_evaluateJavaScript(void * web, wxString const & script, void (*callback)(wxString const &)) | ||||
|  | @ -90,7 +105,11 @@ void WKWebView_evaluateJavaScript(void * web, wxString const & script, void (*ca | |||
|     if (Slic3r::GUI::mainframe_text_field != self){ | ||||
|         [self setTextColor2: textColor]; | ||||
|     }else{ | ||||
|         [self setTextColor2 : NSColor.whiteColor]; | ||||
|         if(Slic3r::GUI::is_in_full_screen_mode){ | ||||
|             [self setTextColor2 : NSColor.darkGrayColor]; | ||||
|         }else{ | ||||
|             [self setTextColor2 : NSColor.whiteColor]; | ||||
|         } | ||||
|     } | ||||
| } | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 tao wang
						tao wang