view include/App.h @ 16:bdfe3327f4ce

Saving progress
author Eris Caffee <discordia@eldalin.com>
date Wed, 24 Nov 2010 21:34:11 -0600
parents 9efbc0c6637b
children
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 &);
54 // main loop functions
55 bool init();
56 void update();
57 void render();
58 void cleanup();
61 // Overrides of EventHandler:
62 void on_InputFocus();
63 void on_InputBlur();
64 void on_KeyDown(SDL_KeyboardEvent key);
65 void on_KeyUp(SDL_KeyboardEvent key);
66 void on_MouseMove(SDL_MouseMotionEvent motion);
67 void on_LButtonDown(SDL_MouseButtonEvent button);
68 void on_LButtonUp(SDL_MouseButtonEvent button);
69 void on_Expose();
70 void on_Quit();
73 // utility functions
74 bool create_new_surface(SDL_Surface * &surface);
75 bool init_sdl();
76 int mouse_move_width(int mx, int my);
77 void set_caption();
78 static Uint32 timer_callback(Uint32 interval, void *param);
80 void set_julia_k(int x, int y);
82 void restore_view();
83 void save_view();
85 bool save_image();
86 int get_next_file_num();
88 #if !defined(WIN32)
89 static int scandir_filter(const struct dirent * d);
90 #endif
93 // data members
94 bool running;
95 bool redraw;
97 SDL_Window * window;
98 SDL_Surface * surf_selection;
99 SDL_Surface * surf_fractal;
101 int selection_x, selection_y, selection_width;
102 bool setting_zoom;
103 bool can_set_julia_k;
104 bool setting_julia_k;
106 std::vector<View *> old_views;
108 Fractal * fractal;
109 };
111 #endif