adapt GUI to use the new Time framework

This commit is contained in:
Fischlurch 2011-05-16 08:38:01 +02:00
parent 042598f04c
commit 7656e5d500
33 changed files with 623 additions and 657 deletions

View file

@ -20,65 +20,47 @@
* *****************************************************/
#include "clip.hpp"
#include "gui/model/clip.hpp"
#include "lib/time/mutation.hpp"
using lib::time::FSecs;
using lib::time::Mutation;
namespace gui {
namespace model {
Clip::Clip()
: begin(1000000),
end(2000000)
: timeCoord_(Time(FSecs(1)), FSecs(2))
{ }
gavl_time_t
Clip::getBegin() const
{
return begin;
}
gavl_time_t
Clip::getEnd() const
{
return end;
}
const std::string
Clip::getName() const
{
return name;
}
bool
Clip::isPlayingAt(lumiera::Time position) const
{
return (begin <= position && end >= position);
}
void
Clip::setBegin(gavl_time_t begin)
Clip::setBegin (Time newStartTime)
{
this->begin = begin;
timeCoord_.accept (Mutation::changeTime (newStartTime));
// TODO: emit signal
}
void
Clip::setEnd(gavl_time_t end)
Clip::setDuration (Duration newLength)
{
this->end = end;
timeCoord_.accept (Mutation::changeDuration(newLength));
// TODO: emit signal
}
void
Clip::setName(const std::string &name)
Clip::setName (string const& name)
{
this->name = name;
nameChangedSignal.emit(name);
this->name_ = name;
nameChangedSignal_.emit (name);
}
sigc::signal<void, std::string>
Clip::signalNameChanged() const
{
return nameChangedSignal;
return nameChangedSignal_;
}
} // namespace model

View file

@ -19,109 +19,87 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/** @file model/clip.hpp
** This file contains the definition of the Clip object
** This file defines a Proxy Clip object to base the GUI implementation on.
** Later this Clip object will be connected to the underlying model in Proc-Layer.
*/
#include <string>
#ifndef GUI_MODEL_CLIP_H
#define GUI_MODEL_CLIP_H
#include "gui/gtk-lumiera.hpp"
#include "lib/time/timevalue.hpp"
//#include "lib/lumitime.hpp"//////////////////////////////TODO
#include <string>
// TODO: Remove once we get real measure of duration.
// This is here *only* for purposes of testing the GUI.
//extern "C" {
//#include <stdint.h>
//#include <gavl/gavltime.h>
//}
using Cairo::Pattern;
#ifndef CLIP_HPP
#define CLIP_HPP
namespace gui {
namespace model {
using std::string;
using lib::time::Time;
using lib::time::TimeSpan;
using lib::time::Duration;
using Cairo::Pattern;
class Clip
{
public:
/**
* Constructor
*/
Clip();
/**
* Gets the begin time of this clip.
*/
gavl_time_t
getBegin() const;
/**
* Gets the end time of this clip.
*/
gavl_time_t
getEnd() const;
/**
* Gets the name of this clip.
*/
const std::string
getName() const;
/**
* Check whether or not the clip will be playing during the given time.
*/
bool
isPlayingAt(lumiera::Time position) const;
/**
* Sets the begin time of this clip.
* @param[in] begin The new begin time to set this clip to.
*/
void
setBegin(gavl_time_t begin);
/**
* Sets the end time of this clip.
* @param[in] end The new end time to set this clip to.
*/
void
setEnd(gavl_time_t end);
/**
* Sets the name of this clip.
* @param[in] name The new name to set this clip to.
*/
void
setName(const std::string &name);
/**
* A signal which fires when the name changes.
* @return Returns the signal. The signal sends the new name for the clip.
*/
sigc::signal<void, std::string>
signalNameChanged() const;
private:
/**
* The name of this clip.
*/
std::string name;
/**
* A signal which fires when the name changes.
*/
sigc::signal<void, std::string> nameChangedSignal;
// TODO: Use a good measure of duration, probably TimeSpan.
// These are here *only* for purposes of testing the GUI.
gavl_time_t begin;
gavl_time_t end;
};
} // namespace model
} // namespace gui
{
TimeSpan timeCoord_;
string name_;
/** fires when the name changes. */
sigc::signal<void, string> nameChangedSignal_;
public:
Clip();
Time getBegin() const { return timeCoord_.start();}
Time getEnd() const { return timeCoord_.end(); }
string const& getName() const { return name_; }
/**
* Check whether or not the clip will be playing during the given time.
*/
bool
isPlayingAt (Time const& position) const
{
return timeCoord_.contains (position);
}
/**
* Sets the begin time of this clip.
* @param[in] begin The new begin time to set this clip to.
*/
void setBegin (Time);
/**
* Sets the end time of this clip.
* @param[in] end The new end time to set this clip to.
*/
void setDuration (Duration);
/**
* Sets the name of this clip.
* @param[in] name The new name to set this clip to.
*/
void setName (string const&);
/**
* A signal which fires when the name changes.
* @return Returns the signal. The signal sends the new name for the clip.
*/
sigc::signal<void, std::string>
signalNameChanged() const;
};
}} // namespace gui::model
#endif // CLIP_HPP

View file

@ -26,7 +26,7 @@
#include "gui/workspace/panel-manager.hpp"
#include "gui/workspace/workspace-window.hpp"
#include "panel.hpp"
#include "gui/panels/panel.hpp"
using namespace Gtk;

View file

@ -59,9 +59,6 @@ protected:
const gchar *stock_id);
public:
/**
* Destructor
*/
~Panel();
/**

View file

@ -20,47 +20,48 @@
* *****************************************************/
#include <boost/foreach.hpp>
#include "gui/gtk-lumiera.hpp"
#include "timeline-panel.hpp"
#include "gui/panels/timeline-panel.hpp"
#include "gui/workspace/workspace-window.hpp"
#include "gui/model/project.hpp"
#include "gui/controller/controller.hpp"
#include "lib/util.hpp"
#include "lib/time.h"
#include <boost/foreach.hpp>
using namespace Gtk;
using namespace sigc;
using namespace std;
using namespace boost;
using namespace util;
using namespace gui::widgets;
using namespace gui::model;
using boost::shared_ptr; ///////////////////////////////TICKET #796
using boost::weak_ptr; ///////////////////////////////TICKET #796
using util::contains;
namespace gui {
namespace panels {
const int TimelinePanel::ZoomToolSteps = 2; // 2 seems comfortable
TimelinePanel::TimelinePanel(workspace::PanelManager &panel_manager,
GdlDockItem *dock_item) :
Panel(panel_manager, dock_item, get_title(), get_stock_id()),
timeCode("sequence_clock", "timecode_widget", true),
previousButton(Stock::MEDIA_PREVIOUS),
rewindButton(Stock::MEDIA_REWIND),
playPauseButton(Stock::MEDIA_PLAY),
stopButton(Stock::MEDIA_STOP),
forwardButton(Stock::MEDIA_FORWARD),
nextButton(Stock::MEDIA_NEXT),
arrowTool(Gtk::StockID("tool_arrow")),
iBeamTool(Gtk::StockID("tool_i_beam")),
zoomIn(Stock::ZOOM_IN),
zoomOut(Stock::ZOOM_OUT),
updatingToolbar(false),
currentTool(timeline::Arrow)
TimelinePanel::TimelinePanel (workspace::PanelManager &panel_manager,
GdlDockItem *dock_item)
: Panel(panel_manager, dock_item, get_title(), get_stock_id())
, timeCode("sequence_clock", "timecode_widget", true)
, previousButton(Stock::MEDIA_PREVIOUS)
, rewindButton(Stock::MEDIA_REWIND)
, playPauseButton(Stock::MEDIA_PLAY)
, stopButton(Stock::MEDIA_STOP)
, forwardButton(Stock::MEDIA_FORWARD)
, nextButton(Stock::MEDIA_NEXT)
, arrowTool(Gtk::StockID("tool_arrow"))
, iBeamTool(Gtk::StockID("tool_i_beam"))
, zoomIn(Stock::ZOOM_IN)
, zoomOut(Stock::ZOOM_OUT)
, updatingToolbar(false)
, currentTool(timeline::Arrow)
{
// Hook up notifications
get_project().get_sequences().signal_changed().connect(mem_fun(this,
@ -123,7 +124,7 @@ TimelinePanel::TimelinePanel(workspace::PanelManager &panel_manager,
zoomOut .set_tooltip_text(_("Zoom out"));
// Setup the timeline widget
shared_ptr<Sequence> sequence
shared_ptr<Sequence> sequence ///////////////////////////////TICKET #796
= *get_project().get_sequences().begin();
timelineWidget.reset(new TimelineWidget(load_state(sequence)));
pack_start(*timelineWidget, PACK_EXPAND_WIDGET);
@ -132,13 +133,9 @@ TimelinePanel::TimelinePanel(workspace::PanelManager &panel_manager,
update_sequence_chooser();
update_tool_buttons();
update_zoom_buttons();
show_time(0);
show_time (Time::ZERO);
}
TimelinePanel::~TimelinePanel()
{
}
const char*
TimelinePanel::get_title()
@ -203,9 +200,9 @@ TimelinePanel::on_zoom_out()
}
void
TimelinePanel::on_mouse_hover(gavl_time_t time)
TimelinePanel::on_mouse_hover(Time)
{
(void)time;
/* do nothing */
}
void
@ -216,8 +213,8 @@ TimelinePanel::on_playback_period_drag_released()
REQUIRE(timelineWidget);
timelineWidget->get_state()->set_playback_point(
timelineWidget->get_state()->get_playback_period_start());
timelineWidget->get_state()->setPlaybackPoint(
timelineWidget->get_state()->getPlaybackPeriodStart());
//----- END TEST CODE
play();
@ -365,27 +362,17 @@ TimelinePanel::set_tool(timeline::ToolType tool)
}
void
TimelinePanel::show_time(gavl_time_t time)
TimelinePanel::show_time(Time time)
{
// timeIndicator.set_text(lumiera_tmpbuf_print_time(time));
////////////TODO integrate the Timecode Widget
// timeIndicator.set_text(string(time));
}
bool
TimelinePanel::on_frame()
{
// TEST CODE!
/*const gavl_time_t point = timelineWidget.get_playback_point()
+ GAVL_TIME_SCALE / 25;
if(point < timelineWidget.get_playback_period_end())
{
show_time(point);
timelineWidget.set_playback_point(point);
}
else
on_stop();*/
/////////TODO what happens here??
return true;
}
@ -407,5 +394,4 @@ TimelinePanel::load_state(weak_ptr<Sequence> sequence)
return shared_ptr< timeline::TimelineState >();
}
} // namespace panels
} // namespace gui
}} // namespace gui::panels

View file

@ -29,9 +29,10 @@
#ifndef TIMELINE_PANEL_HPP
#define TIMELINE_PANEL_HPP
#include "panel.hpp"
#include "gui/panels/panel.hpp"
#include "gui/widgets/timecode-widget.hpp"
#include "gui/widgets/timeline-widget.hpp"
#include "lib/time/timevalue.hpp"
#include <boost/scoped_ptr.hpp>
#include <boost/weak_ptr.hpp>
@ -47,6 +48,9 @@ class Sequence;
namespace panels {
using lib::time::Time;
/**
* The definition of the timeline panel class, which holds timeline
* widgets.
@ -55,17 +59,12 @@ class TimelinePanel : public Panel
{
public:
/**
* Constructor.
* @param panel_manager The owner panel manager widget.
* @param dock_item The GdlDockItem that will host this panel.
*/
TimelinePanel(workspace::PanelManager &panel_manager,
GdlDockItem *dock_item);
GdlDockItem *dock_item);
/**
* Destructor
*/
~TimelinePanel();
/**
* Get the title of the panel.
@ -93,7 +92,7 @@ private:
void on_time_pressed();
void on_mouse_hover(gavl_time_t time);
void on_mouse_hover(Time);
void on_playback_period_drag_released();
/**
@ -121,12 +120,12 @@ private:
bool is_playing();
void set_tool(gui::widgets::timeline::ToolType tool);
void set_tool (gui::widgets::timeline::ToolType tool);
void show_time(gavl_time_t time);
void show_time (Time);
boost::shared_ptr<widgets::timeline::TimelineState> load_state(
boost::weak_ptr<model::Sequence> sequence);
boost::shared_ptr<widgets::timeline::TimelineState> ///////////////////////////////TICKET #796
load_state (boost::weak_ptr<model::Sequence> sequence);
private:
@ -172,7 +171,7 @@ private:
boost::scoped_ptr<TimelineWidget> timelineWidget;
std::map< boost::weak_ptr<model::Sequence>,
boost::shared_ptr<widgets::timeline::TimelineState> >
boost::shared_ptr<widgets::timeline::TimelineState> > ///////////////////////////////TICKET #796
timelineStates;
// Toolbar Widgets

View file

@ -19,7 +19,12 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
* *****************************************************/
#include "timecode-widget.hpp"
#include "gui/util/convert.hpp"
#include "lib/time/diagnostics.hpp" ////////////TODO: temporary solution to get H:M:S components. Use TimeCode instead!
#include <cmath>
#include <stdint.h>
@ -30,9 +35,6 @@
#include <gavl/gavl.h>
#include <sigc++/bind.h>
#include "timecode-widget.hpp"
#include "gui/util/convert.hpp"
using namespace sigc;
using namespace Gtk;
using namespace std;
@ -69,7 +71,7 @@ TimeCode::TimeCode(std::string clock_name, std::string widget_name, bool allow_e
colon4(":"),
colon5(":")
{
last_when = Time(0);
last_when = Time::ZERO;
last_pdelta = 0;
last_sdelta = 0;
key_entry_state = 0;
@ -423,8 +425,10 @@ TimeCode::set(Time when, bool force)
void
TimeCode::set_frames(Time when, bool force)
{
///////////////////////////TICKET #750 : integrate Timecode formats, let Digxel class do the formatting
char buf[32];
snprintf(buf, sizeof(buf), "%u", (unsigned int)when);
snprintf(buf, sizeof(buf), "%u", uint(123));
audio_frames_label.set_text(buf);
}
@ -432,10 +436,10 @@ void
TimeCode::set_minsec(Time when, bool force)
{
char buf[32];
int hrs = when.getHours();
int mins = when.getMins();
float secs = when.getSecs();
////////////TICKET #750 : temporary solution to get H:M:S components. Use TimeCode instead!
int hrs = getHours(when);
int mins = getMins (when);
float secs = getSecs (when);
if (force || hrs != ms_last_hrs)
{
@ -463,11 +467,11 @@ void
TimeCode::set_smpte(Time when, bool force)
{
char buf[32];
////////////TICKET #750 : temporary solution to get H:M:S components. Use TimeCode instead!
int smpte_negative = 0; // FIXME: when < 0;
int smpte_hours = when.getHours();
int smpte_minutes = when.getMins();
int smpte_seconds = when.getSecs();
int smpte_hours = getHours(when);
int smpte_minutes = getMins(when);
int smpte_seconds = getSecs(when);
int smpte_frames = 0; //when.getFrames(framerate);
// if (is_duration) {
@ -1043,20 +1047,22 @@ TimeCode::field_motion_notify_event (GdkEventMotion *ev, Field field)
if (trunc(drag_accum) != 0)
{
int frames;
Time pos;
TimeVar pos(current_time());
int dir;
dir = (drag_accum < 0 ? 1:-1);
pos = current_time();
frames = get_frames(field,pos,dir);
if (frames != 0 && frames * drag_accum < ((gavl_time_t)current_time()))
/////////////////////////////////////////////////////////////TICKET #750 : factor out all timecode calculations
////////////// and concentrate them in lib/time/timecode.cpp
if (frames != 0 && frames * drag_accum < (_raw(current_time())))
{
// minus because up is negative in computer-land
set ((Time) floor (pos - drag_accum * frames), false);
pos = TimeValue (floor (pos - drag_accum * frames));
set (pos, false);
}
else
{
set (Time(0) , false);
set (Time::ZERO, false);
}
drag_accum = 0;
@ -1106,7 +1112,7 @@ TimeCode::get_frames(Field field, Time pos, int dir)
Time
TimeCode::current_time(Time pos) const
{
Time ret = Time(0);
TimeVar ret;
switch (_mode)
{
@ -1132,7 +1138,7 @@ TimeCode::current_time(Time pos) const
Time
TimeCode::current_duration(Time pos) const
{
Time ret = Time(0);
TimeVar ret;
switch (_mode)
{
@ -1202,7 +1208,7 @@ TimeCode::smpte_time_from_display() const
// session->smpte_to_sample(smpte, sample, false /* use_offset */, false /* use_subframes */ );
return Time(0);
return Time::ZERO;
}
Time
@ -1218,13 +1224,14 @@ TimeCode::minsec_time_from_display () const
// return (Time) floor ((hrs * 60.0f * 60.0f * sr) + (mins * 60.0f * sr) + (secs * sr));
return Time(0);
return Time::ZERO;
}
Time
TimeCode::audio_time_from_display () const
{
return Time((gavl_time_t) atoi (audio_frames_label.get_text()));
gavl_time_t parsedAudioFrames = atoi (audio_frames_label.get_text());
return Time(TimeValue(parsedAudioFrames));
}
void

View file

@ -25,6 +25,9 @@
#ifndef TIMECODE_WIDGET_HPP
#define TIMECODE_WIDGET_HPP
#include "gui/gtk-base.hpp"
#include "lib/time/timevalue.hpp"
#include <string>
#include <gtkmm/box.h>
@ -38,6 +41,11 @@
namespace gui {
namespace widgets {
using lib::time::Time;
using lib::time::TimeVar;
using lib::time::TimeValue;
class TimeCode : public Gtk::HBox
{
public:
@ -61,8 +69,8 @@ public:
std::string name() const { return _name; }
Time current_time(Time position = Time(0)) const;
Time current_duration(Time position = Time(0)) const;
Time current_time(Time position = Time::ZERO) const;
Time current_duration(Time position = Time::ZERO) const;
sigc::signal<void> ValueChanged;
sigc::signal<void> ChangeAborted;
@ -129,7 +137,7 @@ private:
Gtk::EventBox clock_base;
Gtk::Frame clock_frame;
Time last_when;
TimeVar last_when;
bool last_pdelta;
bool last_sdelta;
@ -164,7 +172,7 @@ private:
void set_minsec(Time, bool);
void set_frames(Time, bool);
int get_frames(Field, Time pos = Time(0), int dir=1);
int get_frames(Field, Time pos = Time::ZERO, int dir=1);
void smpte_sanitize_display();
Time smpte_time_from_display() const;

View file

@ -30,7 +30,9 @@ using namespace std;
using namespace boost;
using namespace util;
using namespace gui::widgets::timeline;
using namespace lumiera;
using lib::time::Time;
using lib::time::TimeValue;
namespace gui {
namespace widgets {
@ -158,7 +160,7 @@ TimelineWidget::get_hovering_track() const
/* ===== Signals ===== */
sigc::signal<void, lumiera::Time>
sigc::signal<void, Time>
TimelineWidget::mouse_hover_signal() const
{
return mouseHoverSignal;
@ -188,8 +190,10 @@ void
TimelineWidget::on_scroll()
{
if(state)
state->get_view_window().set_time_offset(
Time((gavl_time_t)horizontalAdjustment.get_value()));
{
TimeValue newStartOffset ((gavl_time_t)horizontalAdjustment.get_value());
state->get_view_window().set_time_offset(Time(newStartOffset));
}
}
void
@ -212,7 +216,7 @@ TimelineWidget::on_view_window_changed()
horizontalAdjustment.set_page_size(
window.get_time_scale() * view_width);
horizontalAdjustment.set_value(window.get_time_offset());
horizontalAdjustment.set_value(_raw(window.get_time_offset()));
}
}

View file

@ -23,30 +23,38 @@
** This file contains the definition of timeline widget
*/
#ifndef TIMELINE_WIDGET_HPP
#define TIMELINE_WIDGET_HPP
#include "timeline/timeline-state.hpp"
#include "timeline/timeline-header-container.hpp"
#include "timeline/timeline-body.hpp"
#include "timeline/timeline-ruler.hpp"
#include "timeline/timeline-tool.hpp"
#include "timeline/timeline-arrow-tool.hpp"
#include "timeline/timeline-ibeam-tool.hpp"
#include "timeline/timeline-group-track.hpp"
#include "timeline/timeline-clip-track.hpp"
#include "timeline/timeline-layout-helper.hpp"
#include "gui/widgets/timeline/timeline-state.hpp"
#include "gui/widgets/timeline/timeline-header-container.hpp"
#include "gui/widgets/timeline/timeline-body.hpp"
#include "gui/widgets/timeline/timeline-ruler.hpp"
#include "gui/widgets/timeline/timeline-tool.hpp"
#include "gui/widgets/timeline/timeline-arrow-tool.hpp"
#include "gui/widgets/timeline/timeline-ibeam-tool.hpp"
#include "gui/widgets/timeline/timeline-group-track.hpp"
#include "gui/widgets/timeline/timeline-clip-track.hpp"
#include "gui/widgets/timeline/timeline-layout-helper.hpp"
#include "gui/model/sequence.hpp"
#include "lib/time/timevalue.hpp"
namespace gui {
namespace widgets {
using lib::time::Time;
/**
* The namespace of all timeline widget helper classes.
*/
namespace timeline {}
/**
* The timeline widget class.
* @remarks This widget is a composite of several widgets contained
@ -107,7 +115,7 @@ public:
public:
/* ===== Signals ===== */
sigc::signal<void, lumiera::Time> mouse_hover_signal() const;
sigc::signal<void, lib::time::Time> mouse_hover_signal() const;
sigc::signal<void> playback_period_drag_released_signal() const;
@ -265,7 +273,7 @@ protected:
Gtk::VScrollbar verticalScroll;
// Signals
sigc::signal<void, lumiera::Time> mouseHoverSignal;
sigc::signal<void, Time> mouseHoverSignal;
sigc::signal<void> playbackPeriodDragReleasedSignal;
sigc::signal<void, boost::shared_ptr<timeline::Track> >
hoveringTrackChangedSignal;

View file

@ -19,32 +19,32 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
* *****************************************************/
/** @file basic-draw-strategy.hpp
** Declares the Timeline Entity draw strategy class.
*/
#ifndef TIMELINE_BASIC_DRAW_STRATEGY_HPP
#define TIMELINE_BASIC_DRAW_STRATEGY_HPP
#ifndef WIDGETS_TIMELINE_BASIC_DRAW_STRATEGY_H
#define WIDGETS_TIMELINE_BASIC_DRAW_STRATEGY_H
#include "draw-strategy.hpp"
#include "gui/widgets/timeline/draw-strategy.hpp"
namespace gui {
namespace widgets {
namespace timeline {
class BasicDrawStrategy : public DrawStrategy
{
public:
BasicDrawStrategy();
void draw(const Entity &entity,
Cairo::RefPtr<Cairo::Context> cr,
TimelineViewWindow* const window) const;
};
} // namespace timeline
} // namespace widgets
} // namespace gui
class BasicDrawStrategy
: public DrawStrategy
{
public:
BasicDrawStrategy() { };
void
draw (const Entity &entity,
Cairo::RefPtr<Cairo::Context> cr,
TimelineViewWindow* const window) const;
};
}}} // namespace gui::widgets::timeline
#endif // TIMELINE_BASIC_DRAW_STRATEGY_HPP

View file

@ -1,5 +1,5 @@
/*
basic-draw-strategy.cpp - Implementation of a basic draw strategy
DrawStrategy - Implementation of a basic draw strategy
Copyright (C) Lumiera.org
2010, Stefan Kangas <skangas@skangas.se
@ -20,19 +20,20 @@
* *****************************************************/
#include "basic-draw-strategy.hpp"
#include "gui/widgets/timeline/basic-draw-strategy.hpp"
namespace gui {
namespace widgets {
namespace timeline {
BasicDrawStrategy::BasicDrawStrategy()
{ }
DrawStrategy::~DrawStrategy() { } // emit VTable here
void
BasicDrawStrategy::draw(const Entity &entity,
Cairo::RefPtr<Cairo::Context> cr,
TimelineViewWindow* const window) const
BasicDrawStrategy::draw (const Entity &entity,
Cairo::RefPtr<Cairo::Context> cr,
TimelineViewWindow* const window) const
{
REQUIRE (cr);
REQUIRE (window);
@ -60,8 +61,7 @@ namespace timeline {
cr->set_font_size (9);
cr->show_text (entity.getName());
}
} // namespace timeline
} // namespace widgets
} // namespace gui
}}} // namespace gui::widgets::timeline

View file

@ -19,40 +19,46 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
* *****************************************************/
/** @file draw-strategy.hpp
** Declares the timeline entity drawing strategy interface.
*/
#ifndef TIMELINE_DRAW_STRATEGY_HPP
#define TIMELINE_DRAW_STRATEGY_HPP
#ifndef WIDGETS_TIMELINE_DRAW_STRATEGY_HPP
#define WIDGETS_TIMELINE_DRAW_STRATEGY_HPP
#include "timeline-entity.hpp"
#include "timeline-view-window.hpp"
#include "gui/gtk-base.hpp"
#include "gui/widgets/timeline/timeline-entity.hpp"
#include "gui/widgets/timeline/timeline-view-window.hpp"
namespace gui {
namespace widgets {
namespace timeline {
/////////TODO some questions:
///////// 1) who is allowed to destroy DrawStrategy objects
///////// 2) shouldn't DrawStragegy be boost::noncopyable?
/**
* An interface for drawing strategies for timeline entities.
*/
class DrawStrategy
{
protected:
DrawStrategy() { }
virtual ~DrawStrategy() { }
public:
virtual void draw(const Entity &entity,
Cairo::RefPtr<Cairo::Context> cr,
TimelineViewWindow* const window) const = 0;
};
} // namespace timeline
} // namespace widgets
} // namespace gui
{
protected:
DrawStrategy() { }
virtual ~DrawStrategy();
public:
virtual void
draw (const Entity &entity,
Cairo::RefPtr<Cairo::Context> cr,
TimelineViewWindow* const window) const = 0;
};
}}} // namespace gui::widgets::timeline
#endif // TIMELINE_DRAW_STRATEGY_HPP

View file

@ -20,11 +20,15 @@
* *****************************************************/
#include "timeline-arrow-tool.hpp"
#include "gui/widgets/timeline/timeline-arrow-tool.hpp"
namespace gui {
namespace widgets {
namespace timeline {
using lib::time::Time;
ArrowTool::ArrowTool(TimelineBody &timelineBody) :
Tool(timelineBody)
@ -53,8 +57,8 @@ namespace timeline {
// Convert the mouse click position to a Time
boost::shared_ptr<TimelineState> state = timelineBody.getTimelineWidget().get_state();
REQUIRE(state);
const TimelineViewWindow &window = state->get_view_window();
lumiera::Time tpoint = window.x_to_time(mousePoint.get_x());
TimelineViewWindow const& window = state->get_view_window();
Time tpoint = window.x_to_time(mousePoint.get_x());
// Get the clip, if any
boost::shared_ptr<timeline::Track> track = getHoveringTrack();

View file

@ -19,20 +19,22 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/** @file timeline-arrow-tool.hpp
** This file contains the definition of the arrow tool class
*/
#ifndef TIMELINE_ARROW_TOOL_HPP
#define TIMELINE_ARROW_TOOL_HPP
#ifndef WIDGETS_TIMELINE_ARROW_TOOL_H
#define WIDGETS_TIMELINE_ARROW_TOOL_H
#include <gtkmm.h>
#include "timeline-tool.hpp"
#include "gui/gtk-base.hpp"
#include "gui/widgets/timeline-widget.hpp"
#include "timeline-body.hpp"
#include "timeline-track.hpp"
#include "gui/widgets/timeline/timeline-tool.hpp"
#include "gui/widgets/timeline/timeline-body.hpp"
#include "gui/widgets/timeline/timeline-track.hpp"
#include "lib/time/timevalue.hpp"
namespace gui {
namespace widgets {

View file

@ -43,15 +43,15 @@ namespace gui {
namespace widgets {
namespace timeline {
TimelineBody::TimelineBody(TimelineWidget &timelineWidget) :
Glib::ObjectBase("TimelineBody"),
tool(NULL),
mouseDownX(0),
mouseDownY(0),
dragType(None),
beginShiftTimeOffset(0),
selectionAlpha(0.5),
timelineWidget(timelineWidget)
TimelineBody::TimelineBody (TimelineWidget &timelineWidget)
: Glib::ObjectBase("TimelineBody")
, tool(NULL)
, mouseDownX(0)
, mouseDownY(0)
, dragType(None)
, beginShiftTimeOffset()
, selectionAlpha(0.5)
, timelineWidget(timelineWidget)
{
// Connect up some events
timelineWidget.state_changed_signal().connect(
@ -264,10 +264,11 @@ TimelineBody::on_motion_notify_event(GdkEventMotion *event)
{
TimelineViewWindow &window = view_window();
/////////////////////////////TICKET# 795 : don't reach in from outside and manipulate internals of the timeline view!
///////////////////////////// : either encapsulate this entirely here, or leave it to the timeline view!
const int64_t scale = window.get_time_scale();
Time offset(beginShiftTimeOffset +
(int64_t)(mouseDownX - event->x) * scale);
window.set_time_offset(offset);
window.set_time_offset(beginShiftTimeOffset
+ TimeValue(scale * (mouseDownX - event->x)));
set_vertical_offset((int)(mouseDownY - event->y) +
beginShiftVerticalOffset);
@ -388,9 +389,9 @@ TimelineBody::draw_selection(Cairo::RefPtr<Cairo::Context> cr)
shared_ptr<TimelineState> state = timelineWidget.get_state();
REQUIRE(state);
const TimelineViewWindow &window = state->get_view_window();
const int start_x = window.time_to_x(state->get_selection_start());
const int end_x = window.time_to_x(state->get_selection_end());
TimelineViewWindow const& window = state->get_view_window();
const int start_x = window.time_to_x(state->getSelectionStart());
const int end_x = window.time_to_x(state->getSelectionEnd());
// Draw the cover
if(end_x > 0 && start_x < allocation.get_width())
@ -431,12 +432,10 @@ TimelineBody::draw_playback_point(Cairo::RefPtr<Cairo::Context> cr)
shared_ptr<TimelineState> state = timelineWidget.get_state();
if(state)
{
const Allocation allocation = get_allocation();
const gavl_time_t point = state->get_playback_point();
if(point == (gavl_time_t)GAVL_TIME_UNDEFINED)
return;
if (!state->isPlaying()) return;
const Allocation allocation = get_allocation();
Time point = state->getPlaybackPoint();
const int x = view_window().time_to_x(point);
// Set source

View file

@ -19,15 +19,17 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/** @file timeline-body.hpp
** This file contains the definition of timeline body widget
*/
#ifndef TIMELINE_BODY_HPP
#define TIMELINE_BODY_HPP
#ifndef WIDGETS_TIMELINE_BODY_H
#define WIDGETS_TIMELINE_BODY_H
#include "gui/gtk-lumiera.hpp"
#include "timeline-tool.hpp"
#include "gui/widgets/timeline/timeline-tool.hpp"
#include "lib/time/timevalue.hpp"
#include <boost/scoped_ptr.hpp>
@ -43,9 +45,13 @@ class TimelineWidget;
namespace timeline {
using lib::time::TimeVar;
class Track;
class TimelineViewWindow;
/**
* Implementation of the timeline body subwidget. This widget is
* displayed in the centre of the timeline widget, and displays the
@ -186,7 +192,7 @@ private:
// Scroll State
DragType dragType;
gavl_time_t beginShiftTimeOffset;
TimeVar beginShiftTimeOffset;
int beginShiftVerticalOffset;
// Style properties

View file

@ -57,8 +57,8 @@ namespace timeline {
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),
cairo->rectangle(window->time_to_x(Time::ZERO), 1,
window->time_to_x(Time(500,0)) - window->time_to_x(Time::ZERO),
get_height() - 2);
cairo->set_source_rgb(0.5, 0.5, 0.5);
@ -77,13 +77,13 @@ namespace timeline {
}
boost::shared_ptr<timeline::Clip>
ClipTrack::getClipAt(lumiera::Time position) const
ClipTrack::getClipAt(Time position) const
{
std::pair<shared_ptr<model::Clip>, shared_ptr<timeline::Clip> >
pair;
BOOST_FOREACH (pair, clipMap)
{
if (pair.first->isPlayingAt(position))
if (pair.first->isPlayingAt (position))
return pair.second;
}

View file

@ -28,19 +28,23 @@
#ifndef TIMELINE_CLIP_TRACK_HPP
#define TIMELINE_CLIP_TRACK_HPP
#include <vector>
#include "basic-draw-strategy.hpp"
#include "timeline-track.hpp"
#include "gui/widgets/timeline/basic-draw-strategy.hpp"
#include "gui/widgets/timeline/timeline-track.hpp"
#include "gui/model/clip-track.hpp"
#include "lib/time/timevalue.hpp"
#include <vector>
namespace gui {
namespace widgets {
namespace timeline {
using lib::time::Time;
class Clip;
class TimelineViewWindow;
class ClipTrack : public timeline::Track
{
public:
@ -63,7 +67,7 @@ namespace timeline {
* @param the given time
*/
boost::shared_ptr<timeline::Clip>
getClipAt(lumiera::Time position) const;
getClipAt(Time position) const;
private:

View file

@ -20,17 +20,21 @@
* *****************************************************/
#include "timeline-clip.hpp"
#include "gui/widgets/timeline/timeline-clip.hpp"
namespace gui {
namespace widgets {
namespace timeline {
using boost::shared_ptr; //////////////////////TICKET #796
Clip::Clip(boost::shared_ptr<model::Clip> clip,
boost::shared_ptr<timeline::DrawStrategy> drawStrategy)
: Entity(drawStrategy),
modelClip(clip),
selected(false)
Clip::Clip (boost::shared_ptr<model::Clip> clip,
boost::shared_ptr<timeline::DrawStrategy> drawStrategy)
: Entity(drawStrategy)
, modelClip(clip)
, selected(false)
{
REQUIRE(modelClip);
@ -39,35 +43,33 @@ namespace timeline {
// &Clip::onNameChanged);
}
gavl_time_t
Clip::getBegin () const
Time
Clip::getBegin() const
{
REQUIRE (modelClip);
return modelClip->getBegin();
}
gavl_time_t
Clip::getEnd () const
Time
Clip::getEnd() const
{
REQUIRE (modelClip);
return modelClip->getEnd();
}
std::string
Clip::getName () const
string
Clip::getName() const
{
REQUIRE (modelClip);
return modelClip->getName();
}
void
Clip::setSelected(bool selected)
Clip::setSelected (bool selected)
{
this->selected = selected;
}
} // namespace timeline
} // namespace widgets
} // namespace gui
}}} // namespace gui::widgets::timeline

View file

@ -19,57 +19,57 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/** @file widgets/timeline/timeline-clip.hpp
** This file contains the definition of timeline clip object
*/
#ifndef WIDGETS_TIMELINE_CLIP_H
#define WIDGETS_TIMELINE_CLIP_H
#include "gui/gtk-lumiera.hpp"
#include "gui/model/clip.hpp"
#include "include/logging.h"
#include "lib/time/timevalue.hpp"
#include "draw-strategy.hpp"
#include "timeline-entity.hpp"
#include "gui/widgets/timeline/draw-strategy.hpp"
#include "gui/widgets/timeline/timeline-entity.hpp"
#include <string>
#ifndef TIMELINE_CLIP_HPP
#define TIMELINE_CLIP_HPP
namespace gui {
namespace widgets {
namespace timeline {
using std::string;
using lib::time::Time;
class Clip : public Entity
{
public:
Clip(boost::shared_ptr<model::Clip> clip,
boost::shared_ptr<timeline::DrawStrategy> drawStrategy);
gavl_time_t
getBegin () const;
gavl_time_t
getEnd () const;
std::string
getName () const;
/**
* Sets the selected status of the clip.
*/
void
setSelected (bool state);
private:
boost::shared_ptr<model::Clip> modelClip;
/**
* True when this clip is selected in the GUI.
*/
bool selected;
};
} // namespace timeline
} // namespace widgets
} // namespace gui
{
public:
Clip (boost::shared_ptr<model::Clip> clip,
boost::shared_ptr<timeline::DrawStrategy> drawStrategy);
Time getBegin() const;
Time getEnd() const;
string getName() const;
/** Sets the selected status of the clip. */
void setSelected (bool);
private:
boost::shared_ptr<model::Clip> modelClip; ////////////////////////TICKET #796 : should use std::tr1
/**
* True when this clip is selected in the GUI.
*/
bool selected;
};
}}} // namespace gui::widgets::timeline
#endif // TIMELINE_CLIP_HPP

View file

@ -20,12 +20,10 @@
* *****************************************************/
#include "timeline-entity.hpp"
#include "draw-strategy.hpp"
#include "gui/gtk-lumiera.hpp"
#include "include/logging.h"
#include "gui/widgets/timeline/timeline-entity.hpp"
#include "gui/widgets/timeline/draw-strategy.hpp"
namespace gui {
namespace widgets {

View file

@ -19,6 +19,7 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
* *****************************************************/
/** @file timeline-entity.hpp
** Declares the Timeline Entity class.
*/
@ -26,21 +27,20 @@
#ifndef TIMELINE_ENTITY_HPP
#define TIMELINE_ENTITY_HPP
#include "gui/gtk-base.hpp"
#include "lib/time/timevalue.hpp"
#include <string>
// TODO: Remove once we get better measure of duration.
extern "C" {
#include <stdint.h>
#include <gavl/gavltime.h>
}
#include <boost/shared_ptr.hpp>
#include <cairomm/cairomm.h>
#include <boost/shared_ptr.hpp> //////////////////////TICKET #796
namespace gui {
namespace widgets {
namespace timeline {
using lib::time::Time;
class DrawStrategy;
class TimelineViewWindow;
@ -57,8 +57,6 @@ namespace timeline {
public:
virtual gavl_time_t
getBegin () const = 0;
virtual void
draw(Cairo::RefPtr<Cairo::Context> cairo,
@ -67,7 +65,10 @@ namespace timeline {
bool
getEnabled () const;
virtual gavl_time_t
virtual Time
getBegin () const = 0;
virtual Time
getEnd () const = 0;
virtual std::string

View file

@ -20,12 +20,16 @@
* *****************************************************/
#include "timeline-ibeam-tool.hpp"
#include "gui/widgets/timeline/timeline-ibeam-tool.hpp"
#include "gui/widgets/timeline-widget.hpp"
#include "lib/time/mutation.hpp"
#include <boost/shared_ptr.hpp>
using namespace boost;
using namespace gui::widgets;
using namespace lumiera;
using lib::time::Mutation;
using boost::shared_ptr; /////////////////////////TICKET #796
namespace gui {
namespace widgets {
@ -42,7 +46,7 @@ const int IBeamTool::ScrollSlideEventInterval = 40;
IBeamTool::IBeamTool(TimelineBody &timeline_body) :
Tool(timeline_body),
dragType(None),
pinnedDragTime(0),
pinnedDragTime(),
scrollSlideRate(0)
{
@ -103,20 +107,22 @@ IBeamTool::on_button_press_event(GdkEventButton* event)
{
// User began to drag the start of the selection
dragType = GrabStart;
pinnedDragTime = state->get_selection_end();
pinnedDragTime = state->getSelectionEnd();
}
else if(is_mouse_in_end_drag_zone())
{
// User began to drag the end of the selection
dragType = GrabEnd;
pinnedDragTime = state->get_selection_start();
pinnedDragTime = state->getSelectionStart();
}
else
{
// User began the drag in clear space, begin a Select drag
dragType = Selection;
pinnedDragTime = time;
state->set_selection(time, time);
state->setSelection (Mutation::changeTime(time));
state->setSelection (Mutation::changeDuration(Duration::NIL));
//////////////////////////////////////////////////////TICKET #797 : this is cheesy. Should provide a single Mutation to change all
}
}
}
@ -188,11 +194,15 @@ IBeamTool::set_leading_x(const int x)
shared_ptr<TimelineState> state = get_state();
const bool set_playback_period = dragType == Selection;
const Time time = state->get_view_window().x_to_time(x);
if(time > pinnedDragTime)
state->set_selection(pinnedDragTime, time, set_playback_period);
else
state->set_selection(time, pinnedDragTime, set_playback_period);
TimeVar newStartPoint (state->get_view_window().x_to_time(x));
Offset selectionLength (pinnedDragTime, newStartPoint);
if (newStartPoint > pinnedDragTime)
newStartPoint=pinnedDragTime; // use the smaller one as selection start
state->setSelection (Mutation::changeTime(newStartPoint) , set_playback_period);
state->setSelection (Mutation::changeDuration(selectionLength), set_playback_period);
//////////////////////////////////////////////////////TICKET #797 : this is cheesy. Should provide a single Mutation to change all at once
}
void
@ -217,7 +227,7 @@ bool
IBeamTool::is_mouse_in_start_drag_zone() const
{
const int start_x = view_window().time_to_x(
get_state()->get_selection_start());
get_state()->getSelectionStart());
return (mousePoint.get_x() <= start_x &&
mousePoint.get_x() > start_x - DragZoneWidth);
@ -227,7 +237,7 @@ bool
IBeamTool::is_mouse_in_end_drag_zone() const
{
const int end_x = view_window().time_to_x(
get_state()->get_selection_end());
get_state()->getSelectionEnd());
return (mousePoint.get_x() >= end_x &&
mousePoint.get_x() < end_x + DragZoneWidth);

View file

@ -19,21 +19,26 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/** @file timeline-ibeam-tool.hpp
** This file contains the definition of ibeam tool class
** tool objects
*/
#ifndef TIMELINE_IBEAM_TOOL_HPP
#define TIMELINE_IBEAM_TOOL_HPP
#ifndef WIDGETS_TIMELINE_IBEAM_TOOL_H
#define WIDGETS_TIMELINE_IBEAM_TOOL_H
#include "gui/widgets/timeline/timeline-tool.hpp"
#include "lib/time/timevalue.hpp"
#include <gtkmm.h>
#include "timeline-tool.hpp"
namespace gui {
namespace widgets {
namespace timeline {
using lib::time::TimeVar;
/**
* A helper class to implement the timeline i-beam tool
*/
@ -164,7 +169,7 @@ private:
* the mouse, the other is pinned. pinnedDragTime specifies the time
* of that point.
*/
lumiera::Time pinnedDragTime;
TimeVar pinnedDragTime;
/**
* This connection is used to represent the timer which causes scroll

View file

@ -1,5 +1,5 @@
/*
timeline-ruler.cpp - Implementation of the time ruler widget
TimelineRuler - Implementation of the time ruler widget
Copyright (C) Lumiera.org
2008, Joel Holdsworth <joel@airwebreathe.org.uk>
@ -20,51 +20,52 @@
* *****************************************************/
#include <cairomm/cairomm.h>
#include "timeline-ruler.hpp"
#include "gui/widgets/timeline/timeline-ruler.hpp"
#include "gui/widgets/timeline-widget.hpp"
#include "gui/window-manager.hpp"
#include "gui/util/cairo-util.hpp"
#include "lib/time/timevalue.hpp"
#include "lib/time.h"
#include <cairomm/cairomm.h>
using namespace Gtk;
using namespace Cairo;
using namespace std;
using namespace boost;
using namespace gui;
using namespace gui::widgets;
using namespace gui::widgets::timeline;
using namespace lumiera;
using boost::shared_ptr; ////////////////////TICKET #796
using gui::util::CairoUtil;
using lib::time::Time;
using lib::time::TimeVar;
namespace gui {
namespace widgets {
namespace timeline {
TimelineRuler::TimelineRuler(
gui::widgets::TimelineWidget &timeline_widget) :
Glib::ObjectBase("TimelineRuler"),
isDragging(false),
pinnedDragTime(0),
mouseChevronOffset(0),
annotationHorzMargin(0),
annotationVertMargin(0),
majorTickHeight(0),
minorLongTickHeight(0),
minorShortTickHeight(0),
minDivisionWidth(100),
mouseChevronSize(5),
selectionChevronSize(5),
playbackPointAlpha(0.5f),
playbackPointSize(12),
playbackPeriodArrowAlpha(0.5f),
playbackPeriodArrowSize(10),
playbackPeriodArrowStemSize(3),
timelineWidget(timeline_widget)
TimelineRuler::TimelineRuler (TimelineWidget &timeline_widget)
: Glib::ObjectBase("TimelineRuler")
, isDragging(false)
, pinnedDragTime(Time::ZERO)
, mouseChevronOffset(0)
, annotationHorzMargin(0)
, annotationVertMargin(0)
, majorTickHeight(0)
, minorLongTickHeight(0)
, minorShortTickHeight(0)
, minDivisionWidth(100)
, mouseChevronSize(5)
, selectionChevronSize(5)
, playbackPointAlpha(0.5f)
, playbackPointSize(12)
, playbackPeriodArrowAlpha(0.5f)
, playbackPeriodArrowSize(10)
, playbackPeriodArrowStemSize(3)
, timelineWidget(timeline_widget)
{
// Connect up some events
timeline_widget.state_changed_signal().connect(
@ -238,11 +239,16 @@ TimelineRuler::set_leading_x(const int x)
if(state)
{
const Time time = view_window().x_to_time(x);
if(time > pinnedDragTime)
state->set_playback_period(pinnedDragTime, time);
else
state->set_playback_period(time, pinnedDragTime);
TimeVar newStartPoint (view_window().x_to_time(x));
Offset selectionLength (pinnedDragTime, newStartPoint);
if (newStartPoint > pinnedDragTime)
newStartPoint=pinnedDragTime; // use the smaller one as selection start
state->setPlaybackPeriod (Mutation::changeTime(newStartPoint) );
state->setPlaybackPeriod (Mutation::changeDuration(selectionLength));
//////////////////////////////////////////////////////TICKET #797 : this is cheesy. Should provide a single Mutation to change all at once
////////////////////TODO : code duplication with timeline-ibeam-tool 205
}
}
@ -255,7 +261,7 @@ TimelineRuler::draw_ruler(Cairo::RefPtr<Cairo::Context> cr,
REQUIRE(ruler_rect.get_height() > 0);
const TimelineViewWindow &window = view_window();
const gavl_time_t left_offset = window.get_time_offset();
const gavl_time_t left_offset = _raw(window.get_time_offset());
const int64_t time_scale = window.get_time_scale();
// Preparation steps
@ -301,7 +307,7 @@ TimelineRuler::draw_ruler(Cairo::RefPtr<Cairo::Context> cr,
cr->stroke();
// Draw the text
pango_layout->set_text(lumiera_tmpbuf_print_time(time_offset));
pango_layout->set_text(lumiera_tmpbuf_print_time(time_offset)); ///////////////TICKET #750 : should delegate to a Timecode format here
cr->move_to(annotationHorzMargin + x, annotationVertMargin);
pango_layout->add_to_cairo_context(cr);
cr->fill();
@ -364,7 +370,7 @@ TimelineRuler::draw_selection(Cairo::RefPtr<Cairo::Context> cr,
Gdk::Cairo::set_source_color(cr, style->get_fg(STATE_NORMAL));
// Draw the selection start chevron
const int a = window.time_to_x(state->get_selection_start()) + 1;
const int a = 1 + window.time_to_x(state->getSelectionStart());
if(a >= 0 && a < ruler_rect.get_width())
{
cr->move_to(a, ruler_rect.get_height());
@ -374,7 +380,7 @@ TimelineRuler::draw_selection(Cairo::RefPtr<Cairo::Context> cr,
}
// Draw the selection end chevron
const int b = window.time_to_x(state->get_selection_end());
const int b = window.time_to_x(state->getSelectionEnd());
if(b >= 0 && b < ruler_rect.get_width())
{
cr->move_to(b, ruler_rect.get_height());
@ -399,22 +405,18 @@ TimelineRuler::draw_playback_period(Cairo::RefPtr<Cairo::Context> cr,
// Calculate coordinates
const float halfSize = playbackPeriodArrowSize / 2;
const float a = window.time_to_x(
state->get_playback_period_start()) + 1 + 0.5f;
const float a = 1.5f + window.time_to_x(state->getPlaybackPeriodStart());
const float b = a + halfSize;
const float d = window.time_to_x(
state->get_playback_period_end()) + 0.5f;
const float d = 0.5f + window.time_to_x(state->getPlaybackPeriodEnd());
const float c = d - halfSize;
const float e = ruler_rect.get_height() - playbackPeriodArrowSize
- 0.5f;
const float f = e + (playbackPeriodArrowSize -
playbackPeriodArrowStemSize) / 2;
const float g = ruler_rect.get_height() - playbackPeriodArrowSize / 2
- 0.5f;
const float e = ruler_rect.get_height() - playbackPeriodArrowSize - 0.5f;
const float f = e + (playbackPeriodArrowSize - playbackPeriodArrowStemSize) / 2;
const float g = ruler_rect.get_height() - playbackPeriodArrowSize / 2 - 0.5f;
const float i = ruler_rect.get_height() - 0.5f;
const float h = i - (playbackPeriodArrowSize -
playbackPeriodArrowStemSize) / 2;
const float h = i - (playbackPeriodArrowSize - playbackPeriodArrowStemSize) / 2;
// Contruct the path
if(d - a >= playbackPeriodArrowSize)
@ -466,11 +468,10 @@ TimelineRuler::draw_playback_point(Cairo::RefPtr<Cairo::Context> cr,
shared_ptr<TimelineState> state = timelineWidget.get_state();
REQUIRE(state);
const TimelineViewWindow &window = state->get_view_window();
if (!state->isPlaying()) return;
const gavl_time_t point = state->get_playback_point();
if(point == (gavl_time_t)GAVL_TIME_UNDEFINED)
return;
TimelineViewWindow const& window = state->get_view_window();
Time point = state->getPlaybackPoint();
const int x = window.time_to_x(point);
cr->move_to(x + 0.5, ruler_rect.get_height());

View file

@ -28,6 +28,7 @@
#define TIMELINE_RULER_HPP
#include "gui/gtk-lumiera.hpp"
#include "lib/time/timevalue.hpp"
namespace gui {
namespace widgets {
@ -198,7 +199,7 @@ private:
* the mouse, the other is pinned. pinnedDragTime specifies the time
* of that point.
*/
lumiera::Time pinnedDragTime;
lib::time::TimeVar pinnedDragTime;
// Indicated values
/**

View file

@ -20,31 +20,43 @@
* *****************************************************/
#include "timeline-state.hpp"
using namespace boost;
#include "gui/widgets/timeline/timeline-state.hpp"
#include "lib/time/timevalue.hpp"
#include "lib/time/mutation.hpp"
using namespace Gtk;
using namespace sigc;
using namespace lumiera;
namespace gui {
namespace widgets {
namespace timeline {
TimelineState::TimelineState(
boost::shared_ptr<model::Sequence> source_sequence) :
sequence(source_sequence),
viewWindow(Time(0), 1),
selectionStart(0),
selectionEnd(0),
playbackPeriodStart(0),
playbackPeriodEnd(0),
playbackPoint(Time(GAVL_TIME_UNDEFINED))
using lib::time::FSecs;
using lib::time::Offset;
using lib::time::Duration;
using lib::time::Mutation;
using boost::shared_ptr; /////////////////////////TICKET #796
TimelineState::TimelineState (boost::shared_ptr<model::Sequence> source_sequence)
: sequence(source_sequence)
, viewWindow(Offset(Time::ZERO), 1)
, selection_(Time::ZERO, Duration::NIL)
, playbackPeriod_(Time::ZERO, Duration::NIL)
, playbackPoint_(Time::ZERO)
, isPlayback_(false)
{
REQUIRE(sequence);
////////////////////////////////////////////////////////////TICKET #798: how to handle GUI default state
viewWindow.set_time_scale(GAVL_TIME_SCALE / 200);
set_selection(Time(2000000), Time(4000000));
setSelection (Mutation::changeTime (Time(FSecs(2))));
setSelection (Mutation::changeDuration(Duration(FSecs(2))));
//////////////////////////////////////////////////////TICKET #797 : this is cheesy. Should provide a single Mutation to change all
}
boost::shared_ptr<model::Sequence>
@ -59,87 +71,31 @@ TimelineState::get_view_window()
return viewWindow;
}
Time
TimelineState::get_selection_start() const
{
return selectionStart;
}
Time
TimelineState::get_selection_end() const
{
return selectionEnd;
}
void
TimelineState::set_selection(Time start, Time end,
bool reset_playback_period)
{
if(start < end)
{
selectionStart = start;
selectionEnd = end;
}
else
{
// The selection is back-to-front, flip it round
selectionStart = end;
selectionEnd = start;
}
if(reset_playback_period)
{
playbackPeriodStart = selectionStart;
playbackPeriodEnd = selectionEnd;
}
TimelineState::setSelection (Mutation const& change,
bool resetPlaybackPeriod)
{
selection_.accept (change);
if (resetPlaybackPeriod)
setPlaybackPeriod(change);
selectionChangedSignal.emit();
}
Time
TimelineState::get_playback_period_start() const
{
return playbackPeriodStart;
}
Time
TimelineState::get_playback_period_end() const
{
return playbackPeriodEnd;
}
void
TimelineState::set_playback_period(Time start, Time end)
TimelineState::setPlaybackPeriod (Mutation const& change)
{
if(start < end)
{
playbackPeriodStart = start;
playbackPeriodEnd = end;
}
else
{
// The period is back-to-front, flip it round
playbackPeriodStart = end;
playbackPeriodEnd = start;
}
playbackPeriod_.accept (change);
playbackChangedSignal.emit();
}
void
TimelineState::set_playback_point(Time point)
TimelineState::setPlaybackPoint (Time newPosition)
{
playbackPoint = point;
playbackPoint_ = newPosition;
playbackChangedSignal.emit();
}
Time
TimelineState::get_playback_point() const
{
return playbackPoint;
}
sigc::signal<void>
TimelineState::selection_changed_signal() const
{

View file

@ -26,7 +26,10 @@
#ifndef TIMELINE_STATE_HPP
#define TIMELINE_STATE_HPP
#include "timeline-view-window.hpp"
#include "gui/widgets/timeline/timeline-view-window.hpp"
#include "lib/time/mutation.hpp"
#include <boost/shared_ptr.hpp> /////////////////////////TICKET #796
namespace gui {
@ -36,6 +39,8 @@ class Sequence;
namespace widgets {
namespace timeline {
using lib::time::Mutation;
/**
* TimelineState is a container for the state data for TimelineWidget.
@ -67,56 +72,37 @@ public:
*/
timeline::TimelineViewWindow& get_view_window();
/**
* Gets the time at which the selection begins.
*/
lumiera::Time get_selection_start() const;
/**
* Gets the time at which the selection begins.
*/
lumiera::Time get_selection_end() const;
Time getSelectionStart() const { return selection_.start();}
Time getSelectionEnd() const { return selection_.end(); }
Time getPlaybackPeriodStart() const { return selection_.start();}
Time getPlaybackPeriodEnd() const { return selection_.end(); }
Time getPlaybackPoint() const { return playbackPoint_; }
/** is there currently any ongoing playback process?
* Otherwise the #getPlaybackPoint is meaningless */
bool isPlaying() const { return isPlayback_; }
/**
* Sets the period of the selection.
* @param start The start time.
* @param end The end time.
* @param reset_playback_period Specifies whether to set the playback
* period to the same as this new selection.
* @param resetPlaybackPeriod Specifies whether to set the
* playback period to the same as this new selection.
*/
void set_selection(lumiera::Time start, lumiera::Time end,
bool reset_playback_period = true);
void setSelection(Mutation const& change,
bool resetPlaybackPeriod = true);
void setPlaybackPeriod(Mutation const& change);
/**
* Gets the time at which the playback period begins.
* Sets the time which is currently being played back.
* @param point The time index being played.
* @todo do we ever get the situation that we don't have such a position?
* @todo very likely to be handled differently, once
* the GUI is really connected to the Player
*/
lumiera::Time get_playback_period_start() const;
/**
* Gets the time at which the playback period ends.
*/
lumiera::Time get_playback_period_end() const;
/**
* Sets the playback period.
* @param start The start time.
* @param end The end time.
*/
void set_playback_period(lumiera::Time start, lumiera::Time end);
/**
* Sets the time which is currenty being played back.
* @param point The time index being played. This value may be
* GAVL_TIME_UNDEFINED, if there is no playback point.
*/
void set_playback_point(lumiera::Time point);
/**
* Gets the current playback point.
* @return The time index of the playback point. This value may be
* GAVL_TIME_UNDEFINED, if there is no playback point.
*/
lumiera::Time get_playback_point() const;
void setPlaybackPoint(Time newPos);
/**
* A signal to notify when the selected period has changed.
@ -132,8 +118,7 @@ public:
private:
/**
* A pointer to the sequence object which this timeline_widget will
* represent.
* A pointer to the sequence object which this timeline_widget will represent.
* @remarks This pointer is set by the constructor and is constant, so
* will not change in value during the lifetime of the class.
*/
@ -147,30 +132,20 @@ private:
// Selection State
/**
* The start time of the selection period.
*/
lumiera::Time selectionStart;
/** currently selected time period. */
TimeSpan selection_;
/**
* The end time of the selection period.
*/
lumiera::Time selectionEnd;
/** current playback period. */
TimeSpan playbackPeriod_;
/**
* The start time of the playback period.
/** current playback position.
* @todo very likely to be handled differently
* when actually integrated with the Player
*/
lumiera::Time playbackPeriodStart;
TimeVar playbackPoint_;
/**
* The end time of the playback period.
*/
lumiera::Time playbackPeriodEnd;
bool isPlayback_;
/**
* The time of the playback point.
*/
lumiera::Time playbackPoint;
// Signals

View file

@ -26,10 +26,11 @@
#include "gui/dialogs/name-chooser.hpp"
#include "include/logging.h"
using namespace boost;
using namespace Gtk;
using namespace sigc;
using boost::shared_ptr; //////////////////////////////TICKET #796 : should use std::tr1
namespace gui {
namespace widgets {
namespace timeline {
@ -120,8 +121,8 @@ Track::get_expanded() const
return expanded;
}
boost::shared_ptr<timeline::Clip>
Track::getClipAt(lumiera::Time) const
shared_ptr<timeline::Clip>
Track::getClipAt(Time) const
{
// Default implementation returns empty pointer
return boost::shared_ptr<timeline::Clip>();

View file

@ -38,6 +38,7 @@
#include "gui/widgets/timeline/timeline-clip.hpp"
#include "gui/widgets/timeline/timeline-header-container.hpp"
#include "gui/widgets/timeline/timeline-header-widget.hpp"
#include "lib/time/timevalue.hpp"
#include <boost/scoped_ptr.hpp>
@ -45,6 +46,8 @@
namespace gui {
namespace widgets {
namespace timeline {
using lib::time::Time;
class TimelineViewWindow;
@ -82,7 +85,7 @@ public:
Gtk::Widget& get_header_widget();
boost::shared_ptr<model::Track>
boost::shared_ptr<model::Track> //////////////////////////////TICKET #796 : should use std::tr1
getModelTrack() const;
/**
@ -152,8 +155,8 @@ public:
* The default implementation simply returns an empty pointer.
* @param the given time
*/
virtual boost::shared_ptr<timeline::Clip>
getClipAt(lumiera::Time position) const;
virtual boost::shared_ptr<timeline::Clip> //////////////////////////////TICKET #796 : should use std::tr1
getClipAt (Time position) const;
private:

View file

@ -31,28 +31,29 @@ namespace gui {
namespace widgets {
namespace timeline {
TimelineViewWindow::TimelineViewWindow(
Time offset, int64_t scale) :
timeOffset(offset),
timeScale(scale)
TimelineViewWindow::TimelineViewWindow (Offset offset, int64_t scale)
: timeOffset(offset)
, timeScale(scale)
{
}
Time
TimelineViewWindow::get_time_offset() const
Offset
TimelineViewWindow::get_time_offset() const /////////////////////TODO: this function shouldn't be accessible from outside
{
return timeOffset;
return Offset (timeOffset);
}
void
TimelineViewWindow::set_time_offset(Time offset)
TimelineViewWindow::set_time_offset(TimeValue const& offset) /////////TODO: this function shouldn't be accessible from outside
{
timeOffset = offset;
changedSignal.emit();
}
int64_t
TimelineViewWindow::get_time_scale() const
TimelineViewWindow::get_time_scale() const /////////////////////TODO: this function shouldn't be accessible from outside
{
return timeScale;
}
@ -81,8 +82,9 @@ TimelineViewWindow::zoom_view(int point, int zoom_size)
new_time_scale = TimelineWidget::MaxScale;
// The view must be shifted so that the zoom is centred on the cursor
set_time_offset(Time((gavl_time_t)get_time_offset() +
(timeScale - new_time_scale) * point));
TimeVar newStartPoint = get_time_offset();
newStartPoint += TimeValue(point * (timeScale - new_time_scale));
set_time_offset(newStartPoint);
// Apply the new scale
set_time_scale(new_time_scale);
@ -91,20 +93,20 @@ TimelineViewWindow::zoom_view(int point, int zoom_size)
void
TimelineViewWindow::shift_view(int view_width, int shift_size)
{
set_time_offset(Time((gavl_time_t)get_time_offset() +
shift_size * timeScale * view_width / 256));
set_time_offset(timeOffset + TimeValue(timeScale * shift_size * view_width / 256));
}
int
TimelineViewWindow::time_to_x(gavl_time_t time) const
TimelineViewWindow::time_to_x(TimeValue const& time) const
{
return (int)((time - timeOffset) / timeScale);
return int(_raw(time - timeOffset) / timeScale); //////TODO protect against values out-of range
}
Time
TimelineViewWindow::x_to_time(int x) const
{
return Time((gavl_time_t)((int64_t)x * timeScale + timeOffset));
TimeValue time_in_view (timeScale * x);
return timeOffset + time_in_view;
}
sigc::signal<void>

View file

@ -28,14 +28,24 @@
#define TIMELINE_VIEW_WINDOW_HPP
#include "gui/gtk-lumiera.hpp"
#include "lib/time/timevalue.hpp"
namespace gui {
namespace widgets {
class TimelineWidget;
namespace timeline {
using lib::time::Time;
using lib::time::TimeVar;
using lib::time::TimeValue;
using lib::time::TimeSpan;
using lib::time::Duration;
using lib::time::Offset;
/**
* TimelineViewWindow is a helper class for TimelineWidget which manages
* the view window of the timeline: the zoom and shift. The class also
@ -46,28 +56,34 @@ class TimelineViewWindow
public:
/**
* Constructor
* @param offset The initial view offset.
* @param scale The initial scale.
* @param scale The initial view scale.
*/
TimelineViewWindow(lumiera::Time offset, int64_t scale);
TimelineViewWindow(Offset offset, int64_t scale);
/**
* Gets the time offset. This is the time value displaid at the
* Gets the time offset. This is the time value displayed at the
* left-hand edge of the timeline body area.
* @todo obviously this must be switched to use the relevant time grid
* from the session / current timeline to be displayed. It doesn't
* make sense to display raw time values here, as each timeline might
* turn out to have a different origin; this is the result of resolving
* a placement, and only the session has the necessary informations...
*/
lumiera::Time get_time_offset() const;
Offset get_time_offset() const;
/**
* Sets the time offset. This is the time value displaid at the
* left-hand edge of the timeline body area.
* @todo this is private detail that shouldn't be exposed to the outside //////////////////TICKET# 795
*/
void set_time_offset(lumiera::Time time_offset);
void set_time_offset(TimeValue const&);
/**
* Gets the time scale value.
* @return The scale factor, which is the number of microseconds per
* screen pixel.
* @todo this is private detail that shouldn't be exposed to the outside //////////////////TICKET# 795
*/
int64_t get_time_scale() const;
@ -100,15 +116,20 @@ public:
* @return Returns the x-value as pixels from the left hand edge of
* the timeline body.
*/
int time_to_x(int64_t time) const;
int time_to_x(TimeValue const&) const;
/**
* Converts x coordinates in pixels to time values.
* @param x The x coordinte (as pixels from the left hand edge of
* the timeline body) to convert.
* @return Returns the time at the coordinate.
*
* @todo 5/11 this is good for now, but on the long run I'm tinking
* we rather should treat that like a special frame grid
* (display coordinate system) and then use the same framework
* we use for timecodes and frame counts.
*/
lumiera::Time x_to_time(int x) const;
Time x_to_time(int x) const;
/**
* A signal to indicate that the scale or offset have been changed.
@ -116,7 +137,7 @@ public:
sigc::signal<void> changed_signal() const;
private:
lumiera::Time timeOffset;
TimeVar timeOffset;
int64_t timeScale;
sigc::signal<void> changedSignal;