initial commit
[goodguy/history.git] / cinelerra-5.0 / plugins / yuv / yuvwindow.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 "yuvwindow.h"
23
24 #include <libintl.h>
25 #define _(String) gettext(String)
26 #define gettext_noop(String) String
27 #define N_(String) gettext_noop (String)
28
29
30
31
32
33 YUVWindow::YUVWindow(YUVMain *client)
34  : BC_Window("", MEGREY, client->gui_string, 210, 170, 200, 170, 0, !client->show_initially)
35 { this->client = client; }
36
37 YUVWindow::~YUVWindow()
38 {
39         delete y_slider;
40         delete u_slider;
41         delete v_slider;
42         delete automation[0];
43         delete automation[1];
44         delete automation[2];
45 }
46
47 int YUVWindow::create_objects()
48 {
49         int x = 10, y = 10;
50         add_tool(new BC_Title(x, y, _("Y:")));
51         add_tool(automation[0] = new AutomatedFn(client, this, x + 80, y, 0));
52         y += 20;
53         add_tool(y_slider = new YSlider(client, x, y));
54         y += 35;
55         add_tool(new BC_Title(x, y, _("U:")));
56         add_tool(automation[1] = new AutomatedFn(client, this, x + 80, y, 1));
57         y += 20;
58         add_tool(u_slider = new USlider(client, x, y));
59         y += 35;
60         add_tool(new BC_Title(x, y, _("V:")));
61         add_tool(automation[2] = new AutomatedFn(client, this, x + 80, y, 2));
62         y += 20;
63         add_tool(v_slider = new VSlider(client, x, y));
64 }
65
66 int YUVWindow::close_event()
67 {
68         client->save_defaults();
69         hide_window();
70         client->send_hide_gui();
71 }
72
73 YSlider::YSlider(YUVMain *client, int x, int y)
74  : BC_ISlider(x, y, 190, 30, 200, client->y, -MAXVALUE, MAXVALUE, DKGREY, BLACK, 1)
75 {
76         this->client = client;
77 }
78 YSlider::~YSlider()
79 {
80 }
81 int YSlider::handle_event()
82 {
83         client->y = get_value();
84         client->send_configure_change();
85 }
86
87 USlider::USlider(YUVMain *client, int x, int y)
88  : BC_ISlider(x, y, 190, 30, 200, client->u, -MAXVALUE, MAXVALUE, DKGREY, BLACK, 1)
89 {
90         this->client = client;
91 }
92 USlider::~USlider()
93 {
94 }
95 int USlider::handle_event()
96 {
97         client->u = get_value();
98         client->send_configure_change();
99 }
100
101 VSlider::VSlider(YUVMain *client, int x, int y)
102  : BC_ISlider(x, y, 190, 30, 200, client->v, -MAXVALUE, MAXVALUE, DKGREY, BLACK, 1)
103 {
104         this->client = client;
105 }
106 VSlider::~VSlider()
107 {
108 }
109 int VSlider::handle_event()
110 {
111         client->v = get_value();
112         client->send_configure_change();
113 }
114
115 AutomatedFn::AutomatedFn(YUVMain *client, YUVWindow *window, int x, int y, int number)
116  : BC_CheckBox(x, y, 16, 16, client->automated_function == number, _("Automate"))
117 {
118         this->client = client;
119         this->window = window;
120         this->number = number;
121 }
122
123 AutomatedFn::~AutomatedFn()
124 {
125 }
126
127 int AutomatedFn::handle_event()
128 {
129         for(int i = 0; i < 3; i++)
130         {
131                 if(i != number) window->automation[i]->update(0);
132         }
133         update(1);
134         client->automated_function = number;
135         client->send_configure_change();
136 }
137