/[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 1853 - (hide annotations) (download) (as text)
Sun Mar 1 22:26:36 2009 UTC (15 years, 1 month ago) by schoenebeck
File MIME type: text/x-c++hdr
File size: 12923 byte(s)
* bugfix: inform the sampler when new file(s) has been imported on save
  operation (#82)

1 schoenebeck 1225 /* -*- c++ -*-
2 schoenebeck 1654 * Copyright (C) 2006 - 2008 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     #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 schoenebeck 1411 #include <gtkmm/statusbar.h>
36     #include <gtkmm/image.h>
37 schoenebeck 1225
38     #include <sstream>
39    
40     #include "regionchooser.h"
41     #include "dimregionchooser.h"
42     #include "dimregionedit.h"
43    
44     class MainWindow;
45    
46 persson 1582 class Table : public Gtk::Table
47     {
48     public:
49     Table(int x, int y);
50     void add(BoolEntry& boolentry);
51     void add(BoolEntryPlus6& boolentry);
52     void add(LabelWidget& labelwidget);
53     private:
54     int rowno;
55     };
56    
57 schoenebeck 1225 class PropDialog : public Gtk::Window {
58     public:
59     PropDialog();
60     void set_info(DLS::Info* info);
61 persson 1582 sigc::signal<void>& signal_info_changed();
62 schoenebeck 1225 protected:
63 persson 1582 sigc::signal<void> info_changed;
64     StringEntry eName;
65     StringEntry eCreationDate;
66     StringEntryMultiLine eComments;
67     StringEntry eProduct;
68     StringEntry eCopyright;
69     StringEntry eArtists;
70     StringEntry eGenre;
71     StringEntry eKeywords;
72     StringEntry eEngineer;
73     StringEntry eTechnician;
74     StringEntry eSoftware;
75     StringEntry eMedium;
76     StringEntry eSource;
77     StringEntry eSourceForm;
78     StringEntry eCommissioned;
79     StringEntry eSubject;
80     Gtk::VBox vbox;
81     Gtk::HButtonBox buttonBox;
82     Gtk::Button quitButton;
83     Table table;
84     int update_model;
85     DLS::Info* info;
86    
87     template<typename T>
88     void set_member(T value, T DLS::Info::* member) {
89     if (update_model == 0) {
90     info->*member = value;
91     info_changed();
92     }
93     }
94    
95     template<typename C, typename T>
96     void connect(C& widget, T DLS::Info::* member) {
97     widget.signal_value_changed().connect(
98     sigc::compose(
99     sigc::bind(sigc::mem_fun(*this, &PropDialog::set_member<T>), member),
100     sigc::mem_fun(widget, &C::get_value)));
101     }
102 schoenebeck 1225 };
103    
104     class InstrumentProps : public Gtk::Window {
105     public:
106     InstrumentProps();
107     void set_instrument(gig::Instrument* instrument);
108 schoenebeck 1339 sigc::signal<void>& signal_instrument_changed();
109 schoenebeck 1225 protected:
110 persson 1460 gig::Instrument* instrument;
111     int update_model;
112    
113     template<typename T>
114     void set_value(T value, sigc::slot<void, InstrumentProps*, T> setter) {
115     if (update_model == 0) {
116     setter(this, value);
117     instrument_changed();
118     }
119     }
120    
121     template<typename C, typename T>
122     void connect(C& widget, T gig::Instrument::* member) {
123     widget.signal_value_changed().connect(
124     sigc::compose(
125     sigc::bind(sigc::mem_fun(*this, &InstrumentProps::set_value<T>),
126     sigc::bind(sigc::mem_fun(&InstrumentProps::set_member<T>), member)),
127     sigc::mem_fun(widget, &C::get_value)));
128     }
129    
130     template<typename C, typename T>
131     void connect(C& widget, void (InstrumentProps::*setter)(T)) {
132     widget.signal_value_changed().connect(
133     sigc::compose(
134     sigc::bind(sigc::mem_fun(*this, &InstrumentProps::set_value<T>),
135     sigc::mem_fun(setter)),
136     sigc::mem_fun(widget, &C::get_value)));
137     }
138    
139     template<typename T>
140     void set_member(T value, T gig::Instrument::* member) {
141     instrument->*member = value;
142     }
143    
144     void set_IsDrum(bool value);
145     void set_MIDIBank(uint16_t value);
146     void set_MIDIProgram(uint32_t value);
147     void set_DimensionKeyRange_low(uint8_t value);
148     void set_DimensionKeyRange_high(uint8_t value);
149    
150 schoenebeck 1225 Gtk::VBox vbox;
151     Gtk::HButtonBox buttonBox;
152     Gtk::Button quitButton;
153 persson 1582 Table table;
154 schoenebeck 1225 StringEntry eName;
155     BoolEntry eIsDrum;
156     NumEntryTemp<uint16_t> eMIDIBank;
157     NumEntryTemp<uint32_t> eMIDIProgram;
158     NumEntryGain eAttenuation;
159     BoolEntryPlus6 eGainPlus6;
160     NumEntryTemp<uint16_t> eEffectSend;
161     NumEntryTemp<int16_t> eFineTune;
162     NumEntryTemp<uint16_t> ePitchbendRange;
163     BoolEntry ePianoReleaseMode;
164     NoteEntry eDimensionKeyRangeLow;
165     NoteEntry eDimensionKeyRangeHigh;
166 persson 1261 sigc::signal<void> instrument_changed;
167 schoenebeck 1225 };
168    
169     class LoadDialog : public Gtk::Dialog {
170     public:
171     LoadDialog(const Glib::ustring& title, Gtk::Window& parent);
172     void set_fraction(float fraction) { progressBar.set_fraction(fraction); }
173     protected:
174     Gtk::ProgressBar progressBar;
175     };
176    
177     class Loader : public sigc::trackable {
178     public:
179     Loader(const char* filename);
180     void launch();
181     Glib::Dispatcher& signal_progress();
182     Glib::Dispatcher& signal_finished();
183     void progress_callback(float fraction);
184     float get_progress();
185     const char* filename;
186     gig::File* gig;
187    
188     private:
189     Glib::Thread* thread;
190     void thread_function();
191     Glib::Dispatcher finished_dispatcher;
192     Glib::Dispatcher progress_dispatcher;
193     Glib::Mutex progressMutex;
194     float progress;
195     };
196    
197     class MainWindow : public Gtk::Window {
198     public:
199     MainWindow();
200     virtual ~MainWindow();
201     void load_file(const char* name);
202     void load_instrument(gig::Instrument* instr);
203 persson 1261 void file_changed();
204 schoenebeck 1339 sigc::signal<void, gig::File*>& signal_file_structure_to_be_changed();
205     sigc::signal<void, gig::File*>& signal_file_structure_changed();
206     sigc::signal<void, std::list<gig::Sample*> >& signal_samples_to_be_removed();
207     sigc::signal<void>& signal_samples_removed();
208     sigc::signal<void, gig::Region*>& signal_region_to_be_changed();
209     sigc::signal<void, gig::Region*>& signal_region_changed();
210     sigc::signal<void, gig::DimensionRegion*>& signal_dimreg_to_be_changed();
211     sigc::signal<void, gig::DimensionRegion*>& signal_dimreg_changed();
212 schoenebeck 1853 sigc::signal<void, gig::Sample*>& signal_sample_changed();
213 schoenebeck 1339 sigc::signal<void, gig::Sample*/*old*/, gig::Sample*/*new*/>& signal_sample_ref_changed();
214 schoenebeck 1225
215 schoenebeck 1654 sigc::signal<void, int/*key*/, int/*velocity*/>& signal_note_on();
216     sigc::signal<void, int/*key*/, int/*velocity*/>& signal_note_off();
217    
218 schoenebeck 1660 sigc::signal<void, int/*key*/, int/*velocity*/>& signal_keyboard_key_hit();
219     sigc::signal<void, int/*key*/, int/*velocity*/>& signal_keyboard_key_released();
220    
221 schoenebeck 1225 protected:
222     Glib::RefPtr<Gtk::ActionGroup> actionGroup;
223     Glib::RefPtr<Gtk::UIManager> uiManager;
224    
225 schoenebeck 1411 Gtk::Statusbar m_StatusBar;
226     Gtk::Label m_AttachedStateLabel;
227     Gtk::Image m_AttachedStateImage;
228    
229 schoenebeck 1225 RegionChooser m_RegionChooser;
230     DimRegionChooser m_DimRegionChooser;
231    
232     PropDialog propDialog;
233     InstrumentProps instrumentProps;
234    
235 schoenebeck 1322 sigc::signal<void, gig::File*> file_structure_to_be_changed_signal;
236     sigc::signal<void, gig::File*> file_structure_changed_signal;
237     sigc::signal<void, std::list<gig::Sample*> > samples_to_be_removed_signal;
238     sigc::signal<void> samples_removed_signal;
239     sigc::signal<void, gig::Region*> region_to_be_changed_signal;
240     sigc::signal<void, gig::Region*> region_changed_signal;
241     sigc::signal<void, gig::DimensionRegion*> dimreg_to_be_changed_signal;
242     sigc::signal<void, gig::DimensionRegion*> dimreg_changed_signal;
243 schoenebeck 1853 sigc::signal<void, gig::Sample*> sample_changed_signal;
244 schoenebeck 1322 sigc::signal<void, gig::Sample*/*old*/, gig::Sample*/*new*/> sample_ref_changed_signal;
245    
246 schoenebeck 1654 sigc::signal<void, int/*key*/, int/*velocity*/> note_on_signal;
247     sigc::signal<void, int/*key*/, int/*velocity*/> note_off_signal;
248    
249 schoenebeck 1225 void on_instrument_selection_change(int index);
250     void on_sel_change();
251     void region_changed();
252     void dimreg_changed();
253     void on_loader_progress();
254     void on_loader_finished();
255 persson 1533 void dimreg_all_dimregs_toggled();
256     gig::Instrument* get_instrument();
257     void add_region_to_dimregs(gig::Region* region, bool stereo, bool all_dimregs);
258     void update_dimregs();
259 schoenebeck 1225
260     class ModelColumns : public Gtk::TreeModel::ColumnRecord {
261     public:
262     ModelColumns() {
263     add(m_col_name);
264     add(m_col_instr);
265     }
266    
267     Gtk::TreeModelColumn<Glib::ustring> m_col_name;
268     Gtk::TreeModelColumn<gig::Instrument*> m_col_instr;
269     } m_Columns;
270    
271     Gtk::VBox m_VBox;
272     Gtk::HPaned m_HPaned;
273    
274     Gtk::ScrolledWindow m_ScrolledWindow;
275    
276     Gtk::TreeView m_TreeView;
277     Glib::RefPtr<Gtk::ListStore> m_refTreeModel;
278    
279     class SamplesModel : public Gtk::TreeModel::ColumnRecord {
280     public:
281     SamplesModel() {
282     add(m_col_name);
283     add(m_col_sample);
284     add(m_col_group);
285     }
286    
287     Gtk::TreeModelColumn<Glib::ustring> m_col_name;
288     Gtk::TreeModelColumn<gig::Sample*> m_col_sample;
289     Gtk::TreeModelColumn<gig::Group*> m_col_group;
290     } m_SamplesModel;
291    
292     class SamplesTreeStore : public Gtk::TreeStore {
293     public:
294     static Glib::RefPtr<SamplesTreeStore> create(const SamplesModel& columns) {
295     return Glib::RefPtr<SamplesTreeStore>( new SamplesTreeStore(columns) );
296     }
297     protected:
298     SamplesTreeStore(const SamplesModel& columns) : Gtk::TreeStore(columns) {}
299     };
300    
301     Gtk::ScrolledWindow m_ScrolledWindowSamples;
302     Gtk::TreeView m_TreeViewSamples;
303     Glib::RefPtr<SamplesTreeStore> m_refSamplesTreeModel;
304    
305 persson 1533 Gtk::VBox dimreg_vbox;
306     Gtk::HBox dimreg_hbox;
307     Gtk::Label dimreg_label;
308     Gtk::CheckButton dimreg_all_regions;
309     Gtk::CheckButton dimreg_all_dimregs;
310     Gtk::CheckButton dimreg_stereo;
311 schoenebeck 1225 DimRegionEdit dimreg_edit;
312    
313     Gtk::Notebook m_Notebook;
314     Gtk::Notebook m_TreeViewNotebook;
315    
316     struct SampleImportItem {
317     gig::Sample* gig_sample; // pointer to the gig::Sample to
318     // which the sample data should be
319     // imported to
320     Glib::ustring sample_path; // file name of the sample to be
321     // imported
322     };
323     std::list<SampleImportItem> m_SampleImportQueue;
324    
325    
326     void on_action_file_new();
327     void on_action_file_open();
328     void on_action_file_save();
329     void on_action_file_save_as();
330     void on_action_file_properties();
331 persson 1261 void on_action_quit();
332 schoenebeck 1225 void show_instr_props();
333 schoenebeck 1415 void on_action_view_status_bar();
334 schoenebeck 1225 void on_action_help_about();
335    
336     // sample right-click popup actions
337     void on_sample_treeview_button_release(GdkEventButton* button);
338     void on_action_sample_properties();
339     void on_action_add_group();
340     void on_action_add_sample();
341 schoenebeck 1673 void on_action_replace_all_samples_in_all_groups();
342 schoenebeck 1225 void on_action_remove_sample();
343    
344     void on_action_add_instrument();
345     void on_action_remove_instrument();
346    
347     LoadDialog* load_dialog;
348     Loader* loader;
349 schoenebeck 1382 void load_gig(gig::File* gig, const char* filename, bool isSharedInstrument = false);
350 schoenebeck 1225
351     gig::File* file;
352 schoenebeck 1382 bool file_is_shared;
353 persson 1261 bool file_has_name;
354     bool file_is_changed;
355     std::string filename;
356 persson 1725 std::string current_gig_dir;
357     std::string current_sample_dir;
358 schoenebeck 1225
359 schoenebeck 1411 void set_file_is_shared(bool);
360    
361 persson 1261 bool file_save();
362     bool file_save_as();
363 persson 1303 bool check_if_savable();
364 persson 1261
365 schoenebeck 1225 void on_button_release(GdkEventButton* button);
366 persson 1303 void on_sample_treeview_drag_begin(const Glib::RefPtr<Gdk::DragContext>& context);
367 schoenebeck 1225 void on_sample_treeview_drag_data_get(const Glib::RefPtr<Gdk::DragContext>&,
368     Gtk::SelectionData& selection_data, guint, guint);
369     void on_sample_label_drop_drag_data_received(const Glib::RefPtr<Gdk::DragContext>& context,
370     int, int,
371     const Gtk::SelectionData& selection_data,
372     guint, guint time);
373 persson 1303
374 schoenebeck 1225 void sample_name_changed(const Gtk::TreeModel::Path& path,
375     const Gtk::TreeModel::iterator& iter);
376     void instrument_name_changed(const Gtk::TreeModel::Path& path,
377     const Gtk::TreeModel::iterator& iter);
378    
379     void __import_queued_samples();
380     void __clear();
381    
382 persson 1261 bool close_confirmation_dialog();
383 schoenebeck 1382 bool leaving_shared_mode_dialog();
384 persson 1261
385 schoenebeck 1225 Gtk::Menu* popup_menu;
386 persson 1261
387     bool on_delete_event(GdkEventAny* event);
388 persson 1303
389     bool first_call_to_drag_data_get;
390 schoenebeck 1225 };
391    
392     #endif

  ViewVC Help
Powered by ViewVC