2008-04-12 22:15:07 +02:00
|
|
|
/*
|
2008-05-31 14:22:15 +02:00
|
|
|
timeline-widget.hpp - Declaration of the timeline widget
|
2008-04-12 22:15:07 +02:00
|
|
|
|
|
|
|
|
Copyright (C) Lumiera.org
|
|
|
|
|
2008, Joel Holdsworth <joel@airwebreathe.org.uk>
|
|
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
|
|
*/
|
2008-05-31 14:22:15 +02:00
|
|
|
/** @file timeline-widget.hpp
|
2008-04-19 21:31:27 +02:00
|
|
|
** This file contains the definition of timeline widget
|
2008-04-12 22:15:07 +02:00
|
|
|
*/
|
|
|
|
|
|
2008-04-19 21:31:27 +02:00
|
|
|
#ifndef TIMELINE_WIDGET_HPP
|
|
|
|
|
#define TIMELINE_WIDGET_HPP
|
2008-04-12 22:15:07 +02:00
|
|
|
|
2008-11-19 23:42:38 +01:00
|
|
|
#include "timeline/timeline-view-window.hpp"
|
2008-10-18 12:20:02 +02:00
|
|
|
#include "timeline/timeline-header-container.hpp"
|
2008-05-31 14:22:15 +02:00
|
|
|
#include "timeline/timeline-body.hpp"
|
2008-06-19 00:57:47 +02:00
|
|
|
#include "timeline/timeline-ruler.hpp"
|
2008-07-30 01:12:37 +02:00
|
|
|
#include "timeline/timeline-tool.hpp"
|
2008-08-07 21:27:41 +02:00
|
|
|
#include "timeline/timeline-arrow-tool.hpp"
|
|
|
|
|
#include "timeline/timeline-ibeam-tool.hpp"
|
2008-11-25 22:31:45 +01:00
|
|
|
#include "timeline/timeline-group-track.hpp"
|
|
|
|
|
#include "timeline/timeline-clip-track.hpp"
|
2008-05-31 14:22:15 +02:00
|
|
|
|
2008-11-29 17:13:58 +01:00
|
|
|
#include "../model/sequence.hpp"
|
|
|
|
|
|
2008-04-12 22:15:07 +02:00
|
|
|
namespace gui {
|
2008-04-19 21:31:27 +02:00
|
|
|
namespace widgets {
|
2008-08-16 18:41:57 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The namespace of all timeline widget helper classes.
|
|
|
|
|
*/
|
|
|
|
|
namespace timeline {}
|
2008-04-12 22:15:07 +02:00
|
|
|
|
2008-08-16 18:41:57 +02:00
|
|
|
/**
|
|
|
|
|
* The timeline widget class.
|
|
|
|
|
* @remarks This widget is a composite of several widgets contained
|
|
|
|
|
* within the timeline namespace.
|
|
|
|
|
*/
|
2008-05-31 14:22:15 +02:00
|
|
|
class TimelineWidget : public Gtk::Table
|
2008-06-23 11:54:37 +02:00
|
|
|
{
|
|
|
|
|
public:
|
2008-10-07 22:17:29 +02:00
|
|
|
/**
|
|
|
|
|
* Constructor
|
|
|
|
|
*/
|
2008-12-05 21:17:56 +01:00
|
|
|
TimelineWidget(boost::shared_ptr<model::Sequence> source_sequence);
|
2008-05-31 14:22:15 +02:00
|
|
|
|
2008-10-07 22:17:29 +02:00
|
|
|
/**
|
|
|
|
|
* Destructor
|
|
|
|
|
*/
|
2008-06-23 11:54:37 +02:00
|
|
|
~TimelineWidget();
|
|
|
|
|
|
|
|
|
|
/* ===== Data Access ===== */
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
/**
|
2008-11-19 23:42:38 +01:00
|
|
|
* Gets a reference to the timeline view window object.
|
|
|
|
|
* @return Returns the timeline view window object.
|
2008-07-16 23:33:42 +02:00
|
|
|
**/
|
2008-11-19 23:42:38 +01:00
|
|
|
timeline::TimelineViewWindow& get_view_window();
|
2008-07-16 23:33:42 +02:00
|
|
|
|
2008-08-16 17:02:12 +02:00
|
|
|
/**
|
|
|
|
|
* Gets the time at which the selection begins.
|
|
|
|
|
*/
|
2008-08-07 21:27:41 +02:00
|
|
|
gavl_time_t get_selection_start() const;
|
|
|
|
|
|
2008-08-16 17:02:12 +02:00
|
|
|
/**
|
|
|
|
|
* Gets the time at which the selection begins.
|
|
|
|
|
*/
|
2008-08-07 21:27:41 +02:00
|
|
|
gavl_time_t get_selection_end() const;
|
|
|
|
|
|
2008-08-16 17:02:12 +02:00
|
|
|
/**
|
|
|
|
|
* Sets the period of the selection.
|
2008-08-30 23:34:26 +02:00
|
|
|
* @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.
|
2008-08-16 17:02:12 +02:00
|
|
|
*/
|
2008-08-30 23:34:26 +02:00
|
|
|
void set_selection(gavl_time_t start, gavl_time_t end,
|
|
|
|
|
bool reset_playback_period = true);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Gets the time at which the playback period begins.
|
|
|
|
|
*/
|
|
|
|
|
gavl_time_t get_playback_period_start() const;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Gets the time at which the playback period ends.
|
|
|
|
|
*/
|
|
|
|
|
gavl_time_t get_playback_period_end() const;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Sets the playback period.
|
|
|
|
|
* @param start The start time.
|
|
|
|
|
* @param end The end time.
|
|
|
|
|
*/
|
|
|
|
|
void set_playback_period(gavl_time_t start, gavl_time_t end);
|
2008-08-07 21:27:41 +02:00
|
|
|
|
2008-10-07 22:17:29 +02:00
|
|
|
/**
|
|
|
|
|
* 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(gavl_time_t 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.
|
|
|
|
|
*/
|
|
|
|
|
gavl_time_t get_playback_point() const;
|
|
|
|
|
|
2008-08-16 17:02:12 +02:00
|
|
|
/**
|
|
|
|
|
* Gets the type of the tool currently active.
|
|
|
|
|
*/
|
2008-07-30 01:12:37 +02:00
|
|
|
timeline::ToolType get_tool() const;
|
|
|
|
|
|
2008-08-16 17:02:12 +02:00
|
|
|
/**
|
|
|
|
|
* Sets the type of the tool currently active.
|
|
|
|
|
*/
|
2008-07-30 01:12:37 +02:00
|
|
|
void set_tool(timeline::ToolType tool_type);
|
2008-08-16 23:06:46 +02:00
|
|
|
|
2008-12-08 23:30:54 +01:00
|
|
|
boost::shared_ptr<timeline::Track> get_hovering_track() const;
|
2008-11-15 16:17:26 +01:00
|
|
|
|
2008-08-16 23:06:46 +02:00
|
|
|
public:
|
|
|
|
|
/* ===== Signals ===== */
|
|
|
|
|
sigc::signal<void, gavl_time_t> mouse_hover_signal() const;
|
2008-10-07 22:17:29 +02:00
|
|
|
|
|
|
|
|
sigc::signal<void> playback_period_drag_released_signal() const;
|
2008-11-15 16:17:26 +01:00
|
|
|
|
2008-12-08 23:30:54 +01:00
|
|
|
sigc::signal<void, boost::shared_ptr<timeline::Track> >
|
|
|
|
|
hovering_track_changed_signal() const;
|
2008-11-19 23:42:38 +01:00
|
|
|
|
2008-06-23 11:54:37 +02:00
|
|
|
/* ===== Events ===== */
|
|
|
|
|
protected:
|
2008-10-18 00:36:37 +02:00
|
|
|
|
2008-06-23 11:54:37 +02:00
|
|
|
void on_scroll();
|
|
|
|
|
|
|
|
|
|
void on_size_allocate(Gtk::Allocation& allocation);
|
2008-08-07 21:27:41 +02:00
|
|
|
|
2008-11-19 23:42:38 +01:00
|
|
|
void on_view_window_changed();
|
|
|
|
|
|
2008-12-17 01:03:30 +01:00
|
|
|
void on_add_track_command();
|
|
|
|
|
|
2008-08-07 21:27:41 +02:00
|
|
|
/* ===== Utilities ===== */
|
|
|
|
|
protected:
|
2008-11-19 23:42:38 +01:00
|
|
|
|
2008-05-31 14:22:15 +02:00
|
|
|
|
2008-06-23 11:54:37 +02:00
|
|
|
/* ===== Internals ===== */
|
2008-08-07 21:27:41 +02:00
|
|
|
private:
|
2008-05-31 14:22:15 +02:00
|
|
|
|
2008-12-10 18:22:49 +01:00
|
|
|
// ----- Track Mapping Functions ----- //
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Updates the timeline widget to match the state of the track tree.
|
|
|
|
|
**/
|
2008-06-23 11:54:37 +02:00
|
|
|
void update_tracks();
|
|
|
|
|
|
2008-11-29 17:40:50 +01:00
|
|
|
/**
|
|
|
|
|
* Ensures timeline UI tracks have been created for every model track
|
|
|
|
|
* present in sequence.
|
|
|
|
|
**/
|
2008-11-29 17:13:58 +01:00
|
|
|
void create_timeline_tracks();
|
|
|
|
|
|
2008-11-29 17:40:50 +01:00
|
|
|
/**
|
|
|
|
|
* Iterates through a branch of tracks, recursing into each sub-branch
|
2008-11-29 18:02:27 +01:00
|
|
|
* creating UI timeline tracks for each model track if they don't
|
2008-11-29 17:40:50 +01:00
|
|
|
* already exist in trackMap.
|
2008-11-29 18:02:27 +01:00
|
|
|
* @param list The parent track of the branch.
|
2008-11-29 17:40:50 +01:00
|
|
|
**/
|
2008-11-29 17:13:58 +01:00
|
|
|
void create_timeline_tracks_from_branch(
|
2008-12-06 15:08:03 +01:00
|
|
|
boost::shared_ptr<model::Track> model_track);
|
2008-11-29 17:40:50 +01:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Creates a timeline UI track to correspond to a model track.
|
|
|
|
|
* @param model_track The model track to create a timeline track from.
|
2008-12-08 23:30:54 +01:00
|
|
|
* @return The timeline track created, or an empty shared_ptr if
|
|
|
|
|
* model_track has an unreckognised type (this is an error condition).
|
2008-11-29 17:40:50 +01:00
|
|
|
**/
|
2008-12-08 23:30:54 +01:00
|
|
|
static boost::shared_ptr<timeline::Track>
|
|
|
|
|
create_timeline_track_from_model_track(
|
2008-12-06 15:08:03 +01:00
|
|
|
boost::shared_ptr<model::Track> model_track);
|
2008-11-29 17:13:58 +01:00
|
|
|
|
2008-11-29 17:40:50 +01:00
|
|
|
/**
|
|
|
|
|
* Looks up a timeline UI track in trackMap that corresponds to a
|
|
|
|
|
* given model_track.
|
|
|
|
|
* @param model_track The model track to look up.
|
2008-12-08 23:30:54 +01:00
|
|
|
* @returns The timeline UI track found, or an empty shared_ptr if
|
|
|
|
|
* model_track has no corresponding timeline UI track (this is an
|
|
|
|
|
* error condition).
|
2008-11-29 17:40:50 +01:00
|
|
|
**/
|
2008-12-08 23:30:54 +01:00
|
|
|
boost::shared_ptr<timeline::Track> lookup_timeline_track(
|
2008-12-06 15:08:03 +01:00
|
|
|
boost::shared_ptr<model::Track> model_track);
|
2008-11-29 17:13:58 +01:00
|
|
|
|
2008-12-10 18:22:49 +01:00
|
|
|
// ----- Layout Functions ----- //
|
|
|
|
|
|
2008-06-23 11:54:37 +02:00
|
|
|
void update_scroll();
|
|
|
|
|
|
2008-12-06 15:08:03 +01:00
|
|
|
int measure_branch_height(
|
|
|
|
|
boost::shared_ptr<model::Track> model_track);
|
2008-10-23 00:11:23 +02:00
|
|
|
|
2008-06-23 11:54:37 +02:00
|
|
|
int get_y_scroll_offset() const;
|
|
|
|
|
|
2008-12-10 18:22:49 +01:00
|
|
|
// ----- Event Handlers -----//
|
2008-12-17 01:03:30 +01:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* An event handler that receives notifications for when the
|
|
|
|
|
* sequence's track tree has been changed.
|
|
|
|
|
**/
|
|
|
|
|
void on_track_list_changed();
|
2008-12-10 18:22:49 +01:00
|
|
|
|
2008-10-07 22:17:29 +02:00
|
|
|
void on_playback_period_drag_released();
|
2008-11-15 16:17:26 +01:00
|
|
|
|
2008-12-10 18:22:49 +01:00
|
|
|
bool on_motion_in_body_notify_event(GdkEventMotion *event);
|
|
|
|
|
|
|
|
|
|
// ----- Other Functions ----- //
|
|
|
|
|
|
2008-12-08 23:30:54 +01:00
|
|
|
void set_hovering_track(
|
|
|
|
|
boost::shared_ptr<timeline::Track> hovering_track);
|
2008-06-23 11:54:37 +02:00
|
|
|
|
|
|
|
|
protected:
|
2008-08-07 21:27:41 +02:00
|
|
|
|
2008-11-29 17:13:58 +01:00
|
|
|
// Model Data
|
2008-12-10 18:22:49 +01:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 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.
|
|
|
|
|
**/
|
2008-12-05 21:17:56 +01:00
|
|
|
const boost::shared_ptr<model::Sequence> sequence;
|
2008-12-10 18:22:49 +01:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The trackMap maps model tracks to timeline widget tracks which are
|
|
|
|
|
* responsible for the UI representation of a track.
|
|
|
|
|
* @remarks The tree structure is maintianed by the model, and as the
|
|
|
|
|
* widget is updated with update_tracks, timeline tracks are added and
|
|
|
|
|
* removed from the map in correspondance with the tree.
|
|
|
|
|
**/
|
2008-12-08 23:30:54 +01:00
|
|
|
std::map<const model::Track*, boost::shared_ptr<timeline::Track> >
|
|
|
|
|
trackMap;
|
2008-11-29 17:13:58 +01:00
|
|
|
|
2008-08-07 21:27:41 +02:00
|
|
|
// View State
|
2008-11-19 23:42:38 +01:00
|
|
|
timeline::TimelineViewWindow viewWindow;
|
2008-08-07 21:27:41 +02:00
|
|
|
|
|
|
|
|
// Selection State
|
|
|
|
|
gavl_time_t selectionStart;
|
|
|
|
|
gavl_time_t selectionEnd;
|
2008-08-30 23:34:26 +02:00
|
|
|
gavl_time_t playbackPeriodStart;
|
|
|
|
|
gavl_time_t playbackPeriodEnd;
|
2008-10-07 22:17:29 +02:00
|
|
|
gavl_time_t playbackPoint;
|
2008-11-15 16:17:26 +01:00
|
|
|
|
2008-12-08 23:30:54 +01:00
|
|
|
boost::shared_ptr<timeline::Track> hoveringTrack;
|
2008-06-23 11:54:37 +02:00
|
|
|
|
|
|
|
|
int totalHeight;
|
|
|
|
|
|
2008-10-07 22:17:29 +02:00
|
|
|
// Child Widgets
|
2008-10-18 12:20:02 +02:00
|
|
|
timeline::TimelineHeaderContainer *headerContainer;
|
2008-06-23 11:54:37 +02:00
|
|
|
timeline::TimelineBody *body;
|
2008-08-07 21:27:41 +02:00
|
|
|
timeline::TimelineRuler *ruler;
|
2008-06-23 11:54:37 +02:00
|
|
|
|
|
|
|
|
Gtk::Adjustment horizontalAdjustment, verticalAdjustment;
|
|
|
|
|
Gtk::HScrollbar horizontalScroll;
|
|
|
|
|
Gtk::VScrollbar verticalScroll;
|
2008-08-16 23:06:46 +02:00
|
|
|
|
2008-09-02 23:39:53 +02:00
|
|
|
// Signals
|
2008-08-16 23:06:46 +02:00
|
|
|
sigc::signal<void, gavl_time_t> mouseHoverSignal;
|
2008-10-23 00:11:23 +02:00
|
|
|
sigc::signal<void> playbackPeriodDragReleasedSignal;
|
2008-12-08 23:30:54 +01:00
|
|
|
sigc::signal<void, boost::shared_ptr<timeline::Track> >
|
|
|
|
|
hoveringTrackChangedSignal;
|
2008-07-30 01:12:37 +02:00
|
|
|
|
2008-06-23 11:54:37 +02:00
|
|
|
/* ===== Constants ===== */
|
2008-07-16 23:33:42 +02:00
|
|
|
public:
|
2008-09-02 23:39:53 +02:00
|
|
|
/**
|
|
|
|
|
* The maximum scale for timeline display.
|
|
|
|
|
* @remarks At MaxScale, every pixel on the timeline is equivalent
|
|
|
|
|
* to 30000000 gavl_time_t increments.
|
|
|
|
|
*/
|
2008-07-16 23:33:42 +02:00
|
|
|
static const int64_t MaxScale;
|
|
|
|
|
|
2008-06-23 11:54:37 +02:00
|
|
|
protected:
|
|
|
|
|
static const int TrackPadding;
|
|
|
|
|
static const int HeaderWidth;
|
2008-06-23 12:17:19 +02:00
|
|
|
static const double ZoomIncrement;
|
2008-06-23 11:54:37 +02:00
|
|
|
|
2008-11-19 23:42:38 +01:00
|
|
|
friend class timeline::TimelineViewWindow;
|
2008-06-23 11:54:37 +02:00
|
|
|
friend class timeline::TimelineBody;
|
2008-10-18 12:20:02 +02:00
|
|
|
friend class timeline::TimelineHeaderContainer;
|
2008-08-07 21:27:41 +02:00
|
|
|
friend class timeline::TimelineRuler;
|
2008-08-04 17:39:36 +02:00
|
|
|
friend class timeline::Tool;
|
2008-08-07 21:27:41 +02:00
|
|
|
friend class timeline::ArrowTool;
|
|
|
|
|
friend class timeline::IBeamTool;
|
2008-06-23 11:54:37 +02:00
|
|
|
};
|
2008-04-12 22:15:07 +02:00
|
|
|
|
2008-04-19 21:31:27 +02:00
|
|
|
} // namespace widgets
|
2008-04-12 22:15:07 +02:00
|
|
|
} // namespace gui
|
|
|
|
|
|
2008-04-19 21:31:27 +02:00
|
|
|
#endif // TIMELINE_WIDGET_HPP
|
2008-05-31 14:22:15 +02:00
|
|
|
|