4 * Copyright (C) 1997-2011 Adam Williams <broadcast at earthling dot net>
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.
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.
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
22 #include "bcdisplayinfo.h"
23 #include "bcsignals.h"
27 #include "timeblurwindow.h"
29 #include "localsession.h"
31 #include "pluginserver.h"
37 TimeBlurWindow::TimeBlurWindow(TimeBlurMain *plugin)
38 : PluginClientWindow(plugin, xS(250), yS(50), xS(250), yS(50), 0)
40 this->plugin = plugin;
43 TimeBlurWindow::~TimeBlurWindow()
47 void TimeBlurWindow::create_objects()
49 int margin = plugin->get_theme()->widget_border;
50 int x = margin, y = margin;
52 add_subwindow(select = new TimeBlurSelect(plugin, this, x1, y));
53 x1 += select->get_w() + margin;
54 frames = new TimeBlurFrames(plugin, this, x1, y);
55 frames->create_objects();
56 x1 += frames->get_w() + 3*margin;
57 add_subwindow(clear_frames = new TimeBlurClearFrames(plugin, this, x1, y));
62 TimeBlurSelect::TimeBlurSelect(TimeBlurMain *plugin, TimeBlurWindow *gui,
64 : BC_GenericButton(x, y, xS(100), _("Frames"))
66 this->plugin = plugin;
68 set_tooltip(_("Set frames to selection duration"));
70 int TimeBlurSelect::handle_event()
72 MWindow *mwindow = plugin->server->mwindow;
74 EDL *edl = mwindow->edl;
75 double start = edl->local_session->get_selectionstart();
76 int64_t start_pos = edl->get_frame_rate() * start;
77 double end = edl->local_session->get_selectionend();
78 int64_t end_pos = edl->get_frame_rate() * end;
79 int64_t frames = end_pos - start_pos;
80 gui->frames->update(frames);
81 plugin->config.frames = frames;
82 plugin->send_configure_change();
87 TimeBlurClearFrames::TimeBlurClearFrames(TimeBlurMain *plugin, TimeBlurWindow *gui,
89 : BC_Button(x, y, plugin->get_theme()->get_image_set("reset_button"))
91 this->plugin = plugin;
93 set_tooltip(_("Clear frames"));
96 int TimeBlurClearFrames::handle_event()
98 plugin->config.frames = 0;
99 gui->frames->update(0);
100 plugin->send_configure_change();
104 TimeBlurFrames::TimeBlurFrames(TimeBlurMain *plugin, TimeBlurWindow *gui,
106 : BC_TumbleTextBox(gui, 0, 0, 65535, x, y, xS(80))
108 this->plugin = plugin;
112 int TimeBlurFrames::handle_event()
114 plugin->config.frames = atoi(get_text());
115 plugin->send_configure_change();
119 void TimeBlurFrames::update(int frames)
121 BC_TumbleTextBox::update((int64_t)frames);