@@ -29,15 +29,9 @@ FXKeyboard::FXKeyboard(u8 _x, u8 _y, uint16** _vram, void (*_onFxKeypress)(u8 pr
2929 void (*_onParamSet)(void ), void (*_onFxClear)(void ), bool _visible)
3030 : Widget(_x, _y, FXKEYBOARD_WIDTH, FXKEYBOARD_HEIGHT, _vram, _visible),
3131 caption(0 ), darken_title(false ), onFxKeypress(_onFxKeypress), onParamChange(_onParamChange),
32- onParamSet(_onParamSet), onFxClear(_onFxClear), last_e_cmd (0 )
32+ onParamSet(_onParamSet), onFxClear(_onFxClear), last_cmd (0 )
3333{
34- for (int i = 0 ; i < NUM_FXKEYS; ++i)
35- {
36- fxbuttons[i] = new FXButton (x + FXKEYBOARD_LMARGIN + ((FXBUTTON_WIDTH - 1 ) * i), y + FXKEYBOARD_YMARGIN, _vram, true );
37- fxbuttons[i]->registerPushCallback (onFxKeypress);
38- fxbuttons[i]->setParent (this );
39- gui.registerWidget (fxbuttons[i]);
40- }
34+
4135
4236 effectpar = new DigitBox (186 , 164 , 35 , 17 , _vram, 0 , 0 , 255 , 2 );
4337 effectpar->registerChangeCallback (onParamChange);
@@ -57,6 +51,14 @@ FXKeyboard::FXKeyboard(u8 _x, u8 _y, uint16** _vram, void (*_onFxKeypress)(u8 pr
5751
5852 gui.registerWidget (buttonseteffectpar);
5953
54+ for (int i = 0 ; i < NUM_FXKEYS; ++i)
55+ {
56+ fxbuttons[i] = new FXButton (x + FXKEYBOARD_LMARGIN + ((FXBUTTON_WIDTH - 1 ) * i), y + FXKEYBOARD_YMARGIN, _vram, true );
57+ fxbuttons[i]->registerPushCallback (onFxKeypress);
58+ fxbuttons[i]->setParent (this );
59+ gui.registerWidget (fxbuttons[i]);
60+ }
61+
6062 setCategory (0 );
6163}
6264
@@ -104,14 +106,14 @@ void FXKeyboard::setParam(u8 val)
104106 effectpar->setValue (val);
105107}
106108
107- u8 FXKeyboard::getLastECmd (void )
109+ u8 FXKeyboard::getLastCmd (void )
108110{
109- return last_e_cmd ;
111+ return last_cmd ;
110112}
111113
112- void FXKeyboard::setLastECmd (u8 _last_e_cmd)
114+ void FXKeyboard::setLastCmd (u8 _last_e_cmd)
113115{
114- last_e_cmd = _last_e_cmd;
116+ last_cmd = _last_e_cmd;
115117}
116118
117119void FXKeyboard::useDarkTitle (bool _darken_title)
@@ -125,6 +127,7 @@ void FXKeyboard::updateFxCaption(u8 val)
125127 setCaption (captions[val]);
126128 else if (category == FX_CATEGORY_E)
127129 setCaption (E_captions[val]);
130+ drawCaption ();
128131}
129132
130133void FXKeyboard::setCategory (u8 newcat) {
@@ -136,31 +139,35 @@ void FXKeyboard::setCategory(u8 newcat) {
136139
137140 if (bt == 0 ) continue ;
138141
139- bt->enable ();
140- bt->show ();
142+ bool hidden = false , disabled = false ;
141143
142144 if (newcat == FX_CATEGORY_NORMAL) {
143- if (i >= 5 && i <= 7 ) bt-> disable () ;
145+ if (i >= 5 && i <= 7 ) disabled = true ;
144146
145- fxbuttons[i] ->setSmallCaption (((xy_magicnum >> i) & 0x1 ) ? " XY" : " XX" );
147+ bt ->setSmallCaption (((xy_magicnum >> i) & 0x1 ) ? " XY" : " XX" );
146148 } else if (newcat == FX_CATEGORY_E) {
147- if (i == 0 || (i > 6 && i < 0xC )) bt-> disable () ;
149+ if (i == 0 || (i > 6 && i < 0xC )) disabled = false ;
148150
149151 char lbl[3 ];
150152 snprintf (lbl, 3 , " %1XX" , i);
151- fxbuttons[i] ->setSmallCaption (lbl);
153+ bt ->setSmallCaption (lbl);
152154 } else {
153155 if ((newcat == FX_CATEGORY_FT && i >= 7 ) || (newcat == FX_CATEGORY_VOL && i >= 9 )) {
154- bt-> hide () ;
156+ hidden = true ;
155157 }
156-
157- bt-> disable () ;
158+ bt-> setSmallCaption ( NULL );
159+ disabled = true ;
158160 }
159161
160- const char lbl[2 ] = { fxlabels[i][newcat], ' \0 ' };
161- bt->setCaption (lbl);
162- bt->setCategory (newcat); // calls draw()
163- bt->setValue (i);
162+ if (!hidden) {
163+ const char lbl[2 ] = { fxlabels[i][newcat], ' \0 ' };
164+ bt->setCaption (lbl);
165+ bt->setCategory (newcat);
166+ bt->setValue (i);
167+ bt->set_enabled (!disabled);
168+ }
169+
170+ bt->set_visible (!hidden);
164171 effectpar->setSingleDigit (newcat == FX_CATEGORY_E);
165172 }
166173
@@ -187,9 +194,7 @@ void FXKeyboard::setCategory(u8 newcat) {
187194 useDarkTitle (true );
188195 break ;
189196 }
190-
191-
192- draw ();
197+ drawCaption ();
193198}
194199
195200
@@ -204,18 +209,24 @@ void FXKeyboard::setCaption(const char* _caption) {
204209 if (caption) ntxm_free (caption);
205210 caption = (char *)ntxm_cmalloc (strlen (_caption) + 1 );
206211 strcpy (caption, _caption);
207- draw ();
208212}
209213
210214/* ===================== PRIVATE ===================== */
211215
216+ void FXKeyboard::drawCaption (void ) {
217+ if (!isExposed ()) return ;
218+
219+ drawFullBox (1 , 4 , width-45 , 8 , bgcolor);
220+ u16 capcol = darken_title ? theme->col_fxkeyboard_cmd_label_disabled : theme->col_fxkeyboard_cmd_label ;
221+ drawSmallString (caption, ((NUM_FXKEYS * FXBUTTON_WIDTH) / 2 ) - (2 * strlen (caption)), 4 , capcol); // width=(3px char+1px space) / 2
222+ }
223+
212224void FXKeyboard::draw (void ) {
213225 if (!isExposed ()) return ;
214226
215227 drawFullBox (0 , 0 , width, height, theme->col_bg ); // hide the piano
216228
217- u16 capcol = darken_title ? theme->col_dark_ctrl_disabled : theme->col_text_light ;
218- drawSmallString (caption, ((NUM_FXKEYS * FXBUTTON_WIDTH) / 2 ) - (2 * strlen (caption)), 4 , capcol);
229+ drawCaption ();
219230 gui.revealAll ();
220231 gui.draw ();
221232}
0 commit comments