1 /* === S Y N F I G ========================================================= */
2 /*! \file renderer_timecode.cpp
3 ** \brief Template File
8 ** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
9 ** Copyright (c) 2007 Chris Moore
11 ** This package is free software; you can redistribute it and/or
12 ** modify it under the terms of the GNU General Public License as
13 ** published by the Free Software Foundation; either version 2 of
14 ** the License, or (at your option) any later version.
16 ** This package is distributed in the hope that it will be useful,
17 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 ** General Public License for more details.
22 /* ========================================================================= */
24 /* === H E A D E R S ======================================================= */
33 #include "renderer_timecode.h"
35 #include <pangomm/layout.h>
36 #include <pangomm/context.h>
37 #include <pango/pango.h>
45 /* === U S I N G =========================================================== */
49 using namespace synfig;
50 using namespace studio;
52 /* === M A C R O S ========================================================= */
54 /* === G L O B A L S ======================================================= */
56 /* === P R O C E D U R E S ================================================= */
58 /* === M E T H O D S ======================================================= */
60 Renderer_Timecode::~Renderer_Timecode()
65 Renderer_Timecode::get_enabled_vfunc()const
67 Canvas::Handle canvas(get_work_area()->get_canvas());
68 return (canvas->rend_desc().get_time_start()!=canvas->rend_desc().get_time_end() ||
69 canvas->get_time()!=canvas->rend_desc().get_time_start());
73 Renderer_Timecode::get_grid_size()const
75 return get_work_area()->get_grid_size();
79 Renderer_Timecode::render_vfunc(
80 const Glib::RefPtr<Gdk::Drawable>& drawable,
81 const Gdk::Rectangle& /*expose_area*/
84 assert(get_work_area());
88 //const synfig::RendDesc &rend_desc(get_work_area()->get_canvas()->rend_desc());
90 const synfig::Vector focus_point(get_work_area()->get_focus_point());
92 //std::vector< std::pair<Glib::RefPtr<Gdk::Pixbuf>,int> >& tile_book(get_tile_book());
94 int drawable_w,drawable_h;
95 drawable->get_size(drawable_w,drawable_h);
97 // Calculate the window coordinates of the top-left
98 // corner of the canvas.
99 // const synfig::Vector::value_type
100 // x(focus_point[0]/get_pw()+drawable_w/2-get_w()/2),
101 // y(focus_point[1]/get_ph()+drawable_h/2-get_h()/2);
103 /*const synfig::Vector::value_type window_startx(window_tl[0]);
104 const synfig::Vector::value_type window_endx(window_br[0]);
105 const synfig::Vector::value_type window_starty(window_tl[1]);
106 const synfig::Vector::value_type window_endy(window_br[1]);
109 // tile_w(get_work_area()->get_tile_w()),
110 // tile_h(get_work_area()->get_tile_h());
116 Glib::RefPtr<Gdk::GC> gc(Gdk::GC::create(drawable));
118 //const synfig::Vector grid_size(get_grid_size());
120 // const synfig::Vector::value_type window_startx(get_work_area()->get_window_tl()[0]);
121 // const synfig::Vector::value_type window_endx(get_work_area()->get_window_br()[0]);
122 // const synfig::Vector::value_type window_starty(get_work_area()->get_window_tl()[1]);
123 // const synfig::Vector::value_type window_endy(get_work_area()->get_window_br()[1]);
124 // const float pw(get_pw()),ph(get_ph());
126 Canvas::Handle canvas(get_work_area()->get_canvas());
127 synfig::Time cur_time(canvas->get_time());
129 // Print out the timecode
131 Glib::RefPtr<Pango::Layout> layout(Pango::Layout::create(get_work_area()->get_pango_context()));
133 /* Glib::ustring timecode(cur_time.get_string(rend_desc.get_frame_rate(),App::get_time_format()));
137 timecode+="\n"+canvas->keyframe_list().find(cur_time)->get_description();
138 gc->set_rgb_fg_color(Gdk::Color("#FF0000"));
140 catch(synfig::Exception::NotFound)
143 gc->set_rgb_fg_color(Gdk::Color("#000000"));
146 layout->set_text(timecode);
149 gc->set_rgb_fg_color(Gdk::Color("#5f0000"));
153 layout->set_text(canvas->keyframe_list().find(cur_time)->get_description());
154 layout->get_size(w, h);
155 get_work_area()->timecode_width = int(w*1.0/Pango::SCALE);
156 get_work_area()->timecode_height = int(h*1.0/Pango::SCALE);
158 catch(synfig::Exception::NotFound)
160 get_work_area()->timecode_width = get_work_area()->timecode_height = 0;
167 drawable->draw_layout(gc, 4, 4, layout);