1 /* === S Y N F I G ========================================================= */
2 /*! \file renderer_dragbox.cpp
3 ** \brief Template File
8 ** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
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.
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.
21 /* ========================================================================= */
23 /* === H E A D E R S ======================================================= */
32 #include "renderer_dragbox.h"
40 /* === U S I N G =========================================================== */
44 using namespace synfig;
45 using namespace studio;
47 /* === M A C R O S ========================================================= */
49 /* === G L O B A L S ======================================================= */
51 /* === P R O C E D U R E S ================================================= */
53 /* === M E T H O D S ======================================================= */
55 Renderer_Dragbox::~Renderer_Dragbox()
60 Renderer_Dragbox::get_drag_point()const
62 return get_work_area()->get_drag_point();
66 Renderer_Dragbox::get_curr_point()const
68 return get_work_area()->get_cursor_pos();
72 Renderer_Dragbox::get_enabled_vfunc()const
74 return get_work_area()->get_dragging_mode()==WorkArea::DRAG_BOX;
79 Renderer_Dragbox::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 const synfig::Point& curr_point(get_curr_point());
127 const synfig::Point& drag_point(get_drag_point());
130 gc->set_function(Gdk::COPY);
131 gc->set_rgb_fg_color(Gdk::Color("#000000"));
132 gc->set_line_attributes(1,Gdk::LINE_ON_OFF_DASH,Gdk::CAP_BUTT,Gdk::JOIN_MITER);
133 //gc->set_line_attributes(1,Gdk::LINE_SOLID,Gdk::CAP_BUTT,Gdk::JOIN_MITER);
135 Point tl(std::min(drag_point[0],curr_point[0]),std::min(drag_point[1],curr_point[1]));
136 Point br(std::max(drag_point[0],curr_point[0]),std::max(drag_point[1],curr_point[1]));
138 tl[0]=(tl[0]-window_startx)/pw;
139 tl[1]=(tl[1]-window_starty)/ph;
140 br[0]=(br[0]-window_startx)/pw;
141 br[1]=(br[1]-window_starty)/ph;
147 drawable->draw_rectangle(gc,false,
150 round_to_int(br[0]-tl[0]),
151 round_to_int(br[1]-tl[1])