From 4999cac72764c7692c6d50d3aee12378fe247feb Mon Sep 17 00:00:00 2001 From: EvanR Date: Mon, 5 Jan 2009 00:53:30 -0600 Subject: [PATCH] Song vertical scroll works. It now acts like the old scroll bar from the scrollgroup. I added a layout function to the arranger which serves as the only way that widgets will get updates about the window resizing. It required a kludge similar to the scrollgroup. The fact that the magic kludge value is 2 rather than 4 means the current scheme is twice as good. --- src/arranger.cpp | 23 +++++++++++++++++++++-- src/arranger.h | 2 +- src/main.cpp | 3 +++ src/ui.cpp | 19 +++++++++++++++++++ src/ui.fl | 12 ++++++++---- src/ui.h | 8 ++++++++ src/uihelper.cpp | 11 +++++++++++ src/uihelper.h | 3 +++ 8 files changed, 74 insertions(+), 7 deletions(-) diff --git a/src/arranger.cpp b/src/arranger.cpp index af6b911..0fdc200 100644 --- a/src/arranger.cpp +++ b/src/arranger.cpp @@ -68,8 +68,9 @@ Arranger::Arranger(int x, int y, int w, int h, const char* label = 0) : fltk::Wi maxt = 0; - int fakew = 1000; - int fakeh = 16*30; + fakew = 1000; + fakeh = 16*30; + if(fakeh < h){fakeh = h;} } @@ -693,6 +694,24 @@ void Arranger::update(int pos){ } } +int kludge=2; +void Arranger::layout(){ +printf("ok\n"); + if(kludge!=0){ + kludge--; + return; + } + fakeh = tracks.size()*30; +printf("%d\n",tracks.size()); + if(fakehsong_vscroll->maximum(0); + ui->song_vscroll->minimum(fakeh-h()); + int M = ui->song_vscroll->h() - 30; + ui->song_vscroll->slider_size(M - (fakeh-h())); +} + void Arranger::unselect_all(){ seqpat* s; diff --git a/src/arranger.h b/src/arranger.h index 0d956e1..6a5caf4 100644 --- a/src/arranger.h +++ b/src/arranger.h @@ -131,7 +131,7 @@ class Arranger : public fltk::Widget { void update(int pos); - //void layout(); + void layout(); void reset_handle(){last_handle==NULL;} diff --git a/src/main.cpp b/src/main.cpp index ed18cb8..a334114 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -38,6 +38,9 @@ UI* ui; int main(int argc, char* argv[]){ ui = new UI(); + + init_gui(); + ui->arranger->take_focus(); load_config(); diff --git a/src/ui.cpp b/src/ui.cpp index 0f0d471..94529b8 100644 --- a/src/ui.cpp +++ b/src/ui.cpp @@ -51,6 +51,22 @@ void UI::cb_line(fltk::Button* o, void* v) { ((UI*)(o->parent()->parent()->parent()->parent()->user_data()))->cb_line_i(o,v); } +inline void UI::cb_song_vscroll_i(fltk::Scrollbar* o, void*) { + int target = (int)o->value(); + int dummy = ui->arranger->scrollx; + ui->arranger->scrollTo(dummy,target); +} +void UI::cb_song_vscroll(fltk::Scrollbar* o, void* v) { + ((UI*)(o->parent()->parent()->parent()->parent()->user_data()))->cb_song_vscroll_i(o,v); +} + +inline void UI::cb_song_hscroll_i(fltk::ThumbWheel* o, void*) { + ui->arranger->scrollTo((int)o->value(),ui->arranger->scrolly); +} +void UI::cb_song_hscroll(fltk::ThumbWheel* o, void* v) { + ((UI*)(o->parent()->parent()->parent()->parent()->user_data()))->cb_song_hscroll_i(o,v); +} + inline void UI::cb_event_menu_button_i(fltk::Button* o, void*) { if(o->state()==0){ ui->event_menu->hide(); @@ -496,10 +512,13 @@ UI::UI() { } {fltk::Scrollbar* o = song_vscroll = new fltk::Scrollbar(370, 0, 15, 415); o->set_vertical(); + o->slider_size(60); + o->callback((fltk::Callback*)cb_song_vscroll); } {fltk::ThumbWheel* o = song_hscroll = new fltk::ThumbWheel(0, 415, 370, 15); o->maximum(10000); o->step(10); + o->callback((fltk::Callback*)cb_song_hscroll); } o->end(); fltk::Group::current()->resizable(o); diff --git a/src/ui.fl b/src/ui.fl index 31c23d7..d7d9f94 100644 --- a/src/ui.fl +++ b/src/ui.fl @@ -69,7 +69,7 @@ o->resize(640,455);} visible {fltk::Group} {} {open xywh {0 0 640 445} resizable } { - {fltk::Group} song_edit { + {fltk::Group} song_edit {open xywh {0 0 640 445} } { {fltk::Group} {} { @@ -98,7 +98,7 @@ o->label_scale=4;} class Timeline } } - {fltk::Group} song_scrollgroup { + {fltk::Group} song_scrollgroup {open xywh {255 15 385 430} resizable } { {fltk::Widget} arranger { @@ -109,9 +109,13 @@ o->label_scale=4;} class Arranger } {fltk::Scrollbar} song_vscroll { - xywh {370 0 15 415} + callback {int target = (int)o->value(); +int dummy = ui->arranger->scrollx; +ui->arranger->scrollTo(dummy,target);} selected + xywh {370 0 15 415} slider_size 60 } {fltk::ThumbWheel} song_hscroll { + callback {ui->arranger->scrollTo((int)o->value(),ui->arranger->scrolly);} xywh {0 415 370 15} maximum 10000 step 10 } } @@ -145,7 +149,7 @@ o->edit_flag = 1;} {fltk::Scrollbar} pattern_vscroll { xywh {580 0 15 340} } - {fltk::ThumbWheel} pattern_hscroll {selected + {fltk::ThumbWheel} pattern_hscroll { xywh {0 340 580 15} } } diff --git a/src/ui.h b/src/ui.h index 27d31f3..67cfe85 100644 --- a/src/ui.h +++ b/src/ui.h @@ -51,7 +51,15 @@ public: fltk::Group *song_scrollgroup; Arranger *arranger; fltk::Scrollbar *song_vscroll; +private: + inline void cb_song_vscroll_i(fltk::Scrollbar*, void*); + static void cb_song_vscroll(fltk::Scrollbar*, void*); +public: fltk::ThumbWheel *song_hscroll; +private: + inline void cb_song_hscroll_i(fltk::ThumbWheel*, void*); + static void cb_song_hscroll(fltk::ThumbWheel*, void*); +public: fltk::Group *pattern_edit; Timeline *pattern_timeline; fltk::Group *pattern_scrollgroup; diff --git a/src/uihelper.cpp b/src/uihelper.cpp index 925dac3..b1b9a5a 100644 --- a/src/uihelper.cpp +++ b/src/uihelper.cpp @@ -726,3 +726,14 @@ void add_track(track* t){ void remove_track(int n){ } + + + +void init_gui(){ + ui->arranger->layout(); + ui->song_vscroll->value(0); + + ui->song_hscroll->minimum(0); + ui->song_hscroll->maximum(1<<20); +} + diff --git a/src/uihelper.h b/src/uihelper.h index a85bae9..357dc15 100644 --- a/src/uihelper.h +++ b/src/uihelper.h @@ -83,4 +83,7 @@ void reset_song(); void add_track(track* t); void remove_track(int n); + +void init_gui(); + #endif -- 2.11.4.GIT