| 
									
										
										
										
											2013-08-09 08:01:20 +08:00
										 |  |  | /* Aseprite
 | 
					
						
							| 
									
										
										
										
											2013-01-27 23:13:13 +08:00
										 |  |  |  * Copyright (C) 2001-2013  David Capello | 
					
						
							| 
									
										
										
										
											2012-01-06 06:45:03 +08:00
										 |  |  |  * | 
					
						
							|  |  |  |  * This program is free software; you can redistribute it and/or modify | 
					
						
							|  |  |  |  * it under the terms of the GNU General Public License as published by | 
					
						
							|  |  |  |  * the Free Software Foundation; either version 2 of the License, or | 
					
						
							|  |  |  |  * (at your option) any later version. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * This program is distributed in the hope that it will be useful, | 
					
						
							|  |  |  |  * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
					
						
							|  |  |  |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
					
						
							|  |  |  |  * GNU General Public License for more details. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * You should have received a copy of the GNU General Public License | 
					
						
							|  |  |  |  * along with this program; if not, write to the Free Software | 
					
						
							|  |  |  |  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											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"
 | 
					
						
							|  |  |  | #include "app/commands/command.h"
 | 
					
						
							|  |  |  | #include "app/ui/skin/skin_theme.h"
 | 
					
						
							|  |  |  | #include "app/ui/status_bar.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
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-02-13 10:21:06 +08:00
										 |  |  | #include <allegro.h>
 | 
					
						
							| 
									
										
										
										
											2012-06-18 09:49:58 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-02-13 10:21:06 +08:00
										 |  |  | #if defined ALLEGRO_WINDOWS && defined DEBUGMODE
 | 
					
						
							|  |  |  |   #include <winalleg.h>
 | 
					
						
							| 
									
										
										
										
											2013-03-12 07:29:45 +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(); | 
					
						
							|  |  |  |   Command* clone() { return new RefreshCommand(*this); } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | protected: | 
					
						
							|  |  |  |   void onExecute(Context* context); | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | RefreshCommand::RefreshCommand() | 
					
						
							|  |  |  |   : Command("Refresh", | 
					
						
							|  |  |  |             "Refresh", | 
					
						
							|  |  |  |             CmdUIOnlyFlag) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void RefreshCommand::onExecute(Context* context) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2012-06-18 09:02:54 +08:00
										 |  |  |   ui::jmouse_hide(); | 
					
						
							| 
									
										
										
										
											2012-01-06 06:45:03 +08:00
										 |  |  |   clear_to_color(screen, makecol(0, 0, 0)); | 
					
						
							| 
									
										
										
										
											2012-06-18 09:02:54 +08:00
										 |  |  |   ui::jmouse_show(); | 
					
						
							| 
									
										
										
										
											2012-01-06 06:45:03 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |   // Reload skin
 | 
					
						
							|  |  |  |   { | 
					
						
							| 
									
										
										
										
											2013-08-06 08:20:19 +08:00
										 |  |  |     skin::SkinTheme* theme = (skin::SkinTheme*)ui::CurrentTheme::get(); | 
					
						
							| 
									
										
										
										
											2012-01-06 06:45:03 +08:00
										 |  |  |     theme->reload_skin(); | 
					
						
							|  |  |  |     theme->regenerate(); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-03-12 07:29:45 +08:00
										 |  |  |   app_refresh_screen(); | 
					
						
							| 
									
										
										
										
											2012-01-06 06:45:03 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |   // Print memory information
 | 
					
						
							|  |  |  | #if defined ALLEGRO_WINDOWS && defined DEBUGMODE
 | 
					
						
							|  |  |  |   { | 
					
						
							|  |  |  |     PROCESS_MEMORY_COUNTERS pmc; | 
					
						
							|  |  |  |     if (GetProcessMemoryInfo(GetCurrentProcess(), &pmc, sizeof(pmc))) { | 
					
						
							| 
									
										
										
										
											2012-07-10 00:20:58 +08:00
										 |  |  |       StatusBar::instance() | 
					
						
							| 
									
										
										
										
											2012-01-06 06:45:03 +08:00
										 |  |  |         ->showTip(1000, | 
					
						
							|  |  |  |                   "Current memory: %.16g KB (%lu)\n" | 
					
						
							|  |  |  |                   "Peak of memory: %.16g KB (%lu)", | 
					
						
							|  |  |  |                   pmc.WorkingSetSize / 1024.0, pmc.WorkingSetSize, | 
					
						
							|  |  |  |                   pmc.PeakWorkingSetSize / 1024.0, pmc.PeakWorkingSetSize); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Command* CommandFactory::createRefreshCommand() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   return new RefreshCommand; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2013-08-06 08:20:19 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | } // namespace app
 |