First implementation of track visible in timeline.
This commit is contained in:
parent
74fce587bd
commit
799a8188de
5 changed files with 79 additions and 9 deletions
|
|
@ -89,7 +89,7 @@ public:
|
|||
|
||||
protected:
|
||||
/**
|
||||
* The internal list of child tracks of this paremt.
|
||||
* The internal list of child tracks of this parent.
|
||||
**/
|
||||
lumiera::observable_list< boost::shared_ptr<Track> > tracks;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -20,6 +20,9 @@
|
|||
|
||||
* *****************************************************/
|
||||
|
||||
#include <boost/foreach.hpp>
|
||||
|
||||
#include "timeline-clip.hpp"
|
||||
#include "timeline-clip-track.hpp"
|
||||
#include "timeline-view-window.hpp"
|
||||
|
||||
|
|
@ -28,19 +31,26 @@ using namespace Gtk;
|
|||
namespace gui {
|
||||
namespace widgets {
|
||||
namespace timeline {
|
||||
|
||||
|
||||
ClipTrack::ClipTrack(TimelineWidget &timeline_widget,
|
||||
boost::shared_ptr<model::Track> track) :
|
||||
Track(timeline_widget, track)
|
||||
{
|
||||
// TEST CODE: add a clip to the track
|
||||
boost::shared_ptr<model::Clip> model_clip(new model::Clip());
|
||||
boost::shared_ptr<timeline::Clip> timeline_clip(new timeline::Clip(model_clip));
|
||||
clips.push_back(timeline_clip);
|
||||
// END TEST CODE
|
||||
}
|
||||
|
||||
void
|
||||
ClipTrack::draw_track(Cairo::RefPtr<Cairo::Context> cairo,
|
||||
TimelineViewWindow* const window) const
|
||||
{
|
||||
|
||||
|
||||
REQUIRE(cairo);
|
||||
REQUIRE(window);
|
||||
|
||||
// Draw a rectangle to let us know it works? :-)
|
||||
cairo->rectangle(window->time_to_x(0), 1,
|
||||
window->time_to_x(500000) - window->time_to_x(0),
|
||||
get_height() - 2);
|
||||
|
|
@ -50,6 +60,12 @@ ClipTrack::draw_track(Cairo::RefPtr<Cairo::Context> cairo,
|
|||
|
||||
cairo->set_source_rgb(0.25, 0.25, 0.25);
|
||||
cairo->stroke();
|
||||
|
||||
// Draw all clips
|
||||
BOOST_FOREACH(boost::shared_ptr<timeline::Clip> c, clips)
|
||||
{
|
||||
c->draw_clip(cairo, window);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace timeline
|
||||
|
|
|
|||
|
|
@ -28,6 +28,8 @@
|
|||
#ifndef TIMELINE_CLIP_TRACK_HPP
|
||||
#define TIMELINE_CLIP_TRACK_HPP
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "timeline-track.hpp"
|
||||
#include "../../model/clip-track.hpp"
|
||||
|
||||
|
|
@ -46,7 +48,9 @@ public:
|
|||
|
||||
void draw_track(Cairo::RefPtr<Cairo::Context> cairo,
|
||||
TimelineViewWindow* const window) const;
|
||||
|
||||
|
||||
private:
|
||||
std::vector<boost::shared_ptr<timeline::Clip> > clips;
|
||||
};
|
||||
|
||||
} // namespace timeline
|
||||
|
|
|
|||
|
|
@ -26,11 +26,52 @@ namespace gui {
|
|||
namespace widgets {
|
||||
namespace timeline {
|
||||
|
||||
Clip::Clip()
|
||||
Clip::Clip(boost::shared_ptr<model::Clip> clip)
|
||||
: model_clip(clip)
|
||||
{
|
||||
|
||||
REQUIRE(model_clip);
|
||||
}
|
||||
|
||||
void
|
||||
Clip::draw_clip(Cairo::RefPtr<Cairo::Context> cr,
|
||||
TimelineViewWindow* const window) const
|
||||
{
|
||||
REQUIRE(cr);
|
||||
REQUIRE(window);
|
||||
|
||||
int x = window->time_to_x(1000000);
|
||||
int width = window->time_to_x(2000000) - window->time_to_x(1000000);
|
||||
|
||||
// Draw a rectangle for the clip
|
||||
cr->rectangle(x, 1, width, 100-2);
|
||||
|
||||
// TODO: get duration from the model::Clip
|
||||
// TODO: get height from the Timeline::Track
|
||||
|
||||
cr->set_source_rgb(0.4, 0.4, 0.4);
|
||||
cr->fill_preserve();
|
||||
|
||||
cr->set_source_rgb(0.25, 0.25, 0.25);
|
||||
cr->stroke();
|
||||
|
||||
// Show the clip name
|
||||
cr->rectangle(x, 1, width, 100-2);
|
||||
cr->clip();
|
||||
|
||||
cr->move_to(x + 3, 15);
|
||||
cr->set_source_rgb(1.0, 1.0, 1.0);
|
||||
Cairo::RefPtr<Cairo::ToyFontFace> font =
|
||||
Cairo::ToyFontFace::create("Bitstream Charter",
|
||||
Cairo::FONT_SLANT_NORMAL,
|
||||
Cairo::FONT_WEIGHT_NORMAL);
|
||||
cr->set_font_face(font);
|
||||
cr->set_font_size(11);
|
||||
cr->show_text("Track"); // TODO: get clip name from model
|
||||
|
||||
// TODO: Show thumbnails for clip
|
||||
}
|
||||
|
||||
|
||||
} // namespace timeline
|
||||
} // namespace widgets
|
||||
} // namespace gui
|
||||
|
|
|
|||
|
|
@ -23,7 +23,11 @@
|
|||
** This file contains the definition of timeline clip object
|
||||
*/
|
||||
|
||||
|
||||
#include "../../gtk-lumiera.hpp"
|
||||
#include "../../model/clip.hpp"
|
||||
#include "timeline-view-window.hpp"
|
||||
#include "include/logging.h"
|
||||
|
||||
#ifndef TIMELINE_CLIP_HPP
|
||||
#define TIMELINE_CLIP_HPP
|
||||
|
|
@ -35,11 +39,16 @@ namespace timeline {
|
|||
class Clip : public model::Clip
|
||||
{
|
||||
public:
|
||||
Clip();
|
||||
Clip(boost::shared_ptr<model::Clip> clip);
|
||||
|
||||
void draw_clip(Cairo::RefPtr<Cairo::Context> cairo,
|
||||
TimelineViewWindow* const window) const;
|
||||
|
||||
private:
|
||||
|
||||
boost::shared_ptr<model::Clip> model_clip;
|
||||
};
|
||||
|
||||
|
||||
} // namespace timeline
|
||||
} // namespace widgets
|
||||
} // namespace gui
|
||||
|
|
|
|||
Loading…
Reference in a new issue