view include/App.h @ 7:104dff305563

Added App::on_InputFocus and app::on_InputBlur to make sure the program does not receive mouse clicks when not in foreground. Added option in CmakeLists.txt to support compiling for gprof.
author Eris Caffee <discordia@eldalin.com>
date Mon, 15 Nov 2010 21:55:46 -0600
parents d691ce98f406
children 4a0062095c37
line source
1 ////////////////////////////////////////////////////////////////////////////////
2 //
3 // Fracter - A simple Mandelbrot Set viewer.
4 //
5 // Copyright (C) 2010 Sarah Eris Horsley Caffee
6 //
7 // This file is part of Fracter.
8 //
9 // Fracter is free software: you can redistribute it and/or modify
10 // it under the terms of the GNU General Public License as published by
11 // the Free Software Foundation, either version 3 of the License, or
12 // (at your option) any later version.
13 //
14 // This program is distributed in the hope that it will be useful,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 // GNU General Public License for more details.
18 //
19 // You should have received a copy of the GNU General Public License
20 // along with this program. If not, see <http://www.gnu.org/licenses/>.
21 //
22 //
23 // App.h
24 // Application class definition
25 //
26 ////////////////////////////////////////////////////////////////////////////////
28 #ifndef APP_H
29 #define APP_H
31 #include <vector>
33 #include "SDL.h"
35 #include "EventHandler.h"
36 #include "Fractal.h"
38 class App : public EventHandler
39 {
40 public:
42 App();
43 ~App();
45 int run();
48 private:
49 // Disallow copy constructor and operator=
50 App(const App &);
51 App & operator=(const App &);
53 // main loop functions
54 bool init();
55 void update();
56 void render();
57 void cleanup();
60 // Overrides of EventHandler:
61 void on_InputFocus();
62 void on_InputBlur();
63 void on_KeyDown(SDL_KeyboardEvent key);
64 void on_KeyUp(SDL_KeyboardEvent key);
65 void on_MouseMove(SDL_MouseMotionEvent motion);
66 void on_LButtonDown(SDL_MouseButtonEvent button);
67 void on_LButtonUp(SDL_MouseButtonEvent button);
68 void on_Resize(SDL_ResizeEvent resize);
69 void on_Expose();
70 void on_Quit();
73 // utility functions
74 int mouse_move_width(int mx, int my);
75 bool create_new_surface(SDL_Surface * &surface);
76 void set_julia_k(int x, int y);
77 void restore_view();
78 void save_view();
79 void set_caption();
80 bool save_image();
82 static Uint32 timer_callback(Uint32 interval, void *param);
84 int get_next_file_num();
86 #if !defined(WIN32)
87 static int scandir_filter(const struct dirent * d);
88 #endif
91 // data members
92 bool running;
93 bool redraw;
95 SDL_Surface * surf_display;
96 SDL_Surface * surf_selection;
97 SDL_Surface * surf_fractal;
99 int selection_x, selection_y, selection_width;
100 bool setting_zoom;
101 bool can_set_julia_k;
102 bool setting_julia_k;
104 static std::vector<View *> old_views;
106 Fractal * fractal;
107 };
109 #endif