lumiera_/src/gui/widgets/timeline-widget.hpp

304 lines
8.3 KiB
C++
Raw Normal View History

/*
2008-05-31 14:22:15 +02:00
timeline-widget.hpp - Declaration of the timeline widget
2010-12-17 23:28:49 +01:00
Copyright (C) Lumiera.org
2008, Joel Holdsworth <joel@airwebreathe.org.uk>
2010-12-17 23:28:49 +01:00
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
2010-12-17 23:28:49 +01:00
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.
2010-12-17 23:28:49 +01:00
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.
2010-12-17 23:28:49 +01:00
*/
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-19 21:31:27 +02:00
#ifndef TIMELINE_WIDGET_HPP
#define TIMELINE_WIDGET_HPP
#include "timeline/timeline-state.hpp"
#include "timeline/timeline-header-container.hpp"
2008-05-31 14:22:15 +02:00
#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"
2008-05-31 14:22:15 +02:00
#include "gui/model/sequence.hpp"
2008-11-29 17:13:58 +01: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-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
{
public:
2008-10-07 22:17:29 +02:00
/**
* Constructor
2009-03-27 15:26:08 +01:00
* @param source_state The state that will be used as the data source
* for this timeline widget.
2008-10-07 22:17:29 +02:00
*/
TimelineWidget(
boost::shared_ptr<timeline::TimelineState> source_state);
2008-05-31 14:22:15 +02:00
2008-10-07 22:17:29 +02:00
/**
* Destructor
*/
~TimelineWidget();
/* ===== Data Access ===== */
public:
2009-03-27 15:26:08 +01:00
/**
* Gets a pointer to the current state object.
* @return The state object that the timeline widget is currently
* working with.
**/
boost::shared_ptr<timeline::TimelineState> get_state();
2008-10-07 22:17:29 +02:00
2009-03-27 15:26:08 +01:00
/**
* Replaces the current TimelineState object with another.
* @param new_state The new state to swap in.
**/
void set_state(boost::shared_ptr<timeline::TimelineState> new_state);
2008-10-07 22:17:29 +02:00
/**
* Zooms the view in or out as by a number of steps while keeping a
* given point on the timeline still.
* @param zoom_size The number of steps to zoom by. The scale factor
* is 1.25^(-zoom_size).
**/
void zoom_view(int zoom_size);
2008-10-07 22:17:29 +02:00
/**
* Gets the type of the tool currently active.
*/
timeline::ToolType get_tool() const;
/**
* Sets the type of the tool currently active.
*/
void set_tool(timeline::ToolType tool_type);
2008-08-16 23:06:46 +02:00
2011-01-02 16:57:14 +01:00
boost::shared_ptr<timeline::Track>
get_hovering_track() const;
2008-08-16 23:06:46 +02:00
public:
/* ===== Signals ===== */
sigc::signal<void, lumiera::Time> mouse_hover_signal() const;
2008-10-07 22:17:29 +02:00
sigc::signal<void> playback_period_drag_released_signal() const;
sigc::signal<void, boost::shared_ptr<timeline::Track> >
hovering_track_changed_signal() const;
2009-03-27 15:26:08 +01:00
sigc::signal<void> state_changed_signal() const;
/* ===== Events ===== */
protected:
2008-10-18 00:36:37 +02:00
void on_scroll();
void on_size_allocate(Gtk::Allocation& allocation);
void on_view_window_changed();
void on_body_changed();
void on_add_track_command();
/* ===== Utilities ===== */
protected:
2008-05-31 14:22:15 +02:00
/* ===== Internals ===== */
private:
2008-05-31 14:22:15 +02:00
// ----- Track Mapping Functions ----- //
/**
* Updates the timeline widget to match the state of the track tree.
**/
void update_tracks();
2009-01-22 00:48:56 +01:00
void freeze_update_tracks();
void thaw_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(
boost::shared_ptr<model::Track> modelTrack);
2008-11-29 17:40:50 +01:00
/**
* Creates a timeline UI track to correspond to a model track.
* @param modelTrack The model track to create a timeline track from.
* @return The timeline track created, or an empty shared_ptr if
* modelTrack has an unreckognised type (this is an error condition).
2008-11-29 17:40:50 +01:00
**/
2008-12-20 15:31:11 +01:00
boost::shared_ptr<timeline::Track>
create_timeline_track_from_modelTrack(
boost::shared_ptr<model::Track> modelTrack);
2008-11-29 17:13:58 +01:00
2008-12-20 15:31:11 +01:00
/**
* Removes any UI tracks which no longer have corresponding model
* tracks present in the sequence.
**/
void remove_orphaned_tracks();
void search_orphaned_tracks_in_branch(
boost::shared_ptr<model::Track> modelTrack,
2008-12-20 15:31:11 +01:00
std::map<boost::shared_ptr<model::Track>,
boost::shared_ptr<timeline::Track> > &orphan_track_map);
2008-11-29 17:40:50 +01:00
/**
* Looks up a timeline UI track in trackMap that corresponds to a
* given modelTrack.
* @param modelTrack The model track to look up.
* @returns The timeline UI track found, or an empty shared_ptr if
* modelTrack has no corresponding timeline UI track (this is an
* error condition).
2008-11-29 17:40:50 +01:00
**/
boost::shared_ptr<timeline::Track> lookup_timeline_track(
boost::shared_ptr<model::Track> modelTrack) const;
2008-11-29 17:13:58 +01:00
// ----- Layout Functions ----- //
void on_layout_changed();
void update_scroll();
int get_y_scroll_offset() const;
void set_y_scroll_offset(const int offset);
// ----- Event Handlers -----//
/**
* An event handler that receives notifications for when the
* sequence's track tree has been changed.
**/
void on_track_list_changed();
2008-10-07 22:17:29 +02:00
void on_playback_period_drag_released();
bool on_motion_in_body_notify_event(GdkEventMotion *event);
// ----- Helper Functions ----- //
/**
* Helper to get the sequence object from the state.
* @return Returns a shared pointer to the sequence.
**/
boost::shared_ptr<model::Sequence> sequence() const;
// ----- Other Functions ----- //
void set_hovering_track(
boost::shared_ptr<timeline::Track> hovering_track);
protected:
2009-03-27 15:26:08 +01:00
/**
* The state that will be used as the data source for this timeline
* widget.
**/
boost::shared_ptr<timeline::TimelineState> state;
2008-11-29 17:13:58 +01:00
// Model Data
/**
* The trackMap maps model tracks to timeline widget tracks which are
* responsible for the UI representation of a track.
* @remarks The tree structure is maintained by the model, and as the
* widget is updated with update_tracks, timeline tracks are added and
* removed from the map in correspondence with the tree.
**/
std::map<boost::shared_ptr<model::Track>,
boost::shared_ptr<timeline::Track> >
trackMap;
boost::shared_ptr<timeline::Track> hoveringTrack;
// Helper Classes
timeline::TimelineLayoutHelper layoutHelper;
2008-11-29 17:13:58 +01:00
2008-10-07 22:17:29 +02:00
// Child Widgets
timeline::TimelineHeaderContainer *headerContainer;
timeline::TimelineBody *body;
timeline::TimelineRuler *ruler;
Gtk::Adjustment horizontalAdjustment, verticalAdjustment;
Gtk::HScrollbar horizontalScroll;
Gtk::VScrollbar verticalScroll;
2008-08-16 23:06:46 +02:00
// Signals
sigc::signal<void, lumiera::Time> mouseHoverSignal;
sigc::signal<void> playbackPeriodDragReleasedSignal;
sigc::signal<void, boost::shared_ptr<timeline::Track> >
hoveringTrackChangedSignal;
2009-03-27 15:26:08 +01:00
sigc::signal<void> stateChangedSignal;
2009-01-22 00:48:56 +01:00
bool update_tracks_frozen;
/* ===== Constants ===== */
public:
/**
* The maximum scale for timeline display.
* @remarks At MaxScale, every pixel on the timeline is equivalent
* to 30000000 lumiera::Time increments.
*/
static const int64_t MaxScale;
protected:
static const int TrackPadding;
static const int HeaderWidth;
2009-01-02 14:18:09 +01:00
static const int HeaderIndentWidth;
static const double ZoomIncrement;
friend class timeline::TimelineBody;
friend class timeline::TimelineHeaderContainer;
friend class timeline::TimelineHeaderWidget;
friend class timeline::TimelineLayoutHelper;
friend class timeline::TimelineRuler;
friend class timeline::GroupTrack;
};
2008-04-19 21:31:27 +02:00
} // namespace widgets
} // namespace gui
2008-04-19 21:31:27 +02:00
#endif // TIMELINE_WIDGET_HPP
2008-05-31 14:22:15 +02:00