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, xS(480), yS(480), xS(480), yS(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 xs10 = xS(10), xs15 = xS(15), xs20 = xS(20), xs80 = xS(80), xs100 = xS(100), xs120 = xS(120), xs150 = xS(150);
60 int ys6 = yS(6), ys10 = yS(10), ys20 = yS(20), ys30 = yS(30), ys40 = yS(40), ys170 = yS(170);
61 int x = xs10, y = ys10, x1 = xs10;
64 max_picon = create_pixmap(&max_picon_image);
65 mid_picon = create_pixmap(&mid_picon_image);
66 min_picon = create_pixmap(&min_picon_image);
67 add_subwindow(mode_v = new HistogramMode(plugin, x, y,
68 HISTOGRAM_VALUE, _("Value")));
70 add_subwindow(mode_r = new HistogramMode(plugin, x, y,
71 HISTOGRAM_RED, _("Red")));
73 add_subwindow(mode_g = new HistogramMode(plugin, x, y,
74 HISTOGRAM_GREEN, _("Green")));
76 add_subwindow(mode_b = new HistogramMode(plugin, x, y,
77 HISTOGRAM_BLUE, _("Blue")));
79 // add_subwindow(mode_a = new HistogramMode(plugin, x, y,
80 // HISTOGRAM_ALPHA, _("Alpha")));
82 x = get_w() - HistogramClear::calculate_w(this, _("Clear")) - xs15;
83 add_subwindow(clear = new HistogramClear(plugin, x, y, _("Clear")));
87 add_subwindow(title = new BC_Title(x, y, _("Input X:")));
88 x += title->get_w() + xs10;
89 input_x = new HistogramInputText(plugin, this, x, y, 1);
90 input_x->create_objects();
92 x += input_x->get_w() + xs10;
93 add_subwindow(title = new BC_Title(x, y, _("Input Y:")));
94 x += title->get_w() + xs10;
95 input_y = new HistogramInputText(plugin, this, x, y, 0);
96 input_y->create_objects();
101 canvas_w = get_w() - x - x;
102 canvas_h = get_h() - y - ys170;
104 title2_x = x + (int)(canvas_w * -HIST_MIN_INPUT / FLOAT_RANGE);
105 title3_x = x + (int)(canvas_w * (1.0 - HIST_MIN_INPUT) / FLOAT_RANGE);
106 title4_x = x + (int)(canvas_w);
107 add_subwindow(canvas = new HistogramCanvas(plugin, this,
108 x, y, canvas_w, canvas_h));
109 draw_canvas_overlay();
112 y += canvas->get_h() + 1;
113 add_subwindow(new BC_Title(title1_x, y, "-10%"));
114 add_subwindow(new BC_Title(title2_x, y, "0%"));
115 add_subwindow(new BC_Title(title3_x - get_text_width(MEDIUMFONT, "100"), y, "100%"));
116 add_subwindow(new BC_Title(title4_x - get_text_width(MEDIUMFONT, "110"), y, "110%"));
119 add_subwindow(title = new BC_Title(x, y, _("Output min:")));
120 x += title->get_w() + xs10;
121 output_min = new HistogramOutputText(plugin, this,
122 x, y, &plugin->config.output_min[plugin->mode]);
123 output_min->create_objects();
124 x += output_min->get_w() + xs10;
125 add_subwindow(new BC_Title(x, y, _("Output Max:")));
126 x += title->get_w() + xs10;
127 output_max = new HistogramOutputText(plugin, this,
128 x, y, &plugin->config.output_max[plugin->mode]);
129 output_max->create_objects();
134 add_subwindow(output = new HistogramSlider(plugin, this,
135 x, y, get_w() - xs20, ys30, 0));
140 add_subwindow(automatic = new HistogramAuto(plugin, x, y));
143 add_subwindow(new HistogramReset(plugin, x, y));
145 add_subwindow(new BC_Title(x, y, _("Threshold:")));
147 threshold = new HistogramOutputText(plugin, this,
148 x, y, &plugin->config.threshold);
149 threshold->create_objects();
152 add_subwindow(split = new HistogramSplit(plugin, x, y));
155 add_subwindow(new BC_Title(x,y, _("Interpolation:")));
157 add_subwindow(smoothModeChoser = new HistogramSmoothMode(plugin, this, x, y));
158 smoothModeChoser->create_objects();
163 int HistogramWindow::delete_current_point()
165 if( plugin->current_point < 0 ) return 0;
166 HistogramPoint *current =
167 plugin->config.points[plugin->mode].get_item_number(plugin->current_point);
169 plugin->current_point = -1;
173 int HistogramWindow::keypress_event()
176 if( get_keypress() == BACKSPACE ||
177 get_keypress() == DELETE ) {
178 if( delete_current_point() ) {
181 plugin->send_configure_change();
188 void HistogramWindow::update(int do_input)
190 automatic->update(plugin->config.automatic);
191 threshold->update(plugin->config.threshold);
193 split->set_value(plugin->config.split);
194 if( do_input ) update_input();
196 if( smoothModeChoser->set_mode(plugin->config.smoothMode) )
200 void HistogramWindow::update_input()
206 void HistogramWindow::update_output()
209 output_min->update(plugin->config.output_min[plugin->mode]);
210 output_max->update(plugin->config.output_max[plugin->mode]);
213 void HistogramWindow::update_mode()
215 mode_v->update(plugin->mode == HISTOGRAM_VALUE ? 1 : 0);
216 mode_r->update(plugin->mode == HISTOGRAM_RED ? 1 : 0);
217 mode_g->update(plugin->mode == HISTOGRAM_GREEN ? 1 : 0);
218 mode_b->update(plugin->mode == HISTOGRAM_BLUE ? 1 : 0);
219 output_min->output = &plugin->config.output_min[plugin->mode];
220 output_max->output = &plugin->config.output_max[plugin->mode];
223 void HistogramWindow::draw_canvas_overlay()
227 // Calculate output curve
228 plugin->tabulate_curve(plugin->mode, 0);
231 canvas->set_color(0xffff00);
232 for( int i=0; i<canvas_w; ++i ) {
233 float input = (float)i / canvas_w * FLOAT_RANGE + HIST_MIN_INPUT;
234 float output = plugin->calculate_smooth(input, plugin->mode);
236 int y2 = canvas_h - (int)(output * canvas_h);
238 canvas->draw_line(i - 1, y1, i, y2);
244 // Draw output points
245 HistogramPoint *current = plugin->config.points[plugin->mode].first;
248 canvas->set_color(0x00ff00);
249 int x = (int)((current->x - HIST_MIN_INPUT) * canvas_w / FLOAT_RANGE);
250 int y = (int)(canvas_h - current->y * canvas_h);
251 if(number == plugin->current_point)
252 canvas->draw_box(x - BOX_SIZE / 2, y - BOX_SIZE / 2, BOX_SIZE, BOX_SIZE);
254 canvas->draw_rectangle(x - BOX_SIZE / 2, y - BOX_SIZE / 2, BOX_SIZE, BOX_SIZE);
257 canvas->draw_line(x0, y0, x, y);
260 if (plugin->config.smoothMode > HISTOGRAM_LINEAR) {
262 canvas->set_color(0xffffff);
263 x2 = (int)((current->x + current->xoffset_right - HIST_MIN_INPUT) * canvas_w / FLOAT_RANGE);
264 x1 = (int)((current->x + current->xoffset_left - HIST_MIN_INPUT) * canvas_w / FLOAT_RANGE);
265 y2 = (int)(canvas_h - (current->y + current->xoffset_right * current->gradient) * canvas_h);
266 y1 = (int)(canvas_h - (current->y + current->xoffset_left * current->gradient) * canvas_h);
267 /* x2 = x + (title3_x - title2_x)/20;
268 x1 = x - (title3_x - title2_x)/20;
269 y1 = y + (int)(current->gradient * (float)(canvas_h)/20.0);
270 y2 = y - (int)(current->gradient * (float)(canvas_h)/20.0);
271 int y2 = (int)(canvas_h - canvas_h * (current->y + current->gradient /10));*/
272 canvas->draw_line(x1,y1,x2,y2);
274 canvas->draw_circle(x1 - BOX_SIZE / 4, y1 - BOX_SIZE / 4, BOX_SIZE/2, BOX_SIZE/2);
275 canvas->draw_circle(x2 - BOX_SIZE / 4, y2 - BOX_SIZE / 4, BOX_SIZE/2, BOX_SIZE/2);
283 // Draw 0 and 100% lines.
284 canvas->set_color(0xff0000);
285 canvas->draw_line(title2_x - canvas->get_x(), 0,
286 title2_x - canvas->get_x(), canvas_h);
287 canvas->draw_line(title3_x - canvas->get_x(), 0,
288 title3_x - canvas->get_x(), canvas_h);
291 void HistogramWindow::update_canvas()
293 int bins = plugin->slots * (HISTOGRAM_MAX-HISTOGRAM_MIN)/100;
294 int *accum = plugin->accum[plugin->mode];
299 for( int i=0; i<bins; ++i )
300 if( accum[i] > normalize )
301 normalize = accum[i];
307 for( int i=0; i<canvas_w; ++i ) {
308 int accum_end = bins*i / canvas_w;
310 for( int j=accum_start; j<accum_end; ++j ) {
311 max = MAX(accum[j], max);
314 // max = max * canvas_h / normalize;
315 max = (int)(log(max) / log(normalize) * canvas_h);
317 canvas->set_color(0x333333);
318 canvas->draw_line(i, 0, i, canvas_h - max);
319 canvas->set_color(0x848484);
320 canvas->draw_line(i, canvas_h - max, i, canvas_h);
321 accum_start = accum_end;
325 canvas->set_color(0x333333);
326 canvas->draw_box(0, 0, canvas_w, canvas_h);
330 draw_canvas_overlay();
335 HistogramCanvas::HistogramCanvas(HistogramMain *plugin, HistogramWindow *gui,
336 int x, int y, int w, int h)
337 : BC_SubWindow(x, y, w, h, 0x333333)
339 this->plugin = plugin;
343 int HistogramCanvas::button_press_event()
346 if( is_event_win() && cursor_inside() ) {
347 if( !plugin->dragging_point ) {
348 HistogramPoint *new_point = 0;
350 // Search for existing point under cursor
351 HistogramPoint *current = plugin->config.points[plugin->mode].first;
352 plugin->current_point = -1;
355 int x = (int)((current->x - HIST_MIN_INPUT) * gui->canvas_w / FLOAT_RANGE);
356 int y = (int)(gui->canvas_h - current->y * gui->canvas_h);
358 /* Check for click on main point */
359 if( get_cursor_x() >= x - BOX_SIZE / 2 &&
360 get_cursor_y() >= y - BOX_SIZE / 2 &&
361 get_cursor_x() < x + BOX_SIZE / 2 &&
362 get_cursor_y() < y + BOX_SIZE / 2 ) {
363 plugin->current_point =
364 plugin->config.points[plugin->mode].number_of(current);
365 plugin->point_x_offset = get_cursor_x() - x;
366 plugin->point_y_offset = get_cursor_y() - y;
370 // if (plugin->config.smoothMode == HISTOGRAM_LINEAR)
374 (int)((current->x + current->xoffset_right - HIST_MIN_INPUT) * gui->canvas_w / FLOAT_RANGE);
376 (int)(gui->canvas_h - (current->y + current->xoffset_right * current->gradient) *
379 /* Check for click on right handle */
380 if( get_cursor_x() >= xright - BOX_SIZE / 2 &&
381 get_cursor_y() >= yright - BOX_SIZE / 2 &&
382 get_cursor_x() < xright + BOX_SIZE / 2 &&
383 get_cursor_y() < yright + BOX_SIZE / 2 ) {
384 plugin->current_point =
385 plugin->config.points[plugin->mode].number_of(current);
386 plugin->point_x_offset = get_cursor_x() - xright;
387 plugin->point_y_offset = get_cursor_y() - yright;
392 /* Check for click on left handle */
394 (int)((current->x + current->xoffset_left - HIST_MIN_INPUT) * gui->canvas_w / FLOAT_RANGE);
396 (int)(gui->canvas_h - (current->y + current->xoffset_left * current->gradient) *
398 if( get_cursor_x() >= xleft - BOX_SIZE / 2 &&
399 get_cursor_y() >= yleft - BOX_SIZE / 2 &&
400 get_cursor_x() < xleft + BOX_SIZE / 2 &&
401 get_cursor_y() < yleft + BOX_SIZE / 2 ) {
402 plugin->current_point =
403 plugin->config.points[plugin->mode].number_of(current);
404 plugin->point_x_offset = get_cursor_x() - xleft;
405 plugin->point_y_offset = get_cursor_y() - yleft;
413 if( plugin->current_point < 0 ) {
414 // Create new point under cursor
415 float current_x = (float)get_cursor_x() * FLOAT_RANGE / get_w() + HIST_MIN_INPUT;
416 float current_y = 1.0 - (float)get_cursor_y() / get_h();
418 plugin->config.points[plugin->mode].insert(current_x, current_y);
419 plugin->current_point =
420 plugin->config.points[plugin->mode].number_of(new_point);
421 plugin->point_x_offset = 0;
422 plugin->point_y_offset = 0;
425 // Get 2 points surrounding current position
426 float x1 = 0, x2 = 1, y1 = 0, y2 = 1;
428 HistogramPoint *current = plugin->config.points[plugin->mode].first;
430 while( current && !done ) {
431 if( current->x > current_x ) {
440 current = plugin->config.points[plugin->mode].last;
442 while( current && !done ) {
443 if( current->x <= current_x ) {
451 new_point->gradient = (y2 - y1) / (x2 - x1);
454 else if( dragID == 1 && get_buttonpress() == RIGHT_BUTTON ) {
455 if( gui->delete_current_point() ) {
456 plugin->send_configure_change();
461 plugin->dragging_point = dragID;
464 plugin->config.boundaries();
466 gui->update_canvas();
468 plugin->send_configure_change();
475 int HistogramCanvas::cursor_motion_event()
477 if( plugin->dragging_point ) {
478 HistogramPoints *mode_points = &plugin->config.points[plugin->mode];
479 HistogramPoint *current_point = mode_points->get_item_number(plugin->current_point);
482 (float)(get_cursor_x() - plugin->point_x_offset) * FLOAT_RANGE / get_w() + HIST_MIN_INPUT;
483 float current_y = 1.0 - (float)(get_cursor_y() - plugin->point_y_offset) / get_h();
485 switch( plugin->dragging_point ) {
486 case 1: /* Main point dragged */
487 current_point->x = current_x;
488 current_point->y = current_y;
490 case 2: /* Right control point dragged */
491 if( current_x - current_point->x > 0 ) {
492 current_point->xoffset_right = current_x - current_point->x;
493 current_point->gradient = (current_y - current_point->y) / (current_x - current_point->x);
496 case 3: /* Left control point dragged */
497 if( current_x - current_point->x < 0 ) {
498 current_point->xoffset_left = current_x - current_point->x;
499 current_point->gradient = (current_point->y - current_y) / (current_point->x - current_x);
504 plugin->config.boundaries();
506 gui->update_canvas();
507 plugin->send_configure_change();
513 int HistogramCanvas::button_release_event()
515 if(plugin->dragging_point)
517 // Test for out of order points to delete.
518 HistogramPoint *current =
519 plugin->config.points[plugin->mode].get_item_number(plugin->current_point);
520 HistogramPoint *prev = PREVIOUS;
521 HistogramPoint *next = NEXT;
523 if( (prev && prev->x >= current->x) ||
524 (next && next->x <= current->x) ) {
526 plugin->current_point = -1;
527 plugin->config.boundaries();
529 gui->update_canvas();
532 plugin->send_configure_change();
533 plugin->dragging_point = 0;
539 HistogramReset::HistogramReset(HistogramMain *plugin, int x, int y)
540 : BC_GenericButton(x, y, _("Reset"))
542 this->plugin = plugin;
544 int HistogramReset::handle_event()
546 plugin->config.reset(1);
547 HistogramWindow *window = (HistogramWindow *)plugin->thread->window;
549 window->update_canvas();
550 plugin->send_configure_change();
555 HistogramSlider::HistogramSlider(HistogramMain *plugin, HistogramWindow *gui,
556 int x, int y, int w, int h, int is_input)
557 : BC_SubWindow(x, y, w, h)
559 this->plugin = plugin;
561 this->is_input = is_input;
565 int HistogramSlider::input_to_pixel(float input)
567 return (int)((input - HIST_MIN_INPUT) / FLOAT_RANGE * get_w());
570 int HistogramSlider::button_press_event()
572 if( is_event_win() && cursor_inside() ) {
575 int half_h = get_h() / 2;
579 if( operation == NONE ) {
580 int x1 = input_to_pixel(plugin->config.output_min[plugin->mode]) -
581 gui->mid_picon->get_w() / 2;
582 int x2 = x1 + gui->mid_picon->get_w();
583 if( get_cursor_x() >= x1 && get_cursor_x() < x2 &&
584 get_cursor_y() >= half_h && get_cursor_y() < h ) {
585 operation = DRAG_MIN_OUTPUT;
589 if( operation == NONE ) {
590 int x1 = input_to_pixel(plugin->config.output_max[plugin->mode]) -
591 gui->mid_picon->get_w() / 2;
592 int x2 = x1 + gui->mid_picon->get_w();
593 if( get_cursor_x() >= x1 && get_cursor_x() < x2 &&
594 get_cursor_y() >= half_h && get_cursor_y() < h ) {
595 operation = DRAG_MAX_OUTPUT;
603 int HistogramSlider::button_release_event()
605 if( operation == NONE ) return 0;
610 int HistogramSlider::cursor_motion_event()
612 if( operation == NONE ) return 0;
614 float value = (float)get_cursor_x() / get_w() * FLOAT_RANGE + HIST_MIN_INPUT;
615 CLAMP(value, HIST_MIN_INPUT, HIST_MAX_INPUT);
617 switch( operation ) {
618 case DRAG_MIN_OUTPUT:
619 value = MIN(plugin->config.output_max[plugin->mode], value);
620 plugin->config.output_min[plugin->mode] = value;
622 case DRAG_MAX_OUTPUT:
623 value = MAX(plugin->config.output_min[plugin->mode], value);
624 plugin->config.output_max[plugin->mode] = value;
628 plugin->config.boundaries();
629 gui->update_output();
631 plugin->send_configure_change();
635 void HistogramSlider::update()
637 int w = get_w(), h = get_h();
638 int half_h = get_h() / 2;
639 // int quarter_h = get_h() / 4;
640 int mode = plugin->mode;
641 int r = 0, g = 0, b = 0;
643 clear_box(0, 0, w, h);
646 case HISTOGRAM_RED: r = 0xff; break;
647 case HISTOGRAM_GREEN: g = 0xff; break;
648 case HISTOGRAM_BLUE: b = 0xff; break;
649 case HISTOGRAM_VALUE: r = g = b = 0xff; break;
652 for( int i=0; i<w; ++i ) {
653 int color = (int)(i * 0xff / w);
654 set_color(((r * color / 0xff) << 16) |
655 ((g * color / 0xff) << 8) |
658 draw_line(i, 0, i, half_h);
661 float min = plugin->config.output_min[plugin->mode];
662 draw_pixmap(gui->min_picon,
663 input_to_pixel(min) - gui->min_picon->get_w() / 2,
665 float max = plugin->config.output_max[plugin->mode];
666 draw_pixmap(gui->max_picon,
667 input_to_pixel(max) - gui->max_picon->get_w() / 2,
675 HistogramAuto::HistogramAuto(HistogramMain *plugin, int x, int y)
676 : BC_CheckBox(x, y, plugin->config.automatic, _("Automatic"))
678 this->plugin = plugin;
681 int HistogramAuto::handle_event()
683 plugin->config.automatic = get_value();
684 plugin->send_configure_change();
689 HistogramSplit::HistogramSplit(HistogramMain *plugin, int x, int y)
690 : BC_CheckBox(x, y, plugin->config.split, _("Split picture"))
692 this->plugin = plugin;
695 int HistogramSplit::handle_event()
697 plugin->config.split = get_value();
698 plugin->send_configure_change();
703 HistogramMode::HistogramMode(HistogramMain *plugin, int x, int y,
704 int value, const char *text)
705 : BC_Radial(x, y, plugin->mode == value, text)
707 this->plugin = plugin;
710 int HistogramMode::handle_event()
712 plugin->mode = value;
713 plugin->current_point= -1;
714 HistogramWindow *window = (HistogramWindow *)plugin->thread->window;
715 window->update_mode();
716 window->update_canvas();
717 window->update_input();
718 window->update_output();
719 window->output->update();
720 // plugin->send_configure_change();
725 HistogramClear::HistogramClear(HistogramMain *plugin, int x, int y, const char *text)
726 : BC_GenericButton(x, y, text)
728 this->plugin = plugin;
731 int HistogramClear::handle_event()
733 HistogramPoints *mode_points = &plugin->config.points[plugin->mode];
734 mode_points->clear();
735 plugin->config.output_min[plugin->mode] = 0.0;
736 plugin->config.output_max[plugin->mode] = 1.0;
737 HistogramWindow *window = (HistogramWindow *)plugin->thread->window;
739 window->update_canvas();
740 plugin->send_configure_change();
745 HistogramOutputText::HistogramOutputText(HistogramMain *plugin,
746 HistogramWindow *gui, int x, int y, float *output)
747 : BC_TumbleTextBox(gui, output ? (float)*output : 0.0,
748 (float)HIST_MIN_INPUT, (float)HIST_MAX_INPUT,
751 this->plugin = plugin;
752 this->output = output;
753 set_precision(DIGITS);
754 set_increment(PRECISION);
757 int HistogramOutputText::handle_event()
760 *output = atof(get_text());
763 HistogramWindow *window = (HistogramWindow *)plugin->thread->window;
764 window->output->update();
765 plugin->send_configure_change();
770 HistogramInputText::HistogramInputText(HistogramMain *plugin,
771 HistogramWindow *gui, int x, int y, int do_x)
772 : BC_TumbleTextBox(gui, 0.0,
773 (float)HIST_MIN_INPUT, (float)HIST_MAX_INPUT,
777 this->plugin = plugin;
779 set_precision(DIGITS);
780 set_increment(PRECISION);
783 int HistogramInputText::handle_event()
785 if( plugin->current_point >= 0 &&
786 plugin->current_point < plugin->config.points[plugin->mode].total() ) {
787 HistogramPoints *mode_points = &plugin->config.points[plugin->mode];
788 HistogramPoint *point = mode_points->get_item_number(plugin->current_point);
792 point->x = atof(get_text());
794 point->y = atof(get_text());
796 plugin->config.boundaries();
797 gui->update_canvas();
799 HistogramWindow *window = (HistogramWindow *)plugin->thread->window;
800 window->output->update();
801 plugin->send_configure_change();
807 void HistogramInputText::update()
809 if( plugin->current_point >= 0 &&
810 plugin->current_point < plugin->config.points[plugin->mode].total() ) {
811 HistogramPoints *mode_points = &plugin->config.points[plugin->mode];
812 HistogramPoint *point = mode_points->get_item_number(plugin->current_point);
816 BC_TumbleTextBox::update(point->x);
818 BC_TumbleTextBox::update(point->y);
821 BC_TumbleTextBox::update((float)0.0);
825 BC_TumbleTextBox::update((float)0.0);
831 HistogramSmoothMode::HistogramSmoothMode(HistogramMain*plugin,
832 HistogramWindow *gui, int x, int y)
833 : BC_PopupMenu(x, y, xS(180), to_text(plugin->config.smoothMode), 1)
835 this->plugin = plugin;
838 void HistogramSmoothMode::create_objects()
840 add_item(new BC_MenuItem(to_text(HISTOGRAM_LINEAR)));
841 add_item(new BC_MenuItem(to_text(HISTOGRAM_POLYNOMINAL)));
842 add_item(new BC_MenuItem(to_text(HISTOGRAM_BEZIER)));
845 char* HistogramSmoothMode::to_text(int mode)
848 case HISTOGRAM_LINEAR: return _("Linear");
849 case HISTOGRAM_POLYNOMINAL: return _("Polynominal");
850 case HISTOGRAM_BEZIER: return _("Bezier");
854 int HistogramSmoothMode::set_mode(int mode)
856 const char *tp = to_text(mode);
857 if( strcmp(tp, get_text()) ) {
865 int HistogramSmoothMode::from_text(char *text)
867 if( !strcmp(text, to_text(HISTOGRAM_LINEAR)) ) return HISTOGRAM_LINEAR;
868 if( !strcmp(text, to_text(HISTOGRAM_POLYNOMINAL)) ) return HISTOGRAM_POLYNOMINAL;
869 if( !strcmp(text, to_text(HISTOGRAM_BEZIER)) ) return HISTOGRAM_BEZIER;
870 return HISTOGRAM_LINEAR;
872 int HistogramSmoothMode::get_mode()
874 return from_text(get_text());
877 int HistogramSmoothMode::handle_event()
879 plugin->config.smoothMode = get_mode();
880 gui->update_canvas();
881 plugin->send_configure_change();