~andrewsomething/imagination/debian

« back to all changes in this revision

Viewing changes to src/imagination.h

  • Committer: Andrew Starr-Bochicchio
  • Date: 2009-09-29 23:38:39 UTC
  • mfrom: (1.1.2)
  • Revision ID: a.starr.b@gmail.com-20090929233839-ucjnl2f35kw5fbx8
Tags: 2.0-1
* New upstream release. (Closes: #543218).
* debian/control: Build-depend on xsltproc, docbook-xsl, quilt,
  and doc-base.
* debian/imagination.doc-base: Register docs.
* debian/patches/10_link_math_lib.patch:
 - Add '-lm' to link to the math lib.
* debian/README.source: Explain quilt.
* debian/rules: Add quilt magic.

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
 
28
28
/* Transition preview frame rate. I decided to use 25 fps, which
29
29
 * should be handled on time by most machines. */
30
 
#define PREVIEW_FPS 25
 
30
#define PREVIEW_FPS 15
31
31
 
32
32
/* The transition speed is defined as a duration in seconds. */
33
33
#define FAST    1
34
34
#define NORMAL  4
35
35
#define SLOW    8
36
36
 
37
 
#define comment_string  "Imagination Slideshow Project - http://imagination.sf.net"
38
 
 
39
 
typedef struct _plugin plugin;
40
 
 
41
 
struct _plugin
42
 
{
43
 
        const gchar     *name;          /* The name of the transition */
44
 
        gpointer        address;        /* The mem address of the routine */
 
37
#define old_comment_string \
 
38
        "Imagination Slideshow Project - http://imagination.sf.net"
 
39
#define comment_string \
 
40
        "Imagination 2.0 Slideshow Project - http://imagination.sf.net"
 
41
 
 
42
 
 
43
/* ****************************************************************************
 
44
 * Subtitles related definitions
 
45
 * ************************************************************************* */
 
46
/* Enum that holds all available positions of text. */
 
47
typedef enum
 
48
{
 
49
        IMG_SUB_POS_TOP_LEFT = 0,
 
50
        IMG_SUB_POS_TOP_CENTER,
 
51
        IMG_SUB_POS_TOP_RIGHT,
 
52
        IMG_SUB_POS_MIDDLE_LEFT,
 
53
        IMG_SUB_POS_MIDDLE_CENTER,
 
54
        IMG_SUB_POS_MIDDLE_RIGHT,
 
55
        IMG_SUB_POS_BOTTOM_LEFT,
 
56
        IMG_SUB_POS_BOTTOM_CENTER,
 
57
        IMG_SUB_POS_BOTTOM_RIGHT
 
58
}
 
59
ImgSubPos;
 
60
 
 
61
/* Enum with relative placings */
 
62
typedef enum
 
63
{
 
64
        IMG_REL_PLACING_EXPORTED_VIDEO = 0,
 
65
        IMG_REL_PLACING_ORIGINAL_IMAGE
 
66
}
 
67
ImgRelPlacing;
 
68
 
 
69
/*
 
70
 * TextAnimationFunc:
 
71
 * @cr: cairo context that should be used for drawing
 
72
 * @layout: PangoLayout to be rendered
 
73
 * @sw: surface width
 
74
 * @sh: surface height
 
75
 * @lw: layout width
 
76
 * @lh: layout height
 
77
 * @posx: final position (x coord)
 
78
 * @posy: final position (y coord)
 
79
 * @progress: progress of animation
 
80
 * @font_color: array of RGBA values
 
81
 *
 
82
 * This is prototype for subtitle animation function. It's task it to render
 
83
 * @layout to @cr according to  @progress, @posx and @posy.
 
84
 *
 
85
 * When @progress > 1, @layout should be drawn at (@posx, @posy) without any
 
86
 * scalling.
 
87
 */
 
88
typedef void (*TextAnimationFunc)( cairo_t     *cr,
 
89
                                                                   PangoLayout *layout,
 
90
                                                                   gint         sw,
 
91
                                                                   gint         sh,
 
92
                                                                   gint         lw,
 
93
                                                                   gint         lh,
 
94
                                                                   gint         posx,
 
95
                                                                   gint         posy,
 
96
                                                                   gdouble      progress,
 
97
                                                                   gdouble     *font_color );
 
98
 
 
99
 
 
100
/* ****************************************************************************
 
101
 * Transition related definitions
 
102
 * ************************************************************************* */
 
103
/* Prototype of transition renderer */
 
104
typedef void (*ImgRender)( cairo_t *,
 
105
                                                   cairo_surface_t *,
 
106
                                                   cairo_surface_t *,
 
107
                                                   gdouble );
 
108
 
 
109
/* ****************************************************************************
 
110
 * Ken Burns effect related definitions
 
111
 * ************************************************************************* */
 
112
typedef struct _ImgStopPoint ImgStopPoint;
 
113
struct _ImgStopPoint
 
114
{
 
115
        gint    time; /* Duration of this stop point */
 
116
        gdouble offx; /* X and Y offsets of zoomed image */
 
117
        gdouble offy;
 
118
        gdouble zoom; /* Zoom level */
45
119
};
46
120
 
 
121
/* ****************************************************************************
 
122
 * define for gtk clipboard
 
123
 * ************************************************************************* */
 
124
#define IMG_CLIPBOARD (gdk_atom_intern_static_string ("IMAGINATIO_OWN_CLIPBOARD")) 
 
125
#define IMG_INFO_LIST (gdk_atom_intern_static_string ("application/imagination-info-list"))
 
126
 
 
127
typedef enum
 
128
{
 
129
        IMG_CLIPBOARD_CUT,
 
130
        IMG_CLIPBOARD_COPY
 
131
} ImgClipboardMode;
 
132
 
 
133
/* ****************************************************************************
 
134
 * Common definitions that are used all over the place
 
135
 * ************************************************************************* */
47
136
typedef struct _slide_struct slide_struct;
48
 
 
49
137
struct _slide_struct
50
138
{
51
 
        gchar   *filename;
52
 
        guint   duration;
53
 
        guint   speed;
54
 
        gchar   *resolution;
55
 
        gchar   *type;
56
 
        gchar   *path;  /* transition model string path representation */
57
 
        gint     transition_id;
58
 
        void    (*render) (GdkDrawable*, GdkPixbuf*, GdkPixbuf*, gdouble, gint);
 
139
        /* Common data - always filled */
 
140
        gchar *resolution;        /* Image dimensions */
 
141
        gchar *type;              /* Image type */
 
142
 
 
143
        /* Fields that are filled when we load slide from disk */
 
144
        gchar *filename;          /* Filename of the image that slide represents */
 
145
        gchar *original_filename; /* This is filled if the image has been rotated */
 
146
 
 
147
        /* Fields that are filled if we create slide in memory */
 
148
        gint    gradient;         /* Gradient type */
 
149
        gdouble g_start_color[3]; /* RGB start color */
 
150
        gdouble g_stop_color[3];  /* RGB stop color */
 
151
        gdouble g_start_point[2]; /* x, y coordinates of start point */
 
152
        gdouble g_stop_point[2];  /* x, y coordinates of stop point */
 
153
 
 
154
        /* Still part of the slide params */
 
155
        guint duration; /* Duration of still part */ /* NOTE: sub1 */
 
156
 
 
157
        /* Transition params */
 
158
        gchar     *path;          /* Transition model path to transition */
 
159
        gint       transition_id; /* Transition id */
 
160
        ImgRender  render;        /* Transition render function */
 
161
        guint      speed;         /* Transition speed */ /* NOTE: sub1 */
 
162
 
 
163
        /* Ken Burns effect variables */
 
164
        GList *points;    /* List with stop points */
 
165
        gint   no_points; /* Number of stop points in list */
 
166
        gint   cur_point; /* Currently active stop point */
 
167
 
 
168
        /* Subtitle variables */
 
169
        gchar                *subtitle;      /* Subtitle text */
 
170
        TextAnimationFunc     anim;          /* Animation functions */
 
171
        gint                  anim_id;       /* Animation id */
 
172
        gint                  anim_duration; /* Duration of animation */
 
173
        ImgSubPos             position;      /* Final position of subtitle */
 
174
        ImgRelPlacing         placing;       /* Relative placing */
 
175
        PangoFontDescription *font_desc;     /* Font description */
 
176
        gdouble               font_color[4]; /* Font color (RGBA format) */
59
177
};
60
178
 
61
179
typedef struct _img_window_struct img_window_struct;
62
 
 
63
180
struct _img_window_struct
64
181
{
65
182
        /* Main GUI related variables */
66
183
        GtkWidget       *imagination_window;    // Main window
 
184
        GtkAccelGroup *accel_group;
67
185
        GtkWidget       *open_menu;
68
186
        GtkWidget       *save_menu;
69
187
        GtkWidget       *save_as_menu;
70
 
        GtkWidget       *properties_menu;
71
 
        GtkWidget       *close_menu;
72
188
        GtkWidget       *open_button;
73
189
        GtkWidget       *save_button;
74
 
        GtkWidget       *import_menu;
75
 
        GtkWidget       *import_audio_menu;
 
190
        GtkWidget       *cut;
 
191
        GtkWidget       *copy;
 
192
        GtkWidget       *paste;
76
193
        GtkWidget       *remove_menu;
77
 
        GtkWidget       *import_button;
78
 
        GtkWidget       *import_audio_button;
79
 
        GtkWidget       *remove_button;
80
194
        GtkWidget       *preview_menu;
81
195
        GtkWidget       *preview_button;
82
 
        GtkWidget   *export_menu;
83
 
        GtkWidget   *export_button;
84
196
        GtkWidget       *transition_type;
85
197
        GtkWidget       *random_button;
86
198
        GtkWidget       *duration;                              // Duration spin button
87
199
        GtkWidget       *trans_duration;
88
 
        GtkWidget       *slide_selected_data;
89
 
        GtkWidget       *type_data;
90
200
        GtkWidget       *total_time_data;
91
201
        GtkWidget       *filename_data;
92
 
        GtkWidget       *resolution_data;
93
 
        GtkWidget       *thumb_scrolledwindow;
 
202
        GtkTextBuffer *slide_text_buffer;
 
203
        GtkWidget       *scrolled_win;
 
204
        GtkWidget       *expand_button;
 
205
        GtkWidget   *text_pos_button;
94
206
        GtkWidget       *thumbnail_iconview;
95
207
        GtkWidget       *statusbar;
96
208
        GtkWidget       *progress_bar;
97
 
        GtkWidget       *viewport;
98
209
        GtkWidget       *image_area;
99
210
        guint           context_id;
100
211
        GtkListStore *thumbnail_model;
101
212
        gchar           *current_dir;
 
213
        GSList          *rotated_files;
 
214
 
 
215
        GtkWidget   *paned; /* Main paned (used for saving/restoring geometry) */
 
216
 
 
217
        /* Mode switching */
 
218
        gint       mode;        /* In what mode are we in: 0 - preview
 
219
                                                                                                           1 - overview */
 
220
        gboolean   auto_switch; /* Has been last mode switch made automatically? */
 
221
        GtkWidget *prev_root;   /* Preview mode root widget */
 
222
        GtkWidget *over_root;   /* Overview mode root widget */
 
223
        GtkWidget *thum_root;   /* Thumbnail root widget */
 
224
        GtkWidget *over_icon;   /* Overview iconview */
 
225
        GtkWidget *active_icon; /* Currently active icon view */
 
226
        GObject   *over_cell;   /* Overview cell renderer */
 
227
 
 
228
        /* Ken Burns related controls */
 
229
        GtkWidget *ken_left;     /* Go to left stop point button */
 
230
        GtkWidget *ken_entry;    /* Jump to stop point entry */
 
231
        GtkWidget *ken_right;    /* Go to right stop point button */
 
232
        GtkWidget *ken_duration; /* Stop point duration spin button */
 
233
        GtkWidget *ken_zoom;     /* Zoom slider */
 
234
        GtkWidget *ken_add;      /* Add stop point button */
 
235
        GtkWidget *ken_update;   /* Update stop point button */
 
236
        GtkWidget *ken_remove;   /* Remove stop point button */
 
237
 
 
238
        /* Subtitle related controls */
 
239
        GtkWidget *sub_textview;      /* Text view */
 
240
        GtkWidget *sub_font;          /* Font button */
 
241
        GtkWidget *sub_color;         /* Color selector button */
 
242
        GtkWidget *sub_anim;          /* Animation combo box */
 
243
        GtkWidget *sub_anim_duration; /* Animation duration spin button */
 
244
        GtkWidget *sub_placing;       /* Placing combo box */
 
245
        GtkWidget *sub_pos;           /* Position selector button */
102
246
 
103
247
        /* Import slides dialog variables */
104
248
        GtkWidget       *dim_label;
105
249
        GtkWidget       *size_label;
106
250
        GtkWidget       *preview_image;
107
251
 
 
252
        /* Current image position parameters */
 
253
        gdouble       x;             /* Last button press coordinates */
 
254
        gdouble       y;
 
255
        gdouble       bak_offx;      /* Stored offset at button press */
 
256
        gdouble       bak_offy;
 
257
        gdouble       maxoffx;       /* Maximal offsets for current zoom */
 
258
        gdouble       maxoffy;
 
259
        ImgStopPoint  current_point; /* Data for rendering current image */
 
260
        slide_struct *current_slide;
 
261
        
 
262
        /* Update ids */
 
263
        gint subtitle_update_id; /* Update subtitle display */
 
264
        gint total_dur_id;       /* Update total duration */
 
265
 
108
266
        /* Renderers and module stuff */
109
267
        gint            nr_transitions_loaded;
110
268
        GSList          *plugin_list;
113
271
        gchar       *project_filename;          // project name for saving
114
272
        gboolean        distort_images;
115
273
        gboolean        project_is_modified;
116
 
        guint32     background_color;
 
274
        gint        video_size[2];
 
275
        gdouble     video_ratio;
 
276
        gdouble     background_color[3];
117
277
        gint            total_secs;
118
278
        gint            total_music_secs;
119
279
        gint            slides_nr;
120
280
        slide_struct final_transition;  /* Only speed, render and duration fields
121
 
                                                                           of this structure are used (and duration is
122
 
                                                                           always 0). */
 
281
                                                                           of this structure are used (and duration
 
282
                                                                           is always 0). */
123
283
 
124
284
        /* Variables common to export and preview functions */
125
 
        slide_struct *current_slide;
126
 
        GdkPixbuf       *slide_pixbuf;
127
 
        GdkPixbuf       *pixbuf1;
128
 
        GdkPixbuf       *pixbuf2;
129
 
        GtkTreeIter *cur_ss_iter;
130
 
        guint           source_id;
131
 
        gdouble     progress;
 
285
        slide_struct    *work_slide;
 
286
        cairo_surface_t *current_image;  /* Image in preview area */
 
287
        cairo_surface_t *exported_image; /* Image being exported */
 
288
        cairo_surface_t *image1;         /* Original images */
 
289
        cairo_surface_t *image2;
 
290
        cairo_surface_t *image_from;     /* Images used in transition rendering */
 
291
        cairo_surface_t *image_to;
 
292
        ImgStopPoint    *point1;        /* Last stop point of image1 */
 
293
        ImgStopPoint    *point2;        /* First stop point of image2 */
 
294
        GtkTreeIter      cur_ss_iter;
 
295
        guint                source_id;
 
296
 
 
297
        /* Counters that control animation flow */
 
298
        guint  total_nr_frames;    /* Total number of frames */
 
299
        guint  displayed_frame;    /* Current frame */
 
300
        guint  slide_nr_frames;    /* Number of frames fo current slide */
 
301
        guint  slide_cur_frame;    /* Current slide frame */
 
302
        guint  slide_trans_frames; /* Number of frames in transition */
 
303
        guint  slide_still_frames; /* Number of frames in still part */
 
304
        guint  next_slide_off;     /* Time offset of next slide */
 
305
 
 
306
        gint   still_counter; /* Currently displayed still frame */
 
307
        gint   still_max;     /* Number of frames per stop point */
 
308
        gint   still_offset;  /* Offset in seconds for next stop point */
 
309
        guint  still_cmlt;    /* Cumulative number of still frames */
 
310
        GList *cur_point;     /* Current stop point */
 
311
 
 
312
        gint   cur_text_frame; /* Current text frame being displayed */
 
313
        gint   no_text_frames; /* All text frames */
132
314
 
133
315
        /* Preview related variables */
134
316
        gboolean        preview_is_running;
135
317
        GtkWidget       *import_slide_chooser;
136
 
        GtkWidget       *slide_number_entry;
 
318
        GtkWidget       *total_stop_points_label;
 
319
        GtkWidget       *total_slide_number_label;
 
320
        GtkWidget       *slide_number_entry;
137
321
 
138
322
        /* Export dialog related stuff */
139
323
        gint        export_is_running;  /* 0 - export is not running
154
338
                                                                                 . free audio_file
155
339
                                                                                 */
156
340
        gint        file_desc;
157
 
        guchar      *pixbuf_data;
158
341
        GtkWidget   *export_pbar1;
159
342
        GtkWidget   *export_pbar2;
160
343
        GtkWidget   *export_label;
161
344
        GtkWidget   *export_dialog;
162
345
        gdouble      export_fps;        /* Frame rate for exported video */
163
346
        gchar       *export_cmd_line;   /* ffmpeg spawn cmd line */
164
 
        gchar       *export_audio_file; /* Full path to audio */
165
 
        guint        export_frame_nr;   /* Total number of frames */
166
 
        guint        export_frame_cur;  /* Current frame */
167
 
        guint        export_slide_nr;   /* Number of frames fo current slide */
168
 
        guint        export_slide_cur;  /* Current slide frame */
169
347
        guint        export_slide;              /* Number of slide being exported */
170
 
        GSourceFunc  export_idle_func;  /* If TRUE, connect transition export, else
171
 
                                                                           still export function. */
 
348
        GSourceFunc  export_idle_func;  /* Stored procedure for pause */
172
349
        GPid         ffmpeg_export;     /* ffmpeg's process id */
173
 
        GPid         sox_export;        /* sox's process id - FIXME: This will only
174
 
                                                                           be needed if we decide to mangle audio
175
 
                                                                           files using external sox binary. */
176
 
        
 
350
 
 
351
        /* Sox thread related variables */
 
352
        gint      sox_flags;         /* Thread controls:
 
353
                                                                         0 - normal operation
 
354
                                                                         1 - thread must be killed
 
355
                                                                         2 - thread finished normally */
 
356
        GThread  *sox;               /* sox thread handler */
 
357
        gchar   **exported_audio;    /* Audio files to be exported */
 
358
        gint      exported_audio_no; /* Number of audio files inside array */
 
359
        gchar    *fifo;              /* Named pipe path */
 
360
 
177
361
        /* Audio related stuff */
178
362
        GtkWidget       *music_file_treeview;
179
363
        GtkWidget       *play_audio_button;
181
365
        GtkListStore *music_file_liststore;
182
366
        GtkWidget       *music_time_data;
183
367
        GPid            play_child_pid;
 
368
 
 
369
        /* Application related stuff */
 
370
        gdouble  image_area_zoom; /* Zoom to be applied to image area */
 
371
        gdouble  overview_zoom;   /* Zoom to be applied in overview mode */
 
372
        gboolean low_quality;     /* Preview quality:
 
373
                                                                  TRUE  - preview in low-res
 
374
                                                                  FALSE - preview in hi-res */
 
375
 
 
376
        /* Clipboard related stuff */
 
377
        GList                           *selected_paths;
 
378
        ImgClipboardMode        clipboard_mode;
184
379
};
185
380
 
186
381
#endif