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