initial commit
[goodguy/history.git] / cinelerra-5.0 / plugins / polar / polarwindow.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 "polarwindow.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 PLUGIN_THREAD_OBJECT(PolarMain, PolarThread, PolarWindow)
31
32
33
34
35
36
37
38 PolarWindow::PolarWindow(PolarMain *client)
39  : BC_Window("", 
40         MEGREY, 
41         client->gui_string, 
42         210, 
43         120, 
44         200, 
45         120, 
46         0, 
47         !client->show_initially)
48 {
49         this->client = client; 
50 }
51
52 PolarWindow::~PolarWindow()
53 {
54         delete depth_slider;
55         delete angle_slider;
56         delete automation[0];
57         delete automation[1];
58 }
59
60 int PolarWindow::create_objects()
61 {
62         int x = 10, y = 10;
63         add_tool(new BC_Title(x, y, _("Depth")));
64         add_tool(automation[0] = new AutomatedFn(client, this, x + 80, y, 0));
65         y += 20;
66         add_tool(depth_slider = new DepthSlider(client, x, y));
67         y += 35;
68         add_tool(new BC_Title(x, y, _("Angle")));
69         add_tool(automation[1] = new AutomatedFn(client, this, x + 80, y, 1));
70         y += 20;
71         add_tool(angle_slider = new AngleSlider(client, x, y));
72 }
73
74 int PolarWindow::close_event()
75 {
76         client->save_defaults();
77         hide_window();
78         client->send_hide_gui();
79 }
80
81 DepthSlider::DepthSlider(PolarMain *client, int x, int y)
82  : BC_ISlider(x, y, 190, 30, 200, client->depth, 0, MAXDEPTH, DKGREY, BLACK, 1)
83 {
84         this->client = client;
85 }
86 DepthSlider::~DepthSlider()
87 {
88 }
89 int DepthSlider::handle_event()
90 {
91         client->depth = get_value();
92         client->send_configure_change();
93 }
94
95 AngleSlider::AngleSlider(PolarMain *client, int x, int y)
96  : BC_ISlider(x, y, 190, 30, 200, client->angle, 0, MAXANGLE, DKGREY, BLACK, 1)
97 {
98         this->client = client;
99 }
100 AngleSlider::~AngleSlider()
101 {
102 }
103 int AngleSlider::handle_event()
104 {
105         client->angle = get_value();
106         client->send_configure_change();
107 }
108
109 AutomatedFn::AutomatedFn(PolarMain *client, PolarWindow *window, int x, int y, int number)
110  : BC_CheckBox(x, y, 16, 16, client->automated_function == number, _("Automate"))
111 {
112         this->client = client;
113         this->window = window;
114         this->number = number;
115 }
116
117 AutomatedFn::~AutomatedFn()
118 {
119 }
120
121 int AutomatedFn::handle_event()
122 {
123         for(int i = 0; i < 2; i++)
124         {
125                 if(i != number) window->automation[i]->update(0);
126         }
127         update(1);
128         client->automated_function = number;
129         client->send_configure_change();
130 }
131