4 * Copyright (C) 1997-2011 Adam Williams <broadcast at earthling dot net>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include "bcdisplayinfo.h"
23 #include "bcsignals.h"
26 #include "histogram.h"
27 #include "histogramconfig.h"
28 #include "histogramwindow.h"
31 #include "localsession.h"
33 #include "pluginserver.h"
41 HistogramWindow::HistogramWindow(HistogramMain *plugin)
42 : PluginClientWindow(plugin,
49 this->plugin = plugin;
53 HistogramWindow::~HistogramWindow()
58 void HistogramWindow::create_objects()
60 int margin = plugin->get_theme()->widget_border;
61 int x = margin, y = margin, x1 = margin;
63 add_subwindow(mode_v = new HistogramMode(plugin, x, y,
64 HISTOGRAM_VALUE, _("Value")));
65 x += mode_v->get_w() + margin;
66 add_subwindow(mode_r = new HistogramMode(plugin, x, y,
67 HISTOGRAM_RED, _("Red")));
68 x += mode_r->get_w() + margin;
69 add_subwindow(mode_g = new HistogramMode(plugin, x, y,
70 HISTOGRAM_GREEN, _("Green")));
71 x += mode_g->get_w() + margin;
72 add_subwindow(mode_b = new HistogramMode(plugin, x, y,
73 HISTOGRAM_BLUE, _("Blue")));
74 x = get_w() - margin - plugin->get_theme()->get_image_set("histogram_rgb_toggle")[0]->get_w();
75 add_subwindow(parade_on = new HistogramParade(plugin, this,
77 x -= parade_on->get_w() + margin;
78 add_subwindow(parade_off = new HistogramParade(plugin, this, x, y, 0));
81 y += parade_on->get_h() + margin;
82 add_subwindow(canvas_title1 = new BC_Title(margin, y, "-10%"));
83 x = get_w() - get_text_width(MEDIUMFONT, "110%") - margin;
84 add_subwindow(canvas_title2 = new BC_Title(x, y, "110%"));
86 y += canvas_title2->get_h() + margin;
88 canvas_h = get_h() - y - yS(210);
90 add_subwindow(low_input_carrot = new HistogramCarrot(plugin, this, x, y + canvas_h));
92 x = low_input_carrot->get_w() / 2 + x;
93 canvas_w = get_w() - x - x;
96 title2_x = x + (int)(canvas_w * -HIST_MIN_INPUT / FLOAT_RANGE);
97 title3_x = x + (int)(canvas_w * (1.0 - HIST_MIN_INPUT) / FLOAT_RANGE);
98 title4_x = x + (int)(canvas_w);
100 add_subwindow(canvas = new HistogramCanvas(plugin, this,
101 x, y, canvas_w, canvas_h));
104 draw_3d_border(x - 2, y - 2, canvas_w + 4, canvas_h + 4,
105 get_bg_color(), BLACK, MDGREY, get_bg_color());
107 // Calculate output curve with no value function
108 plugin->tabulate_curve(plugin->preview_lookup, plugin->mode, 0x10000, 0);
110 y += canvas->get_h();
113 add_subwindow(gamma_carrot = new HistogramCarrot(plugin, this,
114 canvas->get_x() + canvas->get_w() / 2 -
115 low_input_carrot->get_w() / 2 , y));
117 add_subwindow(high_input_carrot = new HistogramCarrot(plugin, this,
118 canvas->get_x() + canvas->get_w() -
119 low_input_carrot->get_w() / 2, y));
120 y += low_input_carrot->get_h() + margin;
122 // add_subwindow(title = new BC_Title(x, y, _("Input:")));
123 // x += title->get_w() + margin;
124 low_input = new HistogramText(plugin, this, x, y);
125 low_input->create_objects();
127 x = get_w() / 2 - low_input->get_w() / 2;
128 gamma = new HistogramText(plugin, this, x, y, 0.01, 100.);
129 gamma->create_objects();
131 x = get_w() - low_input->get_w() - margin;
132 high_input = new HistogramText(plugin, this, x, y);
133 high_input->create_objects();
135 y += high_input->get_h() + margin;
138 add_subwindow(output = new HistogramSlider(plugin, this,
139 canvas->get_x(), y, canvas->get_w(), yS(20), 0));
143 draw_3d_border(output->get_x() - 2, output->get_y() - 2,
144 output->get_w() + 4, output->get_h() + 4,
145 get_bg_color(), BLACK, MDGREY, get_bg_color());
146 y += output->get_h();
148 add_subwindow(low_output_carrot = new HistogramCarrot(plugin,
151 add_subwindow(high_output_carrot = new HistogramCarrot(plugin,
152 this, canvas->get_x() + canvas->get_w() -
153 low_output_carrot->get_w() / 2, y));
154 y += high_output_carrot->get_h() + margin;
157 // add_subwindow(title = new BC_Title(x, y, _("Output:")));
158 // x += title->get_w() + margin;
159 low_output = new HistogramText(plugin, this, x, y);
160 low_output->create_objects();
162 const char *linear_text = _("Linear");
163 int xs = get_w()/2 - xS(50);
164 x = xs - BC_Title::calculate_w(this, linear_text) - margin;
165 add_subwindow(log_title1 = new BC_Title(x, y, linear_text));
166 add_subwindow(log_slider = new HistogramLogSlider(plugin, this, xs, y));
167 xs += log_slider->get_w() + margin;
168 add_subwindow(log_title2 = new BC_Title(xs, y, _("Log")));
170 high_output = new HistogramText(plugin, this,
171 get_w() - low_output->get_w() - margin, y);
172 high_output->create_objects();
175 y += high_output->get_h() + margin;
177 add_subwindow(bar = new BC_Bar(x, y, get_w() - margin * 2));
178 y += bar->get_h() + margin;
180 add_subwindow(automatic = new HistogramAuto(plugin, x, y));
182 add_subwindow(threshold_title = new BC_Title(x2, y, _("Threshold:")));
184 threshold = new HistogramText(plugin, this, x3, y);
185 threshold->create_objects();
186 y += automatic->get_h() + margin;
188 add_subwindow(plot = new HistogramPlot(plugin, x1, y));
189 add_subwindow(select = new HistogramSelect(plugin, this, x2, y));
190 frames = new HistogramFrames(plugin, this, x3, y);
191 frames->create_objects();
192 x = x3 + frames->get_w() + margin;
193 add_subwindow(clear_frames = new HistogramClearFrames(plugin, this, x, y));
194 y += plot->get_h() + margin;
197 add_subwindow(split = new HistogramSplit(plugin, x, y));
199 add_subwindow(reset = new HistogramReset(plugin, x, y + yS(5)));
209 int HistogramWindow::resize_event(int w, int h)
211 int xdiff = w - get_w();
212 int ydiff = h - get_h();
214 parade_on->reposition_window(parade_on->get_x() + xdiff,
216 parade_off->reposition_window(parade_off->get_x() + xdiff,
218 canvas_title2->reposition_window(canvas_title2->get_x() + xdiff,
219 canvas_title2->get_y());
221 // Canvas follows window size
222 canvas_w = canvas_w + xdiff;
223 canvas_h = canvas_h + ydiff;
224 canvas->reposition_window(canvas->get_x(), canvas->get_y(),
228 draw_3d_border(canvas->get_x() - 2, canvas->get_y() - 2,
229 canvas_w + 4, canvas_h + 4,
230 get_bg_color(), BLACK, MDGREY, get_bg_color());
232 low_input_carrot->reposition_window(low_input_carrot->get_x(),
233 low_input_carrot->get_y() + ydiff);
234 gamma_carrot->reposition_window(gamma_carrot->get_x(),
235 gamma_carrot->get_y() + ydiff);
236 high_input_carrot->reposition_window(high_input_carrot->get_x(),
237 high_input_carrot->get_y() + ydiff);
239 low_input->reposition_window(low_input->get_x(),
240 low_input->get_y() + ydiff);
241 gamma->reposition_window(w / 2 - gamma->get_w() / 2,
242 gamma->get_y() + ydiff);
243 high_input->reposition_window(high_input->get_x() + xdiff,
244 low_input->get_y() + ydiff);
246 output->reposition_window(output->get_x(),
247 output->get_y() + ydiff,
248 output->get_w() + xdiff,
253 draw_3d_border(output->get_x() - 2, output->get_y() - 2,
254 output->get_w() + 4, output->get_h() + 4,
255 get_bg_color(), BLACK, MDGREY, get_bg_color());
257 low_output_carrot->reposition_window(low_output_carrot->get_x(),
258 low_output_carrot->get_y() + ydiff);
259 high_output_carrot->reposition_window(high_output_carrot->get_x(),
260 high_output_carrot->get_y() + ydiff);
262 low_output->reposition_window(low_output->get_x(),
263 low_output->get_y() + ydiff);
264 int xs = (w - log_slider->get_w()) / 2;
265 int margin = plugin->get_theme()->widget_border;
266 log_title1->reposition_window(xs - log_title1->get_w() - margin,
267 log_title1->get_y() + ydiff);
268 log_slider->reposition_window(xs,
269 log_slider->get_y() + ydiff);
270 log_title2->reposition_window(xs + log_slider->get_w() + margin,
271 log_title2->get_y() + ydiff);
272 high_output->reposition_window(high_output->get_x() + xdiff,
273 high_output->get_y() + ydiff);
275 bar->reposition_window(bar->get_x(),
276 bar->get_y() + ydiff,
277 bar->get_w() + xdiff);
279 automatic->reposition_window(automatic->get_x(),
280 automatic->get_y() + ydiff);
281 threshold_title->reposition_window(threshold_title->get_x(),
282 threshold_title->get_y() + ydiff);
283 threshold->reposition_window(threshold->get_x(),
284 threshold->get_y() + ydiff);
285 plot->reposition_window(plot->get_x(),
286 plot->get_y() + ydiff);
288 split->reposition_window(split->get_x(),
289 split->get_y() + ydiff);
290 reset->reposition_window(reset->get_x(),
291 reset->get_y() + ydiff);
293 frames->reposition_window(frames->get_x(),
294 frames->get_y() + ydiff);
295 select->reposition_window(select->get_x(),
296 select->get_y() + ydiff);
297 clear_frames->reposition_window(clear_frames->get_x(),
298 clear_frames->get_y() + ydiff);
310 int HistogramWindow::keypress_event()
317 for(int i = 0; i < HISTOGRAM_MODES; i++)
319 if(active_value == &plugin->config.gamma[i])
323 if(get_keypress() == RIGHT || get_keypress() == UP)
325 *active_value += sign * PRECISION;
326 plugin->config.boundaries();
328 plugin->send_configure_change();
332 if(get_keypress() == LEFT || get_keypress() == DOWN)
334 *active_value -= sign * PRECISION;
335 plugin->config.boundaries();
337 plugin->send_configure_change();
345 void HistogramWindow::update(int do_canvases,
352 automatic->update(plugin->config.automatic);
353 mode_v->update(plugin->mode == HISTOGRAM_VALUE ? 1 : 0);
354 mode_r->update(plugin->mode == HISTOGRAM_RED ? 1 : 0);
355 mode_g->update(plugin->mode == HISTOGRAM_GREEN ? 1 : 0);
356 mode_b->update(plugin->mode == HISTOGRAM_BLUE ? 1 : 0);
357 plot->update(plugin->config.plot);
358 split->update(plugin->config.split);
359 frames->update(plugin->config.frames);
360 parade_on->update(plugin->parade ? 1 : 0);
361 parade_off->update(plugin->parade ? 0 : 1);
362 log_slider->update(plugin->config.log_slider);
373 low_input_carrot->update();
374 high_input_carrot->update();
375 gamma_carrot->update();
376 low_output_carrot->update();
377 high_output_carrot->update();
384 high_input->update();
385 low_output->update();
386 high_output->update();
394 void HistogramWindow::draw_canvas_mode(int mode, int color, int y, int h)
397 int max = 0, *accum = plugin->accum[mode];
399 for( int i=0,x=0; x<canvas_w; ++x ) {
401 int i1 = (HISTOGRAM_SLOTS * (x+1)) / canvas_w;
402 while( i < i1 ) m += accum[i++];
403 if( max < m ) max = m;
408 double log_slider = plugin->config.log_slider;
409 double lin_slider = 1. - log_slider;
410 double lin_scale = (lin_slider * h) / max;
411 double log_scale = (log_slider * h) / log(max);
412 for( int i=0,x=0; x<canvas_w; ++x ) {
414 int i1 = (HISTOGRAM_SLOTS * (x+1)) / canvas_w;
415 while( i < i1 ) m += accum[i++];
416 double v = m > 0 && i1 > i0 ? (double)m : 0;
417 m = v > 0 ? v*lin_scale + log(v)*log_scale : 0;
419 canvas->set_color(BLACK);
420 canvas->draw_line(x, y, x, y+h - m);
421 canvas->set_color(color);
422 canvas->draw_line(x, y+h - m, x, y+h);
426 canvas->set_color(BLACK);
427 canvas->draw_box(0, y, canvas_w, h);
431 canvas->set_color(WHITE);
432 canvas->set_line_width(2);
436 for( int x=0; x<canvas_w; ++x ) {
437 float input = (float)x / canvas_w * FLOAT_RANGE + HIST_MIN_INPUT;
438 float output = plugin->calculate_level(input, mode, 0);
439 int y2 = h - (int)(output * h);
441 canvas->draw_line(x-1, y+y1, x, y+y2);
445 canvas->set_line_width(1);
449 void HistogramWindow::update_canvas()
453 draw_canvas_mode(HISTOGRAM_RED, RED, 0, canvas_h / 3);
454 draw_canvas_mode(HISTOGRAM_GREEN, GREEN, canvas_h / 3, canvas_h / 3);
455 draw_canvas_mode(HISTOGRAM_BLUE, BLUE, canvas_h * 2 / 3, canvas_h - canvas_h * 2 / 3);
459 draw_canvas_mode(plugin->mode, MEGREY, 0, canvas_h);
463 // Draw 0 and 100% lines.
464 canvas->set_color(RED);
465 int x = (int)(canvas_w * -HIST_MIN_INPUT / FLOAT_RANGE);
470 x = (int)(canvas_w * (1.0 - HIST_MIN_INPUT) / FLOAT_RANGE);
481 HistogramParade::HistogramParade(HistogramMain *plugin,
482 HistogramWindow *gui,
488 value ? plugin->get_theme()->get_image_set("histogram_rgb_toggle") :
489 plugin->get_theme()->get_image_set("histogram_toggle"),
492 this->plugin = plugin;
496 set_tooltip(_("RGB Parade on"));
498 set_tooltip(_("RGB Parade off"));
501 int HistogramParade::handle_event()
504 plugin->parade = value;
518 HistogramCanvas::HistogramCanvas(HistogramMain *plugin,
519 HistogramWindow *gui,
530 this->plugin = plugin;
534 int HistogramCanvas::button_press_event()
537 if(is_event_win() && cursor_inside())
539 if(!plugin->dragging_point &&
540 (!plugin->config.automatic || plugin->mode == HISTOGRAM_VALUE))
548 int HistogramCanvas::cursor_motion_event()
550 if(is_event_win() && cursor_inside())
556 int HistogramCanvas::button_release_event()
562 HistogramReset::HistogramReset(HistogramMain *plugin, int x, int y)
563 : BC_GenericButton(x, y, _("Reset"))
565 this->plugin = plugin;
567 int HistogramReset::handle_event()
569 plugin->config.reset(0);
570 ((HistogramWindow*)plugin->thread->window)->update(1, 1, 1, 1);
571 plugin->send_configure_change();
576 HistogramSelect::HistogramSelect(HistogramMain *plugin, HistogramWindow *gui,
578 : BC_GenericButton(x, y, xS(100), _("Frames"))
580 this->plugin = plugin;
582 set_tooltip(_("Set frames to selection duration"));
584 int HistogramSelect::handle_event()
586 MWindow *mwindow = plugin->server->mwindow;
588 EDL *edl = mwindow->edl;
589 double start = edl->local_session->get_selectionstart();
590 int64_t start_pos = edl->get_frame_rate() * start;
591 double end = edl->local_session->get_selectionend();
592 int64_t end_pos = edl->get_frame_rate() * end;
593 int64_t frames = end_pos - start_pos;
594 gui->frames->update(frames);
595 plugin->config.frames = frames;
596 plugin->send_configure_change();
601 HistogramClearFrames::HistogramClearFrames(HistogramMain *plugin, HistogramWindow *gui,
603 : BC_Button(x, y, plugin->get_theme()->get_image_set("reset_button"))
605 this->plugin = plugin;
607 set_tooltip(_("Clear frames"));
610 int HistogramClearFrames::handle_event()
612 plugin->config.frames = 0;
613 gui->frames->update(0);
614 plugin->send_configure_change();
618 HistogramLogSlider::HistogramLogSlider(HistogramMain *plugin, HistogramWindow *gui,
620 : BC_FSlider(x, y, 0, xS(100), xS(100), 0., 1., plugin->config.log_slider)
623 this->plugin = plugin;
627 int HistogramLogSlider::handle_event()
629 plugin->config.log_slider = get_value();
630 plugin->send_configure_change();
634 HistogramCarrot::HistogramCarrot(HistogramMain *plugin, HistogramWindow *gui, int x, int y)
635 : BC_Toggle(x, y, plugin->get_theme()->get_image_set("histogram_carrot"), 0)
637 this->plugin = plugin;
642 HistogramCarrot::~HistogramCarrot()
646 float* HistogramCarrot::get_value()
648 if( this == gui->low_input_carrot )
649 return &plugin->config.low_input[plugin->mode];
650 if( this == gui->high_input_carrot )
651 return &plugin->config.high_input[plugin->mode];
652 if( this == gui->gamma_carrot )
653 return &plugin->config.gamma[plugin->mode];
654 if( this == gui->low_output_carrot )
655 return &plugin->config.low_output[plugin->mode];
656 if( this == gui->high_output_carrot )
657 return &plugin->config.high_output[plugin->mode];
661 void HistogramCarrot::update()
664 float *value = get_value();
666 if(this != gui->gamma_carrot)
668 new_x = (int)(gui->canvas->get_x() +
669 (*value - HIST_MIN_INPUT) *
670 gui->canvas->get_w() /
671 (HIST_MAX_INPUT - HIST_MIN_INPUT) -
676 float min = plugin->config.low_input[plugin->mode];
677 float max = plugin->config.high_input[plugin->mode];
678 float delta = (max - min) / 2.0;
679 float mid = min + delta;
680 float tmp = log10(1.0 / *value);
681 tmp = mid + delta * tmp;
683 //printf("HistogramCarrot::update %d %f %f\n", __LINE__, *value, tmp);
685 new_x = gui->canvas->get_x() -
687 (int)(gui->canvas->get_w() *
688 (tmp - HIST_MIN_INPUT) /
689 (HIST_MAX_INPUT - HIST_MIN_INPUT));
692 reposition_window(new_x, get_y());
695 int HistogramCarrot::button_press_event()
697 if(is_event_win() && get_buttonpress() == 1)
701 set_status(BC_Toggle::TOGGLE_DOWN);
703 BC_Toggle::update(0);
704 gui->active_value = get_value();
705 // Disable the other toggles
706 if(this != gui->low_input_carrot) gui->low_input_carrot->BC_Toggle::update(0);
707 if(this != gui->high_input_carrot) gui->high_input_carrot->BC_Toggle::update(0);
708 if(this != gui->gamma_carrot) gui->gamma_carrot->BC_Toggle::update(0);
709 if(this != gui->low_output_carrot) gui->low_output_carrot->BC_Toggle::update(0);
710 if(this != gui->high_output_carrot) gui->high_output_carrot->BC_Toggle::update(0);
711 starting_x = get_x();
712 offset_x = gui->get_relative_cursor_x();
713 offset_y = gui->get_relative_cursor_y();
714 //printf("HistogramCarrot::button_press_event %d %d %d\n", __LINE__, starting_x, offset_x);
722 int HistogramCarrot::button_release_event()
724 int result = BC_Toggle::button_release_event();
730 int HistogramCarrot::cursor_motion_event()
732 int cursor_x = gui->get_relative_cursor_x();
736 //printf("HistogramCarrot::cursor_motion_event %d %d\n", __LINE__, cursor_x);
737 int new_x = starting_x + cursor_x - offset_x;
741 float *value = get_value();
742 if(this == gui->gamma_carrot)
744 float min = gui->low_input_carrot->get_x();
745 float max = gui->high_input_carrot->get_x();
746 float delta = (max - min) / 2.0;
749 float mid = min + delta;
750 float tmp = (float)(new_x - mid) /
752 tmp = 1.0 / pow(10, tmp);
753 CLAMP(tmp, MIN_GAMMA, MAX_GAMMA);
755 //printf("HistogramCarrot::update %d %f\n", __LINE__, tmp);
760 int min_x = gui->canvas->get_x() - get_w() / 2;
761 int max_x = gui->canvas->get_x() + gui->canvas->get_w() - get_w() / 2;
762 CLAMP(new_x, min_x, max_x);
763 *value = HIST_MIN_INPUT +
764 (HIST_MAX_INPUT - HIST_MIN_INPUT) *
769 reposition_window(new_x, get_y());
773 (this == gui->low_input_carrot || this == gui->high_input_carrot),
776 plugin->send_configure_change();
790 HistogramSlider::HistogramSlider(HistogramMain *plugin,
791 HistogramWindow *gui,
797 : BC_SubWindow(x, y, w, h)
799 this->plugin = plugin;
801 this->is_input = is_input;
805 int HistogramSlider::input_to_pixel(float input)
807 return (int)((input - HIST_MIN_INPUT) / FLOAT_RANGE * get_w());
810 void HistogramSlider::update()
814 //int half_h = get_h() / 2;
815 //int quarter_h = get_h() / 4;
816 int mode = plugin->mode;
821 clear_box(0, 0, w, h);
828 case HISTOGRAM_GREEN:
836 for(int i = 0; i < w; i++)
838 int color = (int)(i * 0xff / w);
839 set_color(((r * color / 0xff) << 16) |
840 ((g * color / 0xff) << 8) |
843 draw_line(i, 0, i, h);
858 HistogramAuto::HistogramAuto(HistogramMain *plugin,
861 : BC_CheckBox(x, y, plugin->config.automatic, _("Automatic"))
863 this->plugin = plugin;
866 int HistogramAuto::handle_event()
868 plugin->config.automatic = get_value();
869 plugin->send_configure_change();
876 HistogramPlot::HistogramPlot(HistogramMain *plugin,
879 : BC_CheckBox(x, y, plugin->config.plot, _("Plot histogram"))
881 this->plugin = plugin;
884 int HistogramPlot::handle_event()
886 plugin->config.plot = get_value();
887 plugin->send_configure_change();
894 HistogramSplit::HistogramSplit(HistogramMain *plugin,
897 : BC_CheckBox(x, y, plugin->config.split, _("Split output"))
899 this->plugin = plugin;
902 int HistogramSplit::handle_event()
904 plugin->config.split = get_value();
905 plugin->send_configure_change();
910 HistogramMode::HistogramMode(HistogramMain *plugin,
915 : BC_Radial(x, y, plugin->mode == value, text)
917 this->plugin = plugin;
920 int HistogramMode::handle_event()
922 HistogramWindow *gui = (HistogramWindow*)plugin->thread->window;
923 plugin->mode = value;
924 plugin->current_point= -1;
925 gui->active_value = 0;
926 gui->low_input_carrot->BC_Toggle::update(0);
927 gui->gamma_carrot->BC_Toggle::update(0);
928 gui->high_input_carrot->BC_Toggle::update(0);
929 gui->low_output_carrot->BC_Toggle::update(0);
930 gui->high_output_carrot->BC_Toggle::update(0);
931 gui->update(1, 1, 1, 1);
932 // plugin->send_configure_change();
937 HistogramFrames::HistogramFrames(HistogramMain *plugin, HistogramWindow *gui,
939 : BC_TumbleTextBox(gui, 0, 0, 65535, x, y, xS(80))
941 this->plugin = plugin;
945 int HistogramFrames::handle_event()
947 plugin->config.frames = atoi(get_text());
948 plugin->send_configure_change();
952 void HistogramFrames::update(int frames)
954 BC_TumbleTextBox::update((int64_t)frames);
958 HistogramText::HistogramText(HistogramMain *plugin,
959 HistogramWindow *gui, int x, int y, float hist_min, float hist_max)
960 : BC_TumbleTextBox(gui, 0.0, hist_min, hist_max, x, y, xS(80))
962 this->plugin = plugin;
964 set_precision(DIGITS);
965 set_increment(PRECISION);
968 float* HistogramText::get_value()
970 if( this == gui->low_input )
971 return &plugin->config.low_input[plugin->mode];
972 if( this == gui->high_input )
973 return &plugin->config.high_input[plugin->mode];
974 if( this == gui->gamma )
975 return &plugin->config.gamma[plugin->mode];
976 if( this == gui->low_output )
977 return &plugin->config.low_output[plugin->mode];
978 if( this == gui->high_output )
979 return &plugin->config.high_output[plugin->mode];
980 if( this == gui->threshold )
981 return &plugin->config.threshold;
985 int HistogramText::handle_event()
987 float *output = get_value();
989 *output = atof(get_text());
991 gui->update(1, 1, 0, 0);
992 plugin->send_configure_change();
996 void HistogramText::update()
998 float *output = get_value();
1000 BC_TumbleTextBox::update(*output);