4 * Copyright (C) 2008 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"
24 #include "bistogram.h"
25 #include "bistogramconfig.h"
26 #include "bistogramwindow.h"
34 HistogramWindow::HistogramWindow(HistogramMain *plugin)
35 : PluginClientWindow(plugin, 440, 480, 440, 480, 0)
37 this->plugin = plugin;
43 HistogramWindow::~HistogramWindow()
50 #include "min_picon_png.h"
51 #include "mid_picon_png.h"
52 #include "max_picon_png.h"
53 static VFramePng max_picon_image(max_picon_png);
54 static VFramePng mid_picon_image(mid_picon_png);
55 static VFramePng min_picon_image(min_picon_png);
57 void HistogramWindow::create_objects()
59 int x = 10, y = 10, x1 = 10;
62 max_picon = create_pixmap(&max_picon_image);
63 mid_picon = create_pixmap(&mid_picon_image);
64 min_picon = create_pixmap(&min_picon_image);
65 add_subwindow(mode_v = new HistogramMode(plugin, x, y,
66 HISTOGRAM_VALUE, _("Value")));
68 add_subwindow(mode_r = new HistogramMode(plugin, x, y,
69 HISTOGRAM_RED, _("Red")));
71 add_subwindow(mode_g = new HistogramMode(plugin, x, y,
72 HISTOGRAM_GREEN, _("Green")));
74 add_subwindow(mode_b = new HistogramMode(plugin, x, y,
75 HISTOGRAM_BLUE, _("Blue")));
77 // add_subwindow(mode_a = new HistogramMode(plugin, x, y,
78 // HISTOGRAM_ALPHA, _("Alpha")));
80 x = get_w() - HistogramClear::calculate_w(this, _("Clear")) - 15;
81 add_subwindow(clear = new HistogramClear(plugin, x, y, _("Clear")));
85 add_subwindow(title = new BC_Title(x, y, _("Input X:")));
86 x += title->get_w() + 10;
87 input_x = new HistogramInputText(plugin, this, x, y, 1);
88 input_x->create_objects();
90 x += input_x->get_w() + 10;
91 add_subwindow(title = new BC_Title(x, y, _("Input Y:")));
92 x += title->get_w() + 10;
93 input_y = new HistogramInputText(plugin, this, x, y, 0);
94 input_y->create_objects();
99 canvas_w = get_w() - x - x;
100 canvas_h = get_h() - y - 170;
102 title2_x = x + (int)(canvas_w * -HIST_MIN_INPUT / FLOAT_RANGE);
103 title3_x = x + (int)(canvas_w * (1.0 - HIST_MIN_INPUT) / FLOAT_RANGE);
104 title4_x = x + (int)(canvas_w);
105 add_subwindow(canvas = new HistogramCanvas(plugin, this,
106 x, y, canvas_w, canvas_h));
107 draw_canvas_overlay();
110 y += canvas->get_h() + 1;
111 add_subwindow(new BC_Title(title1_x, y, "-10%"));
112 add_subwindow(new BC_Title(title2_x, y, "0%"));
113 add_subwindow(new BC_Title(title3_x - get_text_width(MEDIUMFONT, "100"), y, "100%"));
114 add_subwindow(new BC_Title(title4_x - get_text_width(MEDIUMFONT, "110"), y, "110%"));
117 add_subwindow(title = new BC_Title(x, y, _("Output min:")));
118 x += title->get_w() + 10;
119 output_min = new HistogramOutputText(plugin, this,
120 x, y, &plugin->config.output_min[plugin->mode]);
121 output_min->create_objects();
122 x += output_min->get_w() + 10;
123 add_subwindow(new BC_Title(x, y, _("Output Max:")));
124 x += title->get_w() + 10;
125 output_max = new HistogramOutputText(plugin, this,
126 x, y, &plugin->config.output_max[plugin->mode]);
127 output_max->create_objects();
132 add_subwindow(output = new HistogramSlider(plugin, this,
133 x, y, get_w() - 20, 30, 0));
138 add_subwindow(automatic = new HistogramAuto(plugin, x, y));
141 add_subwindow(new HistogramReset(plugin, x, y));
143 add_subwindow(new BC_Title(x, y, _("Threshold:")));
145 threshold = new HistogramOutputText(plugin, this,
146 x, y, &plugin->config.threshold);
147 threshold->create_objects();
150 add_subwindow(split = new HistogramSplit(plugin, x, y));
153 add_subwindow(new BC_Title(x,y, _("Interpolation:")));
155 add_subwindow(smoothModeChoser = new HistogramSmoothMode(plugin, this, x, y));
156 smoothModeChoser->create_objects();
161 int HistogramWindow::delete_current_point()
163 if( plugin->current_point < 0 ) return 0;
164 HistogramPoint *current =
165 plugin->config.points[plugin->mode].get_item_number(plugin->current_point);
167 plugin->current_point = -1;
171 int HistogramWindow::keypress_event()
174 if( get_keypress() == BACKSPACE ||
175 get_keypress() == DELETE ) {
176 if( delete_current_point() ) {
179 plugin->send_configure_change();
186 void HistogramWindow::update(int do_input)
188 automatic->update(plugin->config.automatic);
189 threshold->update(plugin->config.threshold);
191 split->set_value(plugin->config.split);
192 if( do_input ) update_input();
194 if( smoothModeChoser->set_mode(plugin->config.smoothMode) )
198 void HistogramWindow::update_input()
204 void HistogramWindow::update_output()
207 output_min->update(plugin->config.output_min[plugin->mode]);
208 output_max->update(plugin->config.output_max[plugin->mode]);
211 void HistogramWindow::update_mode()
213 mode_v->update(plugin->mode == HISTOGRAM_VALUE ? 1 : 0);
214 mode_r->update(plugin->mode == HISTOGRAM_RED ? 1 : 0);
215 mode_g->update(plugin->mode == HISTOGRAM_GREEN ? 1 : 0);
216 mode_b->update(plugin->mode == HISTOGRAM_BLUE ? 1 : 0);
217 output_min->output = &plugin->config.output_min[plugin->mode];
218 output_max->output = &plugin->config.output_max[plugin->mode];
221 void HistogramWindow::draw_canvas_overlay()
225 // Calculate output curve
226 plugin->tabulate_curve(plugin->mode, 0);
229 canvas->set_color(0xffff00);
230 for( int i=0; i<canvas_w; ++i ) {
231 float input = (float)i / canvas_w * FLOAT_RANGE + HIST_MIN_INPUT;
232 float output = plugin->calculate_smooth(input, plugin->mode);
234 int y2 = canvas_h - (int)(output * canvas_h);
236 canvas->draw_line(i - 1, y1, i, y2);
242 // Draw output points
243 HistogramPoint *current = plugin->config.points[plugin->mode].first;
246 canvas->set_color(0x00ff00);
247 int x = (int)((current->x - HIST_MIN_INPUT) * canvas_w / FLOAT_RANGE);
248 int y = (int)(canvas_h - current->y * canvas_h);
249 if(number == plugin->current_point)
250 canvas->draw_box(x - BOX_SIZE / 2, y - BOX_SIZE / 2, BOX_SIZE, BOX_SIZE);
252 canvas->draw_rectangle(x - BOX_SIZE / 2, y - BOX_SIZE / 2, BOX_SIZE, BOX_SIZE);
255 canvas->draw_line(x0, y0, x, y);
258 if (plugin->config.smoothMode > HISTOGRAM_LINEAR) {
260 canvas->set_color(0xffffff);
261 x2 = (int)((current->x + current->xoffset_right - HIST_MIN_INPUT) * canvas_w / FLOAT_RANGE);
262 x1 = (int)((current->x + current->xoffset_left - HIST_MIN_INPUT) * canvas_w / FLOAT_RANGE);
263 y2 = (int)(canvas_h - (current->y + current->xoffset_right * current->gradient) * canvas_h);
264 y1 = (int)(canvas_h - (current->y + current->xoffset_left * current->gradient) * canvas_h);
265 /* x2 = x + (title3_x - title2_x)/20;
266 x1 = x - (title3_x - title2_x)/20;
267 y1 = y + (int)(current->gradient * (float)(canvas_h)/20.0);
268 y2 = y - (int)(current->gradient * (float)(canvas_h)/20.0);
269 int y2 = (int)(canvas_h - canvas_h * (current->y + current->gradient /10));*/
270 canvas->draw_line(x1,y1,x2,y2);
272 canvas->draw_circle(x1 - BOX_SIZE / 4, y1 - BOX_SIZE / 4, BOX_SIZE/2, BOX_SIZE/2);
273 canvas->draw_circle(x2 - BOX_SIZE / 4, y2 - BOX_SIZE / 4, BOX_SIZE/2, BOX_SIZE/2);
281 // Draw 0 and 100% lines.
282 canvas->set_color(0xff0000);
283 canvas->draw_line(title2_x - canvas->get_x(), 0,
284 title2_x - canvas->get_x(), canvas_h);
285 canvas->draw_line(title3_x - canvas->get_x(), 0,
286 title3_x - canvas->get_x(), canvas_h);
289 void HistogramWindow::update_canvas()
291 int bins = plugin->slots * (HISTOGRAM_MAX-HISTOGRAM_MIN)/100;
292 int *accum = plugin->accum[plugin->mode];
297 for( int i=0; i<bins; ++i )
298 if( accum[i] > normalize )
299 normalize = accum[i];
305 for( int i=0; i<canvas_w; ++i ) {
306 int accum_end = bins*i / canvas_w;
308 for( int j=accum_start; j<accum_end; ++j ) {
309 max = MAX(accum[j], max);
312 // max = max * canvas_h / normalize;
313 max = (int)(log(max) / log(normalize) * canvas_h);
315 canvas->set_color(0x333333);
316 canvas->draw_line(i, 0, i, canvas_h - max);
317 canvas->set_color(0x848484);
318 canvas->draw_line(i, canvas_h - max, i, canvas_h);
319 accum_start = accum_end;
323 canvas->set_color(0x333333);
324 canvas->draw_box(0, 0, canvas_w, canvas_h);
328 draw_canvas_overlay();
333 HistogramCanvas::HistogramCanvas(HistogramMain *plugin, HistogramWindow *gui,
334 int x, int y, int w, int h)
335 : BC_SubWindow(x, y, w, h, 0x333333)
337 this->plugin = plugin;
341 int HistogramCanvas::button_press_event()
344 if( is_event_win() && cursor_inside() ) {
345 if( !plugin->dragging_point ) {
346 HistogramPoint *new_point = 0;
348 // Search for existing point under cursor
349 HistogramPoint *current = plugin->config.points[plugin->mode].first;
350 plugin->current_point = -1;
353 int x = (int)((current->x - HIST_MIN_INPUT) * gui->canvas_w / FLOAT_RANGE);
354 int y = (int)(gui->canvas_h - current->y * gui->canvas_h);
356 /* Check for click on main point */
357 if( get_cursor_x() >= x - BOX_SIZE / 2 &&
358 get_cursor_y() >= y - BOX_SIZE / 2 &&
359 get_cursor_x() < x + BOX_SIZE / 2 &&
360 get_cursor_y() < y + BOX_SIZE / 2 ) {
361 plugin->current_point =
362 plugin->config.points[plugin->mode].number_of(current);
363 plugin->point_x_offset = get_cursor_x() - x;
364 plugin->point_y_offset = get_cursor_y() - y;
368 // if (plugin->config.smoothMode == HISTOGRAM_LINEAR)
372 (int)((current->x + current->xoffset_right - HIST_MIN_INPUT) * gui->canvas_w / FLOAT_RANGE);
374 (int)(gui->canvas_h - (current->y + current->xoffset_right * current->gradient) *
377 /* Check for click on right handle */
378 if( get_cursor_x() >= xright - BOX_SIZE / 2 &&
379 get_cursor_y() >= yright - BOX_SIZE / 2 &&
380 get_cursor_x() < xright + BOX_SIZE / 2 &&
381 get_cursor_y() < yright + BOX_SIZE / 2 ) {
382 plugin->current_point =
383 plugin->config.points[plugin->mode].number_of(current);
384 plugin->point_x_offset = get_cursor_x() - xright;
385 plugin->point_y_offset = get_cursor_y() - yright;
390 /* Check for click on left handle */
392 (int)((current->x + current->xoffset_left - HIST_MIN_INPUT) * gui->canvas_w / FLOAT_RANGE);
394 (int)(gui->canvas_h - (current->y + current->xoffset_left * current->gradient) *
396 if( get_cursor_x() >= xleft - BOX_SIZE / 2 &&
397 get_cursor_y() >= yleft - BOX_SIZE / 2 &&
398 get_cursor_x() < xleft + BOX_SIZE / 2 &&
399 get_cursor_y() < yleft + BOX_SIZE / 2 ) {
400 plugin->current_point =
401 plugin->config.points[plugin->mode].number_of(current);
402 plugin->point_x_offset = get_cursor_x() - xleft;
403 plugin->point_y_offset = get_cursor_y() - yleft;
411 if( plugin->current_point < 0 ) {
412 // Create new point under cursor
413 float current_x = (float)get_cursor_x() * FLOAT_RANGE / get_w() + HIST_MIN_INPUT;
414 float current_y = 1.0 - (float)get_cursor_y() / get_h();
416 plugin->config.points[plugin->mode].insert(current_x, current_y);
417 plugin->current_point =
418 plugin->config.points[plugin->mode].number_of(new_point);
419 plugin->point_x_offset = 0;
420 plugin->point_y_offset = 0;
423 // Get 2 points surrounding current position
424 float x1 = 0, x2 = 1, y1 = 0, y2 = 1;
426 HistogramPoint *current = plugin->config.points[plugin->mode].first;
428 while( current && !done ) {
429 if( current->x > current_x ) {
438 current = plugin->config.points[plugin->mode].last;
440 while( current && !done ) {
441 if( current->x <= current_x ) {
449 new_point->gradient = (y2 - y1) / (x2 - x1);
452 else if( dragID == 1 && get_buttonpress() == RIGHT_BUTTON ) {
453 if( gui->delete_current_point() ) {
454 plugin->send_configure_change();
459 plugin->dragging_point = dragID;
462 plugin->config.boundaries();
464 gui->update_canvas();
466 plugin->send_configure_change();
473 int HistogramCanvas::cursor_motion_event()
475 if( plugin->dragging_point ) {
476 HistogramPoints *mode_points = &plugin->config.points[plugin->mode];
477 HistogramPoint *current_point = mode_points->get_item_number(plugin->current_point);
480 (float)(get_cursor_x() - plugin->point_x_offset) * FLOAT_RANGE / get_w() + HIST_MIN_INPUT;
481 float current_y = 1.0 - (float)(get_cursor_y() - plugin->point_y_offset) / get_h();
483 switch( plugin->dragging_point ) {
484 case 1: /* Main point dragged */
485 current_point->x = current_x;
486 current_point->y = current_y;
488 case 2: /* Right control point dragged */
489 if( current_x - current_point->x > 0 ) {
490 current_point->xoffset_right = current_x - current_point->x;
491 current_point->gradient = (current_y - current_point->y) / (current_x - current_point->x);
494 case 3: /* Left control point dragged */
495 if( current_x - current_point->x < 0 ) {
496 current_point->xoffset_left = current_x - current_point->x;
497 current_point->gradient = (current_point->y - current_y) / (current_point->x - current_x);
502 plugin->config.boundaries();
504 gui->update_canvas();
505 plugin->send_configure_change();
511 int HistogramCanvas::button_release_event()
513 if(plugin->dragging_point)
515 // Test for out of order points to delete.
516 HistogramPoint *current =
517 plugin->config.points[plugin->mode].get_item_number(plugin->current_point);
518 HistogramPoint *prev = PREVIOUS;
519 HistogramPoint *next = NEXT;
521 if( (prev && prev->x >= current->x) ||
522 (next && next->x <= current->x) ) {
524 plugin->current_point = -1;
525 plugin->config.boundaries();
527 gui->update_canvas();
530 plugin->send_configure_change();
531 plugin->dragging_point = 0;
537 HistogramReset::HistogramReset(HistogramMain *plugin, int x, int y)
538 : BC_GenericButton(x, y, _("Reset"))
540 this->plugin = plugin;
542 int HistogramReset::handle_event()
544 plugin->config.reset(1);
545 HistogramWindow *window = (HistogramWindow *)plugin->thread->window;
547 window->update_canvas();
548 plugin->send_configure_change();
553 HistogramSlider::HistogramSlider(HistogramMain *plugin, HistogramWindow *gui,
554 int x, int y, int w, int h, int is_input)
555 : BC_SubWindow(x, y, w, h)
557 this->plugin = plugin;
559 this->is_input = is_input;
563 int HistogramSlider::input_to_pixel(float input)
565 return (int)((input - HIST_MIN_INPUT) / FLOAT_RANGE * get_w());
568 int HistogramSlider::button_press_event()
570 if( is_event_win() && cursor_inside() ) {
573 int half_h = get_h() / 2;
577 if( operation == NONE ) {
578 int x1 = input_to_pixel(plugin->config.output_min[plugin->mode]) -
579 gui->mid_picon->get_w() / 2;
580 int x2 = x1 + gui->mid_picon->get_w();
581 if( get_cursor_x() >= x1 && get_cursor_x() < x2 &&
582 get_cursor_y() >= half_h && get_cursor_y() < h ) {
583 operation = DRAG_MIN_OUTPUT;
587 if( operation == NONE ) {
588 int x1 = input_to_pixel(plugin->config.output_max[plugin->mode]) -
589 gui->mid_picon->get_w() / 2;
590 int x2 = x1 + gui->mid_picon->get_w();
591 if( get_cursor_x() >= x1 && get_cursor_x() < x2 &&
592 get_cursor_y() >= half_h && get_cursor_y() < h ) {
593 operation = DRAG_MAX_OUTPUT;
601 int HistogramSlider::button_release_event()
603 if( operation == NONE ) return 0;
608 int HistogramSlider::cursor_motion_event()
610 if( operation == NONE ) return 0;
612 float value = (float)get_cursor_x() / get_w() * FLOAT_RANGE + HIST_MIN_INPUT;
613 CLAMP(value, HIST_MIN_INPUT, HIST_MAX_INPUT);
615 switch( operation ) {
616 case DRAG_MIN_OUTPUT:
617 value = MIN(plugin->config.output_max[plugin->mode], value);
618 plugin->config.output_min[plugin->mode] = value;
620 case DRAG_MAX_OUTPUT:
621 value = MAX(plugin->config.output_min[plugin->mode], value);
622 plugin->config.output_max[plugin->mode] = value;
626 plugin->config.boundaries();
627 gui->update_output();
629 plugin->send_configure_change();
633 void HistogramSlider::update()
635 int w = get_w(), h = get_h();
636 int half_h = get_h() / 2;
637 // int quarter_h = get_h() / 4;
638 int mode = plugin->mode;
639 int r = 0, g = 0, b = 0;
641 clear_box(0, 0, w, h);
644 case HISTOGRAM_RED: r = 0xff; break;
645 case HISTOGRAM_GREEN: g = 0xff; break;
646 case HISTOGRAM_BLUE: b = 0xff; break;
647 case HISTOGRAM_VALUE: r = g = b = 0xff; break;
650 for( int i=0; i<w; ++i ) {
651 int color = (int)(i * 0xff / w);
652 set_color(((r * color / 0xff) << 16) |
653 ((g * color / 0xff) << 8) |
656 draw_line(i, 0, i, half_h);
659 float min = plugin->config.output_min[plugin->mode];
660 draw_pixmap(gui->min_picon,
661 input_to_pixel(min) - gui->min_picon->get_w() / 2,
663 float max = plugin->config.output_max[plugin->mode];
664 draw_pixmap(gui->max_picon,
665 input_to_pixel(max) - gui->max_picon->get_w() / 2,
673 HistogramAuto::HistogramAuto(HistogramMain *plugin, int x, int y)
674 : BC_CheckBox(x, y, plugin->config.automatic, _("Automatic"))
676 this->plugin = plugin;
679 int HistogramAuto::handle_event()
681 plugin->config.automatic = get_value();
682 plugin->send_configure_change();
687 HistogramSplit::HistogramSplit(HistogramMain *plugin, int x, int y)
688 : BC_CheckBox(x, y, plugin->config.split, _("Split picture"))
690 this->plugin = plugin;
693 int HistogramSplit::handle_event()
695 plugin->config.split = get_value();
696 plugin->send_configure_change();
701 HistogramMode::HistogramMode(HistogramMain *plugin, int x, int y,
702 int value, const char *text)
703 : BC_Radial(x, y, plugin->mode == value, text)
705 this->plugin = plugin;
708 int HistogramMode::handle_event()
710 plugin->mode = value;
711 plugin->current_point= -1;
712 HistogramWindow *window = (HistogramWindow *)plugin->thread->window;
713 window->update_mode();
714 window->update_canvas();
715 window->update_input();
716 window->update_output();
717 window->output->update();
718 // plugin->send_configure_change();
723 HistogramClear::HistogramClear(HistogramMain *plugin, int x, int y, const char *text)
724 : BC_GenericButton(x, y, text)
726 this->plugin = plugin;
729 int HistogramClear::handle_event()
731 HistogramPoints *mode_points = &plugin->config.points[plugin->mode];
732 mode_points->clear();
733 plugin->config.output_min[plugin->mode] = 0.0;
734 plugin->config.output_max[plugin->mode] = 1.0;
735 HistogramWindow *window = (HistogramWindow *)plugin->thread->window;
737 window->update_canvas();
738 plugin->send_configure_change();
743 HistogramOutputText::HistogramOutputText(HistogramMain *plugin,
744 HistogramWindow *gui, int x, int y, float *output)
745 : BC_TumbleTextBox(gui, output ? (float)*output : 0.0,
746 (float)HIST_MIN_INPUT, (float)HIST_MAX_INPUT,
749 this->plugin = plugin;
750 this->output = output;
751 set_precision(DIGITS);
752 set_increment(PRECISION);
755 int HistogramOutputText::handle_event()
758 *output = atof(get_text());
761 HistogramWindow *window = (HistogramWindow *)plugin->thread->window;
762 window->output->update();
763 plugin->send_configure_change();
768 HistogramInputText::HistogramInputText(HistogramMain *plugin,
769 HistogramWindow *gui, int x, int y, int do_x)
770 : BC_TumbleTextBox(gui, 0.0,
771 (float)HIST_MIN_INPUT, (float)HIST_MAX_INPUT,
775 this->plugin = plugin;
777 set_precision(DIGITS);
778 set_increment(PRECISION);
781 int HistogramInputText::handle_event()
783 if( plugin->current_point >= 0 &&
784 plugin->current_point < plugin->config.points[plugin->mode].total() ) {
785 HistogramPoints *mode_points = &plugin->config.points[plugin->mode];
786 HistogramPoint *point = mode_points->get_item_number(plugin->current_point);
790 point->x = atof(get_text());
792 point->y = atof(get_text());
794 plugin->config.boundaries();
795 gui->update_canvas();
797 HistogramWindow *window = (HistogramWindow *)plugin->thread->window;
798 window->output->update();
799 plugin->send_configure_change();
805 void HistogramInputText::update()
807 if( plugin->current_point >= 0 &&
808 plugin->current_point < plugin->config.points[plugin->mode].total() ) {
809 HistogramPoints *mode_points = &plugin->config.points[plugin->mode];
810 HistogramPoint *point = mode_points->get_item_number(plugin->current_point);
814 BC_TumbleTextBox::update(point->x);
816 BC_TumbleTextBox::update(point->y);
819 BC_TumbleTextBox::update((float)0.0);
823 BC_TumbleTextBox::update((float)0.0);
829 HistogramSmoothMode::HistogramSmoothMode(HistogramMain*plugin,
830 HistogramWindow *gui, int x, int y)
831 : BC_PopupMenu(x, y, 120, to_text(plugin->config.smoothMode), 1)
833 this->plugin = plugin;
836 void HistogramSmoothMode::create_objects()
838 add_item(new BC_MenuItem(to_text(HISTOGRAM_LINEAR)));
839 add_item(new BC_MenuItem(to_text(HISTOGRAM_POLYNOMINAL)));
840 add_item(new BC_MenuItem(to_text(HISTOGRAM_BEZIER)));
843 char* HistogramSmoothMode::to_text(int mode)
846 case HISTOGRAM_LINEAR: return _("Linear");
847 case HISTOGRAM_POLYNOMINAL: return _("Polynominal");
848 case HISTOGRAM_BEZIER: return _("Bezier");
852 int HistogramSmoothMode::set_mode(int mode)
854 const char *tp = to_text(mode);
855 if( strcmp(tp, get_text()) ) {
863 int HistogramSmoothMode::from_text(char *text)
865 if( !strcmp(text, to_text(HISTOGRAM_LINEAR)) ) return HISTOGRAM_LINEAR;
866 if( !strcmp(text, to_text(HISTOGRAM_POLYNOMINAL)) ) return HISTOGRAM_POLYNOMINAL;
867 if( !strcmp(text, to_text(HISTOGRAM_BEZIER)) ) return HISTOGRAM_BEZIER;
868 return HISTOGRAM_LINEAR;
870 int HistogramSmoothMode::get_mode()
872 return from_text(get_text());
875 int HistogramSmoothMode::handle_event()
877 plugin->config.smoothMode = get_mode();
878 gui->update_canvas();
879 plugin->send_configure_change();