| 
									
										
										
										
											2015-02-12 23:16:25 +08:00
										 |  |  | // Aseprite
 | 
					
						
							| 
									
										
										
										
											2020-05-09 04:39:55 +08:00
										 |  |  | // Copyright (C) 2020  Igara Studio S.A.
 | 
					
						
							| 
									
										
										
										
											2017-08-15 21:39:06 +08:00
										 |  |  | // Copyright (C) 2001-2017  David Capello
 | 
					
						
							| 
									
										
										
										
											2015-02-12 23:16:25 +08:00
										 |  |  | //
 | 
					
						
							| 
									
										
										
										
											2016-08-27 04:02:58 +08:00
										 |  |  | // This program is distributed under the terms of
 | 
					
						
							|  |  |  | // the End-User License Agreement for Aseprite.
 | 
					
						
							| 
									
										
										
										
											2012-01-06 06:45:03 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-08-06 08:20:19 +08:00
										 |  |  | #ifdef HAVE_CONFIG_H
 | 
					
						
							| 
									
										
										
										
											2012-01-06 06:45:03 +08:00
										 |  |  | #include "config.h"
 | 
					
						
							| 
									
										
										
										
											2013-08-06 08:20:19 +08:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2012-01-06 06:45:03 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-08-06 08:20:19 +08:00
										 |  |  | #include "app/app.h"
 | 
					
						
							| 
									
										
										
										
											2020-08-04 00:51:40 +08:00
										 |  |  | #include "app/app_menus.h"
 | 
					
						
							| 
									
										
										
										
											2013-08-06 08:20:19 +08:00
										 |  |  | #include "app/commands/command.h"
 | 
					
						
							| 
									
										
										
										
											2020-08-04 00:51:40 +08:00
										 |  |  | #include "app/ui/main_menu_bar.h"
 | 
					
						
							|  |  |  | #include "app/ui/main_window.h"
 | 
					
						
							| 
									
										
										
										
											2013-08-06 08:20:19 +08:00
										 |  |  | #include "app/ui/status_bar.h"
 | 
					
						
							| 
									
										
										
										
											2020-05-09 04:39:55 +08:00
										 |  |  | #include "fmt/format.h"
 | 
					
						
							| 
									
										
										
										
											2017-08-15 21:39:06 +08:00
										 |  |  | #include "ui/scale.h"
 | 
					
						
							| 
									
										
										
										
											2012-06-18 09:49:58 +08:00
										 |  |  | #include "ui/system.h"
 | 
					
						
							|  |  |  | #include "ui/theme.h"
 | 
					
						
							| 
									
										
										
										
											2012-01-06 06:45:03 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-28 23:18:16 +08:00
										 |  |  | #if defined _WIN32 && defined ENABLE_DEVMODE
 | 
					
						
							| 
									
										
										
										
											2014-09-03 11:01:30 +08:00
										 |  |  |   #include <windows.h>
 | 
					
						
							| 
									
										
										
										
											2015-04-17 23:24:33 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-02-13 10:21:06 +08:00
										 |  |  |   #include <psapi.h>
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-08-06 08:20:19 +08:00
										 |  |  | namespace app { | 
					
						
							| 
									
										
										
										
											2012-01-06 06:45:03 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-08-06 08:20:19 +08:00
										 |  |  | class RefreshCommand : public Command { | 
					
						
							| 
									
										
										
										
											2012-01-06 06:45:03 +08:00
										 |  |  | public: | 
					
						
							|  |  |  |   RefreshCommand(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | protected: | 
					
						
							| 
									
										
										
										
											2015-10-01 03:34:43 +08:00
										 |  |  |   void onExecute(Context* context) override; | 
					
						
							| 
									
										
										
										
											2012-01-06 06:45:03 +08:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | RefreshCommand::RefreshCommand() | 
					
						
							| 
									
										
										
										
											2017-12-02 02:10:21 +08:00
										 |  |  |   : Command(CommandId::Refresh(), CmdUIOnlyFlag) | 
					
						
							| 
									
										
										
										
											2012-01-06 06:45:03 +08:00
										 |  |  | { | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void RefreshCommand::onExecute(Context* context) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2020-08-04 00:51:40 +08:00
										 |  |  |   // Reload menus (mainly to reload the File > Scripts menu)
 | 
					
						
							|  |  |  |   //AppMenus::instance()->reload();
 | 
					
						
							|  |  |  |   App::instance()->mainWindow()->getMenuBar()->reload(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   // Reload theme
 | 
					
						
							| 
									
										
										
										
											2017-08-15 21:39:06 +08:00
										 |  |  |   ui::set_theme(ui::get_theme(), | 
					
						
							|  |  |  |                 ui::guiscale()); | 
					
						
							| 
									
										
										
										
											2020-08-04 00:51:40 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |   // Redraw screen
 | 
					
						
							| 
									
										
										
										
											2013-03-12 07:29:45 +08:00
										 |  |  |   app_refresh_screen(); | 
					
						
							| 
									
										
										
										
											2012-01-06 06:45:03 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |   // Print memory information
 | 
					
						
							| 
									
										
										
										
											2017-08-16 02:47:06 +08:00
										 |  |  | #if defined _WIN32 && defined ENABLE_DEVMODE
 | 
					
						
							| 
									
										
										
										
											2012-01-06 06:45:03 +08:00
										 |  |  |   { | 
					
						
							|  |  |  |     PROCESS_MEMORY_COUNTERS pmc; | 
					
						
							| 
									
										
										
										
											2013-10-15 06:58:11 +08:00
										 |  |  |     if (::GetProcessMemoryInfo(GetCurrentProcess(), &pmc, sizeof(pmc))) { | 
					
						
							| 
									
										
										
										
											2020-05-09 04:39:55 +08:00
										 |  |  |       StatusBar::instance()->showTip( | 
					
						
							|  |  |  |         1000, | 
					
						
							|  |  |  |         fmt::format("Current memory: {:.2f} MB ({})\n" | 
					
						
							|  |  |  |                     "Peak of memory: {:.2f} MB ({})", | 
					
						
							|  |  |  |                     pmc.WorkingSetSize / 1024.0 / 1024.0, pmc.WorkingSetSize, | 
					
						
							|  |  |  |                     pmc.PeakWorkingSetSize / 1024.0 / 1024.0, pmc.PeakWorkingSetSize)); | 
					
						
							| 
									
										
										
										
											2012-01-06 06:45:03 +08:00
										 |  |  |     } | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Command* CommandFactory::createRefreshCommand() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   return new RefreshCommand; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2013-08-06 08:20:19 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | } // namespace app
 |