From d0a9f3f7cd8cd377e8de6652acee1f4605e9d2cb Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Fri, 5 Oct 2012 08:04:46 -0700 Subject: [PATCH] Change the karaoke split cursor color to indicate whether it'll add or remove a split --- aegisub/src/audio_karaoke.cpp | 24 ++++++++++++++++-------- aegisub/src/audio_karaoke.h | 7 ++++--- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/aegisub/src/audio_karaoke.cpp b/aegisub/src/audio_karaoke.cpp index 8425799e6..1819970e6 100644 --- a/aegisub/src/audio_karaoke.cpp +++ b/aegisub/src/audio_karaoke.cpp @@ -72,6 +72,7 @@ AudioKaraoke::AudioKaraoke(wxWindow *parent, agi::Context *c) , active_line(0) , kara(new AssKaraoke) , scroll_x(0) +, click_will_remove_split(false) , enabled(false) { using std::tr1::bind; @@ -169,7 +170,10 @@ void AudioKaraoke::OnPaint(wxPaintEvent &) { dc.Blit(-scroll_x, 0, rendered_line.GetWidth(), h, &bmp_dc, 0, 0); // Draw the split line under the mouse - dc.SetPen(*wxRED); + if (click_will_remove_split) + dc.SetPen(*wxRED); + else + dc.SetPen(wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT)); dc.DrawLine(mouse_pos, 0, mouse_pos, h); dc.SetPen(*wxTRANSPARENT_PEN); @@ -303,12 +307,6 @@ void AudioKaraoke::OnMouse(wxMouseEvent &event) { int shifted_pos = mouse_pos + scroll_x; - if (!event.LeftDown()) { - // Erase the old line and draw the new one - split_area->Refresh(false); - return; - } - // Character to insert the new split point before int split_pos = std::min((shifted_pos - char_width / 2) / char_width, spaced_text.size()); @@ -317,7 +315,17 @@ void AudioKaraoke::OnMouse(wxMouseEvent &event) { // If the click is sufficiently close to a line of a syllable split, // remove that split rather than adding a new one - if ((syl > 0 && shifted_pos <= syl_lines[syl - 1] + 2) || (syl < (int)syl_lines.size() && shifted_pos >= syl_lines[syl] - 2)) { + click_will_remove_split = + (syl > 0 && shifted_pos <= syl_lines[syl - 1] + 2) || + (syl < (int)syl_lines.size() && shifted_pos >= syl_lines[syl] - 2); + + if (!event.LeftDown()) { + // Erase the old line and draw the new one + split_area->Refresh(false); + return; + } + + if (click_will_remove_split) { kara->RemoveSplit(syl); } else { diff --git a/aegisub/src/audio_karaoke.h b/aegisub/src/audio_karaoke.h index 71cbb598f..8b5db5b21 100644 --- a/aegisub/src/audio_karaoke.h +++ b/aegisub/src/audio_karaoke.h @@ -97,13 +97,14 @@ class AudioKaraoke : public wxWindow, private SelectionListener { /// Left x coordinate of each character in spaced_text in pixels std::vector char_x; - int scroll_x; - int scroll_dir; - wxTimer scroll_timer; + int scroll_x; ///< Distance the display has been shifted to the left in pixels + int scroll_dir; ///< Direction the display will be scrolled on scroll_timer ticks (+/- 1) + wxTimer scroll_timer; ///< Timer to scroll every 50ms when user holds down scroll button int char_height; ///< Maximum character height in pixels int char_width; ///< Maximum character width in pixels int mouse_pos; ///< Last x coordinate of the mouse + bool click_will_remove_split; ///< If true a click at mouse_pos will remove a split rather than adding one wxFont split_font; ///< Font used in the split/join interface