1 /* === S Y N F I G ========================================================= */
3 ** \brief Template File
5 ** $Id: renderer_dragbox.cpp,v 1.1.1.1 2005/01/07 03:34:36 darco Exp $
8 ** Copyright (c) 2002 Robert B. Quattlebaum Jr.
10 ** This software and associated documentation
11 ** are CONFIDENTIAL and PROPRIETARY property of
12 ** the above-mentioned copyright holder.
14 ** You may not copy, print, publish, or in any
15 ** other way distribute this software without
16 ** a prior written agreement with
17 ** the copyright holder.
20 /* ========================================================================= */
22 /* === H E A D E R S ======================================================= */
31 #include "renderer_dragbox.h"
37 /* === U S I N G =========================================================== */
41 using namespace synfig;
42 using namespace studio;
44 /* === M A C R O S ========================================================= */
46 /* === G L O B A L S ======================================================= */
48 /* === P R O C E D U R E S ================================================= */
50 /* === M E T H O D S ======================================================= */
52 Renderer_Dragbox::~Renderer_Dragbox()
57 Renderer_Dragbox::get_drag_point()const
59 return get_work_area()->get_drag_point();
63 Renderer_Dragbox::get_curr_point()const
65 return get_work_area()->get_cursor_pos();
69 Renderer_Dragbox::get_enabled_vfunc()const
71 return get_work_area()->get_dragging_mode()==WorkArea::DRAG_BOX;
76 Renderer_Dragbox::render_vfunc(
77 const Glib::RefPtr<Gdk::Drawable>& drawable,
78 const Gdk::Rectangle& expose_area
81 assert(get_work_area());
85 const synfig::RendDesc &rend_desc(get_work_area()->get_canvas()->rend_desc());
87 const synfig::Vector focus_point(get_work_area()->get_focus_point());
89 // std::vector< std::pair<Glib::RefPtr<Gdk::Pixbuf>,int> >& tile_book(get_tile_book());
91 int drawable_w,drawable_h;
92 drawable->get_size(drawable_w,drawable_h);
94 // Calculate the window coordinates of the top-left
95 // corner of the canvas.
96 const synfig::Vector::value_type
97 x(focus_point[0]/get_pw()+drawable_w/2-get_w()/2),
98 y(focus_point[1]/get_ph()+drawable_h/2-get_h()/2);
100 /*const synfig::Vector::value_type window_startx(window_tl[0]);
101 const synfig::Vector::value_type window_endx(window_br[0]);
102 const synfig::Vector::value_type window_starty(window_tl[1]);
103 const synfig::Vector::value_type window_endy(window_br[1]);
106 tile_w(get_work_area()->get_tile_w()),
107 tile_h(get_work_area()->get_tile_h());
113 Glib::RefPtr<Gdk::GC> gc(Gdk::GC::create(drawable));
115 //const synfig::Vector grid_size(get_grid_size());
117 const synfig::Vector::value_type window_startx(get_work_area()->get_window_tl()[0]);
118 const synfig::Vector::value_type window_endx(get_work_area()->get_window_br()[0]);
119 const synfig::Vector::value_type window_starty(get_work_area()->get_window_tl()[1]);
120 const synfig::Vector::value_type window_endy(get_work_area()->get_window_br()[1]);
121 const float pw(get_pw()),ph(get_ph());
123 const synfig::Point& curr_point(get_curr_point());
124 const synfig::Point& drag_point(get_drag_point());
127 gc->set_function(Gdk::COPY);
128 gc->set_rgb_fg_color(Gdk::Color("#000000"));
129 gc->set_line_attributes(1,Gdk::LINE_ON_OFF_DASH,Gdk::CAP_BUTT,Gdk::JOIN_MITER);
130 //gc->set_line_attributes(1,Gdk::LINE_SOLID,Gdk::CAP_BUTT,Gdk::JOIN_MITER);
132 Point tl(std::min(drag_point[0],curr_point[0]),std::min(drag_point[1],curr_point[1]));
133 Point br(std::max(drag_point[0],curr_point[0]),std::max(drag_point[1],curr_point[1]));
135 tl[0]=(tl[0]-window_startx)/pw;
136 tl[1]=(tl[1]-window_starty)/ph;
137 br[0]=(br[0]-window_startx)/pw;
138 br[1]=(br[1]-window_starty)/ph;
144 drawable->draw_rectangle(gc,false,
147 round_to_int(br[0]-tl[0]),
148 round_to_int(br[1]-tl[1])