view include/App.h @ 3:0f4ad525f49a

Lot's of cleanup. Applied AbstractFactory to class Fractal and derivatives. Decoupled most objects. Removed remaining standard C function calls. Improved old_views handling.
author Eris Caffee <discordia@eldalin.com>
date Sat, 23 Oct 2010 04:24:48 -0500
parents 0684158d38a8
children df02a7de7fe2
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 "Mandelbrot.h"
23 class App : public EventHandler
24 {
25 public:
27 App();
28 ~App();
30 int run();
34 private:
36 bool init();
37 void update();
38 void render();
39 void cleanup();
41 // Overrides of EventHandler:
42 void on_event(SDL_Event * event);
43 void on_KeyDown(SDLKey sym, SDLMod mod, Uint16 unicode);
44 void on_KeyUp(SDLKey sym, SDLMod mod, Uint16 unicode);
45 void on_Exit();
46 void on_LButtonDown(int mx, int my);
47 void on_LButtonUp(int mx, int my);
48 void on_RButtonDown(int mx, int my);
49 void on_MouseMove(int mx, int my,
50 int relx, int rely,
51 bool left, bool right, bool middle);
52 void on_Resize(int w, int h);
53 void on_Expose();
56 int mouse_move_width(int mx, int my);
58 bool create_new_surface(SDL_Surface * &surface);
60 void set_julia_k(int x, int y);
62 void restore_view();
63 void save_view();
65 void set_caption();
67 bool save_image();
69 static Uint32 timer_callback(Uint32 interval, void *param);
72 bool running;
73 bool redraw;
75 SDL_Surface * surf_display;
76 SDL_Surface * surf_selection;
77 SDL_Surface * surf_fractal;
79 int selection_x, selection_y, selection_width;
80 bool setting_zoom;
81 bool can_set_julia_k;
82 bool setting_julia_k;
84 struct view
85 {
86 std::string type;
87 double re_min, im_max, size;
88 unsigned int max_iter;
89 };
90 static std::vector<view *> old_views;
92 Fractal * fractal;
93 };
95 #endif