1 /* === S Y N F I G ========================================================= */
2 /*!	\file renderer_bonesetup.cpp
3 **	\brief Template File
4 **
5 **	$Id$
6 **
7 **	\legal
8 **	Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
9 **	Copyright (c) 2007 Chris Moore
10 **
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.
15 **
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.
20 **	\endlegal
21 */
22 /* ========================================================================= */
23 
24 /* === H E A D E R S ======================================================= */
25 
26 #ifdef USING_PCH
27 #	include "pch.h"
28 #else
29 #ifdef HAVE_CONFIG_H
30 #	include <config.h>
31 #endif
32 
33 #include <synfig/general.h>
34 
35 #include "renderer_bonesetup.h"
36 #include "workarea.h"
37 #include <pangomm/layout.h>
38 #include <pangomm/context.h>
39 #include <pango/pango.h>
40 #include "app.h"
41 #include <cassert>
42 
43 #include <gui/localization.h>
44 
45 #endif
46 
47 /* === U S I N G =========================================================== */
48 
49 using namespace std;
50 using namespace etl;
51 using namespace synfig;
52 using namespace studio;
53 
54 /* === M A C R O S ========================================================= */
55 
56 /* === G L O B A L S ======================================================= */
57 
58 /* === P R O C E D U R E S ================================================= */
59 
60 /* === M E T H O D S ======================================================= */
61 
~Renderer_BoneSetup()62 Renderer_BoneSetup::~Renderer_BoneSetup()
63 {
64 }
65 
66 bool
get_enabled_vfunc() const67 Renderer_BoneSetup::get_enabled_vfunc()const
68 {
69 	return true;
70 }
71 
72 void
render_vfunc(const Glib::RefPtr<Gdk::Window> & drawable,const Gdk::Rectangle &)73 Renderer_BoneSetup::render_vfunc(const Glib::RefPtr<Gdk::Window>& drawable,
74 								 const Gdk::Rectangle& /*expose_area*/ )
75 {
76 	assert(get_work_area());
77 	if(!get_work_area())
78 		return;
79 
80 	//const synfig::Vector focus_point(get_work_area()->get_focus_point());
81 	//Warning: unused variable focus_point
82 	int drawable_w = drawable->get_width();
83 	int drawable_h = drawable->get_height();
84 
85 	Cairo::RefPtr<Cairo::Context> cr = drawable->create_cairo_context();
86 
87 	Canvas::Handle canvas(get_work_area()->get_canvas());
88 	//synfig::Time cur_time(canvas->get_time());
89 	//Warning: Unused variable cur_time
90 	// Print out the bonesetup
91 	{
92 		Glib::RefPtr<Pango::Layout> layout(Pango::Layout::create(get_work_area()->get_pango_context()));
93 
94 		bool recursive(get_work_area()->get_type_mask() & Duck::TYPE_BONE_RECURSIVE);
95 		if (recursive)
96 		{
97 			int w, h;
98 			layout->set_text(_("Bone Recursive Scale Mode"));
99 			layout->get_size(w, h);
100 			get_work_area()->bonesetup_width = int(w*1.0/Pango::SCALE);
101 			get_work_area()->bonesetup_height = int(h*1.0/Pango::SCALE);
102 		}
103 		else
104 			get_work_area()->timecode_width = get_work_area()->timecode_height = 0;
105 
106 		Gdk::RGBA c("#5f0000");
107 		cr->set_source_rgb(c.get_red(), c.get_green(), c.get_blue());
108 		cr->move_to(bonesetup_x, bonesetup_y);
109 		layout->show_in_cairo_context(cr);
110 	}
111 }
112