view include/App.h @ 5:d691ce98f406

OK. This is the first release. Honest.
author Eris Caffee <discordia@eldalin.com>
date Fri, 12 Nov 2010 23:58:48 -0600
parents df02a7de7fe2
children 104dff305563
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_KeyDown(SDL_KeyboardEvent key);
62 void on_KeyUp(SDL_KeyboardEvent key);
63 void on_MouseMove(SDL_MouseMotionEvent motion);
64 void on_LButtonDown(SDL_MouseButtonEvent button);
65 void on_LButtonUp(SDL_MouseButtonEvent button);
66 void on_Resize(SDL_ResizeEvent resize);
67 void on_Expose();
68 void on_Quit();
71 // utility functions
72 int mouse_move_width(int mx, int my);
73 bool create_new_surface(SDL_Surface * &surface);
74 void set_julia_k(int x, int y);
75 void restore_view();
76 void save_view();
77 void set_caption();
78 bool save_image();
80 static Uint32 timer_callback(Uint32 interval, void *param);
82 int get_next_file_num();
84 #if !defined(WIN32)
85 static int scandir_filter(const struct dirent * d);
86 #endif
89 // data members
90 bool running;
91 bool redraw;
93 SDL_Surface * surf_display;
94 SDL_Surface * surf_selection;
95 SDL_Surface * surf_fractal;
97 int selection_x, selection_y, selection_width;
98 bool setting_zoom;
99 bool can_set_julia_k;
100 bool setting_julia_k;
102 static std::vector<View *> old_views;
104 Fractal * fractal;
105 };
107 #endif