Lumiera  0.pre.03
»edityourfreedom«
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
draw-strategy.cpp
Go to the documentation of this file.
1 /*
2  BasicDrawStrategy - Implementation of a basic draw strategy
3 
4  Copyright (C) Lumiera.org
5  2010, Stefan Kangas <skangas@skangas.se
6 
7  This program is free software; you can redistribute it and/or
8  modify it under the terms of the GNU General Public License as
9  published by the Free Software Foundation; either version 2 of
10  the License, or (at your option) any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program; if not, write to the Free Software
19  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 
21 * *****************************************************/
22 
23 
31 
32 namespace gui {
33 namespace widget {
34 namespace timeline {
35 
36  DrawStrategy::~DrawStrategy() { } // emit VTable here
37 
38 
39  void
41  ,Cairo::RefPtr<Cairo::Context> cr
42  ,TimelineViewWindow* const window) const
43  {
44  REQUIRE (cr);
45  REQUIRE (window);
46 
47  int x = window->time_to_x(entity.getBegin());
48  int width = window->time_to_x(
49  entity.getEnd()) - window->time_to_x(entity.getBegin());
50 
51  // Draw a rectangle for the entity
52  // TODO: get height from the timeline::Entity
53  cr->rectangle(x, 1, width, 100-2);
54  // if (entity.getSelected())
55  cr->set_source(Cairo::SolidPattern::create_rgb (0.4, 0.4, 0.8));
56  // else
57  // cr->set_source(Cairo::SolidPattern::create_rgb (0.4, 0.4, 0.4));
58  cr->fill_preserve();
59  cr->set_source_rgb(0.25, 0.25, 0.25);
60  cr->stroke();
61 
62  // Show the entities name
63  cr->rectangle(x, 1, width, 100-2);
64  cr->clip();
65  cr->move_to (x + 3, 12);
66  cr->set_source_rgb (1.0, 1.0, 1.0);
67  cr->set_font_size (9);
68  cr->show_text (entity.getName());
69  }
70 
71 
72 }}}// namespace gui::widget::timeline
int time_to_x(TimeValue const &) const
Converts time values to x coordinates in pixels.
Lumiera GTK UI implementation root.
Definition: guifacade.cpp:47
Base class for timeline entities.
void draw(Entity const &entity, Cairo::RefPtr< Cairo::Context > cr, TimelineViewWindow *const window) const
TimelineViewWindow is a helper class for TimelineWidget which manages the view window of the timeline...
virtual Time getBegin() const =0
virtual Time getEnd() const =0
virtual std::string getName() const =0