3 * Copyright (C) 2006 Pierre Dumuid
4 * Copyright (C) 1997-2012 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
23 #include "awindowgui.h"
25 #include "labeledit.h"
26 #include "labelpopup.h"
30 #include "localsession.h"
31 #include "mainsession.h"
34 #include "mwindowgui.h"
36 #include "vwindowgui.h"
39 LabelPopup::LabelPopup(MWindow *mwindow, AWindowGUI *gui)
40 : BC_PopupMenu(0, 0, 0, "", 0)
42 this->mwindow = mwindow;
46 LabelPopup::~LabelPopup()
50 void LabelPopup::create_objects()
52 add_item(editlabel = new LabelPopupEdit(mwindow, gui));
53 add_item(new LabelPopupDelete(mwindow, gui));
54 add_item(new LabelPopupGoTo(mwindow, gui));
57 int LabelPopup::update()
59 gui->collect_assets();
64 LabelPopupEdit::LabelPopupEdit(MWindow *mwindow, AWindowGUI *gui)
65 : BC_MenuItem(_("Edit..."))
67 this->mwindow = mwindow;
71 LabelPopupEdit::~LabelPopupEdit()
75 int LabelPopupEdit::handle_event()
77 AssetPicon *result = (AssetPicon*)gui->asset_list->get_selection(0,0);
78 if( result && result->label ) {
80 gui->get_abs_cursor_xy(cur_x, cur_y, 0);
81 gui->awindow->label_edit->start(result->label, cur_x, cur_y);
86 LabelPopupDelete::LabelPopupDelete(MWindow *mwindow, AWindowGUI *gui)
87 : BC_MenuItem(_("Delete"))
89 this->mwindow = mwindow;
92 LabelPopupDelete::~LabelPopupDelete()
96 int LabelPopupDelete::handle_event()
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();
110 LabelPopupGoTo::LabelPopupGoTo(MWindow *mwindow, AWindowGUI *gui)
111 : BC_MenuItem(_("Go to"))
113 this->mwindow = mwindow;
116 LabelPopupGoTo::~LabelPopupGoTo()
120 int LabelPopupGoTo::handle_event()
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");
137 LabelListMenu::LabelListMenu(MWindow *mwindow, AWindowGUI *gui)
138 : BC_PopupMenu(0, 0, 0, "", 0)
140 this->mwindow = mwindow;
144 LabelListMenu:: ~LabelListMenu()
148 void LabelListMenu::create_objects()
150 add_item(format = new AWindowListFormat(mwindow, gui));
151 add_item(new AWindowListSort(mwindow, gui));
154 void LabelListMenu::update()