1 /* === S I N F 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 Robert B. Quattlebaum Jr.
10 ** This software and associated documentation
11 ** are CONFIDENTIAL and PROPRIETARY property of
12 ** the above-mentioned copyright holder.
14 ** You may not copy, print, publish, or in any
15 ** other way distribute this software without
16 ** a prior written agreement with
17 ** the copyright holder.
20 /* ========================================================================= */
22 /* === S T A R T =========================================================== */
24 #ifndef __SINFG_PREVIEW_H
25 #define __SINFG_PREVIEW_H
27 /* === H E A D E R S ======================================================= */
28 #include <gtkmm/drawingarea.h>
29 #include <gtkmm/table.h>
30 #include <gtkmm/adjustment.h>
31 #include <gtkmm/image.h>
32 #include <gdkmm/pixbuf.h>
33 #include <gtkmm/dialog.h>
34 #include <gtkmm/scrollbar.h>
35 #include <gtkmm/checkbutton.h>
36 #include <gtkmm/canvasview.h>
38 #include <sinfg/time.h>
39 #include <sinfg/vector.h>
40 #include <sinfg/general.h>
41 #include <sinfg/renddesc.h>
42 #include <sinfg/canvas.h>
44 #include "widget_sound.h"
51 /* === M A C R O S ========================================================= */
53 /* === T Y P E D E F S ===================================================== */
55 /* === C L A S S E S & S T R U C T S ======================================= */
60 class Preview : public sigc::trackable, public etl::shared_object
66 Glib::RefPtr<Gdk::Pixbuf> buf; //at whatever resolution they are rendered at (resized at run time)
69 etl::handle<studio::AsyncRenderer> renderer;
71 sigc::signal<void, Preview *> signal_destroyed_; //so things can reference us without fear
73 typedef std::vector<FlipbookElem> FlipBook;
78 studio::CanvasView::LooseHandle canvasview;
80 //sinfg::RendDesc description; //for rendering the preview...
82 float begintime,endtime;
83 bool overbegin,overend;
88 //expose the frame information etc.
90 void frame_finish(const Preview_Target *);
92 sigc::signal0<void> sig_changed;
96 Preview(const studio::CanvasView::LooseHandle &h = studio::CanvasView::LooseHandle(),
97 float zoom = 0.5f, float fps = 15);
100 float get_zoom() const {return zoom;}
101 void set_zoom(float z){zoom = z;}
103 float get_fps() const {return fps;}
104 void set_fps(float f){fps = f;}
106 float get_global_fps() const {return global_fps;}
107 void set_global_fps(float f){global_fps = f;}
109 float get_begintime() const
114 return get_canvas()->rend_desc().get_time_start();
118 float get_endtime() const
123 return get_canvas()->rend_desc().get_time_end();
127 void set_begintime(float t) {begintime = t;}
128 void set_endtime(float t) {endtime = t;}
130 bool get_overbegin() const {return overbegin;}
131 void set_overbegin(bool b) {overbegin = b;}
133 bool get_overend() const {return overend;}
134 void set_overend(bool b) {overend = b;}
136 int get_quality() const {return quality;}
137 void set_quality(int i) {quality = i;}
139 sinfg::Canvas::Handle get_canvas() const {return canvasview->get_canvas();}
140 studio::CanvasView::Handle get_canvasview() const {return canvasview;}
142 void set_canvasview(const studio::CanvasView::LooseHandle &h);
145 sigc::signal<void, Preview *> & signal_destroyed() { return signal_destroyed_; }
146 //sigc::signal<void, const sinfg::RendDesc &> &signal_desc_change() {return signal_desc_change_;}
148 //functions for exposing iterators through the preview
149 FlipBook::iterator begin() {return frames.begin();}
150 FlipBook::iterator end() {return frames.end();}
152 FlipBook::const_iterator begin() const {return frames.begin();}
153 FlipBook::const_iterator end() const {return frames.end();}
155 void clear() {frames.clear();}
157 unsigned int numframes() const {return frames.size();}
161 sigc::signal0<void> &signal_changed() { return sig_changed; }
164 class Widget_Preview : public Gtk::Table
166 Gtk::DrawingArea draw_area;
167 Gtk::Adjustment adj_time_scrub; //the adjustment for the managed scrollbar
168 Gtk::HScrollbar scr_time_scrub;
169 Gtk::ToggleButton b_loop;
171 //Glib::RefPtr<Gdk::GC> gc_area;
172 Glib::RefPtr<Gdk::Pixbuf> currentbuf;
179 etl::handle<AudioContainer> audio;
180 sigc::connection scrstartcon;
181 sigc::connection scrstopcon;
182 sigc::connection scrubcon;
184 //preview encapsulation
185 etl::handle<Preview> preview;
186 sigc::connection prevchanged;
188 Widget_Sound disp_sound;
189 Gtk::Adjustment adj_sound;
191 Gtk::Label l_lasttime;
193 //only for internal stuff, doesn't set anything
197 //for accurate time tracking
200 //int curindex; //for later
201 SigC::Connection timecon;
203 void slider_move(); //later to be a time_slider that's cooler
206 //bool play_frameupdate();
209 void scrub_updated(double t);
217 bool scroll_move_event(GdkEvent *);
218 void disconnect_preview(Preview *);
220 bool redraw(GdkEventExpose *heh = 0);
223 sigc::signal<void,float> signal_play_;
224 sigc::signal<void> signal_stop_;
225 sigc::signal<void,float> signal_seek_;
232 //sets a signal to identify disconnection (so we don't hold onto it)...
233 void set_preview(etl::handle<Preview> prev);
234 void set_audioprofile(etl::handle<AudioProfile> p);
235 void set_audio(etl::handle<AudioContainer> a);
245 sigc::signal<void,float> &signal_play() {return signal_play_;}
246 sigc::signal<void> &signal_stop() {return signal_stop_;}
247 sigc::signal<void,float> &signal_seek() {return signal_seek_;}
249 bool get_loop_flag() const {return b_loop.get_active();}
250 void set_loop_flag(bool b) {return b_loop.set_active(b);}
253 }; // END of namespace studio
255 /* === E N D =============================================================== */