r136: This commit was manufactured by cvs2svn to create tag 'hv_1_1_8'.
[cinelerra_cv/mob.git] / hvirtual / cinelerra / transitionpopup.C
blob7c4fad5a4b41cbe697b31f6e6bc7ec9f9fb16979
1 #include "clip.h"
2 #include "edit.h"
3 #include "edl.h"
4 #include "edlsession.h"
5 #include "language.h"
6 #include "mwindow.h"
7 #include "mwindowgui.h"
8 #include "plugin.h"
9 #include "transition.h"
10 #include "track.h"
11 #include "tracks.h"
12 #include "transitionpopup.h"
15 TransitionLengthThread::TransitionLengthThread(MWindow *mwindow, TransitionPopup *popup)
16  : Thread()
18         this->mwindow = mwindow;
19         this->popup = popup;
22 TransitionLengthThread::~TransitionLengthThread()
26 void TransitionLengthThread::run()
28         TransitionLengthDialog window(mwindow, popup->transition);
29         window.create_objects();
30         int result = window.run_window();
38 TransitionLengthDialog::TransitionLengthDialog(MWindow *mwindow, Transition *transition)
39  : BC_Window(PROGRAM_NAME ": Transition length", 
40                                 mwindow->gui->get_abs_cursor_x() - 150,
41                                 mwindow->gui->get_abs_cursor_y() - 50,
42                                 300, 
43                                 100, 
44                                 -1, 
45                                 -1, 
46                                 0,
47                                 0, 
48                                 1)
50         this->mwindow = mwindow;
51         this->transition = transition;
54 TransitionLengthDialog::~TransitionLengthDialog()
58         
59 void TransitionLengthDialog::create_objects()
61         add_subwindow(new BC_Title(10, 10, _("Seconds:")));
62         text = new TransitionLengthText(mwindow, this, 100, 10);
63         text->create_objects();
64         add_subwindow(new BC_OKButton(this));
65         show_window();
68 int TransitionLengthDialog::close_event()
70         set_done(0);
71         return 1;
79 TransitionLengthText::TransitionLengthText(MWindow *mwindow, 
80         TransitionLengthDialog *gui,
81         int x, 
82         int y)
83  : BC_TumbleTextBox(gui, 
84         (float)gui->transition->edit->track->from_units(gui->transition->length),
85         (float)0, 
86         (float)100, 
87         x,
88         y,
89         100)
91         this->mwindow = mwindow;
92         this->gui = gui;
95 int TransitionLengthText::handle_event()
97         double result = atof(get_text());
98         if(!EQUIV(result, gui->transition->length))
99         {
100                 gui->transition->length = gui->transition->track->to_units(result, 1);
101                 if(gui->transition->edit->track->data_type == TRACK_VIDEO) mwindow->restart_brender();
102                 mwindow->sync_parameters(CHANGE_PARAMS);
103                 mwindow->edl->session->default_transition_length = result;
104         }
105         
106         return 1;
119 TransitionPopup::TransitionPopup(MWindow *mwindow, MWindowGUI *gui)
120  : BC_PopupMenu(0, 
121                 0, 
122                 0, 
123                 "", 
124                 0)
126         this->mwindow = mwindow;
127         this->gui = gui;
130 TransitionPopup::~TransitionPopup()
132 //      delete dialog_thread;
136 void TransitionPopup::create_objects()
138         length_thread = new TransitionLengthThread(mwindow, this);
139 //      add_item(attach = new TransitionPopupAttach(mwindow, this));
140         add_item(show = new TransitionPopupShow(mwindow, this));
141         add_item(on = new TransitionPopupOn(mwindow, this));
142         add_item(length = new TransitionPopupLength(mwindow, this));
143         add_item(detach = new TransitionPopupDetach(mwindow, this));
146 int TransitionPopup::update(Transition *transition)
148         this->transition = transition;
149         show->set_checked(transition->show);
150         on->set_checked(transition->on);
151         return 0;
158 TransitionPopupAttach::TransitionPopupAttach(MWindow *mwindow, TransitionPopup *popup)
159  : BC_MenuItem(_("Attach..."))
161         this->mwindow = mwindow;
162         this->popup = popup;
165 TransitionPopupAttach::~TransitionPopupAttach()
169 int TransitionPopupAttach::handle_event()
171 //      popup->dialog_thread->start();
180 TransitionPopupDetach::TransitionPopupDetach(MWindow *mwindow, TransitionPopup *popup)
181  : BC_MenuItem(_("Detach"))
183         this->mwindow = mwindow;
184         this->popup = popup;
187 TransitionPopupDetach::~TransitionPopupDetach()
191 int TransitionPopupDetach::handle_event()
193         mwindow->detach_transition(popup->transition);
194         return 1;
198 TransitionPopupOn::TransitionPopupOn(MWindow *mwindow, TransitionPopup *popup)
199  : BC_MenuItem(_("On"))
201         this->mwindow = mwindow;
202         this->popup = popup;
205 TransitionPopupOn::~TransitionPopupOn()
209 int TransitionPopupOn::handle_event()
211         popup->transition->on = !get_checked();
212         mwindow->sync_parameters(CHANGE_EDL);
213         return 1;
221 TransitionPopupShow::TransitionPopupShow(MWindow *mwindow, TransitionPopup *popup)
222  : BC_MenuItem(_("Show"))
224         this->mwindow = mwindow;
225         this->popup = popup;
228 TransitionPopupShow::~TransitionPopupShow()
232 int TransitionPopupShow::handle_event()
234         mwindow->show_plugin(popup->transition);
235         return 1;
245 TransitionPopupLength::TransitionPopupLength(MWindow *mwindow, TransitionPopup *popup)
246  : BC_MenuItem(_("Length"))
248         this->mwindow = mwindow;
249         this->popup = popup;
252 TransitionPopupLength::~TransitionPopupLength()
256 int TransitionPopupLength::handle_event()
258         popup->length_thread->start();
259         return 1;