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