initial commit
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / plugintoggles.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 "language.h"
23 #include "mwindow.h"
24 #include "plugin.h"
25 #include "plugintoggles.h"
26 #include "theme.h"
27
28
29
30 PluginOn::PluginOn(MWindow *mwindow, int x, int y, Plugin *plugin)
31  : BC_Toggle(x, y, mwindow->theme->get_image_set("plugin_on"), plugin->on)
32 {
33         this->mwindow = mwindow;
34         this->plugin = plugin;
35         in_use = 1;
36         set_tooltip(plugin->on ? _("Turn Off") : _("Turn On"));
37 }
38
39 int PluginOn::calculate_w(MWindow *mwindow)
40 {
41         return mwindow->theme->get_image_set("plugin_on")[0]->get_w();
42 }
43
44 void PluginOn::update(int x, int y, Plugin *plugin)
45 {
46         BC_Toggle::set_value(plugin->on, 0);
47         set_tooltip(plugin->on ? _("Turn Off") : _("Turn On"));
48         reposition_window(x, y);
49         this->plugin = plugin;
50         in_use = 1;
51 }
52
53 int PluginOn::handle_event()
54 {
55         plugin->on = get_value();
56         set_tooltip(plugin->on ? _("Turn Off") : _("Turn On"));
57         unlock_window();
58         mwindow->restart_brender();
59         mwindow->sync_parameters(CHANGE_EDL);
60         lock_window("PluginOn::handle_event");
61         return 1;
62 }
63
64
65
66
67 PluginShow::PluginShow(MWindow *mwindow, int x, int y, Plugin *plugin)
68  : BC_Toggle(x,
69                 y,
70                 mwindow->theme->get_image_set("plugin_show"),
71                 plugin->show)
72 {
73         this->mwindow = mwindow;
74         this->plugin = plugin;
75         in_use = 1;
76         set_tooltip(_("Show controls"));
77 }
78
79 int PluginShow::calculate_w(MWindow *mwindow)
80 {
81         return mwindow->theme->get_image_set("plugin_show")[0]->get_w();
82 }
83
84 void PluginShow::update(int x, int y, Plugin *plugin)
85 {
86         BC_Toggle::set_value(plugin->show, 0);
87         reposition_window(x, y);
88         this->plugin = plugin;
89         in_use = 1;
90 }
91
92 int PluginShow::handle_event()
93 {
94         unlock_window();
95         if(get_value())
96                 mwindow->show_plugin(plugin);
97         else
98                 mwindow->hide_plugin(plugin, 1);
99         lock_window("PluginShow::handle_event");
100         return 1;
101 }
102
103 PluginPresetEdit::PluginPresetEdit(MWindow *mwindow, int x, int y, Plugin *plugin)
104  : BC_Button(x, y, mwindow->theme->get_image_set("preset_edit"))
105 {
106         this->mwindow = mwindow;
107         this->plugin = plugin;
108         in_use = 1;
109         set_tooltip(_("Preset Edit"));
110 }
111
112 int PluginPresetEdit::handle_event()
113 {
114         mwindow->show_keyframe_gui(plugin);
115         return 1;
116 }
117
118 int PluginPresetEdit::calculate_w(MWindow *mwindow)
119 {
120         VFrame **images = mwindow->theme->get_image_set("preset_edit");
121         return images[0]->get_w();
122 }
123
124 void PluginPresetEdit::update(int x, int y, Plugin *plugin)
125 {
126         reposition_window(x, y);
127         this->plugin = plugin;
128         in_use = 1;
129 }
130