label edit deadlock, build openexr cfg option, code cleanup
[goodguy/history.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         int cur_x, cur_y;
79         gui->get_abs_cursor_xy(cur_x, cur_y, 0);
80         if( result && result->label )
81                 gui->awindow->label_edit->start(result->label, cur_x, cur_y);
82         return 1;
83 }
84
85 LabelPopupDelete::LabelPopupDelete(MWindow *mwindow, AWindowGUI *gui)
86  : BC_MenuItem(_("Delete"))
87 {
88         this->mwindow = mwindow;
89         this->gui = gui;
90 }
91 LabelPopupDelete::~LabelPopupDelete()
92 {
93 }
94
95 int LabelPopupDelete::handle_event()
96 {
97         AssetPicon *result = (AssetPicon*)gui->asset_list->get_selection(0,0);
98         if( result && result->label ) {
99                 delete result->label;
100                 mwindow->gui->lock_window("LabelPopupDelete::handle_event");
101                 mwindow->gui->update_timebar(0);
102                 mwindow->gui->unlock_window();
103                 gui->async_update_assets();
104         }
105         return 1;
106 }
107
108
109 LabelPopupGoTo::LabelPopupGoTo(MWindow *mwindow, AWindowGUI *gui)
110  : BC_MenuItem(_("Go to"))
111 {
112         this->mwindow = mwindow;
113         this->gui = gui;
114 }
115 LabelPopupGoTo::~LabelPopupGoTo()
116 {
117 }
118
119 int LabelPopupGoTo::handle_event()
120 {
121         AssetPicon *result = (AssetPicon*)gui->asset_list->get_selection(0,0);
122         if( result && result->label ) {
123                 double position = result->label->position;
124                 gui->unlock_window();
125                 int locked = mwindow->gui->get_window_lock();
126                 if( locked ) mwindow->gui->unlock_window();
127                 PlayTransport *transport = mwindow->gui->mbuttons->transport;
128                 transport->change_position(position);
129                 if( locked ) mwindow->gui->lock_window("LabelPopupGoTo::handle_event");
130                 gui->lock_window("LabelPopupGoTo::handle_event 1");
131         }
132         return 1;
133 }
134
135
136 LabelListMenu::LabelListMenu(MWindow *mwindow, AWindowGUI *gui)
137  : BC_PopupMenu(0, 0, 0, "", 0)
138 {
139         this->mwindow = mwindow;
140         this->gui = gui;
141 }
142
143 LabelListMenu:: ~LabelListMenu()
144 {
145 }
146
147 void LabelListMenu::create_objects()
148 {
149         add_item(format = new AWindowListFormat(mwindow, gui));
150         add_item(new AWindowListSort(mwindow, gui));
151 }
152
153 void LabelListMenu::update()
154 {
155         format->update();
156 }
157