Added "--with-userdir" to configure script to change the default user settings directory
[synfig.git] / synfig-studio / trunk / src / gtkmm / renderer_timecode.cpp
1 /* === S Y N F I G ========================================================= */
2 /*!     \file template.cpp
3 **      \brief Template File
4 **
5 **      $Id: renderer_timecode.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 "renderer_timecode.h"
33 #include "workarea.h"
34 #include <pangomm/layout.h>
35 #include <pangomm/context.h>
36 #include <pango/pango.h>
37 #include "app.h"
38
39 #endif
40
41 /* === U S I N G =========================================================== */
42
43 using namespace std;
44 using namespace etl;
45 using namespace synfig;
46 using namespace studio;
47
48 /* === M A C R O S ========================================================= */
49
50 /* === G L O B A L S ======================================================= */
51
52 /* === P R O C E D U R E S ================================================= */
53
54 /* === M E T H O D S ======================================================= */
55
56 Renderer_Timecode::~Renderer_Timecode()
57 {
58 }
59
60 bool
61 Renderer_Timecode::get_enabled_vfunc()const
62 {
63         Canvas::Handle canvas(get_work_area()->get_canvas());
64         return (canvas->rend_desc().get_time_start()!=canvas->rend_desc().get_time_end() ||
65                 canvas->get_time()!=canvas->rend_desc().get_time_start());
66 }
67
68 synfig::Vector
69 Renderer_Timecode::get_grid_size()const
70 {
71         return get_work_area()->get_grid_size();
72 }
73
74 void
75 Renderer_Timecode::render_vfunc(
76         const Glib::RefPtr<Gdk::Drawable>& drawable,
77         const Gdk::Rectangle& expose_area
78 )
79 {
80         assert(get_work_area());
81         if(!get_work_area())
82                 return;
83         
84         //const synfig::RendDesc &rend_desc(get_work_area()->get_canvas()->rend_desc());
85         
86         const synfig::Vector focus_point(get_work_area()->get_focus_point());
87
88         //std::vector< std::pair<Glib::RefPtr<Gdk::Pixbuf>,int> >& tile_book(get_tile_book());
89         
90         int drawable_w,drawable_h;
91         drawable->get_size(drawable_w,drawable_h);
92         
93         // Calculate the window coordinates of the top-left
94         // corner of the canvas.
95 //      const synfig::Vector::value_type
96 //              x(focus_point[0]/get_pw()+drawable_w/2-get_w()/2),
97 //              y(focus_point[1]/get_ph()+drawable_h/2-get_h()/2);
98
99         /*const synfig::Vector::value_type window_startx(window_tl[0]);
100         const synfig::Vector::value_type window_endx(window_br[0]);
101         const synfig::Vector::value_type window_starty(window_tl[1]);
102         const synfig::Vector::value_type window_endy(window_br[1]);
103         */
104 //      const int
105 //              tile_w(get_work_area()->get_tile_w()),
106 //              tile_h(get_work_area()->get_tile_h());
107
108 //      const int
109 //              w(get_w()),
110 //              h(get_h());
111         
112         Glib::RefPtr<Gdk::GC> gc(Gdk::GC::create(drawable));
113         
114         //const synfig::Vector grid_size(get_grid_size());
115
116 //      const synfig::Vector::value_type window_startx(get_work_area()->get_window_tl()[0]);
117 //      const synfig::Vector::value_type window_endx(get_work_area()->get_window_br()[0]);
118 //      const synfig::Vector::value_type window_starty(get_work_area()->get_window_tl()[1]);
119 //      const synfig::Vector::value_type window_endy(get_work_area()->get_window_br()[1]);
120 //      const float pw(get_pw()),ph(get_ph());
121
122         Canvas::Handle canvas(get_work_area()->get_canvas());
123         synfig::Time cur_time(canvas->get_time());
124         
125         // Print out the timecode
126         {
127                 Glib::RefPtr<Pango::Layout> layout(Pango::Layout::create(get_work_area()->get_pango_context()));
128                 
129 /*              Glib::ustring timecode(cur_time.get_string(rend_desc.get_frame_rate(),App::get_time_format()));
130
131                 try
132                 {
133                         timecode+="\n"+canvas->keyframe_list().find(cur_time)->get_description();
134                         gc->set_rgb_fg_color(Gdk::Color("#FF0000"));
135                 }
136                 catch(synfig::Exception::NotFound)
137                 {
138                         return;
139                         gc->set_rgb_fg_color(Gdk::Color("#000000"));
140                 }
141                 
142                 layout->set_text(timecode);             
143 */
144
145                 gc->set_rgb_fg_color(Gdk::Color("#5f0000"));
146                 try
147                 {
148                         layout->set_text(canvas->keyframe_list().find(cur_time)->get_description());            
149                 }
150                 catch(synfig::Exception::NotFound)
151                 {
152                         return;
153                 }
154                 
155                 drawable->draw_layout(gc, 4, 4, layout);
156         }       
157 }