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();
186 result = context_help_check_and_show();
190 void HistogramWindow::update(int do_input)
192 automatic->update(plugin->config.automatic);
193 threshold->update(plugin->config.threshold);
195 split->set_value(plugin->config.split);
196 if( do_input ) update_input();
198 if( smoothModeChoser->set_mode(plugin->config.smoothMode) )
202 void HistogramWindow::update_input()
208 void HistogramWindow::update_output()
211 output_min->update(plugin->config.output_min[plugin->mode]);
212 output_max->update(plugin->config.output_max[plugin->mode]);
215 void HistogramWindow::update_mode()
217 mode_v->update(plugin->mode == HISTOGRAM_VALUE ? 1 : 0);
218 mode_r->update(plugin->mode == HISTOGRAM_RED ? 1 : 0);
219 mode_g->update(plugin->mode == HISTOGRAM_GREEN ? 1 : 0);
220 mode_b->update(plugin->mode == HISTOGRAM_BLUE ? 1 : 0);
221 output_min->output = &plugin->config.output_min[plugin->mode];
222 output_max->output = &plugin->config.output_max[plugin->mode];
225 void HistogramWindow::draw_canvas_overlay()
229 // Calculate output curve
230 plugin->tabulate_curve(plugin->mode, 0);
233 canvas->set_color(0xffff00);
234 for( int i=0; i<canvas_w; ++i ) {
235 float input = (float)i / canvas_w * FLOAT_RANGE + HIST_MIN_INPUT;
236 float output = plugin->calculate_smooth(input, plugin->mode);
238 int y2 = canvas_h - (int)(output * canvas_h);
240 canvas->draw_line(i - 1, y1, i, y2);
246 // Draw output points
247 HistogramPoint *current = plugin->config.points[plugin->mode].first;
250 canvas->set_color(0x00ff00);
251 int x = (int)((current->x - HIST_MIN_INPUT) * canvas_w / FLOAT_RANGE);
252 int y = (int)(canvas_h - current->y * canvas_h);
253 if(number == plugin->current_point)
254 canvas->draw_box(x - BOX_SIZE / 2, y - BOX_SIZE / 2, BOX_SIZE, BOX_SIZE);
256 canvas->draw_rectangle(x - BOX_SIZE / 2, y - BOX_SIZE / 2, BOX_SIZE, BOX_SIZE);
259 canvas->draw_line(x0, y0, x, y);
262 if (plugin->config.smoothMode > HISTOGRAM_LINEAR) {
264 canvas->set_color(0xffffff);
265 x2 = (int)((current->x + current->xoffset_right - HIST_MIN_INPUT) * canvas_w / FLOAT_RANGE);
266 x1 = (int)((current->x + current->xoffset_left - HIST_MIN_INPUT) * canvas_w / FLOAT_RANGE);
267 y2 = (int)(canvas_h - (current->y + current->xoffset_right * current->gradient) * canvas_h);
268 y1 = (int)(canvas_h - (current->y + current->xoffset_left * current->gradient) * canvas_h);
269 /* x2 = x + (title3_x - title2_x)/20;
270 x1 = x - (title3_x - title2_x)/20;
271 y1 = y + (int)(current->gradient * (float)(canvas_h)/20.0);
272 y2 = y - (int)(current->gradient * (float)(canvas_h)/20.0);
273 int y2 = (int)(canvas_h - canvas_h * (current->y + current->gradient /10));*/
274 canvas->draw_line(x1,y1,x2,y2);
276 canvas->draw_circle(x1 - BOX_SIZE / 4, y1 - BOX_SIZE / 4, BOX_SIZE/2, BOX_SIZE/2);
277 canvas->draw_circle(x2 - BOX_SIZE / 4, y2 - BOX_SIZE / 4, BOX_SIZE/2, BOX_SIZE/2);
285 // Draw 0 and 100% lines.
286 canvas->set_color(0xff0000);
287 canvas->draw_line(title2_x - canvas->get_x(), 0,
288 title2_x - canvas->get_x(), canvas_h);
289 canvas->draw_line(title3_x - canvas->get_x(), 0,
290 title3_x - canvas->get_x(), canvas_h);
293 void HistogramWindow::update_canvas()
295 int bins = plugin->slots * (HISTOGRAM_MAX-HISTOGRAM_MIN)/100;
296 int *accum = plugin->accum[plugin->mode];
301 for( int i=0; i<bins; ++i )
302 if( accum[i] > normalize )
303 normalize = accum[i];
309 for( int i=0; i<canvas_w; ++i ) {
310 int accum_end = bins*i / canvas_w;
312 for( int j=accum_start; j<accum_end; ++j ) {
313 max = MAX(accum[j], max);
316 // max = max * canvas_h / normalize;
317 max = (int)(log(max) / log(normalize) * canvas_h);
319 canvas->set_color(0x333333);
320 canvas->draw_line(i, 0, i, canvas_h - max);
321 canvas->set_color(0x848484);
322 canvas->draw_line(i, canvas_h - max, i, canvas_h);
323 accum_start = accum_end;
327 canvas->set_color(0x333333);
328 canvas->draw_box(0, 0, canvas_w, canvas_h);
332 draw_canvas_overlay();
337 HistogramCanvas::HistogramCanvas(HistogramMain *plugin, HistogramWindow *gui,
338 int x, int y, int w, int h)
339 : BC_SubWindow(x, y, w, h, 0x333333)
341 this->plugin = plugin;
345 int HistogramCanvas::button_press_event()
348 if( is_event_win() && cursor_inside() ) {
349 if( !plugin->dragging_point ) {
350 HistogramPoint *new_point = 0;
352 // Search for existing point under cursor
353 HistogramPoint *current = plugin->config.points[plugin->mode].first;
354 plugin->current_point = -1;
357 int x = (int)((current->x - HIST_MIN_INPUT) * gui->canvas_w / FLOAT_RANGE);
358 int y = (int)(gui->canvas_h - current->y * gui->canvas_h);
360 /* Check for click on main point */
361 if( get_cursor_x() >= x - BOX_SIZE / 2 &&
362 get_cursor_y() >= y - BOX_SIZE / 2 &&
363 get_cursor_x() < x + BOX_SIZE / 2 &&
364 get_cursor_y() < y + BOX_SIZE / 2 ) {
365 plugin->current_point =
366 plugin->config.points[plugin->mode].number_of(current);
367 plugin->point_x_offset = get_cursor_x() - x;
368 plugin->point_y_offset = get_cursor_y() - y;
372 // if (plugin->config.smoothMode == HISTOGRAM_LINEAR)
376 (int)((current->x + current->xoffset_right - HIST_MIN_INPUT) * gui->canvas_w / FLOAT_RANGE);
378 (int)(gui->canvas_h - (current->y + current->xoffset_right * current->gradient) *
381 /* Check for click on right handle */
382 if( get_cursor_x() >= xright - BOX_SIZE / 2 &&
383 get_cursor_y() >= yright - BOX_SIZE / 2 &&
384 get_cursor_x() < xright + BOX_SIZE / 2 &&
385 get_cursor_y() < yright + BOX_SIZE / 2 ) {
386 plugin->current_point =
387 plugin->config.points[plugin->mode].number_of(current);
388 plugin->point_x_offset = get_cursor_x() - xright;
389 plugin->point_y_offset = get_cursor_y() - yright;
394 /* Check for click on left handle */
396 (int)((current->x + current->xoffset_left - HIST_MIN_INPUT) * gui->canvas_w / FLOAT_RANGE);
398 (int)(gui->canvas_h - (current->y + current->xoffset_left * current->gradient) *
400 if( get_cursor_x() >= xleft - BOX_SIZE / 2 &&
401 get_cursor_y() >= yleft - BOX_SIZE / 2 &&
402 get_cursor_x() < xleft + BOX_SIZE / 2 &&
403 get_cursor_y() < yleft + BOX_SIZE / 2 ) {
404 plugin->current_point =
405 plugin->config.points[plugin->mode].number_of(current);
406 plugin->point_x_offset = get_cursor_x() - xleft;
407 plugin->point_y_offset = get_cursor_y() - yleft;
415 if( plugin->current_point < 0 ) {
416 // Create new point under cursor
417 float current_x = (float)get_cursor_x() * FLOAT_RANGE / get_w() + HIST_MIN_INPUT;
418 float current_y = 1.0 - (float)get_cursor_y() / get_h();
420 plugin->config.points[plugin->mode].insert(current_x, current_y);
421 plugin->current_point =
422 plugin->config.points[plugin->mode].number_of(new_point);
423 plugin->point_x_offset = 0;
424 plugin->point_y_offset = 0;
427 // Get 2 points surrounding current position
428 float x1 = 0, x2 = 1, y1 = 0, y2 = 1;
430 HistogramPoint *current = plugin->config.points[plugin->mode].first;
432 while( current && !done ) {
433 if( current->x > current_x ) {
442 current = plugin->config.points[plugin->mode].last;
444 while( current && !done ) {
445 if( current->x <= current_x ) {
453 new_point->gradient = (y2 - y1) / (x2 - x1);
456 else if( dragID == 1 && get_buttonpress() == RIGHT_BUTTON ) {
457 if( gui->delete_current_point() ) {
458 plugin->send_configure_change();
463 plugin->dragging_point = dragID;
466 plugin->config.boundaries();
468 gui->update_canvas();
470 plugin->send_configure_change();
477 int HistogramCanvas::cursor_motion_event()
479 if( plugin->dragging_point ) {
480 HistogramPoints *mode_points = &plugin->config.points[plugin->mode];
481 HistogramPoint *current_point = mode_points->get_item_number(plugin->current_point);
484 (float)(get_cursor_x() - plugin->point_x_offset) * FLOAT_RANGE / get_w() + HIST_MIN_INPUT;
485 float current_y = 1.0 - (float)(get_cursor_y() - plugin->point_y_offset) / get_h();
487 switch( plugin->dragging_point ) {
488 case 1: /* Main point dragged */
489 current_point->x = current_x;
490 current_point->y = current_y;
492 case 2: /* Right control point dragged */
493 if( current_x - current_point->x > 0 ) {
494 current_point->xoffset_right = current_x - current_point->x;
495 current_point->gradient = (current_y - current_point->y) / (current_x - current_point->x);
498 case 3: /* Left control point dragged */
499 if( current_x - current_point->x < 0 ) {
500 current_point->xoffset_left = current_x - current_point->x;
501 current_point->gradient = (current_point->y - current_y) / (current_point->x - current_x);
506 plugin->config.boundaries();
508 gui->update_canvas();
509 plugin->send_configure_change();
515 int HistogramCanvas::button_release_event()
517 if(plugin->dragging_point)
519 // Test for out of order points to delete.
520 HistogramPoint *current =
521 plugin->config.points[plugin->mode].get_item_number(plugin->current_point);
522 HistogramPoint *prev = PREVIOUS;
523 HistogramPoint *next = NEXT;
525 if( (prev && prev->x >= current->x) ||
526 (next && next->x <= current->x) ) {
528 plugin->current_point = -1;
529 plugin->config.boundaries();
531 gui->update_canvas();
534 plugin->send_configure_change();
535 plugin->dragging_point = 0;
541 HistogramReset::HistogramReset(HistogramMain *plugin, int x, int y)
542 : BC_GenericButton(x, y, _("Reset"))
544 this->plugin = plugin;
546 int HistogramReset::handle_event()
548 plugin->config.reset(1);
549 HistogramWindow *window = (HistogramWindow *)plugin->thread->window;
551 window->update_canvas();
552 plugin->send_configure_change();
557 HistogramSlider::HistogramSlider(HistogramMain *plugin, HistogramWindow *gui,
558 int x, int y, int w, int h, int is_input)
559 : BC_SubWindow(x, y, w, h)
561 this->plugin = plugin;
563 this->is_input = is_input;
567 int HistogramSlider::input_to_pixel(float input)
569 return (int)((input - HIST_MIN_INPUT) / FLOAT_RANGE * get_w());
572 int HistogramSlider::button_press_event()
574 if( is_event_win() && cursor_inside() ) {
577 int half_h = get_h() / 2;
581 if( operation == NONE ) {
582 int x1 = input_to_pixel(plugin->config.output_min[plugin->mode]) -
583 gui->mid_picon->get_w() / 2;
584 int x2 = x1 + gui->mid_picon->get_w();
585 if( get_cursor_x() >= x1 && get_cursor_x() < x2 &&
586 get_cursor_y() >= half_h && get_cursor_y() < h ) {
587 operation = DRAG_MIN_OUTPUT;
591 if( operation == NONE ) {
592 int x1 = input_to_pixel(plugin->config.output_max[plugin->mode]) -
593 gui->mid_picon->get_w() / 2;
594 int x2 = x1 + gui->mid_picon->get_w();
595 if( get_cursor_x() >= x1 && get_cursor_x() < x2 &&
596 get_cursor_y() >= half_h && get_cursor_y() < h ) {
597 operation = DRAG_MAX_OUTPUT;
605 int HistogramSlider::button_release_event()
607 if( operation == NONE ) return 0;
612 int HistogramSlider::cursor_motion_event()
614 if( operation == NONE ) return 0;
616 float value = (float)get_cursor_x() / get_w() * FLOAT_RANGE + HIST_MIN_INPUT;
617 CLAMP(value, HIST_MIN_INPUT, HIST_MAX_INPUT);
619 switch( operation ) {
620 case DRAG_MIN_OUTPUT:
621 value = MIN(plugin->config.output_max[plugin->mode], value);
622 plugin->config.output_min[plugin->mode] = value;
624 case DRAG_MAX_OUTPUT:
625 value = MAX(plugin->config.output_min[plugin->mode], value);
626 plugin->config.output_max[plugin->mode] = value;
630 plugin->config.boundaries();
631 gui->update_output();
633 plugin->send_configure_change();
637 void HistogramSlider::update()
639 int w = get_w(), h = get_h();
640 int half_h = get_h() / 2;
641 // int quarter_h = get_h() / 4;
642 int mode = plugin->mode;
643 int r = 0, g = 0, b = 0;
645 clear_box(0, 0, w, h);
648 case HISTOGRAM_RED: r = 0xff; break;
649 case HISTOGRAM_GREEN: g = 0xff; break;
650 case HISTOGRAM_BLUE: b = 0xff; break;
651 case HISTOGRAM_VALUE: r = g = b = 0xff; break;
654 for( int i=0; i<w; ++i ) {
655 int color = (int)(i * 0xff / w);
656 set_color(((r * color / 0xff) << 16) |
657 ((g * color / 0xff) << 8) |
660 draw_line(i, 0, i, half_h);
663 float min = plugin->config.output_min[plugin->mode];
664 draw_pixmap(gui->min_picon,
665 input_to_pixel(min) - gui->min_picon->get_w() / 2,
667 float max = plugin->config.output_max[plugin->mode];
668 draw_pixmap(gui->max_picon,
669 input_to_pixel(max) - gui->max_picon->get_w() / 2,
677 HistogramAuto::HistogramAuto(HistogramMain *plugin, int x, int y)
678 : BC_CheckBox(x, y, plugin->config.automatic, _("Automatic"))
680 this->plugin = plugin;
683 int HistogramAuto::handle_event()
685 plugin->config.automatic = get_value();
686 plugin->send_configure_change();
691 HistogramSplit::HistogramSplit(HistogramMain *plugin, int x, int y)
692 : BC_CheckBox(x, y, plugin->config.split, _("Split picture"))
694 this->plugin = plugin;
697 int HistogramSplit::handle_event()
699 plugin->config.split = get_value();
700 plugin->send_configure_change();
705 HistogramMode::HistogramMode(HistogramMain *plugin, int x, int y,
706 int value, const char *text)
707 : BC_Radial(x, y, plugin->mode == value, text)
709 this->plugin = plugin;
712 int HistogramMode::handle_event()
714 plugin->mode = value;
715 plugin->current_point= -1;
716 HistogramWindow *window = (HistogramWindow *)plugin->thread->window;
717 window->update_mode();
718 window->update_canvas();
719 window->update_input();
720 window->update_output();
721 window->output->update();
722 // plugin->send_configure_change();
727 HistogramClear::HistogramClear(HistogramMain *plugin, int x, int y, const char *text)
728 : BC_GenericButton(x, y, text)
730 this->plugin = plugin;
733 int HistogramClear::handle_event()
735 HistogramPoints *mode_points = &plugin->config.points[plugin->mode];
736 mode_points->clear();
737 plugin->config.output_min[plugin->mode] = 0.0;
738 plugin->config.output_max[plugin->mode] = 1.0;
739 HistogramWindow *window = (HistogramWindow *)plugin->thread->window;
741 window->update_canvas();
742 plugin->send_configure_change();
747 HistogramOutputText::HistogramOutputText(HistogramMain *plugin,
748 HistogramWindow *gui, int x, int y, float *output)
749 : BC_TumbleTextBox(gui, output ? (float)*output : 0.0,
750 (float)HIST_MIN_INPUT, (float)HIST_MAX_INPUT,
753 this->plugin = plugin;
754 this->output = output;
755 set_precision(DIGITS);
756 set_increment(PRECISION);
759 int HistogramOutputText::handle_event()
762 *output = atof(get_text());
765 HistogramWindow *window = (HistogramWindow *)plugin->thread->window;
766 window->output->update();
767 plugin->send_configure_change();
772 HistogramInputText::HistogramInputText(HistogramMain *plugin,
773 HistogramWindow *gui, int x, int y, int do_x)
774 : BC_TumbleTextBox(gui, 0.0,
775 (float)HIST_MIN_INPUT, (float)HIST_MAX_INPUT,
779 this->plugin = plugin;
781 set_precision(DIGITS);
782 set_increment(PRECISION);
785 int HistogramInputText::handle_event()
787 if( plugin->current_point >= 0 &&
788 plugin->current_point < plugin->config.points[plugin->mode].total() ) {
789 HistogramPoints *mode_points = &plugin->config.points[plugin->mode];
790 HistogramPoint *point = mode_points->get_item_number(plugin->current_point);
794 point->x = atof(get_text());
796 point->y = atof(get_text());
798 plugin->config.boundaries();
799 gui->update_canvas();
801 HistogramWindow *window = (HistogramWindow *)plugin->thread->window;
802 window->output->update();
803 plugin->send_configure_change();
809 void HistogramInputText::update()
811 if( plugin->current_point >= 0 &&
812 plugin->current_point < plugin->config.points[plugin->mode].total() ) {
813 HistogramPoints *mode_points = &plugin->config.points[plugin->mode];
814 HistogramPoint *point = mode_points->get_item_number(plugin->current_point);
818 BC_TumbleTextBox::update(point->x);
820 BC_TumbleTextBox::update(point->y);
823 BC_TumbleTextBox::update((float)0.0);
827 BC_TumbleTextBox::update((float)0.0);
833 HistogramSmoothMode::HistogramSmoothMode(HistogramMain*plugin,
834 HistogramWindow *gui, int x, int y)
835 : BC_PopupMenu(x, y, xS(180), to_text(plugin->config.smoothMode), 1)
837 this->plugin = plugin;
840 void HistogramSmoothMode::create_objects()
842 add_item(new BC_MenuItem(to_text(HISTOGRAM_LINEAR)));
843 add_item(new BC_MenuItem(to_text(HISTOGRAM_POLYNOMINAL)));
844 add_item(new BC_MenuItem(to_text(HISTOGRAM_BEZIER)));
847 char* HistogramSmoothMode::to_text(int mode)
850 case HISTOGRAM_LINEAR: return _("Linear");
851 case HISTOGRAM_POLYNOMINAL: return _("Polynominal");
852 case HISTOGRAM_BEZIER: return _("Bezier");
856 int HistogramSmoothMode::set_mode(int mode)
858 const char *tp = to_text(mode);
859 if( strcmp(tp, get_text()) ) {
867 int HistogramSmoothMode::from_text(char *text)
869 if( !strcmp(text, to_text(HISTOGRAM_LINEAR)) ) return HISTOGRAM_LINEAR;
870 if( !strcmp(text, to_text(HISTOGRAM_POLYNOMINAL)) ) return HISTOGRAM_POLYNOMINAL;
871 if( !strcmp(text, to_text(HISTOGRAM_BEZIER)) ) return HISTOGRAM_BEZIER;
872 return HISTOGRAM_LINEAR;
874 int HistogramSmoothMode::get_mode()
876 return from_text(get_text());
879 int HistogramSmoothMode::handle_event()
881 plugin->config.smoothMode = get_mode();
882 gui->update_canvas();
883 plugin->send_configure_change();