view include/App.h @ 4:df02a7de7fe2

I think I've got the Abstract Factory code working pretty robustly now, though I still need to make the factory singletons thread-safe
author Eris Caffee <discordia@eldalin.com>
date Tue, 26 Oct 2010 02:03:47 -0500
parents 0f4ad525f49a
children d691ce98f406
line source
1 ////////////////////////////////////////////////////////////////////////////////
2 //
3 // (C) 2010 Sarah Eris Horsley Caffee
4 //
5 // mandelbrot - A simple Mandelbrot Set viewer.
6 //
7 // App.h
8 // Application class definition
9 //
10 ////////////////////////////////////////////////////////////////////////////////
12 #ifndef APP_H
13 #define APP_H
15 #include <vector>
17 #include "SDL.h"
19 #include "EventHandler.h"
20 #include "Fractal.h"
22 class App : public EventHandler
23 {
24 public:
26 App();
27 ~App();
29 int run();
33 private:
35 bool init();
36 void update();
37 void render();
38 void cleanup();
40 // Overrides of EventHandler:
41 void on_event(SDL_Event * event);
42 void on_KeyDown(SDLKey sym, SDLMod mod, Uint16 unicode);
43 void on_KeyUp(SDLKey sym, SDLMod mod, Uint16 unicode);
44 void on_Exit();
45 void on_LButtonDown(int mx, int my);
46 void on_LButtonUp(int mx, int my);
47 void on_RButtonDown(int mx, int my);
48 void on_MouseMove(int mx, int my,
49 int relx, int rely,
50 bool left, bool right, bool middle);
51 void on_Resize(int w, int h);
52 void on_Expose();
55 int mouse_move_width(int mx, int my);
57 bool create_new_surface(SDL_Surface * &surface);
59 void set_julia_k(int x, int y);
61 void restore_view();
62 void save_view();
64 void set_caption();
66 bool save_image();
68 static Uint32 timer_callback(Uint32 interval, void *param);
70 int get_next_file_num();
72 #if !defined(WIN32)
73 static int scandir_filter(const struct dirent * d);
74 #endif
76 bool running;
77 bool redraw;
79 SDL_Surface * surf_display;
80 SDL_Surface * surf_selection;
81 SDL_Surface * surf_fractal;
83 int selection_x, selection_y, selection_width;
84 bool setting_zoom;
85 bool can_set_julia_k;
86 bool setting_julia_k;
88 struct view
89 {
90 std::string type;
91 double re_min, im_max, size;
92 unsigned int max_iter;
93 };
94 static std::vector<view *> old_views;
96 Fractal * fractal;
97 };
99 #endif