fix delete clip deadlock
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / labelpopup.C
1 /*
2  * CINELERRA
3  * Copyright (C) 2006 Pierre Dumuid
4  * Copyright (C) 1997-2012 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 "awindow.h"
23 #include "awindowgui.h"
24 #include "bcdialog.h"
25 #include "labeledit.h"
26 #include "labelpopup.h"
27 #include "edl.h"
28 #include "fonts.h"
29 #include "language.h"
30 #include "localsession.h"
31 #include "mainsession.h"
32 #include "mbuttons.h"
33 #include "mwindow.h"
34 #include "mwindowgui.h"
35 #include "vwindow.h"
36 #include "vwindowgui.h"
37
38
39 LabelPopup::LabelPopup(MWindow *mwindow, AWindowGUI *gui)
40  : BC_PopupMenu(0, 0, 0, "", 0)
41 {
42         this->mwindow = mwindow;
43         this->gui = gui;
44 }
45
46 LabelPopup::~LabelPopup()
47 {
48 }
49
50 void LabelPopup::create_objects()
51 {
52         add_item(editlabel = new LabelPopupEdit(mwindow, gui));
53         add_item(new LabelPopupDelete(mwindow, gui));
54         add_item(new LabelPopupGoTo(mwindow, gui));
55 }
56
57 int LabelPopup::update()
58 {
59         gui->collect_assets();
60         return 0;
61 }
62
63
64 LabelPopupEdit::LabelPopupEdit(MWindow *mwindow, AWindowGUI *gui)
65  : BC_MenuItem(_("Edit..."))
66 {
67         this->mwindow = mwindow;
68         this->gui = gui;
69 }
70
71 LabelPopupEdit::~LabelPopupEdit()
72 {
73 }
74
75 int LabelPopupEdit::handle_event()
76 {
77         AssetPicon *result = (AssetPicon*)gui->asset_list->get_selection(0,0);
78         if( result && result->label ) {
79                 int cur_x, cur_y;
80                 gui->get_abs_cursor(cur_x, cur_y, 0);
81                 gui->awindow->label_edit->start(result->label, cur_x, cur_y);
82         }
83         return 1;
84 }
85
86 LabelPopupDelete::LabelPopupDelete(MWindow *mwindow, AWindowGUI *gui)
87  : BC_MenuItem(_("Delete"))
88 {
89         this->mwindow = mwindow;
90         this->gui = gui;
91 }
92 LabelPopupDelete::~LabelPopupDelete()
93 {
94 }
95
96 int LabelPopupDelete::handle_event()
97 {
98         AssetPicon *result = (AssetPicon*)gui->asset_list->get_selection(0,0);
99         if( result && result->label ) {
100                 delete result->label;
101                 mwindow->gui->lock_window("LabelPopupDelete::handle_event");
102                 mwindow->gui->update_timebar(0);
103                 mwindow->gui->unlock_window();
104                 gui->async_update_assets();
105         }
106         return 1;
107 }
108
109
110 LabelPopupGoTo::LabelPopupGoTo(MWindow *mwindow, AWindowGUI *gui)
111  : BC_MenuItem(_("Go to"))
112 {
113         this->mwindow = mwindow;
114         this->gui = gui;
115 }
116 LabelPopupGoTo::~LabelPopupGoTo()
117 {
118 }
119
120 int LabelPopupGoTo::handle_event()
121 {
122         AssetPicon *result = (AssetPicon*)gui->asset_list->get_selection(0,0);
123         if( result && result->label ) {
124                 double position = result->label->position;
125                 gui->unlock_window();
126                 int locked = mwindow->gui->get_window_lock();
127                 if( locked ) mwindow->gui->unlock_window();
128                 PlayTransport *transport = mwindow->gui->mbuttons->transport;
129                 transport->change_position(position);
130                 if( locked ) mwindow->gui->lock_window("LabelPopupGoTo::handle_event");
131                 gui->lock_window("LabelPopupGoTo::handle_event 1");
132         }
133         return 1;
134 }
135
136
137 LabelListMenu::LabelListMenu(MWindow *mwindow, AWindowGUI *gui)
138  : BC_PopupMenu(0, 0, 0, "", 0)
139 {
140         this->mwindow = mwindow;
141         this->gui = gui;
142 }
143
144 LabelListMenu:: ~LabelListMenu()
145 {
146 }
147
148 void LabelListMenu::create_objects()
149 {
150         add_item(format = new AWindowListFormat(mwindow, gui));
151         add_item(new AWindowListSort(mwindow, gui));
152 }
153
154 void LabelListMenu::update()
155 {
156         format->update();
157 }
158