From 39dc47c1636063edf099a152a4c8683b59e2ee57 Mon Sep 17 00:00:00 2001 From: EvanR Date: Mon, 5 Jan 2009 17:01:42 -0600 Subject: [PATCH] Fixed minor problems with pattern scroll. I had to use the layout method to update the scrollbar on resize window. This required the kludge variable. Hopefully this does not lead more terrible effects. --- src/arranger.cpp | 8 ++------ src/pianoroll.cpp | 51 ++++++++++++++++++++++++++++++++++++++++++++------- src/pianoroll.h | 1 + 3 files changed, 47 insertions(+), 13 deletions(-) diff --git a/src/arranger.cpp b/src/arranger.cpp index af13875..3d5bd95 100644 --- a/src/arranger.cpp +++ b/src/arranger.cpp @@ -195,7 +195,6 @@ int Arranger::handle(int event){ if(fltk::event_clicks() > 0){//'double click' ui->piano_roll->load(s); ui->event_edit->load(s); - ui->piano_roll->scrollTo(s->scrollx,s->scrolly); ui->pattern_timeline->update(get_play_position()); ui->keyboard->cur_port = tracks[s->track]->port; ui->keyboard->cur_chan = tracks[s->track]->chan; @@ -619,13 +618,10 @@ void Arranger::scrollTo(int X, int Y){ ui->song_hscroll->value(scrollx); return; } - - //and the other one } scrollx = X; ui->song_hscroll->value(scrollx); - //and the other one scrolly = Y; redraw(); ui->song_timeline->scroll = X; @@ -719,7 +715,7 @@ void Arranger::update(int pos){ } } -int kludge=2; +static int kludge=2; void Arranger::layout(){ if(kludge!=0){ kludge--; @@ -731,7 +727,7 @@ void Arranger::layout(){ } ui->song_vscroll->maximum(0); ui->song_vscroll->minimum(fakeh-h()); - int M = ui->song_vscroll->h() - 30; + int M = h() - 30; int newsize = M-(fakeh-h()); if(newsize<20){ newsize=20; diff --git a/src/pianoroll.cpp b/src/pianoroll.cpp index c3317f7..7aa20c0 100644 --- a/src/pianoroll.cpp +++ b/src/pianoroll.cpp @@ -23,6 +23,9 @@ #include #include #include + +#include + #include #include @@ -552,9 +555,25 @@ void PianoRoll::draw(){ void PianoRoll::scrollTo(int X, int Y){ + + if(is_backend_playing() && config.follow){ + int pos = tick2xpix(get_play_position()) - cur_seqpat->tick; + if(pos < X || pos > X + w() - 30 - 30){ + ui->pattern_hscroll->value(scrollx); + return; + } + } + scrollx = X; scrolly = Y; + if(cur_seqpat){ + cur_seqpat->scrollx = X; + cur_seqpat->scrolly = Y; + } redraw(); + ui->pattern_hscroll->value(X); + ui->pattern_hscroll->redraw(); + ui->pattern_vscroll->value(Y); ui->pattern_timeline->scroll = X; ui->pattern_timeline->redraw(); ui->event_edit->scroll = X; @@ -563,17 +582,37 @@ void PianoRoll::scrollTo(int X, int Y){ ui->keyboard->redraw(); } +static int kludge=2; +void PianoRoll::layout(){ + if(kludge!=0){ + kludge--; + return; + } + fakeh = 900; + if(fakehpattern_vscroll; -void PianoRoll::load(seqpat* s){ + sb->maximum(0); + sb->minimum(fakeh-h()); - //ui->pattern_scroll->scrollTo(0,300); + if(sb->value() > sb->minimum()){ + scrollTo(scrollx,900-h()); + } + int M = h() - 30; + int newsize = M-(fakeh-h()); + if(newsize<20){ + newsize=20; + } + ui->song_vscroll->slider_size(60); +} +void PianoRoll::load(seqpat* s){ cur_seqpat = s; + scrollTo(s->scrollx,s->scrolly); cur_track = tracks[s->track]; - int W = tick2xpix(s->dur); - resize(W+300,h()); - ui->pattern_timeline->ticks_offset = s->tick; } @@ -600,8 +639,6 @@ int PianoRoll::quantize(int tick){ void PianoRoll::set_zoom(int z){ zoom = z; relayout(); - //int W = tick2xpix(cur_seqpat->dur); - //resize(W+300,h()); } diff --git a/src/pianoroll.h b/src/pianoroll.h index 282019e..057456d 100644 --- a/src/pianoroll.h +++ b/src/pianoroll.h @@ -123,6 +123,7 @@ class PianoRoll : public fltk::Widget { void update(int pos); + void layout(); int fakeh; int scrollx; -- 2.11.4.GIT