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"
24 #include "colorspacewindow.h"
27 const char *ColorSpaceSpace::color_space[] = {
28 N_("BT601"), // COLOR_SPACE_BT601
29 N_("BT709"), // COLOR_SPACE_BT709
30 N_("BT2020"), // COLOR_SPACE_BT2020
33 ColorSpaceSpace::ColorSpaceSpace(ColorSpaceWindow *gui, int x, int y, int *value)
34 : BC_PopupMenu(x, y, xS(120), _(color_space[*value]), 1)
39 ColorSpaceSpace::~ColorSpaceSpace()
43 void ColorSpaceSpace::create_objects()
45 for( int id=0,nid=sizeof(color_space)/sizeof(color_space[0]); id<nid; ++id )
46 add_item(new ColorSpaceSpaceItem(this, _(color_space[id]), id));
50 void ColorSpaceSpace::update()
52 set_text(_(color_space[*value]));
55 int ColorSpaceSpace::handle_event()
58 gui->plugin->send_configure_change();
62 ColorSpaceSpaceItem::ColorSpaceSpaceItem(ColorSpaceSpace *popup, const char *text, int id)
69 int ColorSpaceSpaceItem::handle_event()
72 return popup->handle_event();
76 const char *ColorSpaceRange::color_range[] = {
77 N_("JPEG"), // COLOR_RANGE_JPEG
78 N_("MPEG"), // COLOR_RANGE_MPEG
81 ColorSpaceRange::ColorSpaceRange(ColorSpaceWindow *gui, int x, int y, int *value)
82 : BC_PopupMenu(x, y, xS(100), _(color_range[*value]), 1)
87 ColorSpaceRange::~ColorSpaceRange()
91 void ColorSpaceRange::create_objects()
93 for( int id=0,nid=sizeof(color_range)/sizeof(color_range[0]); id<nid; ++id )
94 add_item(new ColorSpaceRangeItem(this, _(color_range[id]), id));
98 void ColorSpaceRange::update()
100 set_text(color_range[*value]);
103 int ColorSpaceRange::handle_event()
106 gui->plugin->send_configure_change();
110 ColorSpaceRangeItem::ColorSpaceRangeItem(ColorSpaceRange *popup, const char *text, int id)
117 int ColorSpaceRangeItem::handle_event()
120 return popup->handle_event();
123 ColorSpaceInverse::ColorSpaceInverse(ColorSpaceWindow *gui, int x, int y, int *value)
124 : BC_CheckBox(x, y, value, _("Inverse"))
129 ColorSpaceInverse::~ColorSpaceInverse()
133 void ColorSpaceInverse::update()
135 set_value(*value, 1);
138 int ColorSpaceInverse::handle_event()
140 *value = get_value();
141 gui->plugin->send_configure_change();
146 ColorSpaceWindow::ColorSpaceWindow(ColorSpaceMain *plugin)
147 : PluginClientWindow(plugin, xS(360), yS(130), xS(360), yS(130), 0)
149 this->plugin = plugin;
152 ColorSpaceWindow::~ColorSpaceWindow()
156 void ColorSpaceWindow::create_objects()
159 int x = xS(10), y = ys10;
160 int x1 = x + xS(80), x2 = x1 + xS(150);
162 add_subwindow(title = new BC_Title(x, y, _("Color Space/Range conversion")));
163 ColorSpaceConfig &config = plugin->config;
164 add_subwindow(inverse = new ColorSpaceInverse(this, x2, y, &config.inverse));
165 y += title->get_h() + yS(15);
166 add_subwindow(title = new BC_Title(x1, y, _("Space")));
167 add_subwindow(title = new BC_Title(x2, y, _("Range")));
168 y += title->get_h() + ys10;
169 add_subwindow(title = new BC_Title(x, y, _("Input:")));
170 add_subwindow(inp_space = new ColorSpaceSpace(this, x1, y, &config.inp_colorspace));
171 inp_space->create_objects();
172 add_subwindow(inp_range = new ColorSpaceRange(this, x2, y, &config.inp_colorrange));
173 inp_range->create_objects();
174 y += title->get_h() + ys10;
175 add_subwindow(title = new BC_Title(x, y, _("Output:")));
176 add_subwindow(out_space = new ColorSpaceSpace(this, x1, y, &config.out_colorspace));
177 out_space->create_objects();
178 add_subwindow(out_range = new ColorSpaceRange(this, x2, y, &config.out_colorrange));
179 out_range->create_objects();
185 void ColorSpaceWindow::update()