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-06-07 14:53:17 +02:00
|
|
|
#include "../gtk-lumiera.hpp"
|
2008-06-05 21:27:53 +02:00
|
|
|
#include "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-05-31 14:22:15 +02:00
|
|
|
#include "timeline/track.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-06-23 11:54:37 +02:00
|
|
|
TimelineWidget();
|
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:
|
|
|
|
|
/**
|
|
|
|
|
* Gets the time offset. This is the time value displaid at the
|
|
|
|
|
* left-hand edge of the timeline body area.
|
|
|
|
|
*/
|
|
|
|
|
gavl_time_t get_time_offset() const;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Sets the time offset. This is the time value displaid at the
|
|
|
|
|
* left-hand edge of the timeline body area.
|
|
|
|
|
*/
|
|
|
|
|
void set_time_offset(gavl_time_t time_offset);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Gets the time scale value.
|
|
|
|
|
* @return The scale factor, which is the number of microseconds per
|
|
|
|
|
* screen pixel.
|
|
|
|
|
*/
|
|
|
|
|
int64_t get_time_scale() const;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Sets the time scale value.
|
|
|
|
|
* @param time_scale The scale factor, which is the number of
|
|
|
|
|
* microseconds per screen pixel. This value must be greater than
|
|
|
|
|
* zero
|
|
|
|
|
*/
|
|
|
|
|
void set_time_scale(int64_t time_scale);
|
2008-07-16 23:33:42 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Zooms the view in or out as by a number of steps while keeping
|
|
|
|
|
* centre of the view 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);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 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 point, int zoom_size);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Scrolls the view horizontally as a proportion of the view area.
|
2008-08-15 23:40:57 +02:00
|
|
|
* @param shift_size The size of the shift in 1/256ths of the view
|
2008-07-16 23:33:42 +02:00
|
|
|
* width.
|
|
|
|
|
**/
|
|
|
|
|
void shift_view(int shift_size);
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
/* ===== Signals ===== */
|
2008-09-02 23:39:53 +02:00
|
|
|
sigc::signal<void> view_changed_signal() const;
|
|
|
|
|
|
2008-08-16 23:06:46 +02:00
|
|
|
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-08-07 21:27:41 +02: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
|
|
|
|
|
|
|
|
/* ===== Utilities ===== */
|
|
|
|
|
protected:
|
|
|
|
|
int time_to_x(gavl_time_t time) const;
|
|
|
|
|
|
|
|
|
|
gavl_time_t x_to_time(int x) const;
|
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-06-23 11:54:37 +02:00
|
|
|
void update_tracks();
|
|
|
|
|
|
|
|
|
|
void update_scroll();
|
|
|
|
|
|
|
|
|
|
int get_y_scroll_offset() const;
|
|
|
|
|
|
2008-07-17 20:07:38 +02:00
|
|
|
bool on_motion_in_body_notify_event(GdkEventMotion *event);
|
2008-10-07 22:17:29 +02:00
|
|
|
|
|
|
|
|
void on_playback_period_drag_released();
|
2008-06-23 11:54:37 +02:00
|
|
|
|
|
|
|
|
protected:
|
2008-08-07 21:27:41 +02:00
|
|
|
|
|
|
|
|
// View State
|
2008-06-23 18:07:57 +02:00
|
|
|
gavl_time_t timeOffset;
|
2008-06-23 11:54:37 +02:00
|
|
|
int64_t timeScale;
|
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-06-23 11:54:37 +02:00
|
|
|
|
|
|
|
|
int totalHeight;
|
|
|
|
|
|
2008-07-17 20:35:49 +02:00
|
|
|
timeline::Track video1;
|
|
|
|
|
timeline::Track video2;
|
2008-06-23 11:54:37 +02:00
|
|
|
std::vector<timeline::Track*> tracks;
|
|
|
|
|
|
2008-10-07 22:17:29 +02:00
|
|
|
// Child Widgets
|
2008-06-23 11:54:37 +02:00
|
|
|
timeline::HeaderContainer *headerContainer;
|
|
|
|
|
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
|
|
|
|
|
sigc::signal<void> viewChangedSignal;
|
2008-08-16 23:06:46 +02:00
|
|
|
sigc::signal<void, gavl_time_t> mouseHoverSignal;
|
2008-10-07 22:17:29 +02:00
|
|
|
sigc::signal<void>
|
|
|
|
|
playbackPeriodDragReleasedSignal;
|
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
|
|
|
|
|
|
|
|
friend class timeline::TimelineBody;
|
|
|
|
|
friend class timeline::HeaderContainer;
|
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
|
|
|
|