2012-02-02 00:59:12 +01:00
|
|
|
// Copyright (c) 2012, Thomas Goyne <plorkyeran@aegisub.org>
|
|
|
|
//
|
|
|
|
// Permission to use, copy, modify, and distribute this software for any
|
|
|
|
// purpose with or without fee is hereby granted, provided that the above
|
|
|
|
// copyright notice and this permission notice appear in all copies.
|
|
|
|
//
|
|
|
|
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
|
|
// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
|
|
// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
|
|
// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
|
|
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
|
|
// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
|
|
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
//
|
|
|
|
// Aegisub Project http://www.aegisub.org/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2014-05-23 00:40:16 +02:00
|
|
|
#include "time_range.h"
|
|
|
|
|
2012-02-02 00:59:12 +01:00
|
|
|
#include <libaegisub/signal.h>
|
|
|
|
|
2013-06-08 06:19:40 +02:00
|
|
|
#include <memory>
|
2012-02-02 00:59:12 +01:00
|
|
|
#include <vector>
|
2012-02-02 20:18:10 +01:00
|
|
|
#include <wx/string.h>
|
2012-02-02 00:59:12 +01:00
|
|
|
|
|
|
|
class AudioMarkerKeyframe;
|
|
|
|
class Pen;
|
2014-05-22 01:23:28 +02:00
|
|
|
class Project;
|
|
|
|
class VideoController;
|
2012-02-02 00:59:12 +01:00
|
|
|
class VideoPositionMarker;
|
2012-02-02 20:18:10 +01:00
|
|
|
class wxPen;
|
2012-02-02 00:59:12 +01:00
|
|
|
|
|
|
|
namespace agi {
|
|
|
|
class OptionValue;
|
|
|
|
struct Context;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// @class AudioMarker
|
|
|
|
/// @brief A marker on the audio display
|
|
|
|
class AudioMarker {
|
2014-12-31 04:11:57 +01:00
|
|
|
protected:
|
|
|
|
~AudioMarker()=default;
|
2012-02-02 00:59:12 +01:00
|
|
|
public:
|
|
|
|
/// Describe which directions a marker has feet in
|
|
|
|
enum FeetStyle {
|
|
|
|
Feet_None = 0,
|
|
|
|
Feet_Left,
|
|
|
|
Feet_Right,
|
|
|
|
Feet_Both // Conveniently Feet_Left|Feet_Right
|
|
|
|
};
|
|
|
|
|
|
|
|
/// @brief Get the marker's position
|
|
|
|
/// @return The marker's position in milliseconds
|
|
|
|
virtual int GetPosition() const = 0;
|
|
|
|
|
|
|
|
/// @brief Get the marker's drawing style
|
|
|
|
/// @return A pen object describing the marker's drawing style
|
|
|
|
virtual wxPen GetStyle() const = 0;
|
|
|
|
|
|
|
|
/// @brief Get the marker's feet style
|
|
|
|
/// @return The marker's feet style
|
|
|
|
virtual FeetStyle GetFeet() const = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef std::vector<const AudioMarker*> AudioMarkerVector;
|
|
|
|
|
|
|
|
/// Abstract interface for audio marker providers
|
|
|
|
class AudioMarkerProvider {
|
|
|
|
protected:
|
|
|
|
/// One or more of the markers provided by this object have changed
|
|
|
|
agi::signal::Signal<> AnnounceMarkerMoved;
|
|
|
|
|
2014-12-31 04:11:57 +01:00
|
|
|
~AudioMarkerProvider() = default;
|
|
|
|
public:
|
2012-02-02 00:59:12 +01:00
|
|
|
/// @brief Return markers in a time range
|
|
|
|
virtual void GetMarkers(const TimeRange &range, AudioMarkerVector &out) const = 0;
|
|
|
|
|
|
|
|
DEFINE_SIGNAL_ADDERS(AnnounceMarkerMoved, AddMarkerMovedListener)
|
|
|
|
};
|
|
|
|
|
|
|
|
/// @class AudioLabelProvider
|
|
|
|
/// @brief Abstract interface for audio label providers
|
|
|
|
class AudioLabelProvider {
|
|
|
|
protected:
|
|
|
|
/// One or more of the labels provided by this object have changed
|
|
|
|
agi::signal::Signal<> AnnounceLabelChanged;
|
2014-12-31 04:11:57 +01:00
|
|
|
|
|
|
|
~AudioLabelProvider() = default;
|
2012-02-02 00:59:12 +01:00
|
|
|
public:
|
|
|
|
/// A label for a range of time on the audio display
|
|
|
|
struct AudioLabel {
|
|
|
|
/// Text of the label
|
|
|
|
wxString text;
|
|
|
|
/// Range which this label applies to
|
|
|
|
TimeRange range;
|
|
|
|
};
|
|
|
|
|
|
|
|
/// @brief Get labels in a time range
|
|
|
|
/// @param range Range of times to get labels for
|
|
|
|
/// @param[out] out Vector which should be filled with the labels
|
|
|
|
virtual void GetLabels(TimeRange const& range, std::vector<AudioLabel> &out) const = 0;
|
|
|
|
|
|
|
|
DEFINE_SIGNAL_ADDERS(AnnounceLabelChanged, AddLabelChangedListener)
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/// Marker provider for video keyframes
|
2014-03-13 02:39:07 +01:00
|
|
|
class AudioMarkerProviderKeyframes final : public AudioMarkerProvider {
|
2014-05-22 01:23:28 +02:00
|
|
|
/// Project to get keyframes from
|
|
|
|
Project *p;
|
2012-02-02 00:59:12 +01:00
|
|
|
|
|
|
|
agi::signal::Connection keyframe_slot;
|
|
|
|
agi::signal::Connection timecode_slot;
|
|
|
|
agi::signal::Connection enabled_slot;
|
|
|
|
const agi::OptionValue *enabled_opt;
|
|
|
|
|
|
|
|
/// Current set of markers for the keyframes
|
|
|
|
std::vector<AudioMarkerKeyframe> markers;
|
|
|
|
|
|
|
|
/// Pen used for all keyframe markers, stored here for performance reasons
|
2013-06-08 06:19:40 +02:00
|
|
|
std::unique_ptr<Pen> style;
|
2012-02-02 00:59:12 +01:00
|
|
|
|
|
|
|
/// Regenerate the list of markers
|
|
|
|
void Update();
|
|
|
|
|
|
|
|
public:
|
|
|
|
/// Constructor
|
|
|
|
/// @param c Project context; must have audio and video controllers initialized
|
|
|
|
/// @param opt_name Name of the option to use to decide whether or not this provider is enabled
|
|
|
|
AudioMarkerProviderKeyframes(agi::Context *c, const char *opt_name);
|
|
|
|
/// Explicit destructor needed due to members with incomplete types
|
|
|
|
~AudioMarkerProviderKeyframes();
|
|
|
|
|
|
|
|
/// Get all keyframe markers within a range
|
|
|
|
/// @param range Time range to get markers for
|
|
|
|
/// @param[out] out Vector to fill with markers in the range
|
2013-11-21 18:13:36 +01:00
|
|
|
void GetMarkers(TimeRange const& range, AudioMarkerVector &out) const override;
|
2012-02-02 00:59:12 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
/// Marker provider for the current video playback position
|
2014-03-13 02:39:07 +01:00
|
|
|
class VideoPositionMarkerProvider final : public AudioMarkerProvider {
|
2014-05-22 01:23:28 +02:00
|
|
|
VideoController *vc;
|
2012-02-02 00:59:12 +01:00
|
|
|
|
2013-06-08 06:19:40 +02:00
|
|
|
std::unique_ptr<VideoPositionMarker> marker;
|
2012-02-02 00:59:12 +01:00
|
|
|
|
|
|
|
agi::signal::Connection video_seek_slot;
|
|
|
|
agi::signal::Connection enable_opt_changed_slot;
|
|
|
|
|
|
|
|
void Update(int frame_number);
|
|
|
|
void OptChanged(agi::OptionValue const& opt);
|
|
|
|
|
|
|
|
public:
|
|
|
|
VideoPositionMarkerProvider(agi::Context *c);
|
|
|
|
~VideoPositionMarkerProvider();
|
|
|
|
|
2013-11-21 18:13:36 +01:00
|
|
|
void GetMarkers(const TimeRange &range, AudioMarkerVector &out) const override;
|
2012-02-02 00:59:12 +01:00
|
|
|
};
|
2012-04-27 21:07:29 +02:00
|
|
|
|
|
|
|
/// Marker provider for lines every second
|
2014-03-13 02:39:07 +01:00
|
|
|
class SecondsMarkerProvider final : public AudioMarkerProvider {
|
|
|
|
struct Marker final : public AudioMarker {
|
2012-04-27 21:07:29 +02:00
|
|
|
Pen *style;
|
2014-04-25 19:01:07 +02:00
|
|
|
int position = 0;
|
2012-04-27 21:07:29 +02:00
|
|
|
|
2014-04-25 19:01:07 +02:00
|
|
|
Marker(Pen *style) : style(style) { }
|
2013-11-21 18:13:36 +01:00
|
|
|
int GetPosition() const override { return position; }
|
|
|
|
FeetStyle GetFeet() const override { return Feet_None; }
|
|
|
|
wxPen GetStyle() const override;
|
2012-04-27 21:07:29 +02:00
|
|
|
operator int() const { return position; }
|
|
|
|
};
|
|
|
|
|
|
|
|
/// Pen used by all seconds markers, here for performance
|
2013-06-08 06:19:40 +02:00
|
|
|
std::unique_ptr<Pen> pen;
|
2012-04-27 21:07:29 +02:00
|
|
|
|
|
|
|
/// Markers returned from last call to GetMarkers
|
|
|
|
mutable std::vector<Marker> markers;
|
|
|
|
|
|
|
|
/// Cached reference to the option to enable/disable seconds markers
|
|
|
|
const agi::OptionValue *enabled;
|
|
|
|
|
|
|
|
/// Enabled option change connection
|
|
|
|
agi::signal::Connection enabled_opt_changed;
|
|
|
|
|
|
|
|
void EnabledOptChanged();
|
|
|
|
|
|
|
|
public:
|
|
|
|
SecondsMarkerProvider();
|
2013-11-21 18:13:36 +01:00
|
|
|
void GetMarkers(TimeRange const& range, AudioMarkerVector &out) const override;
|
2012-04-27 21:07:29 +02:00
|
|
|
};
|