no longer need ffmpeg patch0 which was for Termux
[goodguy/cinelerra.git] / cinelerra-5.1 / plugins / colorspace / colorspacewindow.C
1
2 /*
3  * CINELERRA
4  * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
5  *
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.
10  *
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.
15  *
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
19  *
20  */
21
22 #include "bcdisplayinfo.h"
23 #include "language.h"
24 #include "colorspacewindow.h"
25
26
27 const char *ColorSpaceSpace::color_space[] = {
28         N_("BT601"), // COLOR_SPACE_BT601
29         N_("BT709"), // COLOR_SPACE_BT709
30         N_("BT2020"), // COLOR_SPACE_BT2020
31 };
32
33 ColorSpaceSpace::ColorSpaceSpace(ColorSpaceWindow *gui, int x, int y, int *value)
34  : BC_PopupMenu(x, y, xS(120), _(color_space[*value]), 1)
35 {
36         this->gui = gui;
37         this->value = value;
38 }
39 ColorSpaceSpace::~ColorSpaceSpace()
40 {
41 }
42
43 void ColorSpaceSpace::create_objects()
44 {
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));
47         update();
48 }
49
50 void ColorSpaceSpace::update()
51 {
52         set_text(_(color_space[*value]));
53 }
54
55 int ColorSpaceSpace::handle_event()
56 {
57         update();
58         gui->plugin->send_configure_change();
59         return 1;
60 }
61
62 ColorSpaceSpaceItem::ColorSpaceSpaceItem(ColorSpaceSpace *popup, const char *text, int id)
63  : BC_MenuItem(text)
64 {
65         this->popup = popup;
66         this->id = id;
67 }
68
69 int ColorSpaceSpaceItem::handle_event()
70 {
71         *popup->value = id;
72         return popup->handle_event();
73 }
74
75
76 const char *ColorSpaceRange::color_range[] = {
77         N_("JPEG"), // COLOR_RANGE_JPEG
78         N_("MPEG"), // COLOR_RANGE_MPEG
79 };
80
81 ColorSpaceRange::ColorSpaceRange(ColorSpaceWindow *gui, int x, int y, int *value)
82  : BC_PopupMenu(x, y, xS(100), _(color_range[*value]), 1)
83 {
84         this->gui = gui;
85         this->value = value;
86 }
87 ColorSpaceRange::~ColorSpaceRange()
88 {
89 }
90
91 void ColorSpaceRange::create_objects()
92 {
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));
95         update();
96 }
97
98 void ColorSpaceRange::update()
99 {
100         set_text(color_range[*value]);
101 }
102
103 int ColorSpaceRange::handle_event()
104 {
105         update();
106         gui->plugin->send_configure_change();
107         return 1;
108 }
109
110 ColorSpaceRangeItem::ColorSpaceRangeItem(ColorSpaceRange *popup, const char *text, int id)
111  : BC_MenuItem(text)
112 {
113         this->popup = popup;
114         this->id = id;
115 }
116
117 int ColorSpaceRangeItem::handle_event()
118 {
119         *popup->value = id;
120         return popup->handle_event();
121 }
122
123 ColorSpaceInverse::ColorSpaceInverse(ColorSpaceWindow *gui, int x, int y, int *value)
124  : BC_CheckBox(x, y, value, _("Inverse"))
125 {
126         this->gui = gui;
127 }
128
129 ColorSpaceInverse::~ColorSpaceInverse()
130 {
131 }
132
133 void ColorSpaceInverse::update()
134 {
135         set_value(*value, 1);
136 }
137
138 int ColorSpaceInverse::handle_event()
139 {
140         *value = get_value();
141         gui->plugin->send_configure_change();
142         return 1;
143 }
144
145
146 ColorSpaceWindow::ColorSpaceWindow(ColorSpaceMain *plugin)
147  : PluginClientWindow(plugin, xS(360), yS(130), xS(360), yS(130), 0)
148 {
149         this->plugin = plugin;
150 }
151
152 ColorSpaceWindow::~ColorSpaceWindow()
153 {
154 }
155
156 void ColorSpaceWindow::create_objects()
157 {
158         int ys10 = yS(10);
159         int x = xS(10), y = ys10;
160         int x1 = x + xS(80), x2 = x1 + xS(150);
161         BC_Title *title;
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();
180
181         show_window();
182         flush();
183 }
184
185 void ColorSpaceWindow::update()
186 {
187         inverse->update();
188         inp_space->update();
189         inp_range->update();
190         out_space->update();
191         out_range->update();
192 }
193