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