2 * Cinelerra :: Blue Banana - color modification plugin for Cinelerra-CV
3 * Copyright (C) 2012 Monty <monty@xiph.org>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #include "bcdisplayinfo.h"
24 #include "bcsignals.h"
26 #include "bluebanana.h"
27 #include "bluebananaconfig.h"
28 #include "bluebananaslider.h"
29 #include "bluebananawindow.h"
34 #include "bluebananacolor.c"
37 class BluebananaHActive : public BC_CheckBox {
39 BluebananaHActive(BluebananaMain *plugin, BluebananaWindow *gui);
40 virtual int handle_event();
42 BluebananaMain *plugin;
43 BluebananaWindow *gui;
46 class BluebananaSActive : public BC_CheckBox {
48 BluebananaSActive(BluebananaMain *plugin, BluebananaWindow *gui);
49 virtual int handle_event();
51 BluebananaMain *plugin;
52 BluebananaWindow *gui;
55 class BluebananaVActive : public BC_CheckBox {
57 BluebananaVActive(BluebananaMain *plugin, BluebananaWindow *gui);
58 virtual int handle_event();
60 BluebananaMain *plugin;
61 BluebananaWindow *gui;
65 // -------------------------------------------------------------------------------
66 // The below code is because the stock TextTumbler trips too many bugs
67 // in guicast to be useful. If this plugin is to be shipped standalone
68 // and work, we need an independent version that avoids the bugs here.
70 BB_Tumble::BB_Tumble(BluebananaMain *plugin,
71 BluebananaWindow *gui,
78 : BC_TextBox(-1,-1,text_w,1,mid,1,MEDIUMFONT,precision){
80 // We must pass in the precision for initialization to get the
81 // geometry right. But then bctextbox.C immediately clobbers it, so
83 set_precision(precision);
86 this->plugin = plugin;
92 this->text_w = text_w;
93 this->precision = precision;
94 this->increment = increment;
96 this->suppress_events = 0;
99 float BB_Tumble::get_value(){
100 const char *text = get_text();
101 if(!text || text[0]==0) return 0;
105 int BB_Tumble::handle_event(){
106 if(!suppress_events) value_event();
110 int BB_Tumble::activate(){
111 // we want to restore the previous value on ESC
113 // the textbox active member is private, make our own
115 return BC_TextBox::activate();
118 int BB_Tumble::deactivate(){
120 // only fire an event if the value changed; this makes 0/360
121 // behavior in the hue selection readout stick with what the user
122 // actually sets (as opposed to sanity checking flipping the value
123 // if an event fires)
124 if(get_value()!=prev)
129 return BC_TextBox::deactivate();
132 int BB_Tumble::button_press_event(){
134 if(get_buttonpress() < 4) return BC_TextBox::button_press_event();
135 if(get_buttonpress() == 4){
136 float v = get_value()+increment;
140 }else if(get_buttonpress() == 5){
141 float v = get_value()-increment;
151 int BB_Tumble::keypress_event(){
152 if(active && get_keypress()==ESC)
155 // don't fire update events from every keypress when editing; that
156 // will trigger slider updates, which will then sanity-check/clamp
157 // values, and then update/clobber the readout text while we're
160 int ret = BC_TextBox::keypress_event();
165 // --------------------------------------------------------------------------------
167 // 1) create_objects() constructs sliders and readouts with
168 // limits but no values
169 // 2) create_objects() then calls slider update()
170 // update computes and sets slider vals from config
171 // update computes and sets readout vals from config
173 // slider drag event:
174 // 1) slider calls handle_event(). This updates config.
175 // 2) slider calls update()
176 // update computes and [re]sets slider vals from config;
177 // this is where the snap-to-value behavior comes from
178 // update computes and sets readout vals from config
181 // 1) readout calls handle_event(). This updates config.
182 // 2) readout calls slider update() directly
183 // slider update computes and sets slider vals from config
184 // slider update computes and [re]sets readout vals from config;
185 // this does not result in a further handle_event() call, so
186 // no infinite recursion.
188 // importantly, readout and slider values are set from the config
189 // (and vice-versa) in only one place each.
191 // ---------------------------- hue adjustment slider -------------------------------
193 class BluebananaHAReadout : public BB_Tumble {
195 BluebananaHAReadout(BluebananaMain *plugin, BluebananaWindow *gui, int w)
196 : BB_Tumble(plugin,gui,rint(-180),0,rint(180), 0,1,w){}
200 class BluebananaHASlider : public BluebananaSliderSingle {
202 BluebananaHASlider(BluebananaMain *plugin, BluebananaWindow *gui,
203 int x, int y, int w, int h)
204 : BluebananaSliderSingle(plugin,gui,x,y,w,h,-180,180){
206 virtual int handle_event() {
207 plugin->config.Hadj_val = val;
211 plugin->config.Hadj_val=0;
215 val=plugin->config.Hadj_val;
216 highlight = plugin->config.active && plugin->config.Hadj_active;
217 gui->Hadj_readout->update(plugin->config.Hadj_val);
218 gui->slider_labels[7]->set_color(highlight && plugin->config.Hadj_val ?
219 get_resources()->default_text_color : dimtextcolor);
220 gui->enter_config_change();
221 gui->commit_config_change();
223 void trough_color(float hdel, float vdel, float &r, float &g, float &b, float &a){
224 float Hshift = plugin->config.Hsel_active ? (plugin->config.Hsel_lo + plugin->config.Hsel_hi)/720.f-.5f : 0.f;
225 float deg = hdel+Hshift;
228 HSpV_to_RGB(deg*6.f,1.,.2,r,g,b);
233 int BluebananaHAReadout::value_event(){
234 float val = get_value();
235 if(val<-180)val=-180;
237 plugin->config.Hadj_val = val;
238 gui->Hadj_slider->update();
242 // ------------------------------ Filter selection slider --------------------------------
243 class BluebananaFSReadout0 : public BB_Tumble {
245 BluebananaFSReadout0(BluebananaMain *plugin, BluebananaWindow *gui, int w)
246 : BB_Tumble(plugin,gui,-FSrange,0,FSrange, 0,1,w){}
249 class BluebananaFSReadout1 : public BB_Tumble {
251 BluebananaFSReadout1(BluebananaMain *plugin, BluebananaWindow *gui, int w)
252 : BB_Tumble(plugin,gui,-FSrange,0,FSrange, 0,1,w){}
255 class BluebananaFSReadout2 : public BB_Tumble {
257 BluebananaFSReadout2(BluebananaMain *plugin, BluebananaWindow *gui, int w)
258 : BB_Tumble(plugin,gui,-FSrange,0,FSrange, 0,1,w){}
261 class BluebananaFSReadout3 : public BB_Tumble {
263 BluebananaFSReadout3(BluebananaMain *plugin, BluebananaWindow *gui, int w)
264 : BB_Tumble(plugin,gui,0.,0,FSovermax, 0,1,w){}
268 static void paint_dot(float *array,int w, int h, float cx, float cy, float r, int inv){
270 int x0 = floor(cx-r);
271 int x1 = ceil(cx+r)+1;
272 int y0 = floor(cy-r);
273 int y1 = ceil(cy+r)+1;
286 float *row = array+y*w;
288 float rr = hypotf(x-cx,y-cy);
289 /* not correct, but this is merely cosmetic anyway */
294 if(row[x]>1.)row[x]=0.;
297 if(row[x]>1.)row[x]=1.;
304 class BluebananaFSSlider : public BluebananaSliderFill {
306 BluebananaFSSlider(BluebananaMain *plugin, BluebananaWindow *gui,
307 int x, int y, int w, int h)
308 : BluebananaSliderFill(plugin,gui,x,y,w,h,-FSrange,FSrange,FSovermax) {
310 recompute_trough_alpha = 1;
313 ~BluebananaFSSlider(){
314 if(trough_alpha)delete[] trough_alpha;
316 virtual int handle_event() {
317 plugin->config.Fsel_lo = (int)rint(loval);
318 plugin->config.Fsel_mid = (int)rint(midval);
319 plugin->config.Fsel_hi = (int)rint(hival);
320 plugin->config.Fsel_over = (int)rint(overval);
321 recompute_trough_alpha = 1;
325 if(plugin->config.Fsel_lo>0)plugin->config.Fsel_lo=0;
326 if(plugin->config.Fsel_hi<0)plugin->config.Fsel_hi=0;
328 if(highlight!=plugin->config.Fsel_active ||
329 erode!=plugin->config.Fsel_erode ||
330 loval!=plugin->config.Fsel_lo ||
331 midval!=plugin->config.Fsel_mid ||
332 hival!=plugin->config.Fsel_hi ||
333 overval!=plugin->config.Fsel_over){
334 recompute_trough_alpha = 1;
336 erode = plugin->config.Fsel_erode;
337 loval = plugin->config.Fsel_lo;
338 midval = plugin->config.Fsel_mid;
339 hival = plugin->config.Fsel_hi;
340 overval = plugin->config.Fsel_over;
341 highlight = plugin->config.Fsel_active;
342 gui->Fsel_readout0->update(plugin->config.Fsel_lo);
343 gui->Fsel_readout1->update(plugin->config.Fsel_mid);
344 gui->Fsel_readout2->update(plugin->config.Fsel_hi);
345 gui->Fsel_readout3->update(plugin->config.Fsel_over);
346 gui->slider_labels[3]->set_color
348 (plugin->config.Hsel_active || plugin->config.Ssel_active || plugin->config.Vsel_active) &&
349 (plugin->config.Fsel_lo != 0 ||
350 plugin->config.Fsel_mid != 0 ||
351 plugin->config.Fsel_hi != 0 ||
352 plugin->config.Fsel_over!= 0 ) ?
353 get_resources()->default_text_color : dimtextcolor);
355 gui->erode_label->set_color
356 (highlight && plugin->config.Fsel_lo && plugin->config.Fsel_hi &&
357 (plugin->config.Hsel_active || plugin->config.Ssel_active || plugin->config.Vsel_active)?
358 get_resources()->default_text_color : dimtextcolor);
360 gui->enter_config_change();
361 gui->commit_config_change();
363 void trough_color(float hdel, float vdel, float &r, float &g, float &b, float &a){
364 int x = rint(hdel*troughcols-.5);
365 int y = rint(vdel*troughlines-.5);
366 float deg = plugin->config.Hsel_active ?
367 vdel*(plugin->config.Hsel_hi-plugin->config.Hsel_lo)+plugin->config.Hsel_lo :
369 float sat = plugin->config.Ssel_active ?
370 (plugin->config.Ssel_hi+plugin->config.Ssel_lo)/200.:
372 float val = plugin->config.Vsel_active ?
373 (plugin->config.Vsel_hi*3+plugin->config.Vsel_lo)/400:
376 if(deg>=360)deg-=360.f;
377 HSpV_to_RGB(deg/60.,sat,val,r,g,b);
378 a = trough_alpha[troughcols*y+x];
383 trough_alpha = new float[troughcols*troughlines];
385 if(recompute_trough_alpha){
386 int trough_border = FSrange;
387 int tw = troughcols*3+trough_border*2;
388 int th = troughlines*3+trough_border*2;
393 memset(work1,0,sizeof(work1));
396 float hival=FSrange*2-1;
397 float y0 = (th-1)/2.;
398 float y1 = (th-1)/2.;
400 int spacing=rint(FSrange)*2;
404 while((y0+spacing*.5)>0){
405 for(x=(rowflag?spacing/2.:0.);x-spacing*.5<tw;x+=spacing){
406 float r = (((float)x/tw)*(hival-loval)+loval)*.5;
408 paint_dot(work1,tw,th,x,y0,r,0);
410 paint_dot(work1,tw,th,x,y0,r,0);
411 paint_dot(work1,tw,th,x,y1,r,0);
416 rowflag = (rowflag+1)&1;
419 float *final = work1;
420 if(plugin->config.Fsel_active &&
421 (plugin->config.Fsel_lo || plugin->config.Fsel_hi || plugin->config.Fsel_over))
422 final=plugin->fill_selection(work1,work2,tw,th,NULL);
424 /* subsample into trough */
425 float *in = final + (tw+1)*trough_border;
426 for(y=0;y<troughlines;y++){
427 float *out = trough_alpha + troughcols*y;
428 for(x=0;x<troughcols;x++)
429 out[x] = (in[x*3]+in[x*3+1]+in[x*3+2]+
430 in[tw+x*3]+in[tw+x*3+1]+in[x*3+2]+
431 in[tw*2+x*3]+in[tw*2+x*3+1]+in[tw*2+x*3+2])*.1111;
436 recompute_trough_alpha=0;
437 BluebananaSliderFill::update();
442 int recompute_trough_alpha;
446 int BluebananaFSReadout0::value_event(){
447 float val = rint(get_value());
448 if(val<-FSrange)val=-FSrange;
450 if(val>plugin->config.Fsel_mid) val = plugin->config.Fsel_mid;
451 plugin->config.Fsel_lo = val;
452 gui->Fsel_slider->update();
456 int BluebananaFSReadout1::value_event(){
457 float val = rint(get_value());
458 if(val<-FSrange)val=-FSrange;
459 if(val>FSrange)val=FSrange;
460 if(val<plugin->config.Fsel_lo) plugin->config.Fsel_lo=val;
461 if(val>plugin->config.Fsel_hi) plugin->config.Fsel_hi=val;
462 plugin->config.Fsel_mid = val;
463 gui->Fsel_slider->update();
467 int BluebananaFSReadout2::value_event(){
468 float val = rint(get_value());
470 if(val>FSrange)val=FSrange;
471 if(val<plugin->config.Fsel_mid) val = plugin->config.Fsel_mid;
472 plugin->config.Fsel_hi = val;
473 gui->Fsel_slider->update();
477 int BluebananaFSReadout3::value_event(){
478 float val = rint(get_value());
480 if(val>FSovermax)val=FSovermax;
481 plugin->config.Fsel_over = val;
482 gui->Fsel_slider->update();
486 // ------------------------------ value selection slider --------------------------------
487 class BluebananaVSReadout0 : public BB_Tumble {
489 BluebananaVSReadout0(BluebananaMain *plugin, BluebananaWindow *gui, int w)
490 : BB_Tumble(plugin,gui,0.,0,100., 0,1,w){}
493 class BluebananaVSReadout1 : public BB_Tumble {
495 BluebananaVSReadout1(BluebananaMain *plugin, BluebananaWindow *gui, int w)
496 : BB_Tumble(plugin,gui,0.,0,100., 0,1,w){}
499 class BluebananaVSReadout2 : public BB_Tumble {
501 BluebananaVSReadout2(BluebananaMain *plugin, BluebananaWindow *gui, int w)
502 : BB_Tumble(plugin,gui,0.,0,100., 0,1,w){}
506 class BluebananaVSSlider : public BluebananaSliderBracket {
508 BluebananaVSSlider(BluebananaMain *plugin, BluebananaWindow *gui,
509 int x, int y, int w, int h)
510 : BluebananaSliderBracket(plugin,gui,x,y,w,h,0,100) { }
511 virtual int handle_event() {
512 plugin->config.Vsel_lo = rint(loval);
513 plugin->config.Vsel_hi = rint(hival);
514 plugin->config.Vsel_over = rint(overval);
518 int delta = plugin->config.Vsel_hi - plugin->config.Vsel_lo;
519 float r = plugin->get_red();
520 float g = plugin->get_green();
521 float b = plugin->get_blue();
523 RGB_to_HSpV(r,g,b,h,s,v);
528 if(delta>25)delta=25;
529 int lo = v - delta/2;
531 /* shrink the brackets if necessary */
540 plugin->config.Vsel_lo=lo;
541 plugin->config.Vsel_hi=hi;
542 plugin->config.Vsel_active=1;
543 gui->Vsel_active->update(); // this will also call the slider update
546 loval = plugin->config.Vsel_lo;
547 hival = plugin->config.Vsel_hi;
548 midval = (loval+hival)/2.f;
549 overval = plugin->config.Vsel_over;
550 highlight = plugin->config.Vsel_active;
552 gui->Vsel_readout0->update(plugin->config.Vsel_lo);
553 gui->Vsel_readout1->update(plugin->config.Vsel_hi);
554 gui->Vsel_readout2->update(plugin->config.Vsel_over);
555 gui->slider_labels[2]->set_color
556 (highlight && (plugin->config.Vsel_lo != 0 || plugin->config.Vsel_hi != 100) ?
557 get_resources()->default_text_color : dimtextcolor);
559 gui->enter_config_change();
560 if(gui->Fsel_slider)gui->Fsel_slider->update();
561 gui->commit_config_change();
563 void trough_color(float hdel, float vdel, float &r, float &g, float &b, float &a){
564 float deg = plugin->config.Hsel_active ?
565 vdel*(plugin->config.Hsel_hi-plugin->config.Hsel_lo)+plugin->config.Hsel_lo :
567 float sat = plugin->config.Ssel_active ?
568 (plugin->config.Ssel_hi*3+plugin->config.Ssel_lo)/400.:
571 if(deg>=360)deg-=360.f;
572 HSpV_to_RGB(deg/60.,sat,hdel,r,g,b);
573 a= plugin->val_select_alpha(hdel);
577 int BluebananaVSReadout0::value_event(){
578 float val = get_value();
581 if(val>plugin->config.Vsel_hi) val = plugin->config.Vsel_hi;
582 plugin->config.Vsel_lo = val;
583 gui->Vsel_slider->update();
587 int BluebananaVSReadout1::value_event(){
588 float val = get_value();
591 if(val<plugin->config.Vsel_lo) val = plugin->config.Vsel_lo;
592 plugin->config.Vsel_hi = val;
593 gui->Vsel_slider->update();
597 int BluebananaVSReadout2::value_event(){
598 float val = get_value();
601 plugin->config.Vsel_over = val;
602 gui->Vsel_slider->update();
606 // ----------------------------- saturation selection slider -----------------------------
607 class BluebananaSSReadout0 : public BB_Tumble {
609 BluebananaSSReadout0(BluebananaMain *plugin, BluebananaWindow *gui, int w)
610 : BB_Tumble(plugin,gui,0.,0,100., 0,1,w){}
613 class BluebananaSSReadout1 : public BB_Tumble {
615 BluebananaSSReadout1(BluebananaMain *plugin, BluebananaWindow *gui, int w)
616 : BB_Tumble(plugin,gui,0.,0,100., 0,1,w){}
619 class BluebananaSSReadout2 : public BB_Tumble {
621 BluebananaSSReadout2(BluebananaMain *plugin, BluebananaWindow *gui, int w)
622 : BB_Tumble(plugin,gui,0.,0,100., 0,1,w){}
626 class BluebananaSSSlider : public BluebananaSliderBracket {
628 BluebananaSSSlider(BluebananaMain *plugin, BluebananaWindow *gui,
629 int x, int y, int w, int h)
630 : BluebananaSliderBracket(plugin,gui,x,y,w,h,0,100) { }
632 plugin->config.Ssel_lo = rint(loval);
633 plugin->config.Ssel_hi = rint(hival);
634 plugin->config.Ssel_over = rint(overval);
638 int delta = plugin->config.Ssel_hi - plugin->config.Ssel_lo;
639 float r = plugin->get_red();
640 float g = plugin->get_green();
641 float b = plugin->get_blue();
643 RGB_to_HSpV(r,g,b,h,s,v);
648 if(delta>25)delta=25;
649 int lo = s - delta/2;
651 /* shrink the brackets if necessary */
660 plugin->config.Ssel_lo=lo;
661 plugin->config.Ssel_hi=hi;
662 plugin->config.Ssel_active=1;
663 gui->Ssel_active->update(); // this will also call the slider update
666 loval = plugin->config.Ssel_lo;
667 hival = plugin->config.Ssel_hi;
668 midval = (loval+hival)/2.f;
669 overval = plugin->config.Ssel_over;
670 highlight = plugin->config.Ssel_active;
672 gui->Ssel_readout0->update(plugin->config.Ssel_lo);
673 gui->Ssel_readout1->update(plugin->config.Ssel_hi);
674 gui->Ssel_readout2->update(plugin->config.Ssel_over);
675 gui->slider_labels[1]->set_color(highlight &&
676 (plugin->config.Ssel_lo != 0 || plugin->config.Ssel_hi != 100) ?
677 get_resources()->default_text_color : dimtextcolor);
679 gui->enter_config_change();
680 if(gui->Fsel_slider)gui->Fsel_slider->update();
681 gui->commit_config_change();
683 void trough_color(float hdel, float vdel, float &r, float &g, float &b, float &a){
684 float deg = plugin->config.Hsel_active ?
685 vdel*(plugin->config.Hsel_hi-plugin->config.Hsel_lo)+plugin->config.Hsel_lo :
687 if(deg>=360)deg-=360.f;
688 HSpV_to_RGB(deg/60.f,hdel,.7+.3*hdel,r,g,b);
689 a = plugin->sat_select_alpha(hdel);
693 int BluebananaSSReadout0::value_event(){
694 float val = get_value();
697 if(val>plugin->config.Ssel_hi) val = plugin->config.Ssel_hi;
698 plugin->config.Ssel_lo = val;
699 gui->Ssel_slider->update();
703 int BluebananaSSReadout1::value_event(){
704 float val = get_value();
707 if(val<plugin->config.Ssel_lo) val = plugin->config.Ssel_lo;
708 plugin->config.Ssel_hi = val;
709 gui->Ssel_slider->update();
713 int BluebananaSSReadout2::value_event(){
714 float val = get_value();
717 plugin->config.Ssel_over = val;
718 gui->Ssel_slider->update();
722 // ----------------------------- hue selection slider ---------------------------------
723 class BluebananaHSReadout0 : public BB_Tumble {
725 BluebananaHSReadout0(BluebananaMain *plugin, BluebananaWindow *gui, int w)
726 : BB_Tumble(plugin,gui,0.,0,360., 0,1,w){}
729 class BluebananaHSReadout1 : public BB_Tumble {
731 BluebananaHSReadout1(BluebananaMain *plugin, BluebananaWindow *gui, int w)
732 : BB_Tumble(plugin,gui,0.,0,360., 0,1,w){}
735 class BluebananaHSReadout2 : public BB_Tumble {
737 BluebananaHSReadout2(BluebananaMain *plugin, BluebananaWindow *gui, int w)
738 : BB_Tumble(plugin,gui,0.,360.,360., 0,1,w){}
742 class BluebananaHSSlider : public BluebananaSliderCircular {
744 BluebananaHSSlider(BluebananaMain *plugin, BluebananaWindow *gui,
745 int x, int y, int w, int h)
746 : BluebananaSliderCircular(plugin,gui,x,y,w,h,0,360) {
749 plugin->config.Hsel_lo = rint(loval);
750 plugin->config.Hsel_hi = plugin->config.Hsel_lo +
751 (midval<loval ? rint(midval*2-loval*2+720) : rint(midval*2-loval*2));
752 plugin->config.Hsel_over = rint(overval);
756 int delta = plugin->config.Hsel_hi - plugin->config.Hsel_lo;
757 float r = plugin->get_red();
758 float g = plugin->get_green();
759 float b = plugin->get_blue();
761 RGB_to_HSpV(r,g,b,h,s,v);
765 if(delta>30)delta=30;
766 int lo = h - delta/2;
772 plugin->config.Hsel_lo=lo;
773 plugin->config.Hsel_hi=hi;
774 plugin->config.Hsel_active=1;
775 gui->Hsel_active->update(); // this will also call the slider update
778 // Significantly more complex than the other sliders due to the
780 //float delta = (plugin->config.Hsel_hi - plugin->config.Hsel_lo);
781 loval = plugin->config.Hsel_lo;
782 overval = plugin->config.Hsel_over;
783 float newhival = plugin->config.Hsel_hi;
784 float newmidval = (loval+newhival)/2.;
785 if(loval<0)loval+=360.;
786 if(loval>360.)loval-=360.;
787 if(newmidval<0)newmidval+=360.;
788 if(newmidval>360.)newmidval-=360.;
789 if(newhival<0)newhival+=360.;
790 if(newhival>360.)newhival-=360.;
791 highlight = plugin->config.Hsel_active;
793 float checkhi = plugin->config.Hsel_hi;
794 if(checkhi>360)checkhi-=360;
796 // one last weirdness; 0 and 360 are technically the same value on
797 // the circular scale, but the user can set either. This isn't a
798 // problem with lo as it doesn't wrap, but mid/hi is computed for
799 // the slider and could end up at 0 or 360, and then clobber the
800 // slider/readout. To avoid annoying the user, don't override an
801 // existing readout/slider setting with its equivalent.
802 if(newhival==0 && hival==360.){
805 }else if(newhival==360 && hival==0.){
808 }else if(checkhi==0 && gui->Hsel_readout2->get_value()==360){
811 }else if(checkhi==360 && gui->Hsel_readout2->get_value()==0){
816 if(newmidval<1 && midval>359){
818 }else if(newmidval>359.f && midval<1.){
824 gui->Hsel_readout0->update(plugin->config.Hsel_lo);
825 gui->Hsel_readout1->update(checkhi);
826 gui->Hsel_readout2->update(plugin->config.Hsel_over);
827 gui->slider_labels[0]->set_color(highlight &&
828 (plugin->config.Hsel_hi - plugin->config.Hsel_lo != 360) ?
829 get_resources()->default_text_color : dimtextcolor);
831 gui->enter_config_change();
832 if(gui->Fsel_slider)gui->Fsel_slider->update();
833 gui->commit_config_change();
835 void trough_color(float hdel, float vdel, float &r, float &g, float &b, float &a){
836 float deg = hdel*360.f;
837 if(deg>=360)deg-=360.f;
839 HSpV_to_RGB(deg/60.f,1.f,1.f,r,g,b);
840 a = plugin->hue_select_alpha(hdel*360.f);
842 friend class BluebananaHSReadout1;
843 friend class BluebananaHSReadout2;
846 int BluebananaHSReadout0::value_event(){
847 plugin->config.Hsel_lo = get_value();
848 if(plugin->config.Hsel_lo<0)plugin->config.Hsel_lo=0;
849 if(plugin->config.Hsel_lo>360)plugin->config.Hsel_lo=360;
850 if(plugin->config.Hsel_hi - plugin->config.Hsel_lo > 360)
851 plugin->config.Hsel_hi-=360;
852 if(plugin->config.Hsel_lo > plugin->config.Hsel_hi)
853 plugin->config.Hsel_hi+=360;
854 gui->Hsel_slider->update();
858 int BluebananaHSReadout1::value_event(){
859 plugin->config.Hsel_hi = get_value();
860 if(plugin->config.Hsel_hi<0)plugin->config.Hsel_hi=0;
861 if(plugin->config.Hsel_hi>360)plugin->config.Hsel_hi=360;
862 if(plugin->config.Hsel_lo > plugin->config.Hsel_hi)
863 plugin->config.Hsel_hi+=360;
864 gui->Hsel_slider->hival=-1; /* force update to hival, not the hi readout */
865 gui->Hsel_slider->update();
869 int BluebananaHSReadout2::value_event(){
870 float val = get_value();
873 plugin->config.Hsel_over=val;
874 gui->Hsel_slider->update();
878 // ---------------------------- saturation adjustment slider ----------------------------
879 class BluebananaSAReadout0 : public BB_Tumble {
881 BluebananaSAReadout0(BluebananaMain *plugin, BluebananaWindow *gui, int w)
882 : BB_Tumble(plugin,gui,-100,0,100., 0,1,w){}
885 class BluebananaSAReadout1 : public BB_Tumble {
887 BluebananaSAReadout1(BluebananaMain *plugin, BluebananaWindow *gui, int w)
888 : BB_Tumble(plugin,gui,0.,0,200., 0,1,w){}
891 class BluebananaSAReadout2 : public BB_Tumble {
893 BluebananaSAReadout2(BluebananaMain *plugin, BluebananaWindow *gui, int w)
894 : BB_Tumble(plugin,gui,MIN_GAMMA,0,MAX_GAMMA,2,.01,w){}
898 class BluebananaSASlider : public BluebananaSliderChannel {
900 BluebananaSASlider(BluebananaMain *plugin, BluebananaWindow *gui,
901 int x, int y, int w, int h)
902 : BluebananaSliderChannel(plugin,gui,x,y,w,h) { }
903 virtual int handle_event() {
904 plugin->config.Sadj_lo = loval;
905 plugin->config.Sadj_hi = hival;
906 plugin->config.Sadj_gamma = gamma;
910 plugin->config.Sadj_lo=0.;
911 plugin->config.Sadj_hi=100.;
912 plugin->config.Sadj_gamma=1.;
916 loval = plugin->config.Sadj_lo;
917 hival = plugin->config.Sadj_hi;
918 gamma = plugin->config.Sadj_gamma;
920 highlight = plugin->config.active && plugin->config.Sadj_active;
922 gui->Sadj_readout0->update(plugin->config.Sadj_lo);
923 gui->Sadj_readout1->update(plugin->config.Sadj_hi);
924 gui->Sadj_readout2->update(plugin->config.Sadj_gamma);
925 gui->slider_labels[8]->set_color(highlight &&
926 (plugin->config.Sadj_lo != 0 ||
927 plugin->config.Sadj_hi != 100 ||
928 plugin->config.Sadj_gamma != 1.) ?
929 get_resources()->default_text_color : dimtextcolor);
931 gui->enter_config_change();
932 gui->commit_config_change();
934 void trough_color(float hdel, float &r, float &g, float &b){
939 #define BBCLAMP(x,y,z) ((x)<(y) ? (y) : (x)>(z) ? (z) : (x))
941 int BluebananaSAReadout0::value_event(){
942 plugin->config.Sadj_lo = BBCLAMP(get_value(),-100,plugin->config.Sadj_hi);
943 plugin->config.Sadj_lo = BBCLAMP(get_value(),-100,100);
944 gui->Sadj_slider->update();
947 int BluebananaSAReadout1::value_event(){
948 plugin->config.Sadj_hi = BBCLAMP(get_value(),plugin->config.Sadj_lo,200);
949 plugin->config.Sadj_hi = BBCLAMP(get_value(),0,200);
950 gui->Sadj_slider->update();
953 int BluebananaSAReadout2::value_event(){
954 plugin->config.Sadj_gamma = BBCLAMP(get_value(),MIN_GAMMA,MAX_GAMMA);
955 gui->Sadj_slider->update();
959 // ------------------------------- value adjustment slider -------------------------------
960 class BluebananaVAReadout0 : public BB_Tumble {
962 BluebananaVAReadout0(BluebananaMain *plugin, BluebananaWindow *gui, int w)
963 : BB_Tumble(plugin,gui,-100.,0,100., 0,1,w){}
966 class BluebananaVAReadout1 : public BB_Tumble {
968 BluebananaVAReadout1(BluebananaMain *plugin, BluebananaWindow *gui, int w)
969 : BB_Tumble(plugin,gui,0.,0,200., 0,1,w){}
972 class BluebananaVAReadout2 : public BB_Tumble {
974 BluebananaVAReadout2(BluebananaMain *plugin, BluebananaWindow *gui, int w)
975 : BB_Tumble(plugin,gui,MIN_GAMMA,0,MAX_GAMMA,2,.01,w){}
979 class BluebananaVASlider : public BluebananaSliderChannel {
981 BluebananaVASlider(BluebananaMain *plugin, BluebananaWindow *gui,
982 int x, int y, int w, int h)
983 : BluebananaSliderChannel(plugin,gui,x,y,w,h) { }
984 virtual int handle_event() {
985 plugin->config.Vadj_lo = loval;
986 plugin->config.Vadj_hi = hival;
987 plugin->config.Vadj_gamma = gamma;
991 plugin->config.Vadj_lo=0;
992 plugin->config.Vadj_hi=100;
993 plugin->config.Vadj_gamma=1;
997 loval = plugin->config.Vadj_lo;
998 hival = plugin->config.Vadj_hi;
999 gamma = plugin->config.Vadj_gamma;
1001 highlight = plugin->config.active && plugin->config.Vadj_active;
1003 gui->Vadj_readout0->update(plugin->config.Vadj_lo);
1004 gui->Vadj_readout1->update(plugin->config.Vadj_hi);
1005 gui->Vadj_readout2->update(plugin->config.Vadj_gamma);
1006 gui->slider_labels[9]->set_color(highlight &&
1007 (plugin->config.Vadj_lo != 0.f ||
1008 plugin->config.Vadj_hi != 100.f ||
1009 plugin->config.Vadj_gamma != 1.f) ?
1010 get_resources()->default_text_color : dimtextcolor);
1012 gui->enter_config_change();
1013 gui->commit_config_change();
1015 void trough_color(float hdel, float &r, float &g, float &b){
1020 int BluebananaVAReadout0::value_event(){
1021 plugin->config.Vadj_lo = BBCLAMP(get_value(),-100,plugin->config.Vadj_hi);
1022 plugin->config.Vadj_lo = BBCLAMP(get_value(),-100,100);
1023 gui->Vadj_slider->update();
1026 int BluebananaVAReadout1::value_event(){
1027 plugin->config.Vadj_hi = BBCLAMP(get_value(),plugin->config.Vadj_lo,200);
1028 plugin->config.Vadj_hi = BBCLAMP(get_value(),0,200);
1029 gui->Vadj_slider->update();
1032 int BluebananaVAReadout2::value_event(){
1033 plugin->config.Vadj_gamma = BBCLAMP(get_value(),MIN_GAMMA,MAX_GAMMA);
1034 gui->Vadj_slider->update();
1038 // -------------------------------- red adjustment slider --------------------------------
1039 class BluebananaRAReadout0 : public BB_Tumble {
1041 BluebananaRAReadout0(BluebananaMain *plugin, BluebananaWindow *gui, int w)
1042 : BB_Tumble(plugin,gui,-100.,0,100., 0,1,w){}
1045 class BluebananaRAReadout1 : public BB_Tumble {
1047 BluebananaRAReadout1(BluebananaMain *plugin, BluebananaWindow *gui, int w)
1048 : BB_Tumble(plugin,gui,0.,0,200., 0,1,w){}
1051 class BluebananaRAReadout2 : public BB_Tumble {
1053 BluebananaRAReadout2(BluebananaMain *plugin, BluebananaWindow *gui, int w)
1054 : BB_Tumble(plugin,gui,MIN_GAMMA,0,MAX_GAMMA,2,.01,w){}
1058 class BluebananaRASlider : public BluebananaSliderChannel {
1060 BluebananaRASlider(BluebananaMain *plugin, BluebananaWindow *gui,
1061 int x, int y, int w, int h)
1062 : BluebananaSliderChannel(plugin,gui,x,y,w,h) { }
1063 virtual int handle_event() {
1064 plugin->config.Radj_lo = loval;
1065 plugin->config.Radj_hi = hival;
1066 plugin->config.Radj_gamma = gamma;
1070 plugin->config.Radj_lo=0;
1071 plugin->config.Radj_hi=100;
1072 plugin->config.Radj_gamma=1;
1076 loval = plugin->config.Radj_lo;
1077 hival = plugin->config.Radj_hi;
1078 gamma = plugin->config.Radj_gamma;
1080 highlight = plugin->config.active && plugin->config.Radj_active;
1082 gui->Radj_readout0->update(plugin->config.Radj_lo);
1083 gui->Radj_readout1->update(plugin->config.Radj_hi);
1084 gui->Radj_readout2->update(plugin->config.Radj_gamma);
1085 gui->slider_labels[4]->set_color(highlight &&
1086 (plugin->config.Radj_lo != 0 ||
1087 plugin->config.Radj_hi != 100 ||
1088 plugin->config.Radj_gamma != 1) ?
1089 get_resources()->default_text_color : dimtextcolor);
1091 gui->enter_config_change();
1092 gui->commit_config_change();
1094 void trough_color(float hdel, float &r, float &g, float &b){
1097 }else if(hdel<=1.f){
1107 int BluebananaRAReadout0::value_event(){
1108 plugin->config.Radj_lo = BBCLAMP(get_value(),-100,plugin->config.Radj_hi);
1109 plugin->config.Radj_lo = BBCLAMP(get_value(),-100,100);
1110 gui->Radj_slider->update();
1113 int BluebananaRAReadout1::value_event(){
1114 plugin->config.Radj_hi = BBCLAMP(get_value(),plugin->config.Radj_lo,200);
1115 plugin->config.Radj_hi = BBCLAMP(get_value(),0,200);
1116 gui->Radj_slider->update();
1119 int BluebananaRAReadout2::value_event(){
1120 plugin->config.Radj_gamma = BBCLAMP(get_value(),MIN_GAMMA,MAX_GAMMA);
1121 gui->Radj_slider->update();
1125 // ---------------------------- green adjustment slider ----------------------------
1126 class BluebananaGAReadout0 : public BB_Tumble {
1128 BluebananaGAReadout0(BluebananaMain *plugin, BluebananaWindow *gui, int w)
1129 : BB_Tumble(plugin,gui,-100.,0,100., 0,1,w){}
1132 class BluebananaGAReadout1 : public BB_Tumble {
1134 BluebananaGAReadout1(BluebananaMain *plugin, BluebananaWindow *gui, int w)
1135 : BB_Tumble(plugin,gui,0.,0,200., 0,1,w){}
1138 class BluebananaGAReadout2 : public BB_Tumble {
1140 BluebananaGAReadout2(BluebananaMain *plugin, BluebananaWindow *gui, int w)
1141 : BB_Tumble(plugin,gui,MIN_GAMMA,0,MAX_GAMMA,2,.01,w){}
1145 class BluebananaGASlider : public BluebananaSliderChannel {
1147 BluebananaGASlider(BluebananaMain *plugin, BluebananaWindow *gui,
1148 int x, int y, int w, int h)
1149 : BluebananaSliderChannel(plugin,gui,x,y,w,h) { }
1150 virtual int handle_event() {
1151 plugin->config.Gadj_lo = loval;
1152 plugin->config.Gadj_hi = hival;
1153 plugin->config.Gadj_gamma = gamma;
1157 plugin->config.Gadj_lo=0;
1158 plugin->config.Gadj_hi=100;
1159 plugin->config.Gadj_gamma=1;
1163 loval = plugin->config.Gadj_lo;
1164 hival = plugin->config.Gadj_hi;
1165 gamma = plugin->config.Gadj_gamma;
1167 highlight = plugin->config.active && plugin->config.Gadj_active;
1169 gui->Gadj_readout0->update(plugin->config.Gadj_lo);
1170 gui->Gadj_readout1->update(plugin->config.Gadj_hi);
1171 gui->Gadj_readout2->update(plugin->config.Gadj_gamma);
1172 gui->slider_labels[5]->set_color(highlight &&
1173 (plugin->config.Gadj_lo != 0 ||
1174 plugin->config.Gadj_hi != 100 ||
1175 plugin->config.Gadj_gamma != 1) ?
1176 get_resources()->default_text_color : dimtextcolor);
1178 gui->enter_config_change();
1179 gui->commit_config_change();
1181 void trough_color(float hdel, float &r, float &g, float &b){
1184 }else if(hdel<=1.f){
1194 int BluebananaGAReadout0::value_event(){
1195 plugin->config.Gadj_lo = BBCLAMP(get_value(),-100,plugin->config.Gadj_hi);
1196 plugin->config.Gadj_lo = BBCLAMP(get_value(),-100,100);
1197 gui->Gadj_slider->update();
1200 int BluebananaGAReadout1::value_event(){
1201 plugin->config.Gadj_hi = BBCLAMP(get_value(),plugin->config.Gadj_lo,200);
1202 plugin->config.Gadj_hi = BBCLAMP(get_value(),0,200);
1203 gui->Gadj_slider->update();
1206 int BluebananaGAReadout2::value_event(){
1207 plugin->config.Gadj_gamma = BBCLAMP(get_value(),MIN_GAMMA,MAX_GAMMA);
1208 gui->Gadj_slider->update();
1212 // ------------------------------- blue adjustment slider -------------------------------
1213 class BluebananaBAReadout0 : public BB_Tumble {
1215 BluebananaBAReadout0(BluebananaMain *plugin, BluebananaWindow *gui, int w)
1216 : BB_Tumble(plugin,gui,-100.,0,100., 0,1,w){}
1219 class BluebananaBAReadout1 : public BB_Tumble {
1221 BluebananaBAReadout1(BluebananaMain *plugin, BluebananaWindow *gui, int w)
1222 : BB_Tumble(plugin,gui,0.,0,200., 0,1,w){}
1225 class BluebananaBAReadout2 : public BB_Tumble {
1227 BluebananaBAReadout2(BluebananaMain *plugin, BluebananaWindow *gui, int w)
1228 : BB_Tumble(plugin,gui,MIN_GAMMA,0,MAX_GAMMA,2,.01,w){}
1232 class BluebananaBASlider : public BluebananaSliderChannel {
1234 BluebananaBASlider(BluebananaMain *plugin, BluebananaWindow *gui,
1235 int x, int y, int w, int h)
1236 : BluebananaSliderChannel(plugin,gui,x,y,w,h) { }
1237 virtual int handle_event() {
1238 plugin->config.Badj_lo = loval;
1239 plugin->config.Badj_hi = hival;
1240 plugin->config.Badj_gamma = gamma;
1244 plugin->config.Badj_lo=0;
1245 plugin->config.Badj_hi=100;
1246 plugin->config.Badj_gamma=1;
1250 loval = plugin->config.Badj_lo;
1251 hival = plugin->config.Badj_hi;
1252 gamma = plugin->config.Badj_gamma;
1254 highlight = plugin->config.active && plugin->config.Badj_active;
1256 gui->Badj_readout0->update(plugin->config.Badj_lo);
1257 gui->Badj_readout1->update(plugin->config.Badj_hi);
1258 gui->Badj_readout2->update(plugin->config.Badj_gamma);
1259 gui->slider_labels[6]->set_color(highlight &&
1260 (plugin->config.Badj_lo != 0 ||
1261 plugin->config.Badj_hi != 100 ||
1262 plugin->config.Badj_gamma != 1) ?
1263 get_resources()->default_text_color : dimtextcolor);
1265 gui->enter_config_change();
1266 gui->commit_config_change();
1268 void trough_color(float hdel, float &r, float &g, float &b){
1271 }else if(hdel<=1.f){
1281 int BluebananaBAReadout0::value_event(){
1282 plugin->config.Badj_lo = BBCLAMP(get_value(),-100,plugin->config.Badj_hi);
1283 plugin->config.Badj_lo = BBCLAMP(get_value(),-100,100);
1284 gui->Badj_slider->update();
1287 int BluebananaBAReadout1::value_event(){
1288 plugin->config.Badj_hi = BBCLAMP(get_value(),plugin->config.Badj_lo,200);
1289 plugin->config.Badj_hi = BBCLAMP(get_value(),0,200);
1290 gui->Badj_slider->update();
1293 int BluebananaBAReadout2::value_event(){
1294 plugin->config.Badj_gamma = BBCLAMP(get_value(),MIN_GAMMA,MAX_GAMMA);
1295 gui->Badj_slider->update();
1299 // ---------------------------------- opacity slider ---------------------------------
1300 class BluebananaOAReadout : public BB_Tumble {
1302 BluebananaOAReadout(BluebananaMain *plugin, BluebananaWindow *gui, int w)
1303 : BB_Tumble(plugin,gui,0.,0,100., 0,1,w){}
1307 class BluebananaOASlider : public BluebananaSliderSingle {
1309 BluebananaOASlider(BluebananaMain *plugin, BluebananaWindow *gui,
1310 int x, int y, int w, int h)
1311 : BluebananaSliderSingle(plugin,gui,x,y,w,h,0,100) { }
1312 virtual int handle_event() {
1313 plugin->config.Oadj_val = val;
1317 plugin->config.Oadj_val=100;
1321 val = plugin->config.Oadj_val;
1322 highlight = plugin->config.active && plugin->config.Oadj_active;
1323 gui->Oadj_readout->update(plugin->config.Oadj_val);
1324 gui->slider_labels[10]->set_color(highlight &&
1325 plugin->config.Oadj_val != 100 ?
1326 get_resources()->default_text_color : dimtextcolor);
1327 gui->enter_config_change();
1328 gui->commit_config_change();
1330 void trough_color(float hdel, float vdel, float &r, float &g, float &b, float &a){
1332 a=1-cos(hdel*M_PI*.5);
1336 int BluebananaOAReadout::value_event(){
1337 float val = get_value();
1338 plugin->config.Oadj_val = val;
1339 gui->Oadj_slider->update();
1343 // ---------------------------------- alpha slider ---------------------------------
1344 class BluebananaAAReadout : public BB_Tumble {
1346 BluebananaAAReadout(BluebananaMain *plugin, BluebananaWindow *gui, int w)
1347 : BB_Tumble(plugin,gui,0.,0,100., 0,1,w){}
1351 class BluebananaAASlider : public BluebananaSliderSingle {
1353 BluebananaAASlider(BluebananaMain *plugin, BluebananaWindow *gui,
1354 int x, int y, int w, int h)
1355 : BluebananaSliderSingle(plugin,gui,x,y,w,h,0,100) {}
1356 virtual int handle_event() {
1357 plugin->config.Aadj_val = val;
1361 plugin->config.Aadj_val=100;
1365 val = plugin->config.Aadj_val;
1366 if( BC_CModels::has_alpha(plugin->colormodel) ) {
1367 if( is_hidden() ) show_window();
1369 if( !is_hidden() ) hide_window();
1371 if( is_hidden() ) return;
1372 highlight = plugin->config.active && plugin->config.Aadj_active;
1373 gui->Aadj_readout->update(plugin->config.Aadj_val);
1374 gui->slider_labels[11]->set_color(highlight && plugin->config.Aadj_val != 100 ?
1375 get_resources()->default_text_color : dimtextcolor);
1376 gui->enter_config_change();
1377 gui->commit_config_change();
1379 void trough_color(float hdel, float vdel, float &r, float &g, float &b, float &a){
1381 a=1-cos(hdel*M_PI*.5);
1385 int BluebananaAAReadout::value_event(){
1386 float val = get_value();
1387 plugin->config.Aadj_val = val;
1388 gui->Aadj_slider->update();
1392 // ------------------------------------- picker buttons -----------------------------------------
1393 class BluebananaHPicker : public BC_GenericButton{
1395 BluebananaHPicker(BluebananaWindow *gui, int w) : BC_GenericButton(-1, -1, w, _("Pick")){
1398 int handle_event() { gui->Hsel_slider->pick(); return 1; }
1399 BluebananaWindow *gui;
1401 class BluebananaSPicker : public BC_GenericButton{
1403 BluebananaSPicker(BluebananaWindow *gui, int w) : BC_GenericButton(-1, -1, w, _("Pick")){
1406 int handle_event() { gui->Ssel_slider->pick(); return 1; }
1407 BluebananaWindow *gui;
1409 class BluebananaVPicker : public BC_GenericButton{
1411 BluebananaVPicker(BluebananaWindow *gui, int w) : BC_GenericButton(-1, -1, w, _("Pick")){
1414 int handle_event() { gui->Vsel_slider->pick(); return 1; }
1415 BluebananaWindow *gui;
1418 // -------------------------------------- reset buttons -----------------------------------------
1420 class BluebananaHAReset : public BC_GenericButton{
1422 BluebananaHAReset(BluebananaWindow *gui, int w) : BC_GenericButton(-1, -1, w, _("Reset")){
1425 int handle_event() { gui->Hadj_slider->reset(); return 1;}
1426 BluebananaWindow *gui;
1428 class BluebananaSAReset : public BC_GenericButton{
1430 BluebananaSAReset(BluebananaWindow *gui, int w) : BC_GenericButton(-1, -1, w, _("Reset")){
1433 int handle_event() { gui->Sadj_slider->reset(); return 1;}
1434 BluebananaWindow *gui;
1436 class BluebananaVAReset : public BC_GenericButton{
1438 BluebananaVAReset(BluebananaWindow *gui, int w) : BC_GenericButton(-1, -1, w, _("Reset")){
1441 int handle_event() { gui->Vadj_slider->reset(); return 1;}
1442 BluebananaWindow *gui;
1444 class BluebananaRAReset : public BC_GenericButton{
1446 BluebananaRAReset(BluebananaWindow *gui, int w) : BC_GenericButton(-1, -1, w, _("Reset")){
1449 int handle_event() { gui->Radj_slider->reset(); return 1;}
1450 BluebananaWindow *gui;
1452 class BluebananaGAReset : public BC_GenericButton{
1454 BluebananaGAReset(BluebananaWindow *gui, int w) : BC_GenericButton(-1, -1, w, _("Reset")){
1457 int handle_event() { gui->Gadj_slider->reset(); return 1;}
1458 BluebananaWindow *gui;
1460 class BluebananaBAReset : public BC_GenericButton{
1462 BluebananaBAReset(BluebananaWindow *gui, int w) : BC_GenericButton(-1, -1, w, _("Reset")){
1465 int handle_event() { gui->Badj_slider->reset(); return 1;}
1466 BluebananaWindow *gui;
1468 class BluebananaOAReset : public BC_GenericButton{
1470 BluebananaOAReset(BluebananaWindow *gui, int w) : BC_GenericButton(-1, -1, w, _("Reset")){
1473 int handle_event() { gui->Oadj_slider->reset(); return 1;}
1474 BluebananaWindow *gui;
1476 class BluebananaAAReset : public BC_GenericButton{
1478 BluebananaAAReset(BluebananaWindow *gui, int w) : BC_GenericButton(-1, -1, w, _("Reset")){
1481 int handle_event() { gui->Aadj_slider->reset(); return 1;}
1482 BluebananaWindow *gui;
1485 // ----------------------------------- slider active buttons ------------------------------------
1487 BluebananaHActive::BluebananaHActive(BluebananaMain *plugin, BluebananaWindow *gui)
1488 : BC_CheckBox(-1, -1, &plugin->config.Hsel_active, ""){
1489 this->plugin = plugin;
1492 int BluebananaHActive::handle_event(){
1493 plugin->config.Hsel_active = get_value();
1497 void BluebananaHActive::update(){
1498 this->BC_CheckBox::update(plugin->config.Hsel_active,1);
1499 gui->Hsel_slider->update();
1502 BluebananaSActive::BluebananaSActive(BluebananaMain *plugin, BluebananaWindow *gui)
1503 : BC_CheckBox(-1, -1, &plugin->config.Ssel_active, ""){
1504 this->plugin = plugin;
1507 int BluebananaSActive::handle_event(){
1508 plugin->config.Ssel_active = get_value();
1512 void BluebananaSActive::update(){
1513 this->BC_CheckBox::update(plugin->config.Ssel_active,1);
1514 gui->Ssel_slider->update();
1517 BluebananaVActive::BluebananaVActive(BluebananaMain *plugin, BluebananaWindow *gui)
1518 : BC_CheckBox(-1, -1, &plugin->config.Vsel_active, ""){
1519 this->plugin = plugin;
1522 int BluebananaVActive::handle_event(){
1523 plugin->config.Vsel_active = get_value();
1527 void BluebananaVActive::update(){
1528 this->BC_CheckBox::update(plugin->config.Vsel_active,1);
1529 gui->Vsel_slider->update();
1532 class BluebananaFActive : public BC_CheckBox {
1534 BluebananaFActive(BluebananaMain *plugin, BluebananaWindow *gui)
1535 : BC_CheckBox(-1, -1, &plugin->config.Fsel_active, ""){
1536 this->plugin = plugin;
1539 virtual int handle_event(){
1540 plugin->config.Fsel_active = get_value();
1545 this->BC_CheckBox::update(plugin->config.Fsel_active,1);
1546 gui->Fsel_slider->update();
1548 BluebananaMain *plugin;
1549 BluebananaWindow *gui;
1552 class BluebananaHAActive : public BC_CheckBox {
1554 BluebananaHAActive(BluebananaMain *plugin, BluebananaWindow *gui)
1555 : BC_CheckBox(-1, -1, &plugin->config.Hadj_active, ""){
1556 this->plugin = plugin;
1559 virtual int handle_event(){
1560 plugin->config.Hadj_active = get_value();
1565 this->BC_CheckBox::update(plugin->config.Hadj_active,1);
1566 gui->Hadj_slider->update();
1568 BluebananaMain *plugin;
1569 BluebananaWindow *gui;
1572 class BluebananaSAActive : public BC_CheckBox {
1574 BluebananaSAActive(BluebananaMain *plugin, BluebananaWindow *gui)
1575 : BC_CheckBox(-1, -1, &plugin->config.Sadj_active, ""){
1576 this->plugin = plugin;
1579 virtual int handle_event(){
1580 plugin->config.Sadj_active = get_value();
1585 this->BC_CheckBox::update(plugin->config.Sadj_active,1);
1586 gui->Sadj_slider->update();
1588 BluebananaMain *plugin;
1589 BluebananaWindow *gui;
1592 class BluebananaVAActive : public BC_CheckBox {
1594 BluebananaVAActive(BluebananaMain *plugin, BluebananaWindow *gui)
1595 : BC_CheckBox(-1, -1, &plugin->config.Vadj_active, ""){
1596 this->plugin = plugin;
1599 virtual int handle_event(){
1600 plugin->config.Vadj_active = get_value();
1605 this->BC_CheckBox::update(plugin->config.Vadj_active,1);
1606 gui->Vadj_slider->update();
1608 BluebananaMain *plugin;
1609 BluebananaWindow *gui;
1612 class BluebananaRAActive : public BC_CheckBox {
1614 BluebananaRAActive(BluebananaMain *plugin, BluebananaWindow *gui)
1615 : BC_CheckBox(-1, -1, &plugin->config.Radj_active, ""){
1616 this->plugin = plugin;
1619 virtual int handle_event(){
1620 plugin->config.Radj_active = get_value();
1625 this->BC_CheckBox::update(plugin->config.Radj_active,1);
1626 gui->Radj_slider->update();
1628 BluebananaMain *plugin;
1629 BluebananaWindow *gui;
1632 class BluebananaGAActive : public BC_CheckBox {
1634 BluebananaGAActive(BluebananaMain *plugin, BluebananaWindow *gui)
1635 : BC_CheckBox(-1, -1, &plugin->config.Gadj_active, ""){
1636 this->plugin = plugin;
1639 virtual int handle_event(){
1640 plugin->config.Gadj_active = get_value();
1645 this->BC_CheckBox::update(plugin->config.Gadj_active,1);
1646 gui->Gadj_slider->update();
1648 BluebananaMain *plugin;
1649 BluebananaWindow *gui;
1652 class BluebananaBAActive : public BC_CheckBox {
1654 BluebananaBAActive(BluebananaMain *plugin, BluebananaWindow *gui)
1655 : BC_CheckBox(-1, -1, &plugin->config.Badj_active, ""){
1656 this->plugin = plugin;
1659 virtual int handle_event(){
1660 plugin->config.Badj_active = get_value();
1665 this->BC_CheckBox::update(plugin->config.Badj_active,1);
1666 gui->Badj_slider->update();
1668 BluebananaMain *plugin;
1669 BluebananaWindow *gui;
1672 class BluebananaOAActive : public BC_CheckBox {
1674 BluebananaOAActive(BluebananaMain *plugin, BluebananaWindow *gui)
1675 : BC_CheckBox(-1, -1, &plugin->config.Oadj_active, ""){
1676 this->plugin = plugin;
1679 virtual int handle_event(){
1680 plugin->config.Oadj_active = get_value();
1685 this->BC_CheckBox::update(plugin->config.Oadj_active,1);
1686 gui->Oadj_slider->update();
1688 BluebananaMain *plugin;
1689 BluebananaWindow *gui;
1692 class BluebananaAAActive : public BC_CheckBox {
1695 BluebananaAAActive(BluebananaMain *plugin, BluebananaWindow *gui)
1696 : BC_CheckBox(-1, -1, &plugin->config.Aadj_active, ""){
1697 this->plugin = plugin;
1700 virtual int handle_event(){
1701 plugin->config.Aadj_active =
1702 !BC_CModels::has_alpha(plugin->colormodel) ? 0 : get_value();
1707 this->BC_CheckBox::update(plugin->config.Aadj_active,1);
1708 if( BC_CModels::has_alpha(plugin->colormodel) ) {
1709 if( is_hidden() ) show_window();
1711 if( !is_hidden() ) hide_window();
1713 if( is_hidden() ) return;
1714 gui->Aadj_slider->update();
1716 BluebananaMain *plugin;
1717 BluebananaWindow *gui;
1720 // -------------------------------------------- Erode --------------------------------------------
1721 class BluebananaErode : public BC_CheckBox {
1723 BluebananaErode(BluebananaMain *plugin, BluebananaWindow *gui)
1724 : BC_CheckBox(-1, -1, &plugin->config.Fsel_erode, ""){
1725 this->plugin = plugin;
1728 virtual int handle_event(){
1729 plugin->config.Fsel_erode = get_value();
1734 this->BC_CheckBox::update(plugin->config.Fsel_erode,1);
1735 gui->Fsel_slider->update();
1737 BluebananaMain *plugin;
1738 BluebananaWindow *gui;
1742 // -------------------------------------- Invert Selection ---------------------------------------
1743 class BluebananaIS : public BC_CheckBox {
1745 BluebananaIS(BluebananaMain *plugin, BluebananaWindow *gui)
1746 : BC_CheckBox(-1, -1, &plugin->config.invert_selection, ""){
1747 this->plugin = plugin;
1750 virtual int handle_event(){
1751 plugin->config.invert_selection = get_value();
1756 this->BC_CheckBox::update(plugin->config.invert_selection,1);
1757 gui->enter_config_change();
1758 gui->commit_config_change();
1760 BluebananaMain *plugin;
1761 BluebananaWindow *gui;
1765 // -------------------------------------------- Mark --------------------------------------------
1766 class BluebananaMark : public BC_CheckBox {
1768 BluebananaMark(BluebananaMain *plugin, BluebananaWindow *gui)
1769 : BC_CheckBox(-1, -1, 0, ""){
1770 this->plugin = plugin;
1773 virtual int handle_event() {
1774 if(plugin->config.mark != get_value()){
1775 plugin->config.mark = get_value();
1776 plugin->save_nonauto();
1777 if(plugin->config.mark){
1778 gui->set_repeat(207);
1780 gui->unset_repeat(207);
1782 plugin->server->mwindow->sync_parameters();
1787 if(plugin->config.mark != get_value()){
1788 this->BC_CheckBox::update(plugin->config.mark,1);
1789 if(plugin->config.mark){
1790 gui->set_repeat(207);
1792 gui->unset_repeat(207);
1796 BluebananaMain *plugin;
1797 BluebananaWindow *gui;
1800 // ------------------------------------------- Active -------------------------------------------
1801 class BluebananaActive : public BC_CheckBox {
1803 BluebananaActive(BluebananaMain *plugin, BluebananaWindow *gui)
1804 : BC_CheckBox(-1, -1, &plugin->config.active, ""){
1805 this->plugin = plugin;
1809 virtual int handle_event(){
1810 active = get_value();
1815 if(active != plugin->config.active){
1816 plugin->config.active = active;
1817 this->BC_CheckBox::update(plugin->config.active,1);
1818 gui->enter_config_change();
1819 gui->Hadj_slider->update();
1820 gui->Sadj_slider->update();
1821 gui->Vadj_slider->update();
1822 gui->Radj_slider->update();
1823 gui->Gadj_slider->update();
1824 gui->Badj_slider->update();
1825 gui->Oadj_slider->update();
1826 gui->Aadj_slider->update();
1827 gui->commit_config_change();
1830 BluebananaMain *plugin;
1831 BluebananaWindow *gui;
1835 // ---------------------------------------- Capture mask ---------------------------------------
1836 class BluebananaUnmask : public BC_CheckBox {
1838 BluebananaUnmask(BluebananaMain *plugin, BluebananaWindow *gui,int padx)
1839 : BC_CheckBox(-1, -1, &plugin->config.capture_mask, ""){
1840 this->plugin = plugin;
1843 this->label = new BC_Title(-1,-1,_(" End Mask"));
1846 gui->add_subwindow(this->label);
1847 gui->add_subwindow(this);
1849 virtual int handle_event(){
1850 plugin->config.capture_mask=get_value();
1851 plugin->save_nonauto();
1853 gui->enter_config_change();
1854 gui->commit_config_change();
1858 return label->get_h();
1861 return BC_CheckBox::get_w()+label->get_w()+padx*4;
1863 void reposition_window(int x, int y){
1864 int h = label->get_h();
1867 label->reposition_window(x+padx,y);
1868 BC_CheckBox::reposition_window(x+padx*2+label->get_w(),y+(h-BC_CheckBox::get_h())/2);
1875 int hideme = !plugin->config.use_mask;
1876 switch(plugin->colormodel){
1886 if(hideme && !is_hidden()){
1888 label->hide_window();
1889 gui->set_color(get_resources()->get_bg_color());
1890 gui->draw_box(x,y,w,h);
1891 gui->set_color(get_resources()->default_text_color);
1892 gui->draw_line(x,y+h/2,x+w,y+h/2);
1896 if(!hideme && is_hidden()){
1897 gui->set_color(get_resources()->get_bg_color());
1898 gui->draw_box(x,y,w,h);
1900 label->show_window();
1904 if(plugin->config.capture_mask != get_value())
1905 this->BC_CheckBox::update(plugin->config.capture_mask,1);
1907 gui->flash(x,y,w,h);
1909 BluebananaMain *plugin;
1910 BluebananaWindow *gui;
1915 // ------------------------------------------ Use mask ----------------------------------------
1916 class BluebananaA2Sel : public BC_CheckBox {
1918 BluebananaA2Sel(BluebananaMain *plugin, BluebananaWindow *gui,int padx)
1919 : BC_CheckBox(-1, -1, &plugin->config.use_mask, ""){
1920 this->plugin = plugin;
1923 this->label = new BC_Title(-1,-1,_(" Mask Selection"));
1926 gui->add_subwindow(this->label);
1927 gui->add_subwindow(this);
1929 virtual int handle_event(){
1930 plugin->config.use_mask=get_value();
1931 plugin->save_nonauto();
1933 gui->enter_config_change();
1934 gui->commit_config_change();
1938 return label->get_h();
1941 return BC_CheckBox::get_w()+label->get_w()+padx*4;
1943 void reposition_window(int x, int y){
1944 int h = label->get_h();
1947 label->reposition_window(x+padx,y);
1948 BC_CheckBox::reposition_window(x+padx*2+label->get_w(),y+(h-BC_CheckBox::get_h())/2);
1956 if(gui->capture_mask)
1957 gui->capture_mask->update();
1959 switch(plugin->colormodel){
1967 label->hide_window();
1968 gui->set_color(get_resources()->get_bg_color());
1969 gui->draw_box(x,y,w,h);
1970 gui->set_color(get_resources()->default_text_color);
1971 gui->draw_line(x,y+h/2,x+w,y+h/2);
1978 case BC_RGBA16161616:
1979 case BC_YUVA16161616:
1981 gui->set_color(get_resources()->get_bg_color());
1982 gui->draw_box(x,y,w,h);
1984 label->show_window();
1989 // not initialized yet
1992 fprintf(stderr,_("Unknown colormodel in BluebananaA2Sel:update()\n"));
1995 if(plugin->config.use_mask != get_value())
1996 this->BC_CheckBox::update(plugin->config.use_mask,1);
1998 gui->flash(x,y,w,h);
2000 BluebananaMain *plugin;
2001 BluebananaWindow *gui;
2006 // --------------------------------------- Main GUI window --------------------------------------
2007 BluebananaWindow::BluebananaWindow(BluebananaMain *plugin)
2008 : PluginClientWindow(plugin,1000,1000,0,1,1)
2013 this->plugin = plugin;
2014 config_refcount=1; // suppress pushing config during startup
2037 BluebananaWindow::~BluebananaWindow()
2041 void BluebananaWindow::create_objects()
2043 int xmargin = 20, ymargin = 10;
2044 float row_padding = .1;
2045 float column_padding = .3;
2049 int row_h=0, row_adv=0;
2055 int tumbler_w=0,tumbler_ww=0,tumbler_h=0;
2056 int tumbler_col1_x=0,tumbler_col2_x=0,tumbler_col2_w=0;
2059 //BluebananaHAReset *hareset=NULL;
2062 enter_config_change();
2064 /* window headline */
2066 BC_Title *l = new BC_Title(xmargin,y,_("Color Selection"));
2067 BC_Title *l2 = new BC_Title(-1,-1,_(" Mark Selected Areas"));
2068 add_subwindow(mark = new BluebananaMark(plugin,this));
2071 padx = l->get_h()*column_padding;
2072 label_x = xmargin + l->get_w();
2074 int x0 = get_w()-xmargin-mark->get_w();
2075 mark->reposition_window(x0,y-(mark->get_h()-l->get_h())/2);
2076 x0 -= padx+l2->get_w();
2077 l2->reposition_window(x0,y);
2080 set_color(get_resources()->default_text_color);
2081 draw_line(label_x+padx, (int)(y+l->get_h()*.5), x0, (int)(y+l->get_h()*.5));
2083 y += l->get_h()*(row_padding+1.);
2086 const char *labels[12]={_("hue"),_("saturation"),_("value"),_("fill"),_("red"),_("green"),_("blue"),_("hue"),_("saturation"),_("value"),_("fade"),_("alpha")};
2088 add_subwindow(slider_labels[i] = new BC_Title(-1,-1,labels[i]));
2089 if(slider_labels[i]->get_w()>label_w)label_w=slider_labels[i]->get_w();
2092 int tumbler_text_ww = MAX(get_text_width(MEDIUMFONT,"-000"),get_text_width(MEDIUMFONT,"5.00"))+8;
2093 int tumbler_text_w = get_text_width(MEDIUMFONT,"50")+8;
2094 if(tumbler_text_w*3<tumbler_text_ww*2){
2095 tumbler_text_ww = (tumbler_text_ww*2+2)/3*3/2;
2096 tumbler_text_w=tumbler_text_ww*2/3;
2099 erode_label = new BC_Title(xmargin,y,_("pre-erode"));
2100 BluebananaErode *erode = new BluebananaErode(plugin,this);
2101 add_subwindow(erode_label);
2102 add_subwindow(erode);
2105 BC_GenericButton *p=NULL;
2106 BluebananaSlider *s=NULL;
2107 BB_Tumble *t0 = NULL, *t1=NULL, *t2=NULL;
2108 BC_Toggle *a = NULL;
2109 BC_Title *l = slider_labels[i];
2114 add_subwindow(t0 = Hsel_readout0 = new BluebananaHSReadout0(plugin,this,tumbler_text_ww));
2115 add_subwindow(t1 = Hsel_readout1 = new BluebananaHSReadout1(plugin,this,tumbler_text_ww));
2116 add_subwindow(t2 = Hsel_readout2 = new BluebananaHSReadout2(plugin,this,tumbler_text_ww));
2117 add_subwindow(a = Hsel_active = new BluebananaHActive(plugin,this));
2119 /* need a narrow and a wide wide tumbler */
2120 add_subwindow(Fsel_readout0 = new BluebananaFSReadout0(plugin,this,tumbler_text_w));
2121 add_subwindow(Fsel_readout1 = new BluebananaFSReadout1(plugin,this,tumbler_text_w));
2122 add_subwindow(Fsel_readout2 = new BluebananaFSReadout2(plugin,this,tumbler_text_w));
2123 add_subwindow(Fsel_readout3 = new BluebananaFSReadout3(plugin,this,tumbler_text_ww));
2124 tumbler_w = Fsel_readout0->get_w();
2125 tumbler_ww = t0->get_w();
2126 tumbler_h = t0->get_h();
2128 /* need a reset button's width */
2129 reset_w = BC_GenericButton::calculate_w(this, _("Reset"));
2130 picker_w = BC_GenericButton::calculate_w(this, _("Pick"));
2132 /* determine row spacing */
2133 row_h = 30; /* minimum widget height allowance for the row
2134 (really, min height for the slider) */
2135 if(row_h<a->get_h())row_h=a->get_h();
2136 if(row_h<l->get_h())row_h=l->get_h();
2137 if(row_h<BC_GenericButton::calculate_h())row_h=BC_GenericButton::calculate_h();
2138 if(row_h<t2->get_h())row_h=t2->get_h();
2139 row_adv = row_h*(1.+row_padding);
2141 /* determine horizontal element positioning; two main setups */
2142 /* setup 1: three tumblers + button */
2143 tumbler_col2_w = MAX(reset_w,picker_w);
2145 /* setup 2: four tumblers + erode */
2147 int threew = tumbler_ww*3 + padx*4 + tumbler_col2_w;
2148 int fourw = tumbler_w*3 + tumbler_ww + padx*5 + erode->get_w() + erode_label->get_w();
2149 if(fourw>threew) tumbler_col2_w += fourw-threew;
2152 tumbler_col2_x = get_w()-xmargin-tumbler_col2_w;
2153 tumbler_col1_x = tumbler_col2_x - tumbler_ww*3 - padx*5;
2154 slider_x = label_x+padx;
2155 slider_w = (tumbler_col1_x - slider_x - padx*3);
2157 /* make sure the label x doesn't cause any labels to go off the
2160 int lx = label_x - padx - a->get_w();
2161 if (lx-label_w < xmargin){
2162 slider_x += ((xmargin+label_w)-lx);
2163 label_x += ((xmargin+label_w)-lx);
2164 slider_w -= ((xmargin+label_w)-lx);
2168 y += row_adv/3; /* extra half row spacing under headline */
2169 s = Hsel_slider = new BluebananaHSSlider(plugin,this,slider_x,y,slider_w,row_h);
2170 add_subwindow(p = new BluebananaHPicker(this,tumbler_col2_w));
2172 /* Move the upper alpha <->selection config buttons into place */
2174 int x0 = slider_x+slider_w+padx*2;
2175 invert_selection = new BluebananaIS(plugin,this);
2176 BC_Title *l = new BC_Title(xmargin,y,_(" Invert Selection"));
2178 add_subwindow(invert_selection);
2179 int w0 = padx+l->get_w()+padx+invert_selection->get_w()+padx*2;
2180 set_color(get_resources()->get_bg_color());
2181 draw_box(x0-w0,ymargin,w0,ymargin+l->get_h());
2183 x0-=invert_selection->get_w();
2184 invert_selection->reposition_window(x0,ymargin+(l->get_h()-invert_selection->get_h())/2);
2187 l->reposition_window(x0,ymargin);
2191 use_mask = new BluebananaA2Sel(plugin,this,padx);
2192 x0-=use_mask->get_w();
2193 use_mask->reposition_window(x0, ymargin);
2194 capture_mask = new BluebananaUnmask(plugin,this,padx);
2195 x0-=padx*5 + capture_mask->get_w();
2196 capture_mask->reposition_window(x0, ymargin);
2203 add_subwindow(t0 = Ssel_readout0 = new BluebananaSSReadout0(plugin,this,tumbler_text_ww));
2204 add_subwindow(t1 = Ssel_readout1 = new BluebananaSSReadout1(plugin,this,tumbler_text_ww));
2205 add_subwindow(t2 = Ssel_readout2 = new BluebananaSSReadout2(plugin,this,tumbler_text_ww));
2206 add_subwindow(a = Ssel_active = new BluebananaSActive(plugin,this));
2207 add_subwindow(p = new BluebananaSPicker(this,tumbler_col2_w));
2208 s = Ssel_slider = new BluebananaSSSlider(plugin,this,slider_x,y,slider_w,row_h);
2213 add_subwindow(t0 = Vsel_readout0 = new BluebananaVSReadout0(plugin,this,tumbler_text_ww));
2214 add_subwindow(t1 = Vsel_readout1 = new BluebananaVSReadout1(plugin,this,tumbler_text_ww));
2215 add_subwindow(t2 = Vsel_readout2 = new BluebananaVSReadout2(plugin,this,tumbler_text_ww));
2216 add_subwindow(a = Vsel_active = new BluebananaVActive(plugin,this));
2217 add_subwindow(p = new BluebananaVPicker(this,tumbler_col2_w));
2218 s = Vsel_slider = new BluebananaVSSlider(plugin,this,slider_x,y,slider_w,row_h);
2223 add_subwindow(a = Fsel_active = new BluebananaFActive(plugin,this));
2224 s = Fsel_slider = new BluebananaFSSlider(plugin,this,slider_x,y,slider_w,row_h);
2226 Fsel_readout0->reposition_window(tumbler_col1_x, y + (row_h-tumbler_h)/2 + 1);
2227 Fsel_readout1->reposition_window(tumbler_col1_x+tumbler_w, y + (row_h-tumbler_h)/2 + 1);
2228 Fsel_readout2->reposition_window(tumbler_col1_x+tumbler_w*2, y + (row_h-tumbler_h)/2 + 1);
2229 Fsel_readout3->reposition_window(tumbler_col1_x+tumbler_w*3+padx*2,
2230 y + (row_h-tumbler_h)/2 + 1);
2233 int x = get_w() - xmargin - erode->get_w();
2234 erode->reposition_window(x,y+(row_h-erode->get_h())/2);
2235 erode_label->reposition_window(x-erode_label->get_w()-padx,y+(row_h-erode_label->get_h())/2);
2242 add_subwindow(t0 = Radj_readout0 = new BluebananaRAReadout0(plugin,this,tumbler_text_ww));
2243 add_subwindow(t1 = Radj_readout1 = new BluebananaRAReadout1(plugin,this,tumbler_text_ww));
2244 add_subwindow(t2 = Radj_readout2 = new BluebananaRAReadout2(plugin,this,tumbler_text_ww));
2245 add_subwindow(a = Radj_active = new BluebananaRAActive(plugin,this));
2246 add_subwindow(p = new BluebananaRAReset(this,tumbler_col2_w));
2247 s = Radj_slider = new BluebananaRASlider(plugin,this,slider_x,y,slider_w,row_h);
2252 add_subwindow(t0 = Gadj_readout0 = new BluebananaGAReadout0(plugin,this,tumbler_text_ww));
2253 add_subwindow(t1 = Gadj_readout1 = new BluebananaGAReadout1(plugin,this,tumbler_text_ww));
2254 add_subwindow(t2 = Gadj_readout2 = new BluebananaGAReadout2(plugin,this,tumbler_text_ww));
2255 add_subwindow(a = Gadj_active = new BluebananaGAActive(plugin,this));
2256 add_subwindow(p = new BluebananaGAReset(this,tumbler_col2_w));
2257 s = Gadj_slider = new BluebananaGASlider(plugin,this,slider_x,y,slider_w,row_h);
2262 add_subwindow(t0 = Badj_readout0 = new BluebananaBAReadout0(plugin,this,tumbler_text_ww));
2263 add_subwindow(t1 = Badj_readout1 = new BluebananaBAReadout1(plugin,this,tumbler_text_ww));
2264 add_subwindow(t2 = Badj_readout2 = new BluebananaBAReadout2(plugin,this,tumbler_text_ww));
2265 add_subwindow(a = Badj_active = new BluebananaBAActive(plugin,this));
2266 add_subwindow(p = new BluebananaBAReset(this,tumbler_col2_w));
2267 s = Badj_slider = new BluebananaBASlider(plugin,this,slider_x,y,slider_w,row_h);
2272 add_subwindow(t0 = Hadj_readout = new BluebananaHAReadout(plugin,this,tumbler_text_ww));
2273 add_subwindow(a = Hadj_active = new BluebananaHAActive(plugin,this));
2274 add_subwindow(p = new BluebananaHAReset(this,tumbler_col2_w));
2275 s = Hadj_slider = new BluebananaHASlider(plugin,this,slider_x,y,slider_w,row_h);
2280 add_subwindow(t0 = Sadj_readout0 = new BluebananaSAReadout0(plugin,this,tumbler_text_ww));
2281 add_subwindow(t1 = Sadj_readout1 = new BluebananaSAReadout1(plugin,this,tumbler_text_ww));
2282 add_subwindow(t2 = Sadj_readout2 = new BluebananaSAReadout2(plugin,this,tumbler_text_ww));
2284 add_subwindow(a = Sadj_active = new BluebananaSAActive(plugin,this));
2285 add_subwindow(p = new BluebananaSAReset(this,tumbler_col2_w));
2286 s = Sadj_slider = new BluebananaSASlider(plugin,this,slider_x,y,slider_w,row_h);
2291 add_subwindow(t0 = Vadj_readout0 = new BluebananaVAReadout0(plugin,this,tumbler_text_ww));
2292 add_subwindow(t1 = Vadj_readout1 = new BluebananaVAReadout1(plugin,this,tumbler_text_ww));
2293 add_subwindow(t2 = Vadj_readout2 = new BluebananaVAReadout2(plugin,this,tumbler_text_ww));
2294 add_subwindow(a = Vadj_active = new BluebananaVAActive(plugin,this));
2295 add_subwindow(p = new BluebananaVAReset(this,tumbler_col2_w));
2296 s = Vadj_slider = new BluebananaVASlider(plugin,this,slider_x,y,slider_w,row_h);
2301 add_subwindow(t0 = Oadj_readout = new BluebananaOAReadout(plugin,this,tumbler_text_ww));
2302 add_subwindow(a = Oadj_active = new BluebananaOAActive(plugin,this));
2303 add_subwindow(p = new BluebananaOAReset(this,tumbler_col2_w));
2304 s = Oadj_slider = new BluebananaOASlider(plugin,this,slider_x,y,slider_w,row_h);
2309 add_subwindow(t0 = Aadj_readout = new BluebananaAAReadout(plugin,this,tumbler_text_ww));
2310 add_subwindow(a = Aadj_active = new BluebananaAAActive(plugin,this));
2311 add_subwindow(p = new BluebananaAAReset(this,tumbler_col2_w));
2312 s = Aadj_slider = new BluebananaAASlider(plugin,this,slider_x,y,slider_w,row_h);
2318 if(a)a->reposition_window(label_x - padx - a->get_w(), y + (row_h-a->get_h())/2 + 1);
2319 if(l)l->reposition(label_x - l->get_w() - padx*2 - a->get_w(), y + (row_h-l->get_h())/2 + 1);
2322 p->BC_SubWindow::reposition_window(tumbler_col2_x, y + (row_h-p->get_h())/2 + 1,
2323 MAX(tumbler_col2_w,picker_w),p->get_h());
2325 // work around bug; the reposition step does not fully redraw the button
2329 if(t0)t0->reposition_window(tumbler_col1_x,
2330 y + (row_h-tumbler_h)/2 + 1);
2332 if(t1)t1->reposition_window(tumbler_col1_x+tumbler_ww,
2333 y + (row_h-tumbler_h)/2 + 1);
2335 if(t2)t2->reposition_window(tumbler_col1_x+tumbler_ww*2+padx*2+(tumbler_ww-t2->get_w())/2,
2336 y + (row_h-tumbler_h)/2 + 1);
2345 BC_Title *l = new BC_Title(xmargin,y,_("Color Adjustment"));
2346 BC_Title *l2 = new BC_Title(-1,-1,_(" Filter Active"));
2349 add_subwindow(active = new BluebananaActive(plugin,this));
2351 int x0 = get_w()-xmargin-mark->get_w();
2352 active->reposition_window(x0,y-(active->get_h()-l->get_h())/2);
2353 x0 -= padx+l2->get_w();
2354 l2->reposition_window(x0,y);
2356 set_color(get_resources()->default_text_color);
2357 draw_line(xmargin+l->get_w()+padx, y+l->get_h()*.5, x0, y+l->get_h()*.5);
2359 y += l->get_h()*(row_padding+1.);
2367 set_color((s->dimtextcolor + get_resources()->default_text_color)/2);
2368 draw_line(slider_x+20, y+l->get_h()*.5, tumbler_col2_x-30, y+l->get_h()*.5);
2370 y += l->get_h()*(row_padding+1.);
2378 plugin->update_lookups(0);
2381 resize_window(get_w(),y);
2383 reposition_window(windowx,windowy,get_w(),y);
2384 leave_config_change(); // also forces render
2385 plugin->server->mwindow->sync_parameters();
2388 int BluebananaWindow::close_event(){
2393 // adds one to config push refcount
2394 // updates any internal state immediately
2395 void BluebananaWindow::enter_config_change(){
2397 if(!config_change && !plugin->update_cache.equivalent(plugin->config)){
2400 plugin->update_lookups(0);
2403 // decrements one from config push refcount. If refcount drops to
2404 // zero, pushes new config up to application
2406 // also compresses events; waits 184ms for new events before pushing
2407 // configuration changes
2408 void BluebananaWindow::commit_config_change(){
2409 if(--config_refcount==0){
2420 // decrements one from config push refcount. Does not push config up
2421 // to application when refcount drops to zero (used to wrap update
2422 // requests coming from the application, not user-initiated state
2424 void BluebananaWindow::leave_config_change(){
2426 plugin->update_cache.copy_from(plugin->config);
2427 if(--config_refcount==0){
2432 int BluebananaWindow::flush_config_change(){
2436 plugin->update_cache.copy_from(plugin->config);
2437 plugin->send_configure_change();
2439 config_consume=config_produce;
2443 int BluebananaWindow::repeat_event(int64_t d){
2445 if(config_consume==config_produce)
2446 flush_config_change();
2447 config_consume=config_produce;
2451 /* if background render is active and we're showing the zebra, mark
2452 the current frame uncached so that we can push zebra changes */
2453 if(plugin->config.mark && plugin->server->mwindow->brender)
2454 plugin->server->mwindow->brender->set_video_map(plugin->source_position, BRender::SCANNED);
2456 /* push update request without an EDL update */
2457 plugin->server->mwindow->sync_parameters();
2462 /* engine -> gui update; don't allow any EDL pushes */
2463 void BluebananaWindow::update(){
2465 // called to suppress configuration pushes
2466 enter_config_change();
2468 // full configuration recompute and redraw
2469 Hsel_slider->update();
2470 Ssel_slider->update();
2471 Vsel_slider->update();
2472 Fsel_slider->update();
2473 Hadj_slider->update();
2474 Sadj_slider->update();
2475 Vadj_slider->update();
2476 Radj_slider->update();
2477 Gadj_slider->update();
2478 Badj_slider->update();
2479 Oadj_slider->update();
2480 Aadj_slider->update();
2485 capture_mask->update();
2486 invert_selection->update();
2488 Hsel_active->update();
2489 Ssel_active->update();
2490 Vsel_active->update();
2491 Fsel_active->update();
2493 Hadj_active->update();
2494 Sadj_active->update();
2495 Vadj_active->update();
2496 Radj_active->update();
2497 Gadj_active->update();
2498 Badj_active->update();
2499 Oadj_active->update();
2500 Aadj_active->update();
2502 // called to release configuration without pushing
2503 leave_config_change();
2506 void BluebananaWindow::render(){
2508 Hsel_slider->render();
2509 Ssel_slider->render();
2510 Vsel_slider->render();
2511 Fsel_slider->render();
2512 Hadj_slider->render();
2513 Sadj_slider->render();
2514 Vadj_slider->render();
2515 Radj_slider->render();
2516 Gadj_slider->render();
2517 Badj_slider->render();
2518 Oadj_slider->render();
2519 Aadj_slider->render();
2523 void BluebananaWindow::update_histograms(BluebananaMain *plugin){
2524 int w = plugin->frame->get_w();
2525 int h = plugin->frame->get_h();
2527 if(Radj_slider)Radj_slider->update_histogram(plugin->red_histogram,0,0,0,w*h);
2528 if(Gadj_slider)Gadj_slider->update_histogram(plugin->green_histogram,0,0,0,w*h);
2529 if(Badj_slider)Badj_slider->update_histogram(plugin->blue_histogram,0,0,0,w*h);
2532 Hadj_slider->update_histogram(plugin->hue_histogram,
2533 plugin->hue_histogram_red,
2534 plugin->hue_histogram_green,
2535 plugin->hue_histogram_blue,w*h);
2538 Sadj_slider->update_histogram(plugin->sat_histogram,
2539 plugin->sat_histogram_red,
2540 plugin->sat_histogram_green,
2541 plugin->sat_histogram_blue,w*h);
2544 Vadj_slider->update_histogram(plugin->value_histogram,
2545 plugin->value_histogram_red,
2546 plugin->value_histogram_green,
2547 plugin->value_histogram_blue,w*h);