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)
, 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<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,
// 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 {

View file

@ -97,13 +97,14 @@ class AudioKaraoke : public wxWindow, private SelectionListener<AssDialogue> {
/// Left x coordinate of each character in spaced_text in pixels
std::vector<int> 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