Move draw functionality to timeline::Entity base class

This commit is contained in:
Stefan Kangas 2011-01-14 18:46:41 +01:00
parent 1c284fb497
commit 2fba7aba2c
7 changed files with 26 additions and 58 deletions

View file

@ -36,9 +36,6 @@ namespace timeline {
{
public:
/**
* Constructor.
*/
BasicDrawStrategy();
void draw(const Entity &entity,

View file

@ -40,18 +40,12 @@ namespace timeline {
{
protected:
/**
* Constructor.
*/
DrawStrategy()
{ }
DrawStrategy() { }
virtual ~DrawStrategy() { }
public:
/**
* Draw the entity.
* @param entity draw the
*/
virtual void draw(const Entity &entity,
Cairo::RefPtr<Cairo::Context> cr,
TimelineViewWindow* const window) const = 0;

View file

@ -72,7 +72,7 @@ namespace timeline {
pair;
BOOST_FOREACH (pair, clipMap)
{
pair.second->draw_clip(cairo, window);
pair.second->draw(cairo, window);
}
}

View file

@ -39,17 +39,6 @@ namespace timeline {
// &Clip::onNameChanged);
}
void
Clip::draw_clip(Cairo::RefPtr<Cairo::Context> cr,
TimelineViewWindow* const window) const
{
REQUIRE (cr);
REQUIRE (window);
REQUIRE (modelClip);
getDrawStrategy()->draw(*this, cr, window);
}
gavl_time_t
Clip::getBegin () const
{

View file

@ -23,15 +23,12 @@
** This file contains the definition of timeline clip object
*/
#include <cairomm/pattern.h>
#include "gui/gtk-lumiera.hpp"
#include "gui/model/clip.hpp"
#include "include/logging.h"
#include "draw-strategy.hpp"
#include "timeline-entity.hpp"
#include "timeline-view-window.hpp"
#ifndef TIMELINE_CLIP_HPP
#define TIMELINE_CLIP_HPP
@ -46,9 +43,6 @@ namespace timeline {
Clip(boost::shared_ptr<model::Clip> clip,
boost::shared_ptr<timeline::DrawStrategy> drawStrategy);
void draw_clip(Cairo::RefPtr<Cairo::Context> cairo,
TimelineViewWindow* const window) const;
gavl_time_t
getBegin () const;

View file

@ -22,6 +22,11 @@
#include "timeline-entity.hpp"
#include "draw-strategy.hpp"
#include "gui/gtk-lumiera.hpp"
#include "include/logging.h"
namespace gui {
namespace widgets {
namespace timeline {
@ -31,11 +36,17 @@ namespace timeline {
drawStrategy(drawStrategy)
{ }
Entity::~Entity()
{ }
boost::shared_ptr<timeline::DrawStrategy>
Entity::getDrawStrategy () const
void
Entity::draw(Cairo::RefPtr<Cairo::Context> cr,
TimelineViewWindow* const window) const
{
return drawStrategy;
REQUIRE (cr);
REQUIRE (window);
drawStrategy->draw(*this, cr, window);
}
bool

View file

@ -34,13 +34,15 @@ extern "C" {
#include <gavl/gavltime.h>
}
#include "boost/shared_ptr.hpp"
#include <boost/shared_ptr.hpp>
#include <cairomm/cairomm.h>
namespace gui {
namespace widgets {
namespace timeline {
class DrawStrategy;
class TimelineViewWindow;
/**
* Base class for timeline entities.
@ -49,52 +51,33 @@ namespace timeline {
class Entity {
protected:
/**
* Constructor
*/
Entity(boost::shared_ptr<timeline::DrawStrategy> drawStrategy);
virtual ~Entity();
public:
/**
* Gets the beginning of this entity's duration.
*/
virtual gavl_time_t
getBegin () const = 0;
boost::shared_ptr<timeline::DrawStrategy>
getDrawStrategy () const;
virtual void
draw(Cairo::RefPtr<Cairo::Context> cairo,
TimelineViewWindow* const window) const;
/**
* Gets the enabled property of this entity.
*/
bool
getEnabled () const;
/**
* Gets the end of this entity's duration.
*/
virtual gavl_time_t
getEnd () const = 0;
/**
* Gets the name of this entity.
*/
virtual std::string
getName () const = 0;
/**
* Sets the enabled property of this entity.
*/
void
setEnabled(bool selected);
private:
/**
* True when this entity is enabled.
*/
bool enabled;
boost::shared_ptr<timeline::DrawStrategy> drawStrategy;