initial version
[synfig.git] / synfig-studio / trunk / src / gtkmm / dialog_preview.cpp
1 /* === S I N F G =========================================================== */
2 /*!     \file dialog_preview.cpp
3 **      \brief Preview dialog File
4 **
5 **      $Id: dialog_preview.cpp,v 1.1.1.1 2005/01/07 03:34:36 darco Exp $
6 **
7 **      \legal
8 **      Copyright (c) 2002 Robert B. Quattlebaum Jr.
9 **
10 **      This software and associated documentation
11 **      are CONFIDENTIAL and PROPRIETARY property of
12 **      the above-mentioned copyright holder.
13 **
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.
18 **      \endlegal
19 */
20 /* ========================================================================= */
21
22 /* === H E A D E R S ======================================================= */
23
24 #ifdef USING_PCH
25 #       include "pch.h"
26 #else
27 #ifdef HAVE_CONFIG_H
28 #       include <config.h>
29 #endif
30
31 #include "dialog_preview.h"
32 #include "preview.h"
33 #include <gtkmm/spinbutton.h>
34
35 #endif
36
37 /* === U S I N G =========================================================== */
38
39 using namespace std;
40 using namespace etl;
41 using namespace sinfg;
42 using namespace studio;
43 using namespace Gtk;
44
45 /* === M A C R O S ========================================================= */
46
47 /* === G L O B A L S ======================================================= */
48
49 /* === P R O C E D U R E S ================================================= */
50
51 /* === M E T H O D S ======================================================= */
52
53 /* === E N T R Y P O I N T ================================================= */
54
55 //dialog_preview stuff...
56 Dialog_Preview::Dialog_Preview()
57 :Dialog(_("Preview Window"),false,true),
58 settings(this,"preview")
59 {
60         get_vbox()->pack_start(preview);
61 }
62
63 Dialog_Preview::~Dialog_Preview()
64 {
65 }
66
67 void Dialog_Preview::set_preview(handle<Preview>        prev)
68 {
69         get_window().clear();
70         preview.set_preview(prev);
71         //preview.update();
72 }
73
74 void Dialog_Preview::on_hide()
75 {
76         Dialog::on_hide();
77         preview.stop();
78         preview.stoprender();
79 }
80
81 //dialog_previewoptions stuff
82 Dialog_PreviewOptions::Dialog_PreviewOptions()
83 :Dialog(_("Preview Options"),false,true),
84 adj_zoom(0.5,0.1,5.0,0.1,0.2),
85 adj_fps(15,1,120,1,5),
86 check_overbegin(_("Begin Time"),false),
87 check_overend(_("End Time"),false),
88 settings(this,"prevoptions")
89 {
90         //framerate = 15.0f;
91         //zoom = 0.2f;
92         
93         //set the fps of the time widgets       
94         Gtk::Table      *ot = manage(new class Gtk::Table);
95         
96         ot->attach(*manage(new class Gtk::Label(_("Zoom"))),0,1,0,1);   
97         ot->attach(*manage(new class Gtk::Label(_("FPS"))),1,2,0,1);
98         
99         ot->attach(*manage(new class Gtk::SpinButton(adj_zoom,0.1,2)),0,1,1,2); 
100         ot->attach(*manage(new class Gtk::SpinButton(adj_fps,1,1)),1,2,1,2);
101         
102         ot->attach(check_overbegin,0,1,2,3);
103         ot->attach(check_overend,1,2,2,3);
104         check_overbegin.signal_toggled().connect(sigc::mem_fun(*this,&Dialog_PreviewOptions::on_overbegin_toggle));
105         check_overend.signal_toggled().connect(sigc::mem_fun(*this,&Dialog_PreviewOptions::on_overend_toggle));
106                 
107         ot->attach(time_begin,0,1,3,4);
108         ot->attach(time_end,1,2,3,4);
109         
110         Gtk::Button *okbutton = manage(new Gtk::Button(_("Preview")));
111         okbutton->signal_clicked().connect(sigc::mem_fun(*this,&Dialog_PreviewOptions::on_ok_pressed));
112         ot->attach(*okbutton,0,2,4,5);
113         
114         ot->show_all();
115         
116         get_vbox()->pack_start(*ot);
117         
118         time_begin.set_sensitive(false);
119         time_end.set_sensitive(false);
120 }
121
122 Dialog_PreviewOptions::~Dialog_PreviewOptions()
123 {
124 }
125
126 void Dialog_PreviewOptions::on_ok_pressed()
127 {
128         PreviewInfo     i;
129         i.zoom = get_zoom();
130         i.fps = get_fps();
131         i.overbegin = get_begin_override();
132         i.overend = get_end_override();
133         if(i.overbegin) i.begintime = (float)get_begintime();
134         if(i.overend)   i.endtime = (float)get_endtime();
135         
136         hide();
137         signal_finish_(i);
138         signal_finish_.clear();
139 }
140
141 void Dialog_PreviewOptions::on_overbegin_toggle()
142 {
143         time_begin.set_sensitive(get_begin_override());
144 }
145
146 void Dialog_PreviewOptions::on_overend_toggle()
147 {
148         time_end.set_sensitive(get_end_override());
149 }
150
151 void studio::Dialog_PreviewOptions::set_global_fps(float f) 
152
153         globalfps = f; 
154         time_begin.set_fps(f); 
155         time_end.set_fps(f);
156 }