From 2fba7aba2caa25a330544c3cb8b3e4dc784c2320 Mon Sep 17 00:00:00 2001 From: Stefan Kangas Date: Fri, 14 Jan 2011 18:46:41 +0100 Subject: [PATCH] Move draw functionality to timeline::Entity base class --- .../widgets/timeline/basic-draw-strategy.hpp | 3 -- src/gui/widgets/timeline/draw-strategy.hpp | 12 ++----- .../widgets/timeline/timeline-clip-track.cpp | 2 +- src/gui/widgets/timeline/timeline-clip.cpp | 11 ------- src/gui/widgets/timeline/timeline-clip.hpp | 6 ---- src/gui/widgets/timeline/timeline-entity.cpp | 17 ++++++++-- src/gui/widgets/timeline/timeline-entity.hpp | 33 +++++-------------- 7 files changed, 26 insertions(+), 58 deletions(-) diff --git a/src/gui/widgets/timeline/basic-draw-strategy.hpp b/src/gui/widgets/timeline/basic-draw-strategy.hpp index 2661d4526..511ae9808 100644 --- a/src/gui/widgets/timeline/basic-draw-strategy.hpp +++ b/src/gui/widgets/timeline/basic-draw-strategy.hpp @@ -36,9 +36,6 @@ namespace timeline { { public: - /** - * Constructor. - */ BasicDrawStrategy(); void draw(const Entity &entity, diff --git a/src/gui/widgets/timeline/draw-strategy.hpp b/src/gui/widgets/timeline/draw-strategy.hpp index 759ff84df..72eaa8828 100644 --- a/src/gui/widgets/timeline/draw-strategy.hpp +++ b/src/gui/widgets/timeline/draw-strategy.hpp @@ -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 cr, TimelineViewWindow* const window) const = 0; diff --git a/src/gui/widgets/timeline/timeline-clip-track.cpp b/src/gui/widgets/timeline/timeline-clip-track.cpp index f18930f60..b07b3ee1c 100644 --- a/src/gui/widgets/timeline/timeline-clip-track.cpp +++ b/src/gui/widgets/timeline/timeline-clip-track.cpp @@ -72,7 +72,7 @@ namespace timeline { pair; BOOST_FOREACH (pair, clipMap) { - pair.second->draw_clip(cairo, window); + pair.second->draw(cairo, window); } } diff --git a/src/gui/widgets/timeline/timeline-clip.cpp b/src/gui/widgets/timeline/timeline-clip.cpp index 9c286b89d..001964ae1 100644 --- a/src/gui/widgets/timeline/timeline-clip.cpp +++ b/src/gui/widgets/timeline/timeline-clip.cpp @@ -39,17 +39,6 @@ namespace timeline { // &Clip::onNameChanged); } - void - Clip::draw_clip(Cairo::RefPtr cr, - TimelineViewWindow* const window) const - { - REQUIRE (cr); - REQUIRE (window); - REQUIRE (modelClip); - - getDrawStrategy()->draw(*this, cr, window); - } - gavl_time_t Clip::getBegin () const { diff --git a/src/gui/widgets/timeline/timeline-clip.hpp b/src/gui/widgets/timeline/timeline-clip.hpp index bce1fc7ee..f3b8c0151 100644 --- a/src/gui/widgets/timeline/timeline-clip.hpp +++ b/src/gui/widgets/timeline/timeline-clip.hpp @@ -23,15 +23,12 @@ ** This file contains the definition of timeline clip object */ -#include - #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 clip, boost::shared_ptr drawStrategy); - void draw_clip(Cairo::RefPtr cairo, - TimelineViewWindow* const window) const; - gavl_time_t getBegin () const; diff --git a/src/gui/widgets/timeline/timeline-entity.cpp b/src/gui/widgets/timeline/timeline-entity.cpp index d9cf3ae2e..0514dafd4 100644 --- a/src/gui/widgets/timeline/timeline-entity.cpp +++ b/src/gui/widgets/timeline/timeline-entity.cpp @@ -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 - Entity::getDrawStrategy () const + void + Entity::draw(Cairo::RefPtr cr, + TimelineViewWindow* const window) const { - return drawStrategy; + REQUIRE (cr); + REQUIRE (window); + + drawStrategy->draw(*this, cr, window); } bool diff --git a/src/gui/widgets/timeline/timeline-entity.hpp b/src/gui/widgets/timeline/timeline-entity.hpp index 6b785f583..fc1e8e345 100644 --- a/src/gui/widgets/timeline/timeline-entity.hpp +++ b/src/gui/widgets/timeline/timeline-entity.hpp @@ -34,13 +34,15 @@ extern "C" { #include } -#include "boost/shared_ptr.hpp" +#include +#include 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 drawStrategy); + virtual ~Entity(); + public: - /** - * Gets the beginning of this entity's duration. - */ virtual gavl_time_t getBegin () const = 0; - - boost::shared_ptr - getDrawStrategy () const; + virtual void + draw(Cairo::RefPtr 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 drawStrategy;