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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2893 - (hide annotations) (download) (as text)
Fri Apr 29 14:19:53 2016 UTC (7 years, 11 months ago) by schoenebeck
File MIME type: text/x-c++hdr
File size: 17212 byte(s)
* Automatically save & restore window size and position
  (yet limited to main window and script editor window).
* Bumped version (1.0.0.svn6).

1 schoenebeck 1225 /* -*- c++ -*-
2 schoenebeck 2893 * Copyright (C) 2006 - 2016 Andreas Persson
3 schoenebeck 1225 *
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 persson 2844 #include <gtkmm/box.h>
26 schoenebeck 1225 #include <gtkmm/actiongroup.h>
27     #include <gtkmm/buttonbox.h>
28     #include <gtkmm/dialog.h>
29     #include <gtkmm/liststore.h>
30 persson 2442 #include <gtkmm/menu.h>
31 schoenebeck 1225 #include <gtkmm/paned.h>
32     #include <gtkmm/progressbar.h>
33 persson 2442 #include <gtkmm/radiomenuitem.h>
34 schoenebeck 1225 #include <gtkmm/scrolledwindow.h>
35     #include <gtkmm/treestore.h>
36     #include <gtkmm/uimanager.h>
37     #include <gtkmm/window.h>
38 schoenebeck 1411 #include <gtkmm/statusbar.h>
39     #include <gtkmm/image.h>
40 schoenebeck 1225
41     #include <sstream>
42    
43     #include "regionchooser.h"
44     #include "dimregionchooser.h"
45     #include "dimregionedit.h"
46 persson 2507 #include "midirules.h"
47 persson 2325 #ifndef OLD_THREADS
48     #include <glibmm/threads.h>
49     #endif
50 schoenebeck 2893 #include "ManagedWindow.h"
51 schoenebeck 1225
52     class MainWindow;
53    
54 persson 2423 class PropDialog : public Gtk::Window,
55     public PropEditor<DLS::Info> {
56 persson 1582 public:
57 schoenebeck 1225 PropDialog();
58     void set_info(DLS::Info* info);
59 schoenebeck 2560 void set_file(gig::File* file);
60 schoenebeck 1225 protected:
61 schoenebeck 2560 ChoiceEntry<int> eFileFormat;
62 persson 1582 StringEntry eName;
63     StringEntry eCreationDate;
64     StringEntryMultiLine eComments;
65     StringEntry eProduct;
66     StringEntry eCopyright;
67     StringEntry eArtists;
68     StringEntry eGenre;
69     StringEntry eKeywords;
70     StringEntry eEngineer;
71     StringEntry eTechnician;
72     StringEntry eSoftware;
73     StringEntry eMedium;
74     StringEntry eSource;
75     StringEntry eSourceForm;
76     StringEntry eCommissioned;
77     StringEntry eSubject;
78     Gtk::VBox vbox;
79     Gtk::HButtonBox buttonBox;
80     Gtk::Button quitButton;
81     Table table;
82 schoenebeck 2560
83     gig::File* m_file;
84    
85     void onFileFormatChanged();
86 schoenebeck 1225 };
87    
88 persson 2423 class InstrumentProps : public Gtk::Window,
89     public PropEditor<gig::Instrument> {
90 schoenebeck 1225 public:
91     InstrumentProps();
92     void set_instrument(gig::Instrument* instrument);
93 persson 2445 gig::Instrument* get_instrument() { return m; }
94     void update_name();
95     sigc::signal<void>& signal_name_changed() {
96     return sig_name_changed;
97     }
98 schoenebeck 1225 protected:
99 persson 2445 void set_Name(const gig::String& name);
100 persson 1460 void set_IsDrum(bool value);
101     void set_MIDIBank(uint16_t value);
102     void set_MIDIProgram(uint32_t value);
103    
104 persson 2445 sigc::signal<void> sig_name_changed;
105 schoenebeck 1225 Gtk::VBox vbox;
106     Gtk::HButtonBox buttonBox;
107     Gtk::Button quitButton;
108 persson 1582 Table table;
109 schoenebeck 1225 StringEntry eName;
110     BoolEntry eIsDrum;
111     NumEntryTemp<uint16_t> eMIDIBank;
112     NumEntryTemp<uint32_t> eMIDIProgram;
113     NumEntryGain eAttenuation;
114     BoolEntryPlus6 eGainPlus6;
115     NumEntryTemp<uint16_t> eEffectSend;
116     NumEntryTemp<int16_t> eFineTune;
117     NumEntryTemp<uint16_t> ePitchbendRange;
118     BoolEntry ePianoReleaseMode;
119     NoteEntry eDimensionKeyRangeLow;
120     NoteEntry eDimensionKeyRangeHigh;
121     };
122    
123 schoenebeck 2683 class ProgressDialog : public Gtk::Dialog {
124 schoenebeck 1225 public:
125 schoenebeck 2683 ProgressDialog(const Glib::ustring& title, Gtk::Window& parent);
126 schoenebeck 1225 void set_fraction(float fraction) { progressBar.set_fraction(fraction); }
127     protected:
128     Gtk::ProgressBar progressBar;
129     };
130    
131     class Loader : public sigc::trackable {
132     public:
133     Loader(const char* filename);
134     void launch();
135     Glib::Dispatcher& signal_progress();
136 schoenebeck 2683 Glib::Dispatcher& signal_finished(); ///< Finished successfully, without error.
137     Glib::Dispatcher& signal_error();
138 schoenebeck 1225 void progress_callback(float fraction);
139     float get_progress();
140 schoenebeck 2683 const Glib::ustring filename;
141     Glib::ustring error_message;
142 schoenebeck 1225 gig::File* gig;
143    
144     private:
145 persson 2325 Glib::Threads::Thread* thread;
146 schoenebeck 1225 void thread_function();
147     Glib::Dispatcher finished_dispatcher;
148     Glib::Dispatcher progress_dispatcher;
149 schoenebeck 2683 Glib::Dispatcher error_dispatcher;
150 persson 2325 Glib::Threads::Mutex progressMutex;
151 schoenebeck 1225 float progress;
152     };
153    
154 schoenebeck 2683 class Saver : public sigc::trackable {
155     public:
156     Saver(gig::File* file, Glib::ustring filename = ""); ///< one argument means "save", two arguments means "save as"
157     void launch();
158     Glib::Dispatcher& signal_progress();
159     Glib::Dispatcher& signal_finished(); ///< Finished successfully, without error.
160     Glib::Dispatcher& signal_error();
161     void progress_callback(float fraction);
162     float get_progress();
163     gig::File* gig;
164     const Glib::ustring filename;
165     Glib::ustring error_message;
166    
167     private:
168     Glib::Threads::Thread* thread;
169     void thread_function();
170     Glib::Dispatcher finished_dispatcher;
171     Glib::Dispatcher progress_dispatcher;
172     Glib::Dispatcher error_dispatcher;
173     Glib::Threads::Mutex progressMutex;
174     float progress;
175     };
176    
177 schoenebeck 2893 class MainWindow : public ManagedWindow {
178 schoenebeck 1225 public:
179     MainWindow();
180     virtual ~MainWindow();
181     void load_file(const char* name);
182     void load_instrument(gig::Instrument* instr);
183 persson 1261 void file_changed();
184 schoenebeck 1339 sigc::signal<void, gig::File*>& signal_file_structure_to_be_changed();
185     sigc::signal<void, gig::File*>& signal_file_structure_changed();
186     sigc::signal<void, std::list<gig::Sample*> >& signal_samples_to_be_removed();
187     sigc::signal<void>& signal_samples_removed();
188     sigc::signal<void, gig::Region*>& signal_region_to_be_changed();
189     sigc::signal<void, gig::Region*>& signal_region_changed();
190     sigc::signal<void, gig::DimensionRegion*>& signal_dimreg_to_be_changed();
191     sigc::signal<void, gig::DimensionRegion*>& signal_dimreg_changed();
192 schoenebeck 1853 sigc::signal<void, gig::Sample*>& signal_sample_changed();
193 schoenebeck 1339 sigc::signal<void, gig::Sample*/*old*/, gig::Sample*/*new*/>& signal_sample_ref_changed();
194 schoenebeck 1225
195 schoenebeck 1654 sigc::signal<void, int/*key*/, int/*velocity*/>& signal_note_on();
196     sigc::signal<void, int/*key*/, int/*velocity*/>& signal_note_off();
197    
198 schoenebeck 1660 sigc::signal<void, int/*key*/, int/*velocity*/>& signal_keyboard_key_hit();
199     sigc::signal<void, int/*key*/, int/*velocity*/>& signal_keyboard_key_released();
200    
201 schoenebeck 2689 sigc::signal<void, gig::Instrument*>& signal_switch_sampler_instrument();
202 schoenebeck 2893
203     // implementation for abstract methods of interface class "ManagedWindow"
204     virtual Settings::Property<int>* windowSettingX() { return &Settings::singleton()->mainWindowX; }
205     virtual Settings::Property<int>* windowSettingY() { return &Settings::singleton()->mainWindowY; }
206     virtual Settings::Property<int>* windowSettingWidth() { return &Settings::singleton()->mainWindowW; }
207     virtual Settings::Property<int>* windowSettingHeight() { return &Settings::singleton()->mainWindowH; }
208 schoenebeck 2689
209 schoenebeck 1225 protected:
210     Glib::RefPtr<Gtk::ActionGroup> actionGroup;
211     Glib::RefPtr<Gtk::UIManager> uiManager;
212    
213 schoenebeck 1411 Gtk::Statusbar m_StatusBar;
214     Gtk::Label m_AttachedStateLabel;
215     Gtk::Image m_AttachedStateImage;
216    
217 schoenebeck 1225 RegionChooser m_RegionChooser;
218     DimRegionChooser m_DimRegionChooser;
219    
220     PropDialog propDialog;
221     InstrumentProps instrumentProps;
222 persson 2507 MidiRules midiRules;
223 schoenebeck 1225
224 schoenebeck 1322 sigc::signal<void, gig::File*> file_structure_to_be_changed_signal;
225     sigc::signal<void, gig::File*> file_structure_changed_signal;
226     sigc::signal<void, std::list<gig::Sample*> > samples_to_be_removed_signal;
227     sigc::signal<void> samples_removed_signal;
228     sigc::signal<void, gig::Region*> region_to_be_changed_signal;
229     sigc::signal<void, gig::Region*> region_changed_signal;
230     sigc::signal<void, gig::DimensionRegion*> dimreg_to_be_changed_signal;
231     sigc::signal<void, gig::DimensionRegion*> dimreg_changed_signal;
232 schoenebeck 1853 sigc::signal<void, gig::Sample*> sample_changed_signal;
233 schoenebeck 1322 sigc::signal<void, gig::Sample*/*old*/, gig::Sample*/*new*/> sample_ref_changed_signal;
234    
235 schoenebeck 1654 sigc::signal<void, int/*key*/, int/*velocity*/> note_on_signal;
236     sigc::signal<void, int/*key*/, int/*velocity*/> note_off_signal;
237    
238 schoenebeck 2689 sigc::signal<void, gig::Instrument*> switch_sampler_instrument_signal;
239    
240 persson 2442 void on_instrument_selection_change(Gtk::RadioMenuItem* item);
241 schoenebeck 1225 void on_sel_change();
242     void region_changed();
243     void dimreg_changed();
244 schoenebeck 2701 void select_instrument(gig::Instrument* instrument);
245 schoenebeck 2695 bool select_dimension_region(gig::DimensionRegion* dimRgn);
246 schoenebeck 2691 void select_sample(gig::Sample* sample);
247 schoenebeck 1225 void on_loader_progress();
248     void on_loader_finished();
249 schoenebeck 2683 void on_loader_error();
250     void on_saver_progress();
251     void on_saver_error();
252     void on_saver_finished();
253    
254 persson 1533 void dimreg_all_dimregs_toggled();
255     gig::Instrument* get_instrument();
256     void add_region_to_dimregs(gig::Region* region, bool stereo, bool all_dimregs);
257     void update_dimregs();
258 schoenebeck 1225
259     class ModelColumns : public Gtk::TreeModel::ColumnRecord {
260     public:
261     ModelColumns() {
262     add(m_col_name);
263     add(m_col_instr);
264     }
265    
266     Gtk::TreeModelColumn<Glib::ustring> m_col_name;
267     Gtk::TreeModelColumn<gig::Instrument*> m_col_instr;
268     } m_Columns;
269    
270     Gtk::VBox m_VBox;
271     Gtk::HPaned m_HPaned;
272    
273     Gtk::ScrolledWindow m_ScrolledWindow;
274    
275     Gtk::TreeView m_TreeView;
276     Glib::RefPtr<Gtk::ListStore> m_refTreeModel;
277    
278 persson 2442 Gtk::Menu* instrument_menu;
279    
280 schoenebeck 2621 std::map<gig::Sample*,int> sample_ref_count;
281    
282 schoenebeck 1225 class SamplesModel : public Gtk::TreeModel::ColumnRecord {
283     public:
284     SamplesModel() {
285     add(m_col_name);
286     add(m_col_sample);
287     add(m_col_group);
288 schoenebeck 2621 add(m_col_refcount);
289     add(m_color);
290 schoenebeck 1225 }
291    
292     Gtk::TreeModelColumn<Glib::ustring> m_col_name;
293     Gtk::TreeModelColumn<gig::Sample*> m_col_sample;
294     Gtk::TreeModelColumn<gig::Group*> m_col_group;
295 schoenebeck 2621 Gtk::TreeModelColumn<Glib::ustring> m_col_refcount;
296     Gtk::TreeModelColumn<Glib::ustring> m_color;
297 schoenebeck 1225 } m_SamplesModel;
298    
299     class SamplesTreeStore : public Gtk::TreeStore {
300     public:
301     static Glib::RefPtr<SamplesTreeStore> create(const SamplesModel& columns) {
302     return Glib::RefPtr<SamplesTreeStore>( new SamplesTreeStore(columns) );
303     }
304     protected:
305     SamplesTreeStore(const SamplesModel& columns) : Gtk::TreeStore(columns) {}
306     };
307    
308     Gtk::ScrolledWindow m_ScrolledWindowSamples;
309     Gtk::TreeView m_TreeViewSamples;
310     Glib::RefPtr<SamplesTreeStore> m_refSamplesTreeModel;
311    
312 schoenebeck 2604 class ScriptsModel : public Gtk::TreeModel::ColumnRecord {
313     public:
314     ScriptsModel() {
315     add(m_col_name);
316     add(m_col_script);
317     add(m_col_group);
318     }
319    
320     Gtk::TreeModelColumn<Glib::ustring> m_col_name;
321     Gtk::TreeModelColumn<gig::Script*> m_col_script;
322     Gtk::TreeModelColumn<gig::ScriptGroup*> m_col_group;
323     } m_ScriptsModel;
324    
325     class ScriptsTreeStore : public Gtk::TreeStore {
326     public:
327     static Glib::RefPtr<ScriptsTreeStore> create(const ScriptsModel& columns) {
328     return Glib::RefPtr<ScriptsTreeStore>( new ScriptsTreeStore(columns) );
329     }
330     protected:
331     ScriptsTreeStore(const ScriptsModel& columns) : Gtk::TreeStore(columns) {}
332     };
333    
334     Gtk::ScrolledWindow m_ScrolledWindowScripts;
335     Gtk::TreeView m_TreeViewScripts;
336     Glib::RefPtr<ScriptsTreeStore> m_refScriptsTreeModel;
337    
338 persson 1533 Gtk::VBox dimreg_vbox;
339     Gtk::HBox dimreg_hbox;
340     Gtk::Label dimreg_label;
341     Gtk::CheckButton dimreg_all_regions;
342     Gtk::CheckButton dimreg_all_dimregs;
343     Gtk::CheckButton dimreg_stereo;
344 schoenebeck 1225 DimRegionEdit dimreg_edit;
345    
346     Gtk::Notebook m_TreeViewNotebook;
347    
348     struct SampleImportItem {
349     gig::Sample* gig_sample; // pointer to the gig::Sample to
350     // which the sample data should be
351     // imported to
352     Glib::ustring sample_path; // file name of the sample to be
353     // imported
354     };
355     std::list<SampleImportItem> m_SampleImportQueue;
356    
357    
358     void on_action_file_new();
359     void on_action_file_open();
360     void on_action_file_save();
361     void on_action_file_save_as();
362     void on_action_file_properties();
363 persson 1261 void on_action_quit();
364 schoenebeck 1225 void show_instr_props();
365 persson 2445 bool instr_props_set_instrument();
366 persson 2507 void show_midi_rules();
367 schoenebeck 2610 void show_script_slots();
368 schoenebeck 1415 void on_action_view_status_bar();
369 schoenebeck 2772 void on_action_refresh_all();
370 schoenebeck 2541 void on_action_warn_user_on_extensions();
371 schoenebeck 2689 void on_action_sync_sampler_instrument_selection();
372 schoenebeck 2773 void on_action_move_root_note_with_region_moved();
373 schoenebeck 1225 void on_action_help_about();
374    
375     // sample right-click popup actions
376     void on_sample_treeview_button_release(GdkEventButton* button);
377     void on_action_sample_properties();
378     void on_action_add_group();
379     void on_action_add_sample();
380 schoenebeck 2715 void on_action_replace_sample();
381 schoenebeck 1673 void on_action_replace_all_samples_in_all_groups();
382 schoenebeck 1225 void on_action_remove_sample();
383 schoenebeck 2772 void on_action_remove_unused_samples();
384    
385 schoenebeck 2604 // script right-click popup actions
386     void on_script_treeview_button_release(GdkEventButton* button);
387     void on_action_add_script_group();
388     void on_action_add_script();
389     void on_action_edit_script();
390     void on_action_remove_script();
391 schoenebeck 1225
392     void on_action_add_instrument();
393 schoenebeck 2395 void on_action_duplicate_instrument();
394 schoenebeck 1225 void on_action_remove_instrument();
395    
396 schoenebeck 2625 void show_samples_tab();
397     void show_intruments_tab();
398     void show_scripts_tab();
399    
400 persson 2442 void add_instrument(gig::Instrument* instrument);
401     Gtk::RadioMenuItem* add_instrument_to_menu(const Glib::ustring& name,
402     int position = -1);
403     void remove_instrument_from_menu(int index);
404    
405 schoenebeck 2683 ProgressDialog* progress_dialog;
406 schoenebeck 1225 Loader* loader;
407 schoenebeck 2683 Saver* saver;
408 schoenebeck 1382 void load_gig(gig::File* gig, const char* filename, bool isSharedInstrument = false);
409 schoenebeck 2621 void updateSampleRefCountMap(gig::File* gig);
410 schoenebeck 1225
411     gig::File* file;
412 schoenebeck 1382 bool file_is_shared;
413 persson 1261 bool file_has_name;
414     bool file_is_changed;
415     std::string filename;
416 persson 1725 std::string current_gig_dir;
417     std::string current_sample_dir;
418 schoenebeck 1225
419 schoenebeck 1411 void set_file_is_shared(bool);
420    
421 persson 1261 bool file_save();
422     bool file_save_as();
423 persson 1303 bool check_if_savable();
424 persson 1261
425 schoenebeck 1225 void on_button_release(GdkEventButton* button);
426 schoenebeck 2701 void on_instruments_treeview_drag_begin(const Glib::RefPtr<Gdk::DragContext>& context);
427     void on_instruments_treeview_drag_data_get(const Glib::RefPtr<Gdk::DragContext>&,
428     Gtk::SelectionData& selection_data, guint, guint);
429     void on_instruments_treeview_drop_drag_data_received(
430     const Glib::RefPtr<Gdk::DragContext>& context, int, int,
431     const Gtk::SelectionData& selection_data, guint, guint time
432     );
433 schoenebeck 2610 void on_scripts_treeview_drag_begin(const Glib::RefPtr<Gdk::DragContext>& context);
434     void on_scripts_treeview_drag_data_get(const Glib::RefPtr<Gdk::DragContext>&,
435     Gtk::SelectionData& selection_data, guint, guint);
436 persson 1303 void on_sample_treeview_drag_begin(const Glib::RefPtr<Gdk::DragContext>& context);
437 schoenebeck 1225 void on_sample_treeview_drag_data_get(const Glib::RefPtr<Gdk::DragContext>&,
438     Gtk::SelectionData& selection_data, guint, guint);
439     void on_sample_label_drop_drag_data_received(const Glib::RefPtr<Gdk::DragContext>& context,
440     int, int,
441     const Gtk::SelectionData& selection_data,
442     guint, guint time);
443 persson 1303
444 schoenebeck 2604 void script_name_changed(const Gtk::TreeModel::Path& path,
445     const Gtk::TreeModel::iterator& iter);
446 schoenebeck 2644 void script_double_clicked(const Gtk::TreeModel::Path& path, Gtk::TreeViewColumn* column);
447 schoenebeck 1225 void sample_name_changed(const Gtk::TreeModel::Path& path,
448     const Gtk::TreeModel::iterator& iter);
449     void instrument_name_changed(const Gtk::TreeModel::Path& path,
450     const Gtk::TreeModel::iterator& iter);
451 persson 2445 void instr_name_changed_by_instr_props(Gtk::TreeModel::iterator& it);
452 persson 2442 sigc::connection instrument_name_connection;
453 schoenebeck 1225
454 schoenebeck 2548 void on_action_combine_instruments();
455 schoenebeck 2624 void on_action_view_references();
456 schoenebeck 2553 void on_action_merge_files();
457     void mergeFiles(const std::vector<std::string>& filenames);
458 schoenebeck 2548
459 schoenebeck 2621 void on_sample_ref_changed(gig::Sample* oldSample, gig::Sample* newSample);
460     void on_sample_ref_count_incremented(gig::Sample* sample, int offset);
461     void on_samples_to_be_removed(std::list<gig::Sample*> samples);
462    
463 schoenebeck 2715 void add_or_replace_sample(bool replace);
464    
465 schoenebeck 1225 void __import_queued_samples();
466     void __clear();
467 schoenebeck 2553 void __refreshEntireGUI();
468 schoenebeck 1225
469 persson 1261 bool close_confirmation_dialog();
470 schoenebeck 1382 bool leaving_shared_mode_dialog();
471 persson 1261
472 schoenebeck 1225 Gtk::Menu* popup_menu;
473 persson 1261
474     bool on_delete_event(GdkEventAny* event);
475 persson 1303
476     bool first_call_to_drag_data_get;
477 schoenebeck 2464
478     bool is_copy_samples_unity_note_enabled() const;
479     bool is_copy_samples_fine_tune_enabled() const;
480     bool is_copy_samples_loop_enabled() const;
481 schoenebeck 1225 };
482    
483     #endif

  ViewVC Help
Powered by ViewVC