1 /* === S Y N F I G ========================================================= */
3 ** \brief Previews an animation
5 ** $Id: preview.h,v 1.2 2005/01/10 08:13:44 darco Exp $
8 ** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
10 ** This package is free software; you can redistribute it and/or
11 ** modify it under the terms of the GNU General Public License as
12 ** published by the Free Software Foundation; either version 2 of
13 ** the License, or (at your option) any later version.
15 ** This package is distributed in the hope that it will be useful,
16 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 ** General Public License for more details.
21 /* ========================================================================= */
23 /* === S T A R T =========================================================== */
25 #ifndef __SYNFIG_PREVIEW_H
26 #define __SYNFIG_PREVIEW_H
28 /* === H E A D E R S ======================================================= */
29 #include <gtkmm/drawingarea.h>
30 #include <gtkmm/table.h>
31 #include <gtkmm/adjustment.h>
32 #include <gtkmm/image.h>
33 #include <gdkmm/pixbuf.h>
34 #include <gtkmm/dialog.h>
35 #include <gtkmm/scrollbar.h>
36 #include <gtkmm/checkbutton.h>
37 #include <gtkmm/canvasview.h>
39 #include <synfig/time.h>
40 #include <synfig/vector.h>
41 #include <synfig/general.h>
42 #include <synfig/renddesc.h>
43 #include <synfig/canvas.h>
45 #include "widget_sound.h"
52 /* === M A C R O S ========================================================= */
54 /* === T Y P E D E F S ===================================================== */
56 /* === C L A S S E S & S T R U C T S ======================================= */
61 class Preview : public sigc::trackable, public etl::shared_object
67 Glib::RefPtr<Gdk::Pixbuf> buf; //at whatever resolution they are rendered at (resized at run time)
70 etl::handle<studio::AsyncRenderer> renderer;
72 sigc::signal<void, Preview *> signal_destroyed_; //so things can reference us without fear
74 typedef std::vector<FlipbookElem> FlipBook;
79 studio::CanvasView::LooseHandle canvasview;
81 //synfig::RendDesc description; //for rendering the preview...
83 float begintime,endtime;
84 bool overbegin,overend;
89 //expose the frame information etc.
91 void frame_finish(const Preview_Target *);
93 sigc::signal0<void> sig_changed;
97 Preview(const studio::CanvasView::LooseHandle &h = studio::CanvasView::LooseHandle(),
98 float zoom = 0.5f, float fps = 15);
101 float get_zoom() const {return zoom;}
102 void set_zoom(float z){zoom = z;}
104 float get_fps() const {return fps;}
105 void set_fps(float f){fps = f;}
107 float get_global_fps() const {return global_fps;}
108 void set_global_fps(float f){global_fps = f;}
110 float get_begintime() const
115 return get_canvas()->rend_desc().get_time_start();
119 float get_endtime() const
124 return get_canvas()->rend_desc().get_time_end();
128 void set_begintime(float t) {begintime = t;}
129 void set_endtime(float t) {endtime = t;}
131 bool get_overbegin() const {return overbegin;}
132 void set_overbegin(bool b) {overbegin = b;}
134 bool get_overend() const {return overend;}
135 void set_overend(bool b) {overend = b;}
137 int get_quality() const {return quality;}
138 void set_quality(int i) {quality = i;}
140 synfig::Canvas::Handle get_canvas() const {return canvasview->get_canvas();}
141 studio::CanvasView::Handle get_canvasview() const {return canvasview;}
143 void set_canvasview(const studio::CanvasView::LooseHandle &h);
146 sigc::signal<void, Preview *> & signal_destroyed() { return signal_destroyed_; }
147 //sigc::signal<void, const synfig::RendDesc &> &signal_desc_change() {return signal_desc_change_;}
149 //functions for exposing iterators through the preview
150 FlipBook::iterator begin() {return frames.begin();}
151 FlipBook::iterator end() {return frames.end();}
153 FlipBook::const_iterator begin() const {return frames.begin();}
154 FlipBook::const_iterator end() const {return frames.end();}
156 void clear() {frames.clear();}
158 unsigned int numframes() const {return frames.size();}
162 sigc::signal0<void> &signal_changed() { return sig_changed; }
165 class Widget_Preview : public Gtk::Table
167 Gtk::DrawingArea draw_area;
168 Gtk::Adjustment adj_time_scrub; //the adjustment for the managed scrollbar
169 Gtk::HScrollbar scr_time_scrub;
170 Gtk::ToggleButton b_loop;
172 //Glib::RefPtr<Gdk::GC> gc_area;
173 Glib::RefPtr<Gdk::Pixbuf> currentbuf;
180 etl::handle<AudioContainer> audio;
181 sigc::connection scrstartcon;
182 sigc::connection scrstopcon;
183 sigc::connection scrubcon;
185 //preview encapsulation
186 etl::handle<Preview> preview;
187 sigc::connection prevchanged;
189 Widget_Sound disp_sound;
190 Gtk::Adjustment adj_sound;
192 Gtk::Label l_lasttime;
194 //only for internal stuff, doesn't set anything
198 //for accurate time tracking
201 //int curindex; //for later
202 SigC::Connection timecon;
204 void slider_move(); //later to be a time_slider that's cooler
207 //bool play_frameupdate();
210 void scrub_updated(double t);
218 bool scroll_move_event(GdkEvent *);
219 void disconnect_preview(Preview *);
221 bool redraw(GdkEventExpose *heh = 0);
224 sigc::signal<void,float> signal_play_;
225 sigc::signal<void> signal_stop_;
226 sigc::signal<void,float> signal_seek_;
233 //sets a signal to identify disconnection (so we don't hold onto it)...
234 void set_preview(etl::handle<Preview> prev);
235 void set_audioprofile(etl::handle<AudioProfile> p);
236 void set_audio(etl::handle<AudioContainer> a);
246 sigc::signal<void,float> &signal_play() {return signal_play_;}
247 sigc::signal<void> &signal_stop() {return signal_stop_;}
248 sigc::signal<void,float> &signal_seek() {return signal_seek_;}
250 bool get_loop_flag() const {return b_loop.get_active();}
251 void set_loop_flag(bool b) {return b_loop.set_active(b);}
254 }; // END of namespace studio
256 /* === E N D =============================================================== */