From ed39a82f9123be7c2921d0e718a6c091cd099c2a Mon Sep 17 00:00:00 2001 From: EvanR Date: Tue, 6 Jan 2009 00:23:38 -0600 Subject: [PATCH] Added unclone tool. Adjusted GUI. Added icons. Added edit icon. Edit mode is the default mode. Added color icon. The color tool changes block colors. Added fork icon. The unclone tool hard-copies blocks. I made some adjustments to includes in some files that did not need to know about the UI. Changing the GUI at this time causes almost all the files to be recompiled, and it is starting to take too long. --- gfx/Makefile.am | 2 +- gfx/color.gif | Bin 285 -> 158 bytes gfx/edit.gif | Bin 0 -> 152 bytes gfx/fork.gif | Bin 0 -> 135 bytes src/arranger.cpp | 34 ++++++++++++++++++++++++- src/arranger.h | 5 ++++ src/jack.cpp | 2 +- src/trackselect.cpp | 6 +++-- src/ui.cpp | 70 +++++++++++++++++++++++++++++++++++++++++----------- src/ui.fl | 58 ++++++++++++++++++++++++++----------------- src/ui.h | 25 ++++++++++++++++--- src/uihelper.cpp | 51 ++++++++++++++++++++++++++++++++++++++ src/uihelper.h | 1 + src/util.cpp | 17 +++++++++++++ src/util.h | 2 ++ 15 files changed, 227 insertions(+), 46 deletions(-) create mode 100644 gfx/edit.gif create mode 100644 gfx/fork.gif diff --git a/gfx/Makefile.am b/gfx/Makefile.am index a97b646..ce6aa26 100644 --- a/gfx/Makefile.am +++ b/gfx/Makefile.am @@ -1,2 +1,2 @@ gfxdir = $(datarootdir)/@PACKAGE@/gfx -gfx_DATA = README hand.gif loop.gif color.gif conf.gif scope.gif file.gif help.gif q4.gif q8.gif q16.gif q32.gif q64.gif q128.gif q0.gif +gfx_DATA = README hand.gif loop.gif color.gif conf.gif scope.gif file.gif help.gif q4.gif q8.gif q16.gif q32.gif q64.gif q128.gif q0.gif edit.gif fork.gif diff --git a/gfx/color.gif b/gfx/color.gif index 0a94450b98881907241412a474e6103930ca292a..aad7525bcd6bbbbf879dcc504e2dc877fe779e70 100644 GIT binary patch literal 158 zcwTe&bhEHb6k`x$c+AZpBP}(Hfx%Eu*T;a@(!wmsmiHP9OR7C@XNW**QtY%z-SIa3 z$Vl-g3nLc;KZ6bf5P-~JVDbKN(sT7*i|n3r&)UC--ZktAsa!Pa)V7DGc4;KFyDvPg z@b0s?Ym$eIkl7)nk2?ez=3RJxT(Z?~^|juE4XicWZZ|~yVQoLTeoIwuCj)~u0AGbT ArvLx| literal 285 zcwTe&bhEHb6k`x$c+A1Tz%Yw};T;HrnKQtw*Y6nq;{b~P(w*}QDvL7HGfEURk~I}v z%M$Yxf->_`GZKqR6pRcEEVx24GK&>5a}(236@ZMK%;eO(;?xv{(!7+^B88HSR0Vgx zPzCqYywsw^9EE_=B%lffABZZ2vecsD%=|nBBRvMipDc`A3>*wPK$kIqoXfxxFL2Ux z^qT6fD_`_zwf%l&+8ycIM1R1OWZr*w+ diff --git a/gfx/edit.gif b/gfx/edit.gif new file mode 100644 index 0000000000000000000000000000000000000000..967284c59c48511701601370c4458130a830f76d GIT binary patch literal 152 zcwTe&bhEHb6k`x$c+ATH1eyMvonG3lX@Z;b{iaOg**=@$WNY&3+5Xpd2w%D){pm)` z{}kz!qmJxnKd9TOXDlMlJ?+1|0?<0I6kQ_Nmx) z=ih}+kA4NwdlOY99gpWQDrhaKT(&J0CkTwy8r+H literal 0 HcwPel00001 diff --git a/src/arranger.cpp b/src/arranger.cpp index c2a1a17..f0ec508 100644 --- a/src/arranger.cpp +++ b/src/arranger.cpp @@ -21,6 +21,7 @@ */ #include +#include #include #include #include @@ -77,6 +78,9 @@ Arranger::Arranger(int x, int y, int w, int h, const char* label = 0) : fltk::Wi resize_s = NULL; resize_handle_width = 4; + unclone_flag=0; + join_flag=0; + split_flag=0; } int Arranger::handle(int event){ @@ -160,7 +164,7 @@ int Arranger::handle(int event){ if(event_button()==1){//left mouse seqpat* s = over_seqpat(); if(s==NULL){ - if(color_flag){//do nothing + if(color_flag || unclone_flag){//do nothing } else if(event_state()&fltk::SHIFT){//begin box box_flag = 1; @@ -192,6 +196,9 @@ int Arranger::handle(int event){ color_v = color_orig_v; return 1; } + if(unclone_flag){ + apply_unclone(); + } if(!s->selected && !(event_state()&SHIFT)){ unselect_all(); } @@ -1188,4 +1195,29 @@ int Arranger::check_paste_safety(){ } +void Arranger::apply_unclone(){ + Command* c; + + pattern* p2 = new pattern(main_sel->p); + //does p2 need to have its ref_c set + float a = randf(0.2,0.8); + while(fabs(p2->v - a)<0.1){ + a = randf(0.2,0.8); + } + p2->v = a; + p2->regen_colors(); + + //this creates a copy of the block, but uses a copy of the pattern + seqpat* s2 = new seqpat(main_sel,p2); + + + c = new DeleteSeqpat(main_sel); + set_undo(c); + main_sel = NULL; + + c = new CreateSeqpat(s2->track,s2->tick,s2,0); + set_undo(c); + + undo_push(2); +} diff --git a/src/arranger.h b/src/arranger.h index fd1d9b5..373374a 100644 --- a/src/arranger.h +++ b/src/arranger.h @@ -110,6 +110,8 @@ class Arranger : public fltk::Widget { void apply_lresize(); void apply_insert(); + void apply_unclone(); + int check_move_safety(); int check_insert_safety(); int check_resize_safety(); @@ -126,6 +128,9 @@ class Arranger : public fltk::Widget { int zoom_n; int color_flag; + int unclone_flag; + int join_flag; + int split_flag; int q_tick; diff --git a/src/jack.cpp b/src/jack.cpp index 485bc1d..b69026f 100644 --- a/src/jack.cpp +++ b/src/jack.cpp @@ -44,7 +44,7 @@ lash_client_t* lash_client; #include "backend.h" -#include "ui.h" +//#include "ui.h" #define PORT_COUNT 8 diff --git a/src/trackselect.cpp b/src/trackselect.cpp index 53ea8aa..80d3d6d 100644 --- a/src/trackselect.cpp +++ b/src/trackselect.cpp @@ -24,11 +24,13 @@ #include #include #include -#include "ui.h" +#include +//#include "ui.h" +#include "trackselect.h" -extern UI* ui; +//extern UI* ui; TrackSelect::TrackSelect(int x, int y, int w, int h, const char* label = 0) : fltk::Widget(x, y, w, h, label) { diff --git a/src/ui.cpp b/src/ui.cpp index 4ed0a3d..5d2f39b 100644 --- a/src/ui.cpp +++ b/src/ui.cpp @@ -211,11 +211,39 @@ void UI::cb_tool_button(fltk::Button* o, void* v) { ((UI*)(o->parent()->parent()->parent()->user_data()))->cb_tool_button_i(o,v); } -inline void UI::cb_color_toggle_i(fltk::Button* o, void*) { - arranger->color_flag = o->state(); +inline void UI::cb_edit_button_i(fltk::Button*, void*) { + set_songtool(0); } -void UI::cb_color_toggle(fltk::Button* o, void* v) { - ((UI*)(o->parent()->parent()->parent()->user_data()))->cb_color_toggle_i(o,v); +void UI::cb_edit_button(fltk::Button* o, void* v) { + ((UI*)(o->parent()->parent()->parent()->user_data()))->cb_edit_button_i(o,v); +} + +inline void UI::cb_color_button_i(fltk::Button*, void*) { + set_songtool(1); +} +void UI::cb_color_button(fltk::Button* o, void* v) { + ((UI*)(o->parent()->parent()->parent()->user_data()))->cb_color_button_i(o,v); +} + +inline void UI::cb_unclone_button_i(fltk::Button*, void*) { + set_songtool(2); +} +void UI::cb_unclone_button(fltk::Button* o, void* v) { + ((UI*)(o->parent()->parent()->parent()->user_data()))->cb_unclone_button_i(o,v); +} + +inline void UI::cb_split_button_i(fltk::Button*, void*) { + set_songtool(3); +} +void UI::cb_split_button(fltk::Button* o, void* v) { + ((UI*)(o->parent()->parent()->parent()->user_data()))->cb_split_button_i(o,v); +} + +inline void UI::cb_join_button_i(fltk::Button*, void*) { + set_songtool(4); +} +void UI::cb_join_button(fltk::Button* o, void* v) { + ((UI*)(o->parent()->parent()->parent()->user_data()))->cb_join_button_i(o,v); } inline void UI::cb_loop_toggle_i(fltk::Button*, void*) { @@ -706,21 +734,32 @@ UI::UI() { } o->end(); } - {fltk::Group* o = song_buttons = new fltk::Group(340, 5, 115, 25); + {fltk::Group* o = song_buttons = new fltk::Group(330, 5, 145, 25); o->begin(); - {fltk::Button* o = color_toggle = new fltk::Button(0, 0, 25, 25); - o->callback((fltk::Callback*)cb_color_toggle); + {fltk::Button* o = edit_button = new fltk::Button(0, 0, 25, 25); + o->set_flag(fltk::STATE); + o->callback((fltk::Callback*)cb_edit_button); + o->tooltip("create delete move resize select paste blocks"); + } + {fltk::Button* o = color_button = new fltk::Button(25, 0, 25, 25); + o->callback((fltk::Callback*)cb_color_button); o->tooltip("color tool"); o->type(fltk::Button::TOGGLE); } - {fltk::Button* o = unclone_button = new fltk::Button(30, 0, 25, 25, "dclo"); - o->tooltip("unclone selected block"); + {fltk::Button* o = unclone_button = new fltk::Button(50, 0, 25, 25); + o->callback((fltk::Callback*)cb_unclone_button); + o->tooltip("click on blocks to unclone them"); + o->type(fltk::Button::TOGGLE); } - {fltk::Button* o = join_button = new fltk::Button(60, 0, 25, 25, "join"); - o->tooltip("join selected blocks"); + {fltk::Button* o = split_button = new fltk::Button(75, 0, 25, 25); + o->callback((fltk::Callback*)cb_split_button); + o->tooltip("click on a block to split in two"); + o->type(fltk::Button::TOGGLE); } - {fltk::Button* o = split_button = new fltk::Button(90, 0, 25, 25, "split"); - o->tooltip("split selected block"); + {fltk::Button* o = join_button = new fltk::Button(100, 0, 25, 25); + o->callback((fltk::Callback*)cb_join_button); + o->tooltip("click on adjacent blocks to join them"); + o->type(fltk::Button::TOGGLE); } o->end(); } @@ -1137,7 +1176,10 @@ track."); file_button->image(fltk::SharedImage::get(ROOT_DATA_DIR"gfx/file.gif")); help_button->image(fltk::SharedImage::get(ROOT_DATA_DIR"gfx/help.gif")); - color_toggle->image(fltk::SharedImage::get(ROOT_DATA_DIR"gfx/color.gif")); + edit_button->image(fltk::SharedImage::get(ROOT_DATA_DIR"gfx/edit.gif")); + color_button->image(fltk::SharedImage::get(ROOT_DATA_DIR"gfx/color.gif")); + unclone_button->image(fltk::SharedImage::get(ROOT_DATA_DIR"gfx/fork.gif")); + qbutton4->image(fltk::SharedImage::get(ROOT_DATA_DIR"gfx/q4.gif")); qbutton8->image(fltk::SharedImage::get(ROOT_DATA_DIR"gfx/q8.gif")); qbutton16->image(fltk::SharedImage::get(ROOT_DATA_DIR"gfx/q16.gif")); diff --git a/src/ui.fl b/src/ui.fl index b366ada..68d496a 100644 --- a/src/ui.fl +++ b/src/ui.fl @@ -57,16 +57,16 @@ action_window->hide(); scope_window->hide(); o->hide(); -save_config();} open - xywh {31 41 640 480} resizable +save_config();} + xywh {31 41 640 480} hide resizable extra_code {\#include \#include \#include "seq.h" \#include "trackmodule.h" o->size_range(640,455); -o->resize(640,455);} visible +o->resize(640,455);} } { - {fltk::Group} {} {open + {fltk::Group} {} { xywh {0 0 640 445} resizable } { {fltk::Group} song_edit {open @@ -334,29 +334,37 @@ o->state(1);} xywh {75 0 25 25} } } - {fltk::Group} song_buttons { - xywh {340 5 115 25} + {fltk::Group} song_buttons {open + xywh {330 5 145 25} } { - {fltk::Button} color_toggle { - callback {arranger->color_flag = o->state();} + {fltk::Button} edit_button { + callback {set_songtool(0);} + tooltip {create delete move resize select paste blocks} + xywh {0 0 25 25} value 1 + } + {fltk::Button} color_button { + callback {set_songtool(1);} tooltip {color tool} - xywh {0 0 25 25} + xywh {25 0 25 25} extra_code {o->type(fltk::Button::TOGGLE);} } {fltk::Button} unclone_button { - label dclo - tooltip {unclone selected block} - xywh {30 0 25 25} - } - {fltk::Button} join_button { - label join - tooltip {join selected blocks} - xywh {60 0 25 25} + callback {set_songtool(2);} + tooltip {click on blocks to unclone them} + xywh {50 0 25 25} + extra_code {o->type(fltk::Button::TOGGLE);} } {fltk::Button} split_button { - label split - tooltip {split selected block} - xywh {90 0 25 25} + callback {set_songtool(3);} + tooltip {click on a block to split in two} + xywh {75 0 25 25} + extra_code {o->type(fltk::Button::TOGGLE);} + } + {fltk::Button} join_button { + callback {set_songtool(4);} + tooltip {click on adjacent blocks to join them} + xywh {100 0 25 25} + extra_code {o->type(fltk::Button::TOGGLE);} } } {fltk::Button} loop_toggle { @@ -371,7 +379,7 @@ o->state(1);} } else{ ui->config_window->hide(); -}} selected +}} tooltip configuration xywh {520 5 25 25} extra_code {o->type(fltk::Button::TOGGLE);} @@ -925,14 +933,18 @@ scope_button->image(fltk::SharedImage::get(ROOT_DATA_DIR"gfx/scope.gif")); file_button->image(fltk::SharedImage::get(ROOT_DATA_DIR"gfx/file.gif")); help_button->image(fltk::SharedImage::get(ROOT_DATA_DIR"gfx/help.gif")); -color_toggle->image(fltk::SharedImage::get(ROOT_DATA_DIR"gfx/color.gif")); +edit_button->image(fltk::SharedImage::get(ROOT_DATA_DIR"gfx/edit.gif")); +color_button->image(fltk::SharedImage::get(ROOT_DATA_DIR"gfx/color.gif")); +unclone_button->image(fltk::SharedImage::get(ROOT_DATA_DIR"gfx/fork.gif")); + qbutton4->image(fltk::SharedImage::get(ROOT_DATA_DIR"gfx/q4.gif")); qbutton8->image(fltk::SharedImage::get(ROOT_DATA_DIR"gfx/q8.gif")); qbutton16->image(fltk::SharedImage::get(ROOT_DATA_DIR"gfx/q16.gif")); qbutton32->image(fltk::SharedImage::get(ROOT_DATA_DIR"gfx/q32.gif")); qbutton64->image(fltk::SharedImage::get(ROOT_DATA_DIR"gfx/q64.gif")); qbutton128->image(fltk::SharedImage::get(ROOT_DATA_DIR"gfx/q128.gif")); -qbutton0->image(fltk::SharedImage::get(ROOT_DATA_DIR"gfx/q0.gif"));} {} +qbutton0->image(fltk::SharedImage::get(ROOT_DATA_DIR"gfx/q0.gif"));} {selected + } code {track_info->set_rec(0);} {} code {start_monitor();} {} code {main_window->show();} {} diff --git a/src/ui.h b/src/ui.h index c5b0158..b861b8a 100644 --- a/src/ui.h +++ b/src/ui.h @@ -156,14 +156,31 @@ private: static void cb_tool_button(fltk::Button*, void*); public: fltk::Group *song_buttons; - fltk::Button *color_toggle; + fltk::Button *edit_button; private: - inline void cb_color_toggle_i(fltk::Button*, void*); - static void cb_color_toggle(fltk::Button*, void*); + inline void cb_edit_button_i(fltk::Button*, void*); + static void cb_edit_button(fltk::Button*, void*); +public: + fltk::Button *color_button; +private: + inline void cb_color_button_i(fltk::Button*, void*); + static void cb_color_button(fltk::Button*, void*); public: fltk::Button *unclone_button; - fltk::Button *join_button; +private: + inline void cb_unclone_button_i(fltk::Button*, void*); + static void cb_unclone_button(fltk::Button*, void*); +public: fltk::Button *split_button; +private: + inline void cb_split_button_i(fltk::Button*, void*); + static void cb_split_button(fltk::Button*, void*); +public: + fltk::Button *join_button; +private: + inline void cb_join_button_i(fltk::Button*, void*); + static void cb_join_button(fltk::Button*, void*); +public: fltk::Button *loop_toggle; private: inline void cb_loop_toggle_i(fltk::Button*, void*); diff --git a/src/uihelper.cpp b/src/uihelper.cpp index 6443623..36403e4 100644 --- a/src/uihelper.cpp +++ b/src/uihelper.cpp @@ -573,6 +573,57 @@ void set_quant(int q){ } } +void set_songtool(int i){ + switch(i){ + case 0: + ui->edit_button->state(1); + ui->color_button->state(0); + ui->unclone_button->state(0); + ui->split_button->state(0); + ui->join_button->state(0); + ui->arranger->color_flag = 0; + ui->arranger->unclone_flag = 0; + break; + case 1: + ui->edit_button->state(0); + ui->color_button->state(1); + ui->unclone_button->state(0); + ui->split_button->state(0); + ui->join_button->state(0); + ui->arranger->color_flag = 1; + ui->arranger->unclone_flag = 0; + break; + case 2: + ui->edit_button->state(0); + ui->color_button->state(0); + ui->unclone_button->state(1); + ui->split_button->state(0); + ui->join_button->state(0); + ui->arranger->color_flag = 0; + ui->arranger->unclone_flag = 1; + break; + case 3: + ui->edit_button->state(0); + ui->color_button->state(0); + ui->unclone_button->state(0); + ui->split_button->state(1); + ui->join_button->state(0); + ui->arranger->color_flag = 0; + ui->arranger->unclone_flag = 0; + break; + case 4: + ui->edit_button->state(0); + ui->color_button->state(0); + ui->unclone_button->state(0); + ui->split_button->state(0); + ui->join_button->state(1); + ui->arranger->color_flag = 0; + ui->arranger->unclone_flag = 0; + break; + } +} + + void set_beats_per_measure(int n){ config.beats_per_measure = n; diff --git a/src/uihelper.h b/src/uihelper.h index 357dc15..0180979 100644 --- a/src/uihelper.h +++ b/src/uihelper.h @@ -49,6 +49,7 @@ void press_panic(); void press_play(); void set_quant(int q); +void set_songtool(int i); void turnonscope(); void turnoffscope(); diff --git a/src/util.cpp b/src/util.cpp index bd5459b..196e592 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -147,3 +147,20 @@ int unmodify_and_unstick_tracks(){ } } } + + +float randf(float l, float r){ + float L,R; + if(l > r){ + L=r; + R=l; + } + else{ + L=l; + R=r; + } + float M = (rand()*1.0)/RAND_MAX; + float ans = M*(R-L) + L; + return ans; +} + diff --git a/src/util.h b/src/util.h index 8495bda..f3c2e28 100644 --- a/src/util.h +++ b/src/util.h @@ -33,4 +33,6 @@ int note2ypix(int note, int* black); void unmodify_blocks(); int unmodify_and_unstick_tracks(); + +float randf(float l, float r); #endif -- 2.11.4.GIT