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>
38 #include <gtkmm/tooltips.h>
40 #include <synfig/time.h>
41 #include <synfig/vector.h>
42 #include <synfig/general.h>
43 #include <synfig/renddesc.h>
44 #include <synfig/canvas.h>
46 #include "widget_sound.h"
53 /* === M A C R O S ========================================================= */
55 /* === T Y P E D E F S ===================================================== */
57 /* === C L A S S E S & S T R U C T S ======================================= */
62 class Preview : public sigc::trackable, public etl::shared_object
68 Glib::RefPtr<Gdk::Pixbuf> buf; //at whatever resolution they are rendered at (resized at run time)
71 etl::handle<studio::AsyncRenderer> renderer;
73 sigc::signal<void, Preview *> signal_destroyed_; //so things can reference us without fear
75 typedef std::vector<FlipbookElem> FlipBook;
80 studio::CanvasView::LooseHandle canvasview;
82 //synfig::RendDesc description; //for rendering the preview...
84 float begintime,endtime;
85 bool overbegin,overend;
90 //expose the frame information etc.
92 void frame_finish(const Preview_Target *);
94 sigc::signal0<void> sig_changed;
98 Preview(const studio::CanvasView::LooseHandle &h = studio::CanvasView::LooseHandle(),
99 float zoom = 0.5f, float fps = 15);
102 float get_zoom() const {return zoom;}
103 void set_zoom(float z){zoom = z;}
105 float get_fps() const {return fps;}
106 void set_fps(float f){fps = f;}
108 float get_global_fps() const {return global_fps;}
109 void set_global_fps(float f){global_fps = f;}
111 float get_begintime() const
116 return get_canvas()->rend_desc().get_time_start();
120 float get_endtime() const
125 return get_canvas()->rend_desc().get_time_end();
129 void set_begintime(float t) {begintime = t;}
130 void set_endtime(float t) {endtime = t;}
132 bool get_overbegin() const {return overbegin;}
133 void set_overbegin(bool b) {overbegin = b;}
135 bool get_overend() const {return overend;}
136 void set_overend(bool b) {overend = b;}
138 int get_quality() const {return quality;}
139 void set_quality(int i) {quality = i;}
141 synfig::Canvas::Handle get_canvas() const {return canvasview->get_canvas();}
142 studio::CanvasView::Handle get_canvasview() const {return canvasview;}
144 void set_canvasview(const studio::CanvasView::LooseHandle &h);
147 sigc::signal<void, Preview *> & signal_destroyed() { return signal_destroyed_; }
148 //sigc::signal<void, const synfig::RendDesc &> &signal_desc_change() {return signal_desc_change_;}
150 //functions for exposing iterators through the preview
151 FlipBook::iterator begin() {return frames.begin();}
152 FlipBook::iterator end() {return frames.end();}
154 FlipBook::const_iterator begin() const {return frames.begin();}
155 FlipBook::const_iterator end() const {return frames.end();}
157 void clear() {frames.clear();}
159 unsigned int numframes() const {return frames.size();}
163 sigc::signal0<void> &signal_changed() { return sig_changed; }
166 class Widget_Preview : public Gtk::Table
168 Gtk::DrawingArea draw_area;
169 Gtk::Adjustment adj_time_scrub; //the adjustment for the managed scrollbar
170 Gtk::HScrollbar scr_time_scrub;
171 Gtk::ToggleButton b_loop;
172 Gtk::Tooltips tooltips;
174 //Glib::RefPtr<Gdk::GC> gc_area;
175 Glib::RefPtr<Gdk::Pixbuf> currentbuf;
182 etl::handle<AudioContainer> audio;
183 sigc::connection scrstartcon;
184 sigc::connection scrstopcon;
185 sigc::connection scrubcon;
187 //preview encapsulation
188 etl::handle<Preview> preview;
189 sigc::connection prevchanged;
191 Widget_Sound disp_sound;
192 Gtk::Adjustment adj_sound;
194 Gtk::Label l_lasttime;
196 //only for internal stuff, doesn't set anything
200 //for accurate time tracking
203 //int curindex; //for later
204 SigC::Connection timecon;
206 void slider_move(); //later to be a time_slider that's cooler
209 //bool play_frameupdate();
212 void scrub_updated(double t);
220 bool scroll_move_event(GdkEvent *);
221 void disconnect_preview(Preview *);
223 bool redraw(GdkEventExpose *heh = 0);
226 sigc::signal<void,float> signal_play_;
227 sigc::signal<void> signal_stop_;
228 sigc::signal<void,float> signal_seek_;
235 //sets a signal to identify disconnection (so we don't hold onto it)...
236 void set_preview(etl::handle<Preview> prev);
237 void set_audioprofile(etl::handle<AudioProfile> p);
238 void set_audio(etl::handle<AudioContainer> a);
248 sigc::signal<void,float> &signal_play() {return signal_play_;}
249 sigc::signal<void> &signal_stop() {return signal_stop_;}
250 sigc::signal<void,float> &signal_seek() {return signal_seek_;}
252 bool get_loop_flag() const {return b_loop.get_active();}
253 void set_loop_flag(bool b) {return b_loop.set_active(b);}
256 }; // END of namespace studio
258 /* === E N D =============================================================== */