/[svn]/gigedit/trunk/src/gigedit/mainwindow.h
ViewVC logotype

Contents of /gigedit/trunk/src/gigedit/mainwindow.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2423 - (show annotations) (download) (as text)
Sun Feb 24 15:19:39 2013 UTC (11 years, 1 month ago) by persson
File MIME type: text/x-c++hdr
File size: 10890 byte(s)
* code refactoring: created a PropEdit class for property editor
  windows, moved Table class from mainwindow to paramedit
* minor gui tweaks: made note entry fields a bit wider, set a minimum
  width for scales
* bug fix: avoid stale information in the instrument properties window
  when a new file is loaded or the instrument is removed

1 /* -*- c++ -*-
2 * Copyright (C) 2006 - 2013 Andreas Persson
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation; either version 2, or (at
7 * your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with program; see the file COPYING. If not, write to the Free
16 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
17 * 02110-1301 USA.
18 */
19
20 #ifndef GIGEDIT_MAINWINDOW_H
21 #define GIGEDIT_MAINWINDOW_H
22
23 #include <gig.h>
24
25 #include <gtkmm/actiongroup.h>
26 #include <gtkmm/buttonbox.h>
27 #include <gtkmm/dialog.h>
28 #include <gtkmm/liststore.h>
29 #include <gtkmm/paned.h>
30 #include <gtkmm/progressbar.h>
31 #include <gtkmm/scrolledwindow.h>
32 #include <gtkmm/treestore.h>
33 #include <gtkmm/uimanager.h>
34 #include <gtkmm/window.h>
35 #include <gtkmm/statusbar.h>
36 #include <gtkmm/image.h>
37
38 #include <sstream>
39
40 #include "regionchooser.h"
41 #include "dimregionchooser.h"
42 #include "dimregionedit.h"
43 #ifndef OLD_THREADS
44 #include <glibmm/threads.h>
45 #endif
46
47 class MainWindow;
48
49 class PropDialog : public Gtk::Window,
50 public PropEditor<DLS::Info> {
51 public:
52 PropDialog();
53 void set_info(DLS::Info* info);
54 protected:
55 StringEntry eName;
56 StringEntry eCreationDate;
57 StringEntryMultiLine eComments;
58 StringEntry eProduct;
59 StringEntry eCopyright;
60 StringEntry eArtists;
61 StringEntry eGenre;
62 StringEntry eKeywords;
63 StringEntry eEngineer;
64 StringEntry eTechnician;
65 StringEntry eSoftware;
66 StringEntry eMedium;
67 StringEntry eSource;
68 StringEntry eSourceForm;
69 StringEntry eCommissioned;
70 StringEntry eSubject;
71 Gtk::VBox vbox;
72 Gtk::HButtonBox buttonBox;
73 Gtk::Button quitButton;
74 Table table;
75 };
76
77 class InstrumentProps : public Gtk::Window,
78 public PropEditor<gig::Instrument> {
79 public:
80 InstrumentProps();
81 void set_instrument(gig::Instrument* instrument);
82 protected:
83 void set_IsDrum(bool value);
84 void set_MIDIBank(uint16_t value);
85 void set_MIDIProgram(uint32_t value);
86
87 Gtk::VBox vbox;
88 Gtk::HButtonBox buttonBox;
89 Gtk::Button quitButton;
90 Table table;
91 StringEntry eName;
92 BoolEntry eIsDrum;
93 NumEntryTemp<uint16_t> eMIDIBank;
94 NumEntryTemp<uint32_t> eMIDIProgram;
95 NumEntryGain eAttenuation;
96 BoolEntryPlus6 eGainPlus6;
97 NumEntryTemp<uint16_t> eEffectSend;
98 NumEntryTemp<int16_t> eFineTune;
99 NumEntryTemp<uint16_t> ePitchbendRange;
100 BoolEntry ePianoReleaseMode;
101 NoteEntry eDimensionKeyRangeLow;
102 NoteEntry eDimensionKeyRangeHigh;
103 };
104
105 class LoadDialog : public Gtk::Dialog {
106 public:
107 LoadDialog(const Glib::ustring& title, Gtk::Window& parent);
108 void set_fraction(float fraction) { progressBar.set_fraction(fraction); }
109 protected:
110 Gtk::ProgressBar progressBar;
111 };
112
113 class Loader : public sigc::trackable {
114 public:
115 Loader(const char* filename);
116 void launch();
117 Glib::Dispatcher& signal_progress();
118 Glib::Dispatcher& signal_finished();
119 void progress_callback(float fraction);
120 float get_progress();
121 const char* filename;
122 gig::File* gig;
123
124 private:
125 Glib::Threads::Thread* thread;
126 void thread_function();
127 Glib::Dispatcher finished_dispatcher;
128 Glib::Dispatcher progress_dispatcher;
129 Glib::Threads::Mutex progressMutex;
130 float progress;
131 };
132
133 class MainWindow : public Gtk::Window {
134 public:
135 MainWindow();
136 virtual ~MainWindow();
137 void load_file(const char* name);
138 void load_instrument(gig::Instrument* instr);
139 void file_changed();
140 sigc::signal<void, gig::File*>& signal_file_structure_to_be_changed();
141 sigc::signal<void, gig::File*>& signal_file_structure_changed();
142 sigc::signal<void, std::list<gig::Sample*> >& signal_samples_to_be_removed();
143 sigc::signal<void>& signal_samples_removed();
144 sigc::signal<void, gig::Region*>& signal_region_to_be_changed();
145 sigc::signal<void, gig::Region*>& signal_region_changed();
146 sigc::signal<void, gig::DimensionRegion*>& signal_dimreg_to_be_changed();
147 sigc::signal<void, gig::DimensionRegion*>& signal_dimreg_changed();
148 sigc::signal<void, gig::Sample*>& signal_sample_changed();
149 sigc::signal<void, gig::Sample*/*old*/, gig::Sample*/*new*/>& signal_sample_ref_changed();
150
151 sigc::signal<void, int/*key*/, int/*velocity*/>& signal_note_on();
152 sigc::signal<void, int/*key*/, int/*velocity*/>& signal_note_off();
153
154 sigc::signal<void, int/*key*/, int/*velocity*/>& signal_keyboard_key_hit();
155 sigc::signal<void, int/*key*/, int/*velocity*/>& signal_keyboard_key_released();
156
157 protected:
158 Glib::RefPtr<Gtk::ActionGroup> actionGroup;
159 Glib::RefPtr<Gtk::UIManager> uiManager;
160
161 Gtk::Statusbar m_StatusBar;
162 Gtk::Label m_AttachedStateLabel;
163 Gtk::Image m_AttachedStateImage;
164
165 RegionChooser m_RegionChooser;
166 DimRegionChooser m_DimRegionChooser;
167
168 PropDialog propDialog;
169 InstrumentProps instrumentProps;
170
171 sigc::signal<void, gig::File*> file_structure_to_be_changed_signal;
172 sigc::signal<void, gig::File*> file_structure_changed_signal;
173 sigc::signal<void, std::list<gig::Sample*> > samples_to_be_removed_signal;
174 sigc::signal<void> samples_removed_signal;
175 sigc::signal<void, gig::Region*> region_to_be_changed_signal;
176 sigc::signal<void, gig::Region*> region_changed_signal;
177 sigc::signal<void, gig::DimensionRegion*> dimreg_to_be_changed_signal;
178 sigc::signal<void, gig::DimensionRegion*> dimreg_changed_signal;
179 sigc::signal<void, gig::Sample*> sample_changed_signal;
180 sigc::signal<void, gig::Sample*/*old*/, gig::Sample*/*new*/> sample_ref_changed_signal;
181
182 sigc::signal<void, int/*key*/, int/*velocity*/> note_on_signal;
183 sigc::signal<void, int/*key*/, int/*velocity*/> note_off_signal;
184
185 void on_instrument_selection_change(int index);
186 void on_sel_change();
187 void region_changed();
188 void dimreg_changed();
189 void on_loader_progress();
190 void on_loader_finished();
191 void dimreg_all_dimregs_toggled();
192 gig::Instrument* get_instrument();
193 void add_region_to_dimregs(gig::Region* region, bool stereo, bool all_dimregs);
194 void update_dimregs();
195
196 class ModelColumns : public Gtk::TreeModel::ColumnRecord {
197 public:
198 ModelColumns() {
199 add(m_col_name);
200 add(m_col_instr);
201 }
202
203 Gtk::TreeModelColumn<Glib::ustring> m_col_name;
204 Gtk::TreeModelColumn<gig::Instrument*> m_col_instr;
205 } m_Columns;
206
207 Gtk::VBox m_VBox;
208 Gtk::HPaned m_HPaned;
209
210 Gtk::ScrolledWindow m_ScrolledWindow;
211
212 Gtk::TreeView m_TreeView;
213 Glib::RefPtr<Gtk::ListStore> m_refTreeModel;
214
215 class SamplesModel : public Gtk::TreeModel::ColumnRecord {
216 public:
217 SamplesModel() {
218 add(m_col_name);
219 add(m_col_sample);
220 add(m_col_group);
221 }
222
223 Gtk::TreeModelColumn<Glib::ustring> m_col_name;
224 Gtk::TreeModelColumn<gig::Sample*> m_col_sample;
225 Gtk::TreeModelColumn<gig::Group*> m_col_group;
226 } m_SamplesModel;
227
228 class SamplesTreeStore : public Gtk::TreeStore {
229 public:
230 static Glib::RefPtr<SamplesTreeStore> create(const SamplesModel& columns) {
231 return Glib::RefPtr<SamplesTreeStore>( new SamplesTreeStore(columns) );
232 }
233 protected:
234 SamplesTreeStore(const SamplesModel& columns) : Gtk::TreeStore(columns) {}
235 };
236
237 Gtk::ScrolledWindow m_ScrolledWindowSamples;
238 Gtk::TreeView m_TreeViewSamples;
239 Glib::RefPtr<SamplesTreeStore> m_refSamplesTreeModel;
240
241 Gtk::VBox dimreg_vbox;
242 Gtk::HBox dimreg_hbox;
243 Gtk::Label dimreg_label;
244 Gtk::CheckButton dimreg_all_regions;
245 Gtk::CheckButton dimreg_all_dimregs;
246 Gtk::CheckButton dimreg_stereo;
247 DimRegionEdit dimreg_edit;
248
249 Gtk::Notebook m_TreeViewNotebook;
250
251 struct SampleImportItem {
252 gig::Sample* gig_sample; // pointer to the gig::Sample to
253 // which the sample data should be
254 // imported to
255 Glib::ustring sample_path; // file name of the sample to be
256 // imported
257 };
258 std::list<SampleImportItem> m_SampleImportQueue;
259
260
261 void on_action_file_new();
262 void on_action_file_open();
263 void on_action_file_save();
264 void on_action_file_save_as();
265 void on_action_file_properties();
266 void on_action_quit();
267 void show_instr_props();
268 void on_action_view_status_bar();
269 void on_action_help_about();
270
271 // sample right-click popup actions
272 void on_sample_treeview_button_release(GdkEventButton* button);
273 void on_action_sample_properties();
274 void on_action_add_group();
275 void on_action_add_sample();
276 void on_action_replace_all_samples_in_all_groups();
277 void on_action_remove_sample();
278
279 void on_action_add_instrument();
280 void on_action_duplicate_instrument();
281 void on_action_remove_instrument();
282
283 LoadDialog* load_dialog;
284 Loader* loader;
285 void load_gig(gig::File* gig, const char* filename, bool isSharedInstrument = false);
286
287 gig::File* file;
288 bool file_is_shared;
289 bool file_has_name;
290 bool file_is_changed;
291 std::string filename;
292 std::string current_gig_dir;
293 std::string current_sample_dir;
294
295 void set_file_is_shared(bool);
296
297 bool file_save();
298 bool file_save_as();
299 bool check_if_savable();
300
301 void on_button_release(GdkEventButton* button);
302 void on_sample_treeview_drag_begin(const Glib::RefPtr<Gdk::DragContext>& context);
303 void on_sample_treeview_drag_data_get(const Glib::RefPtr<Gdk::DragContext>&,
304 Gtk::SelectionData& selection_data, guint, guint);
305 void on_sample_label_drop_drag_data_received(const Glib::RefPtr<Gdk::DragContext>& context,
306 int, int,
307 const Gtk::SelectionData& selection_data,
308 guint, guint time);
309
310 void sample_name_changed(const Gtk::TreeModel::Path& path,
311 const Gtk::TreeModel::iterator& iter);
312 void instrument_name_changed(const Gtk::TreeModel::Path& path,
313 const Gtk::TreeModel::iterator& iter);
314
315 void __import_queued_samples();
316 void __clear();
317
318 bool close_confirmation_dialog();
319 bool leaving_shared_mode_dialog();
320
321 Gtk::Menu* popup_menu;
322
323 bool on_delete_event(GdkEventAny* event);
324
325 bool first_call_to_drag_data_get;
326 };
327
328 #endif

  ViewVC Help
Powered by ViewVC