From 66d2dbd3ca1e0a329dfe4de5526dd280a568affa Mon Sep 17 00:00:00 2001 From: EvanR Date: Sun, 4 Jan 2009 22:34:24 -0600 Subject: [PATCH] Fixed some GUI bugs. Arranger GUI temporarily fixed. The scroll group widget is beyond repair. I tried my best to make it do what it should be doing by using kludges and an almost trivial subclass. The bottom line is that the scroll group widget is broken. Details: When the scroll group is manipulated, it does not call its own callback. It does call relayout on its children. However, when the window is maximized, the scroll group itself does not fully relayout itselt correctly. In corrects itself if it scrolls twice more. In some circumstances the scroll group will get caught in a strange loop if the children are at the very edge of the scrolling region, and fooling with it enough will fix it, but it is still broken. In this program, maximize, scrollTo, and other factors lead to graphical breakage. The scroll group widget will be dumped in a new branch soon. It will be replaced with two scroll bar widgets that simply use the regular callback api, which the scroll group should be doing, and control the main canvases just like layout was controlling the timelines, event editor, virtual keyboard, and track info. --- src/arranger.cpp | 70 +++++++++++++++++++++++++++++++++++------------------ src/timeline.cpp | 1 + src/timeline.h | 1 + src/trackmodule.cpp | 2 ++ src/ui.cpp | 3 ++- src/ui.fl | 18 +++++++------- 6 files changed, 61 insertions(+), 34 deletions(-) diff --git a/src/arranger.cpp b/src/arranger.cpp index 3f86e46..8442ecb 100644 --- a/src/arranger.cpp +++ b/src/arranger.cpp @@ -606,6 +606,28 @@ void Arranger::layout(){ return; } +/* this function has given some trouble so i will +document what it is supposed to do + +it is called, ideally, when the scroller is dragged, +when zoom changes, the window is resized or when +something changes in the arranger that means it needs +to be resized. + +this function is supposed to tell the timeline and +track info widgets to update their scroll state and +redraw to simulate being controlled by the scroller. + +the arranger widget itself needs to resize itself +so that it covers + +vertically, all track modules and scroll area, whichever is bigger +horizontally, all blocks (plus some) and scroll area, whichever is bigger + +*/ + + + maxt = 0; for(int i=0; ihead->next; @@ -614,41 +636,41 @@ void Arranger::layout(){ s=s->next; } } - int ws = tick2xpix(maxt); - if(ws > w()-120){ - w(ws+500); - } - if(ws < w()-120){ - w(ws+500); - } - int wp = ui->song_scroll->w(); - if(wp > w()){ - w(wp+500); - } - int hp = ui->song_scroll->h(); - if(hp > h()){ - h(hp); - } - else{ - h(16*30); - } + + int wp1 = ui->song_scroll->w(); + int wp2 = tick2xpix(maxt)+500; + int hp1 = ui->song_scroll->h(); + int hp2 = tracks.size() * 30; int xp = ui->song_scroll->xposition(); int yp = ui->song_scroll->yposition(); + + ui->song_timeline->scroll = xp; ui->track_info->scroll = yp; - if(xp_last != xp){ - ui->song_timeline->redraw(); + int hp = hp1>hp2 ? hp1 : hp2; + if(h() < hp){ + h(hp); } - if(yp_last != yp){ - ui->track_info->redraw(); + + ui->track_info->scroll = yp; + ui->track_info->redraw(); + + int wp = wp1>wp2 ? wp1 : wp2; + if(w() < wp){ + w(wp); } - yp_last = yp; - xp_last = xp; +//printf("relayout arranger %d %d\n",w(),h()); + + ui->song_timeline->scroll = xp; + ui->song_timeline->redraw(); + +// yp_last = yp; +// xp_last = xp; } diff --git a/src/timeline.cpp b/src/timeline.cpp index 1917219..ec236dd 100644 --- a/src/timeline.cpp +++ b/src/timeline.cpp @@ -206,3 +206,4 @@ int Timeline::xpix2tick(int xpix){ int Timeline::quantize(int tick){ return tick/128 * 128; } + diff --git a/src/timeline.h b/src/timeline.h index 8313797..462be1b 100644 --- a/src/timeline.h +++ b/src/timeline.h @@ -55,6 +55,7 @@ class Timeline : public fltk::Widget { void update(int ticks); void set_zoom(int level); + }; diff --git a/src/trackmodule.cpp b/src/trackmodule.cpp index 2828225..d4adf8f 100644 --- a/src/trackmodule.cpp +++ b/src/trackmodule.cpp @@ -68,6 +68,8 @@ void progcb(fltk::Widget* w, long i){ t->prog = prog; program_change(i, prog); if(config.autotrackname){ + free(t->name); + t->name = (char*)malloc(64); strncpy(t->name,gm_names[prog],64); ui->track_info->update(); } diff --git a/src/ui.cpp b/src/ui.cpp index 466920b..e569ce9 100644 --- a/src/ui.cpp +++ b/src/ui.cpp @@ -531,6 +531,7 @@ UI::UI() { o->begin(); {EventEdit* o = event_edit = new EventEdit(0, 0, 580, 75, "event editor"); o->box(fltk::FLAT_BOX); + fltk::Group::current()->resizable(o); } {EventMenu* o = event_menu = new EventMenu(0, 0, 580, 75); o->box(fltk::FLAT_BOX); @@ -613,7 +614,7 @@ UI::UI() { o->color((fltk::Color)56); o->labelcolor((fltk::Color)0xffffff00); } - {fltk::Group* o = new fltk::Group(200, 0, 20, 35); + {fltk::Group* o = new fltk::Group(125, 0, 20, 35); o->set_vertical(); fltk::Group::current()->resizable(o); } diff --git a/src/ui.fl b/src/ui.fl index 63aeb46..14d349d 100644 --- a/src/ui.fl +++ b/src/ui.fl @@ -66,7 +66,7 @@ save_config();} open o->size_range(640,455); o->resize(640,455);} visible } { - {fltk::Group} {} { + {fltk::Group} {} {open xywh {0 0 640 445} resizable } { {fltk::Group} song_edit { @@ -115,10 +115,10 @@ o->resize(1000,30*16);} } } } - {fltk::Group} pattern_edit { + {fltk::Group} pattern_edit {open xywh {0 0 640 445} hide } { - {fltk::Group} {} { + {fltk::Group} {} {open xywh {45 0 595 445} resizable } { {fltk::Group} {} { @@ -148,8 +148,8 @@ o->resize(960,900);} xywh {0 370 595 75} } { {fltk::Widget} event_edit { - label {event editor} - xywh {0 0 580 75} box FLAT_BOX + label {event editor} selected + xywh {0 0 580 75} resizable box FLAT_BOX extra_code {\#include "eventedit.h"} class EventEdit } @@ -201,7 +201,7 @@ ui->event_edit->redraw();} } } } - {fltk::Group} {} {open + {fltk::Group} {} { xywh {0 0 45 445} horizontal } { {fltk::Button} {} { @@ -263,8 +263,8 @@ ui->event_edit->redraw();} extra_code {\#include } class Metronome } - {fltk::Group} {} { - xywh {200 0 20 35} resizable + {fltk::Group} {} {open + xywh {125 0 20 35} resizable } {} {fltk::Group} pattern_buttons { xywh {145 5 310 25} hide @@ -881,7 +881,7 @@ savesmf(fltk::file_chooser("export file",NULL,get_last_dir()));} } } {fltk::Window} scope_window { - label scope open selected + label scope xywh {647 310 425 280} hide resizable } { {fltk::TextDisplay} scope { -- 2.11.4.GIT