add BC_SCALE env var for hi def monitors, cleanup theme data
[goodguy/cinelerra.git] / cinelerra-5.1 / plugins / yuv411 / yuv411win.C
1 #include "bcdisplayinfo.h"
2 #include "yuv411win.h"
3 #include "language.h"
4
5 yuv411Window::yuv411Window(yuv411Main *client)
6  : PluginClientWindow(client, xS(250), yS(255), xS(250), yS(255), 0)
7 {
8         this->client = client;
9 }
10
11 yuv411Window::~yuv411Window()
12 {
13 }
14
15 void yuv411Window::create_objects()
16 {
17         int xs10 = xS(10), xs90 = xS(90);
18         int ys10 = yS(10), ys30 = yS(30), ys35 = yS(35);
19         int x = xs10, y = ys10, x1=xs90;
20         add_tool(avg_vertical = new yuv411Toggle(client,
21                 &(client->config.avg_vertical),
22                 _("Vertical average"),
23                 x,
24                 y));
25         y += ys30;
26         add_tool(int_horizontal = new yuv411Toggle(client,
27                 &(client->config.int_horizontal),
28                 _("Horizontal interpolate"),
29                 x,
30                 y));
31         y += ys30;
32         add_tool(inpainting = new yuv411Toggle(client,
33                 &(client->config.inpainting),
34                 _("Inpainting method"),
35                 x,
36                 y));
37         y += ys30;
38         add_subwindow(new BC_Title(x, y, _("Offset:")));
39         add_subwindow(offset=new yuv411Offset(client,x1,y));
40         y += ys30;
41         add_subwindow(new BC_Title(x, y, _("Threshold:")));
42         add_subwindow(thresh=new yuv411Thresh(client,x1,y));
43         y += ys30;
44         add_subwindow(new BC_Title(x, y, _("Bias:")));
45         add_subwindow(bias=new yuv411Bias(client,x1,y));
46         y += ys30;
47         add_subwindow(reset = new yuv411Reset(client, this, x, y+ys35));
48         show_window();
49         flush();
50
51         yuv_warning = new BC_Title(x, y, _("Warning: colormodel not YUV"),MEDIUMFONT,RED);
52         add_subwindow(yuv_warning);
53         yuv_warning->hide_window();
54 }
55
56 void yuv411Window::update()
57 {
58         avg_vertical->update(client->config.avg_vertical);
59         int_horizontal->update(client->config.int_horizontal);
60         inpainting->update(client->config.inpainting);
61         offset->update(client->config.offset);
62         thresh->update(client->config.thresh);
63         bias->update(client->config.bias);
64 }
65
66 int yuv411Window::close_event()
67 {
68         set_done(1);
69         return 1;
70 }
71
72 yuv411Toggle::yuv411Toggle(yuv411Main *client, int *output, char *string, int x, int y)
73  : BC_CheckBox(x, y, *output, string)
74 {
75         this->client = client;
76         this->output = output;
77 }
78 yuv411Toggle::~yuv411Toggle()
79 {
80 }
81 int yuv411Toggle::handle_event()
82 {
83         *output = get_value();
84         ((yuv411Window*)client->thread->window)->update_enables();
85         client->send_configure_change();
86         return 1;
87 }
88
89 yuv411Offset::yuv411Offset(yuv411Main *client, int x, int y)
90  :  BC_FSlider(x, y, 0, xS(100), yS(100), (float)0, (float)2,
91             (float)client->config.offset)
92 {
93         this->client = client;
94         set_precision(1.0);
95 }
96 int yuv411Offset::handle_event()
97 {
98         client->config.offset = get_value();
99         client->send_configure_change();
100         return 1;
101 }
102
103 yuv411Thresh::yuv411Thresh(yuv411Main *client, int x, int y)
104  :  BC_FSlider(x, y, 0, xS(100), yS(100), (float)1, (float)100,
105             (float)client->config.thresh)
106 {
107         this->client = client;
108         set_precision(1.0);
109 }
110 int yuv411Thresh::handle_event()
111 {
112         client->config.thresh = get_value();
113         client->send_configure_change();
114         return 1;
115 }
116
117 yuv411Bias::yuv411Bias(yuv411Main *client, int x, int y)
118  :  BC_FSlider(x, y, 0, xS(100), yS(100), (float)0, (float)25,
119             (float)client->config.bias)
120 {
121         this->client = client;
122         set_precision(1.0);
123 }
124
125 int yuv411Bias::handle_event()
126 {
127         client->config.bias = get_value();
128         client->send_configure_change();
129         return 1;
130 }
131
132 yuv411Reset::yuv411Reset(yuv411Main *client, yuv411Window *window, int x, int y)
133  : BC_GenericButton(x, y, _("Reset"))
134 {
135         this->client = client;
136         this->window = window;
137 }
138 yuv411Reset::~yuv411Reset()
139 {
140 }
141 int yuv411Reset::handle_event()
142 {
143         client->config.reset();
144         window->update();
145         window->update_enables();
146         client->send_configure_change();
147         return 1;
148 }
149
150
151 void yuv411Window::update_enables()
152 {
153         yuv411Config &config = client->config;
154         if( !config.int_horizontal && config.inpainting ) {
155                 config.inpainting = 0;
156                 inpainting->set_value(0);
157         }
158         if( config.int_horizontal ) {
159                 inpainting->enable();
160                 offset->show_window();
161         }
162         else {
163                 inpainting->disable();
164                 offset->hide_window();
165         }
166         if( config.int_horizontal && config.inpainting ) {
167                 thresh->show_window();
168                 bias->show_window();
169         }
170         else {
171                 thresh->hide_window();
172                 bias->hide_window();
173         }
174 }
175
176 void yuv411Window::show_warning(int warn)
177 {
178         if( warn )
179                 yuv_warning->show_window();
180         else
181                 yuv_warning->hide_window();
182 }
183
184