Change the karaoke split cursor color to indicate whether it'll add or remove a split

This commit is contained in:
Thomas Goyne 2012-10-05 08:04:46 -07:00
parent 1cd9f2dcf2
commit d0a9f3f7cd
2 changed files with 20 additions and 11 deletions

View file

@ -72,6 +72,7 @@ AudioKaraoke::AudioKaraoke(wxWindow *parent, agi::Context *c)
, active_line(0) , active_line(0)
, kara(new AssKaraoke) , kara(new AssKaraoke)
, scroll_x(0) , scroll_x(0)
, click_will_remove_split(false)
, enabled(false) , enabled(false)
{ {
using std::tr1::bind; 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); dc.Blit(-scroll_x, 0, rendered_line.GetWidth(), h, &bmp_dc, 0, 0);
// Draw the split line under the mouse // 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.DrawLine(mouse_pos, 0, mouse_pos, h);
dc.SetPen(*wxTRANSPARENT_PEN); dc.SetPen(*wxTRANSPARENT_PEN);
@ -303,12 +307,6 @@ void AudioKaraoke::OnMouse(wxMouseEvent &event) {
int shifted_pos = mouse_pos + scroll_x; 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 // Character to insert the new split point before
int split_pos = std::min<int>((shifted_pos - char_width / 2) / char_width, spaced_text.size()); int split_pos = std::min<int>((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, // If the click is sufficiently close to a line of a syllable split,
// remove that split rather than adding a new one // 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); kara->RemoveSplit(syl);
} }
else { else {

View file

@ -97,13 +97,14 @@ class AudioKaraoke : public wxWindow, private SelectionListener<AssDialogue> {
/// Left x coordinate of each character in spaced_text in pixels /// Left x coordinate of each character in spaced_text in pixels
std::vector<int> char_x; std::vector<int> char_x;
int scroll_x; int scroll_x; ///< Distance the display has been shifted to the left in pixels
int scroll_dir; int scroll_dir; ///< Direction the display will be scrolled on scroll_timer ticks (+/- 1)
wxTimer scroll_timer; wxTimer scroll_timer; ///< Timer to scroll every 50ms when user holds down scroll button
int char_height; ///< Maximum character height in pixels int char_height; ///< Maximum character height in pixels
int char_width; ///< Maximum character width in pixels int char_width; ///< Maximum character width in pixels
int mouse_pos; ///< Last x coordinate of the mouse 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 wxFont split_font; ///< Font used in the split/join interface