From 7c1046e162aff7ee4447b17ba72bbb891c18b751 Mon Sep 17 00:00:00 2001 From: Joel Holdsworth Date: Wed, 10 Dec 2008 18:04:02 +0000 Subject: [PATCH] Unified Sequence and Track together as TrackBase --- src/gui/Makefile.am | 2 + src/gui/model/sequence.cpp | 20 +----- src/gui/model/sequence.hpp | 18 ++---- src/gui/model/track-base.cpp | 53 ++++++++++++++++ src/gui/model/track-base.hpp | 61 +++++++++++++++++++ src/gui/model/track.cpp | 16 ----- src/gui/model/track.hpp | 12 +--- src/gui/widgets/timeline-widget.cpp | 4 +- src/gui/widgets/timeline/timeline-body.cpp | 4 +- .../timeline/timeline-header-container.cpp | 2 +- 10 files changed, 130 insertions(+), 62 deletions(-) create mode 100644 src/gui/model/track-base.cpp create mode 100644 src/gui/model/track-base.hpp diff --git a/src/gui/Makefile.am b/src/gui/Makefile.am index 3c7cc80f7..1c4c0fb67 100644 --- a/src/gui/Makefile.am +++ b/src/gui/Makefile.am @@ -80,6 +80,8 @@ lumigui_SOURCES = \ $(lumigui_srcdir)/widgets/timeline/timeline-clip.hpp \ $(lumigui_srcdir)/model/project.cpp \ $(lumigui_srcdir)/model/project.hpp \ + $(lumigui_srcdir)/model/track-base.cpp \ + $(lumigui_srcdir)/model/track-base.hpp \ $(lumigui_srcdir)/model/sequence.cpp \ $(lumigui_srcdir)/model/sequence.hpp \ $(lumigui_srcdir)/model/track.cpp \ diff --git a/src/gui/model/sequence.cpp b/src/gui/model/sequence.cpp index bf3064123..e480b02db 100644 --- a/src/gui/model/sequence.cpp +++ b/src/gui/model/sequence.cpp @@ -49,29 +49,11 @@ Sequence::Sequence() // END TEST CODE } -const Glib::ustring -Sequence::get_name() const -{ - return name; -} - -void -Sequence::set_name(const Glib::ustring &name) -{ - this->name = name; -} - const std::list< boost::shared_ptr >& -Sequence::get_tracks() const +Sequence::get_child_tracks() const { return tracks; } -void -Sequence::add_track(shared_ptr track) -{ - tracks.push_back(track); -} - } // namespace model } // namespace gui diff --git a/src/gui/model/sequence.hpp b/src/gui/model/sequence.hpp index 4c9e4aa98..2df7a3f11 100644 --- a/src/gui/model/sequence.hpp +++ b/src/gui/model/sequence.hpp @@ -27,7 +27,7 @@ #ifndef SEQUENCE_HPP #define SEQUENCE_HPP -#include "../gtk-lumiera.hpp" +#include "track-base.hpp" // TEST CODE #include "group-track.hpp" @@ -38,22 +38,16 @@ namespace model { class Track; -class Sequence +class Sequence : public TrackBase { public: Sequence(); - const Glib::ustring get_name() const; - - void set_name(const Glib::ustring &name); - - const std::list< boost::shared_ptr >& get_tracks() const; - - void add_track(boost::shared_ptr track); - + const std::list< boost::shared_ptr >& + get_child_tracks() const; + private: - Glib::ustring name; - + //----- Data -----// std::list< boost::shared_ptr > tracks; }; diff --git a/src/gui/model/track-base.cpp b/src/gui/model/track-base.cpp new file mode 100644 index 000000000..d6fd2357f --- /dev/null +++ b/src/gui/model/track-base.cpp @@ -0,0 +1,53 @@ +/* + track-base.cpp - Implementation of the TrackBase class + + Copyright (C) Lumiera.org + 2008, Joel Holdsworth + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +* *****************************************************/ + +#include "track.hpp" + +namespace gui { +namespace model { + +const std::list< boost::shared_ptr > TrackBase::NoChildren; + +TrackBase::TrackBase() +{ +} + +const std::list< boost::shared_ptr >& +TrackBase::get_child_tracks() const +{ + return NoChildren; +} + +const Glib::ustring +TrackBase::get_name() const +{ + return name; +} + +void +TrackBase::set_name(const Glib::ustring &name) +{ + this->name = name; +} + +} // namespace model +} // namespace gui diff --git a/src/gui/model/track-base.hpp b/src/gui/model/track-base.hpp new file mode 100644 index 000000000..5ae555e01 --- /dev/null +++ b/src/gui/model/track-base.hpp @@ -0,0 +1,61 @@ +/* + track-track.hpp - Definition of the TrackBase class + + Copyright (C) Lumiera.org + 2008, Joel Holdsworth + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ +/** @file track-base.hpp + ** This file contains the definition of TrackBase, a class which + ** represents a base functionality for tracks and sequences which + ** are also track parents. This class wraps proc layer data + */ + +#include "../gtk-lumiera.hpp" + +#ifndef TRACK_BASE_HPP +#define TRACK_BASE_HPP + +namespace gui { +namespace model { + +class Track; + +class TrackBase +{ +public: + TrackBase(); + + virtual void add_child_track(Track* child) {}; + + virtual const std::list< boost::shared_ptr >& + get_child_tracks() const; + + const Glib::ustring get_name() const; + + void set_name(const Glib::ustring &name); + +private: + Glib::ustring name; + + static const std::list< boost::shared_ptr > NoChildren; +}; + +} // namespace model +} // namespace gui + +#endif // TRACK_BASE_HPP diff --git a/src/gui/model/track.cpp b/src/gui/model/track.cpp index 0734b648a..8541e17f9 100644 --- a/src/gui/model/track.cpp +++ b/src/gui/model/track.cpp @@ -20,31 +20,15 @@ * *****************************************************/ -#include - #include "track.hpp" namespace gui { namespace model { -const std::list< boost::shared_ptr > Track::NoChildren; - Track::Track() { } -const std::list< boost::shared_ptr >& -Track::get_child_tracks() const -{ - return NoChildren; -} - -Glib::ustring -Track::get_title() -{ - return "Hello"; -} - } // namespace model } // namespace gui diff --git a/src/gui/model/track.hpp b/src/gui/model/track.hpp index f38f6a4bf..4fe852b30 100644 --- a/src/gui/model/track.hpp +++ b/src/gui/model/track.hpp @@ -24,7 +24,7 @@ ** represents a track, and wraps proc layer data */ -#include "../gtk-lumiera.hpp" +#include "track-base.hpp" #ifndef TRACK_HPP #define TRACK_HPP @@ -32,20 +32,12 @@ namespace gui { namespace model { -class Track +class Track : public TrackBase { public: Track(); - virtual void add_child_track(Track* child) {}; - virtual const std::list< boost::shared_ptr >& - get_child_tracks() const; - - Glib::ustring get_title(); - -private: - static const std::list< boost::shared_ptr > NoChildren; }; } // namespace model diff --git a/src/gui/widgets/timeline-widget.cpp b/src/gui/widgets/timeline-widget.cpp index 2266f93b7..8b4a442d6 100644 --- a/src/gui/widgets/timeline-widget.cpp +++ b/src/gui/widgets/timeline-widget.cpp @@ -284,7 +284,7 @@ TimelineWidget::update_tracks() // Recalculate the total height of the timeline scrolled area totalHeight = 0; - BOOST_FOREACH(shared_ptr track, sequence->get_tracks()) + BOOST_FOREACH(shared_ptr track, sequence->get_child_tracks()) { ASSERT(track); totalHeight += measure_branch_height(track); @@ -296,7 +296,7 @@ TimelineWidget::create_timeline_tracks() { REQUIRE(sequence); - BOOST_FOREACH(shared_ptr child, sequence->get_tracks()) + BOOST_FOREACH(shared_ptr child, sequence->get_child_tracks()) create_timeline_tracks_from_branch(child); } diff --git a/src/gui/widgets/timeline/timeline-body.cpp b/src/gui/widgets/timeline/timeline-body.cpp index d3df1fe82..b1d1eb6da 100644 --- a/src/gui/widgets/timeline/timeline-body.cpp +++ b/src/gui/widgets/timeline/timeline-body.cpp @@ -284,7 +284,7 @@ TimelineBody::draw_tracks(Cairo::RefPtr cr) // Interate drawing each track BOOST_FOREACH( shared_ptr model_track, - timelineWidget->sequence->get_tracks() ) + timelineWidget->sequence->get_child_tracks() ) draw_track_recursive(cr, model_track, allocation.get_width()); // Restore the view matrix @@ -431,7 +431,7 @@ TimelineBody::track_from_point(const int y) const int offset = -get_vertical_offset(); BOOST_FOREACH( shared_ptr model_track, - timelineWidget->sequence->get_tracks() ) + timelineWidget->sequence->get_child_tracks() ) { shared_ptr result = track_from_branch( model_track, y, offset); diff --git a/src/gui/widgets/timeline/timeline-header-container.cpp b/src/gui/widgets/timeline/timeline-header-container.cpp index 7ff1128eb..aa9d76358 100644 --- a/src/gui/widgets/timeline/timeline-header-container.cpp +++ b/src/gui/widgets/timeline/timeline-header-container.cpp @@ -502,7 +502,7 @@ TimelineHeaderContainer::get_tracks() const { REQUIRE(timelineWidget != NULL); REQUIRE(timelineWidget->sequence); - return timelineWidget->sequence->get_tracks(); + return timelineWidget->sequence->get_child_tracks(); } void