Update NTK.
[nondaw.git] / sequencer / src / gui / widgets.fl
bloba25b314581645fe9ccb9089e725be142fc57c36b
1 # data file for the Fltk User Interface Designer (fluid)
2 version 1.0108 
3 header_name {.H} 
4 code_name {.C}
5 comment {//
6 // Copyright (C) 2008 Jonathan Moore Liles
7 //
8 // This program is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU General Public License
10 // as published by the Free Software Foundation; either version 2
11 // of the License, or (at your option) any later version.
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 // GNU General Public License for more details.
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the Free Software
20 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
22 } {in_source in_header
23
25 class List_Chooser {} {
26   Function {List_Chooser( const char *name, const char *action )} {open
27   } {
28     Fl_Window window {open
29       xywh {696 57 310 524} type Single non_modal size_range {310 524 0 0} visible
30     } {
31       Fl_Pack {} {open
32         xywh {2 10 303 501}
33         code0 {o->spacing( 20 );}
34       } {
35         Fl_Browser browser {
36           label name
37           xywh {15 30 280 447} type Multi color 32 selection_color 47 align 1 textcolor 55 resizable
38           code0 {o->label( name );}
39         }
40         Fl_Group {} {open
41           xywh {17 485 278 26}
42         } {
43           Fl_Button {} {
44             label Cancel
45             callback {browser->clear();
46 window->hide();}
47             xywh {17 485 75 26}
48           }
49           Fl_Return_Button button {
50             label action
51             callback {window->hide();}
52             xywh {105 485 190 26}
53             code0 {o->label( action );}
54           }
55         }
56       }
57     }
58   }
59   Function {show()} {open
60   } {
61     code {window->show();} {}
62   }
63   Function {shown()} {open return_type bool
64   } {
65     code {return window->shown();} {}
66   }
67   Function {add( const char *item )} {open
68   } {
69     code {browser->add( item );} {}
70   }
71
73 decl {\#include "../transport.H"} {public
74
76 decl {extern Fl_Color velocity_colors[];} {} 
78 decl {\#include <FL/Fl_Box.H>} {} 
80 decl {\#include <stdio.h>} {} 
82 decl {\#include <stdlib.h>} {} 
84 widget_class Visual_Metronome {open selected
85   xywh {763 217 1278 1003} type Single resizable
86   code0 {_bpb = _tpb = -1; _beat = _tick = _flip = 0;}
87   code1 {this->box( FL_NO_BOX );}
88   code2 {this->label( 0 );}
89   class Fl_Group visible
90 } {
91   Fl_Slider progress {
92     private xywh {119 95 1149 23} type Horizontal box THIN_UP_BOX color 32 selection_color 71
93     code0 {o->resize( x(), (y() + h()) - (h() / 3), w(), h() / 3 );}
94     code1 {o->slider_size( 0.25 );}
95     code2 {o->slider( FL_THIN_UP_BOX );}
96   }
97   Fl_Pack pack {open
98     private xywh {119 7 1149 78} type HORIZONTAL resizable
99     code0 {o->resize( x(), y(), w(), h() - progress->h() );}
100   } {}
101   decl {int _bpb} {}
102   decl {int _tpb} {}
103   decl {int _beat} {}
104   decl {bool _flip} {}
105   decl {int _tick} {}
106   Function {bpb( int b )} {open private return_type void
107   } {
108     code {if ( b == _bpb )
109         return;
111 _bpb = b;
113 pack->clear();
115 int bw = w() / _bpb;
117 for ( int i = 1; i <= b; ++i )
119         Fl_Box *box = new Fl_Box( FL_THIN_UP_BOX, 0, 0, bw, 1, 0 );
120         
121         char *pat = (char *)malloc( 4 );
122         
123         sprintf( pat, "%d", i );
124         
125         box->label( pat );
126         box->color( fl_lighter( FL_GRAY ) );
127         box->color2( FL_GRAY );
128         pack->add( box );
132 // try to clear the background.
134 parent()->parent()->damage( FL_DAMAGE_ALL, x(), y(), w(), h() );
135 redraw();} {}
136   }
137   Function {tpb( int ticks )} {open private return_type void
138   } {
139     code {_tpb = ticks;
141 progress->minimum( 0 );
142 progress->maximum( ticks );} {}
143   }
144   Function {beat( int b )} {open private return_type void
145   } {
146     code {if ( b == _beat || b >= _bpb )
147         return;
150 pack->child( _beat )->color( fl_lighter( FL_GRAY ) );
151 pack->child( _beat )->redraw();
153 pack->child( b )->color( velocity_colors[ b * 127 / _bpb ] );
154 pack->child( b )->redraw();
156 _flip = ! _flip;
158 _beat = b;} {}
159   }
160   Function {tick( int tick )} {open private return_type void
161   } {
162     code {if ( tick == _tick )
163         return;
164         
165 if ( _beat < 0 )
166         return;
168 if ( _flip )
170         progress->selection_color( FL_RED );
171         progress->value( _tpb - tick );
173 else
175         progress->selection_color( FL_GREEN );
176         progress->value( tick );
179 \#if 0
180 Fl_Widget *c = pack->child( _beat );
182 if ( c )
184         c->color( velocity_colors[ tick * 127 / _tpb ] );
185         c->redraw();
187 \#endif
189 _tick = tick;} {}
190   }
191   Function {resize( int X, int Y, int W, int H )} {open return_type void
192   } {
193     code {// pack->resize( 0, 0, W, pack->h() );
196 Fl_Group::resize( X, Y, W, H );
198 for ( int i = pack->children(); i-- ; )
199         pack->child( i )->resize( 0, 0, W / pack->children(), pack->h() );} {}
200   }
201   Function {update( void )} {open return_type void
202   } {
203     code {if ( transport.beats_per_bar ) {
204 bpb( transport.beats_per_bar );
205 tpb( transport.ticks_per_beat );
206 beat( transport.beat - 1 );
207 tick( transport.tick - 1 );}} {}
208   }