prevent popup deactivation while button_down
[goodguy/history.git] / cinelerra-5.0 / cinelerra / awindowmenu.C
1
2 /*
3  * CINELERRA
4  * Copyright (C) 2008 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 "awindowmenu.h"
25 #include "edl.h"
26 #include "edlsession.h"
27 #include "language.h"
28 #include "mwindow.h"
29
30
31
32
33
34 AssetListMenu::AssetListMenu(MWindow *mwindow, AWindowGUI *gui)
35  : BC_PopupMenu(0, 
36                 0, 
37                 0, 
38                 "", 
39                 0)
40 {
41         this->mwindow = mwindow;
42         this->gui = gui;
43 }
44
45 AssetListMenu::~AssetListMenu()
46 {
47 }
48
49 void AssetListMenu::create_objects()
50 {
51         add_item(format = new AssetListFormat(mwindow));
52         add_item(new AssetListSort(mwindow));
53         update_titles();
54 }
55
56 void AssetListMenu::update_titles()
57 {
58         format->update();
59 }
60
61
62
63
64
65
66
67
68 AssetListFormat::AssetListFormat(MWindow *mwindow)
69  : BC_MenuItem("")
70 {
71         this->mwindow = mwindow;
72 }
73
74 void AssetListFormat::update()
75 {
76         set_text(mwindow->edl->session->assetlist_format == ASSETS_TEXT ?
77                 (char*)_("Display icons") : (char*)_("Display text"));
78 }
79
80 int AssetListFormat::handle_event()
81 {
82         AWindowGUI *agui = mwindow->awindow->gui;
83         agui->stop_vicon_drawing();
84
85         EDLSession *session = mwindow->edl->session;
86         switch(session->assetlist_format) {
87         case ASSETS_TEXT:
88                 session->assetlist_format = ASSETS_ICONS;
89                 session->folderlist_format = ASSETS_ICONS;
90                 break;
91         case ASSETS_ICONS:
92                 session->assetlist_format = ASSETS_TEXT;
93                 session->folderlist_format = ASSETS_TEXT;
94                 break;
95         }
96
97         agui->asset_list->update_format(session->assetlist_format, 1);
98         agui->folder_list->update_format(session->folderlist_format, 1);
99         agui->start_vicon_drawing();
100         return 1;
101 }
102
103
104
105
106 AssetListSort::AssetListSort(MWindow *mwindow)
107  : BC_MenuItem(_("Sort items"))
108 {
109         this->mwindow = mwindow;
110 }
111
112 int AssetListSort::handle_event()
113 {
114         mwindow->awindow->gui->sort_assets();
115         return 1;
116 }
117
118
119
120
121 FolderListMenu::FolderListMenu(MWindow *mwindow, AWindowGUI *gui)
122  : BC_PopupMenu(0, 
123                 0, 
124                 0, 
125                 "", 
126                 0)
127 {
128         this->mwindow = mwindow;
129         this->gui = gui;
130 }
131
132 FolderListMenu::~FolderListMenu()
133 {
134 }
135         
136 void FolderListMenu::create_objects()
137 {
138         add_item(format = new FolderListFormat(mwindow, this));
139         update_titles();
140 }
141
142
143
144 void FolderListMenu::update_titles()
145 {
146         format->set_text(mwindow->edl->session->folderlist_format == FOLDERS_TEXT ?
147                 (char*)_("Display icons") : (char*)_("Display text"));
148 }
149
150
151
152
153
154
155
156 FolderListFormat::FolderListFormat(MWindow *mwindow, FolderListMenu *menu)
157  : BC_MenuItem("")
158 {
159         this->mwindow = mwindow;
160         this->menu = menu;
161 }
162 int FolderListFormat::handle_event()
163 {
164         switch(mwindow->edl->session->folderlist_format)
165         {
166                 case ASSETS_TEXT:
167                         mwindow->edl->session->assetlist_format = ASSETS_ICONS;
168                         mwindow->edl->session->folderlist_format = ASSETS_ICONS;
169                         break;
170                 case ASSETS_ICONS:
171                         mwindow->edl->session->assetlist_format = ASSETS_TEXT;
172                         mwindow->edl->session->folderlist_format = ASSETS_TEXT;
173                         break;
174         }
175
176         mwindow->awindow->gui->asset_list->update_format(
177                 mwindow->edl->session->folderlist_format, 1);
178         mwindow->awindow->gui->folder_list->update_format(
179                 mwindow->edl->session->folderlist_format, 1);
180         menu->update_titles();
181
182         return 1;
183 }
184
185
186