-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathslideshow.h
More file actions
171 lines (136 loc) · 3.55 KB
/
slideshow.h
File metadata and controls
171 lines (136 loc) · 3.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
// This is free software licensed under the GNU GPL; see COPYING for details
#if !defined(AFX_SLIDESHOW_H__A644DF2D_934C_44DE_B80C_E4DB28603405__INCLUDED_)
#define AFX_SLIDESHOW_H__A644DF2D_934C_44DE_B80C_E4DB28603405__INCLUDED_
#if _MSC_VER > 1000
#pragma warning ( disable : 4786 )
#pragma once
#endif // _MSC_VER > 1000
#ifdef MACOSX
#include <SDL/SDL.h>
#else
#include <SDL.h>
#endif
#include <string>
#include "cache.h"
#define MN_SLIDESHOW_VERSION 0.9
class file_list;
class SDLFont;
class slideshow
{
public:
enum transition_t {
tran_none,
tran_random,
tran_BEGIN,
tran_fade,
tran_blinds,
tran_checkers,
tran_uncover,
tran_END
};
struct options
{
enum {
DEFAULT_WIDTH = 0,
DEFAULT_HEIGHT = 0
};
int width;
int height;
bool windowed;
bool repeat;
bool display_name;
bool display_number;
bool show_ready_indicator;
double advance_time;
transition_t transition;
options() :
width(DEFAULT_WIDTH),
height(DEFAULT_HEIGHT),
windowed(false),
repeat(false),
display_name(false),
display_number(false),
show_ready_indicator(false),
advance_time(0.0),
transition(tran_none)
{
}
};
slideshow(options *opt, file_list *fl);
virtual ~slideshow();
bool run();
private:
options *m_options;
file_list *m_file_list;
// === Graphics utility ====================================
SDL_Surface *m_sdl;
SDLFont *m_font;
SDL_Surface *m_imageSurface;
bool init_graphics();
void init_true_color_format();
SDL_PixelFormat m_true_color_format;
bool is_true_color(SDL_Surface *in);
SDL_Surface *convert_to_true_color(SDL_Surface *in);
SDL_Surface *frame_image(SDL_Surface *in, int w, int h);
SDL_Surface *scale_image(SDL_Surface *in, int w, int h);
void bilinearpix(SDL_Surface *in, double u, double v, Uint8 *c);
void reset_zoom(void);
void correct_image_rect(SDL_Surface *image);
void draw_centered_dialog_box(SDLFont *font, const std::string &text, int x_arg, int y_arg);
void draw_shadow_text(SDLFont &font, const std::string &text, int x, int y, int r, int g, int b);
void center_shadow_text(SDLFont &font, const std::string &text, int x, int y, int r, int g, int b);
void confirm_delete();
void draw_picture_name();
void draw_picture_number();
void do_transition(SDL_Surface *from, SDL_Surface *to);
// === Slideshow mechanics =================================
SDL_TimerID m_timer_id;
int m_image_index;
int m_prev_image_index;
Uint32 m_frame_color;
int m_zoom_percent;
bool m_zoom_mode;
bool m_image_move;
SDL_Surface *m_image_in_zoom;
SDL_Rect m_rect_image;
SDL_Rect m_display_rect;
enum user_command {
c_next_slide,
c_prev_slide,
c_first_slide,
c_last_slide,
c_toggle_timer,
c_redraw,
c_timer_advance,
c_zoom,
c_quit
};
user_command wait_for_command();
void start_timer();
void stop_timer();
void show_image(SDL_Surface *image);
// === Image cache =========================================
public:
SDL_Surface *prep_image(int index);
private:
SDL_Surface *create_placeholder_image( const std::string &filename, const char *error_str );
typedef cache<int, SDL_Surface *> image_cache;
class image_cache_callback : public image_cache::data_callback
{
public:
image_cache_callback(slideshow &sw) : m_slideshow(sw) { }
SDL_Surface *load(int ix)
{
return m_slideshow.prep_image(ix);
}
void discard(SDL_Surface *data)
{
SDL_FreeSurface(data);
}
private:
slideshow &m_slideshow;
};
image_cache_callback *m_cache_callback;
image_cache *m_image_cache;
};
#endif