diff --git a/aegisub/build/aegisub_vs2008/aegisub_vs2008.vcproj b/aegisub/build/aegisub_vs2008/aegisub_vs2008.vcproj
index 32bc99594..a040ae26a 100644
--- a/aegisub/build/aegisub_vs2008/aegisub_vs2008.vcproj
+++ b/aegisub/build/aegisub_vs2008/aegisub_vs2008.vcproj
@@ -887,6 +887,14 @@
RelativePath="..\..\src\mythes.hxx"
>
+
+
+
+
diff --git a/aegisub/build/msbuild/Aegisub/Aegisub.vcxproj b/aegisub/build/msbuild/Aegisub/Aegisub.vcxproj
index 079f5e217..8592e9a3c 100644
--- a/aegisub/build/msbuild/Aegisub/Aegisub.vcxproj
+++ b/aegisub/build/msbuild/Aegisub/Aegisub.vcxproj
@@ -153,6 +153,7 @@
+
@@ -344,6 +345,7 @@
+
diff --git a/aegisub/build/msbuild/Aegisub/Aegisub.vcxproj.filters b/aegisub/build/msbuild/Aegisub/Aegisub.vcxproj.filters
index 1ad000a0f..f0420b8b1 100644
--- a/aegisub/build/msbuild/Aegisub/Aegisub.vcxproj.filters
+++ b/aegisub/build/msbuild/Aegisub/Aegisub.vcxproj.filters
@@ -645,6 +645,9 @@
Preferences
+
+ Utilities\UI utilities
+
@@ -1193,6 +1196,9 @@
Commands
+
+ Utilities\UI utilities
+
diff --git a/aegisub/src/Makefile b/aegisub/src/Makefile
index 5b39dd04c..6b8370d59 100644
--- a/aegisub/src/Makefile
+++ b/aegisub/src/Makefile
@@ -198,6 +198,7 @@ SRC += \
md5.c \
mkv_wrap.cpp \
mythes.cxx \
+ pen.cpp \
persist_location.cpp \
plugin_manager.cpp \
preferences.cpp \
diff --git a/aegisub/src/audio_controller.cpp b/aegisub/src/audio_controller.cpp
index 13ed7b294..961d2c9b8 100644
--- a/aegisub/src/audio_controller.cpp
+++ b/aegisub/src/audio_controller.cpp
@@ -53,6 +53,7 @@
#include "include/aegisub/audio_player.h"
#include "include/aegisub/audio_provider.h"
#include "include/aegisub/context.h"
+#include "pen.h"
#include "main.h"
#include "selection_controller.h"
#include "standard_paths.h"
@@ -60,25 +61,18 @@
class AudioMarkerKeyframe : public AudioMarker {
int64_t position;
- static wxPen style;
+ Pen *style;
public:
- AudioMarkerKeyframe(int64_t position) : position(position) { }
+ AudioMarkerKeyframe(Pen *style, int64_t position) : style(style), position(position) { }
int64_t GetPosition() const { return position; }
FeetStyle GetFeet() const { return Feet_None; }
bool CanSnap() const { return true; }
- wxPen GetStyle() const
- {
- if (!style.IsOk())
- /// @todo Make this colour configurable
- style = wxPen(wxColour(255,0,255), 1);
- return style;
- }
+ wxPen GetStyle() const { return *style; }
bool operator < (const AudioMarkerKeyframe &other) const { return position < other.position; }
operator int64_t() const { return position; }
};
bool operator < (int64_t a, const AudioMarkerKeyframe &b) { return a < b.GetPosition(); }
bool operator < (const AudioMarkerKeyframe &a, int64_t b) { return a.GetPosition() < b; }
-wxPen AudioMarkerKeyframe::style;
class AudioMarkerProviderKeyframes : public AudioMarkerProvider {
VideoContext *vc;
@@ -90,6 +84,8 @@ class AudioMarkerProviderKeyframes : public AudioMarkerProvider {
std::vector keyframe_samples;
AudioController *controller;
+ Pen style;
+
void Update()
{
std::vector const& keyframes = vc->GetKeyFrames();
@@ -110,7 +106,7 @@ class AudioMarkerProviderKeyframes : public AudioMarkerProvider {
keyframe_samples.reserve(keyframes.size());
for (size_t i = 0; i < keyframes.size(); ++i)
{
- keyframe_samples.push_back(AudioMarkerKeyframe(
+ keyframe_samples.push_back(AudioMarkerKeyframe(&style,
controller->SamplesFromMilliseconds(timecodes.TimeAtFrame(keyframes[i]))));
}
AnnounceMarkerMoved();
@@ -118,11 +114,12 @@ class AudioMarkerProviderKeyframes : public AudioMarkerProvider {
public:
AudioMarkerProviderKeyframes(AudioController *controller, agi::Context *c)
- : vc(c->videoController)
- , keyframe_slot(vc->AddKeyframesListener(&AudioMarkerProviderKeyframes::Update, this))
- , audio_open_slot(controller->AddAudioOpenListener(&AudioMarkerProviderKeyframes::Update, this))
- , timecode_slot(vc->AddTimecodesListener(&AudioMarkerProviderKeyframes::Update, this))
- , controller(controller)
+ : vc(c->videoController)
+ , keyframe_slot(vc->AddKeyframesListener(&AudioMarkerProviderKeyframes::Update, this))
+ , audio_open_slot(controller->AddAudioOpenListener(&AudioMarkerProviderKeyframes::Update, this))
+ , timecode_slot(vc->AddTimecodesListener(&AudioMarkerProviderKeyframes::Update, this))
+ , controller(controller)
+ , style("Colour/Audio Display/Keyframe")
{
Update();
}
@@ -142,21 +139,14 @@ public:
};
class VideoPositionMarker : public AudioMarker {
- agi::signal::Connection colour_changed;
-
int64_t position;
- wxPen style;
+ Pen style;
- void OnColourChanged(agi::OptionValue const& opt)
- {
- style = wxPen(lagi_wxColour(opt.GetColour()), 1);
- }
public:
VideoPositionMarker()
- : colour_changed(OPT_SUB("Colour/Audio Display/Play Cursor", &VideoPositionMarker::OnColourChanged, this))
+ : style("Colour/Audio Display/Play Cursor")
, position(-1)
{
- OnColourChanged(*OPT_GET("Colour/Audio Display/Play Cursor"));
}
void SetPosition(int64_t new_pos)
diff --git a/aegisub/src/audio_timing_dialogue.cpp b/aegisub/src/audio_timing_dialogue.cpp
index 85d6f1e8e..ca5c0b477 100644
--- a/aegisub/src/audio_timing_dialogue.cpp
+++ b/aegisub/src/audio_timing_dialogue.cpp
@@ -46,6 +46,7 @@
#include "audio_timing.h"
#include "include/aegisub/context.h"
#include "main.h"
+#include "pen.h"
#include "selection_controller.h"
#include "utils.h"
@@ -66,6 +67,12 @@ class AudioMarkerDialogueTiming : public AudioMarker {
/// Foot style for the marker
FeetStyle feet;
+ /// Draw style for the left marker
+ Pen style_left;
+ /// Draw style for the right marker
+ Pen style_right;
+
+
public:
// AudioMarker interface
int64_t GetPosition() const { return position; }
@@ -198,9 +205,6 @@ void AudioMarkerDialogueTiming::SetPosition(int64_t new_position)
if (other)
{
- wxPen style_left(wxColour(OPT_GET("Colour/Audio Display/Line boundary Start")->GetColour()), 2);
- wxPen style_right(wxColour(OPT_GET("Colour/Audio Display/Line boundary End")->GetColour()), 2);
-
if (position < other->position)
{
feet = Feet_Right;
@@ -224,6 +228,8 @@ AudioMarkerDialogueTiming::AudioMarkerDialogueTiming()
, position(0)
, style(*wxTRANSPARENT_PEN)
, feet(Feet_None)
+, style_left("Colour/Audio Display/Line boundary Start", "Audio/Line Boundaries Thickness")
+, style_right("Colour/Audio Display/Line boundary End", "Audio/Line Boundaries Thickness")
{
// Nothing more to do
}
diff --git a/aegisub/src/audio_timing_karaoke.cpp b/aegisub/src/audio_timing_karaoke.cpp
index afc6e92db..e69e4974f 100644
--- a/aegisub/src/audio_timing_karaoke.cpp
+++ b/aegisub/src/audio_timing_karaoke.cpp
@@ -31,6 +31,7 @@
#include "audio_timing.h"
#include "include/aegisub/context.h"
#include "main.h"
+#include "pen.h"
#include "utils.h"
#ifndef AGI_PRE
@@ -41,7 +42,7 @@
/// @brief AudioMarker implementation for AudioTimingControllerKaraoke
class KaraokeMarker : public AudioMarker {
int64_t position;
- wxPen *pen;
+ Pen *pen;
FeetStyle style;
public:
@@ -52,7 +53,7 @@ public:
void Move(int64_t new_pos) { position = new_pos; }
- KaraokeMarker(int64_t position, wxPen *pen, FeetStyle style)
+ KaraokeMarker(int64_t position, Pen *pen, FeetStyle style)
: position(position)
, pen(pen)
, style(style)
@@ -82,11 +83,11 @@ class AudioTimingControllerKaraoke : public AudioTimingController {
size_t cur_syl; ///< Index of currently selected syllable in the line
/// Pen used for the mid-syllable markers
- wxPen separator_pen;
+ Pen separator_pen;
/// Pen used for the start-of-line marker
- wxPen start_pen;
+ Pen start_pen;
/// Pen used for the end-of-line marker
- wxPen end_pen;
+ Pen end_pen;
/// Immobile marker for the beginning of the line
KaraokeMarker start_marker;
@@ -105,9 +106,6 @@ class AudioTimingControllerKaraoke : public AudioTimingController {
void OnAutoCommitChange(agi::OptionValue const& opt);
void OnAutoNextChange(agi::OptionValue const& opt);
- /// Reload all style options from the user preferences
- void RegenStyles();
-
int64_t ToMS(int64_t samples) const { return c->audioController->MillisecondsFromSamples(samples); }
int64_t ToSamples(int64_t ms) const { return c->audioController->SamplesFromMilliseconds(ms); }
@@ -144,6 +142,9 @@ AudioTimingControllerKaraoke::AudioTimingControllerKaraoke(agi::Context *c, AssK
, active_line(c->selectionController->GetActiveLine())
, kara(kara)
, cur_syl(0)
+, separator_pen("Colour/Audio Display/Syllable Boundaries", "Audio/Line Boundaries Thickness", wxPENSTYLE_DOT)
+, start_pen("Colour/Audio Display/Line boundary Start", "Audio/Line Boundaries Thickness")
+, end_pen("Colour/Audio Display/Line boundary End", "Audio/Line Boundaries Thickness")
, start_marker(ToSamples(active_line->Start.GetMS()), &start_pen, AudioMarker::Feet_Right)
, end_marker(ToSamples(active_line->End.GetMS()), &end_pen, AudioMarker::Feet_Left)
, auto_commit(OPT_GET("Audio/Auto/Commit")->GetBool())
@@ -153,23 +154,11 @@ AudioTimingControllerKaraoke::AudioTimingControllerKaraoke(agi::Context *c, AssK
slots.push_back(kara->AddSyllablesChangedListener(&AudioTimingControllerKaraoke::Revert, this));
slots.push_back(OPT_SUB("Audio/Auto/Commit", &AudioTimingControllerKaraoke::OnAutoCommitChange, this));
slots.push_back(OPT_SUB("Audio/Next Line on Commit", &AudioTimingControllerKaraoke::OnAutoNextChange, this));
- slots.push_back(OPT_SUB("Audio/Line Boundaries Thickness", &AudioTimingControllerKaraoke::RegenStyles, this));
- slots.push_back(OPT_SUB("Colour/Audio Display/Syllable Boundaries", &AudioTimingControllerKaraoke::RegenStyles, this));
- slots.push_back(OPT_SUB("Colour/Audio Display/Line boundary Start", &AudioTimingControllerKaraoke::RegenStyles, this));
- slots.push_back(OPT_SUB("Colour/Audio Display/Line boundary End", &AudioTimingControllerKaraoke::RegenStyles, this));
- RegenStyles();
Revert();
}
-void AudioTimingControllerKaraoke::RegenStyles() {
- int width = OPT_GET("Audio/Line Boundaries Thickness")->GetInt();
- separator_pen = wxPen(wxColour(OPT_GET("Colour/Audio Display/Syllable Boundaries")->GetColour()), 1, wxPENSTYLE_DOT);
- start_pen = wxPen(wxColour(OPT_GET("Colour/Audio Display/Line boundary Start")->GetColour()), width);
- end_pen = wxPen(wxColour(OPT_GET("Colour/Audio Display/Line boundary End")->GetColour()), width);
-}
-
void AudioTimingControllerKaraoke::OnAutoCommitChange(agi::OptionValue const& opt) {
auto_commit = opt.GetBool();
}
diff --git a/aegisub/src/libresrc/default_config.json b/aegisub/src/libresrc/default_config.json
index ff8e4f261..4196222d4 100644
--- a/aegisub/src/libresrc/default_config.json
+++ b/aegisub/src/libresrc/default_config.json
@@ -98,6 +98,7 @@
"Selection" : "rgb(64, 64, 64)",
"Selection Modified" : "rgb(92, 0, 0)"
},
+ "Keyframe" : "rgb(255,0,255)",
"Line Boundary Inactive Line" : "rgb(190,190,190)",
"Line boundary End" : "rgb(0, 0, 216)",
"Line boundary Start" : "rgb(216, 0, 0)",
diff --git a/aegisub/src/pen.cpp b/aegisub/src/pen.cpp
new file mode 100644
index 000000000..9082ab956
--- /dev/null
+++ b/aegisub/src/pen.cpp
@@ -0,0 +1,45 @@
+// Copyright (c) 2011, Thomas Goyne
+//
+// 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/
+//
+// $Id$
+
+#include "config.h"
+
+#include "pen.h"
+
+#include "compat.h"
+#include "main.h"
+
+void Pen::OnColourChanged(agi::OptionValue const& opt) {
+ impl.SetColour(lagi_wxColour(opt.GetColour()));
+}
+
+void Pen::OnWidthChanged(agi::OptionValue const& opt) {
+ impl.SetWidth(opt.GetInt());
+}
+
+Pen::Pen(const char *colour_opt, const char *width_opt, wxPenStyle style)
+: impl(lagi_wxColour(OPT_GET(colour_opt)->GetColour()), OPT_GET(width_opt)->GetInt(), style)
+, colour_con(OPT_SUB(colour_opt, &Pen::OnColourChanged, this))
+, width_con(OPT_SUB(width_opt, &Pen::OnWidthChanged, this))
+{
+}
+
+Pen::Pen(const char *colour_opt, int width, wxPenStyle style)
+: impl(lagi_wxColour(OPT_GET(colour_opt)->GetColour()), width, style)
+, colour_con(OPT_SUB(colour_opt, &Pen::OnColourChanged, this))
+{
+}
diff --git a/aegisub/src/pen.h b/aegisub/src/pen.h
new file mode 100644
index 000000000..2ede66338
--- /dev/null
+++ b/aegisub/src/pen.h
@@ -0,0 +1,53 @@
+// Copyright (c) 2011, Thomas Goyne
+//
+// 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/
+//
+// $Id$
+
+#ifndef AGI_PRE
+#include
+#endif
+
+#include
+
+namespace agi { class OptionValue; }
+
+/// @class Pen
+/// @brief A simple wrapper around wxPen to bind the colour and width to the
+/// value of an option
+class Pen {
+ wxPen impl;
+ agi::signal::Connection colour_con;
+ agi::signal::Connection width_con;
+
+ void OnColourChanged(agi::OptionValue const& opt);
+ void OnWidthChanged(agi::OptionValue const& opt);
+
+public:
+ /// Constructor
+ /// @param colour_opt Option name to get the colour from
+ /// @param width_opt Option name to get the width from
+ /// @param style Pen style
+ Pen(const char *colour_opt, const char *width_opt, wxPenStyle style = wxPENSTYLE_SOLID);
+
+ /// Constructor
+ /// @param colour_opt Option name to get the colour from
+ /// @param width Pen width
+ /// @param style Pen style
+ Pen(const char *colour_opt, int width = 1, wxPenStyle style = wxPENSTYLE_SOLID);
+
+ /// Implicit conversion to wxPen
+ operator wxPen const&() const { return impl; }
+};