/[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 1411 - (show annotations) (download) (as text)
Fri Oct 12 17:46:29 2007 UTC (12 years, 2 months ago) by schoenebeck
File MIME type: text/x-c++hdr
File size: 9322 byte(s)
* added status bar to the bottom of main window (independent area on the
  right shows whether gigedit is running stand-alone or attached to
  LinuxSampler)
* minor cosmetical fix in dimension manager widget
* regionchooser.cpp: temporary fix for a crash which occured when gigedit
  was compiled with CXXFLAGS="-g"

1 /* -*- c++ -*-
2 * Copyright (C) 2006, 2007 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
44 class MainWindow;
45
46 class PropDialog : public Gtk::Window {
47 public:
48 PropDialog();
49 void set_info(DLS::Info* info);
50 protected:
51 Gtk::Table table;
52 Gtk::Label label[16];
53 Gtk::Entry entry[16];
54 };
55
56 class InstrumentProps : public Gtk::Window {
57 public:
58 InstrumentProps();
59 void set_instrument(gig::Instrument* instrument);
60 sigc::signal<void>& signal_instrument_changed();
61 protected:
62 Gtk::VBox vbox;
63 Gtk::HButtonBox buttonBox;
64 Gtk::Button quitButton;
65 Gtk::Table table;
66 StringEntry eName;
67 BoolEntry eIsDrum;
68 NumEntryTemp<uint16_t> eMIDIBank;
69 NumEntryTemp<uint32_t> eMIDIProgram;
70 NumEntryGain eAttenuation;
71 BoolEntryPlus6 eGainPlus6;
72 NumEntryTemp<uint16_t> eEffectSend;
73 NumEntryTemp<int16_t> eFineTune;
74 NumEntryTemp<uint16_t> ePitchbendRange;
75 BoolEntry ePianoReleaseMode;
76 NoteEntry eDimensionKeyRangeLow;
77 NoteEntry eDimensionKeyRangeHigh;
78 int rowno;
79 void add_prop(BoolEntry& prop);
80 void add_prop(BoolEntryPlus6& prop);
81 void add_prop(LabelWidget& prop);
82 void key_range_low_changed();
83 void key_range_high_changed();
84 sigc::signal<void> instrument_changed;
85 };
86
87 class LoadDialog : public Gtk::Dialog {
88 public:
89 LoadDialog(const Glib::ustring& title, Gtk::Window& parent);
90 void set_fraction(float fraction) { progressBar.set_fraction(fraction); }
91 protected:
92 Gtk::ProgressBar progressBar;
93 };
94
95 class Loader : public sigc::trackable {
96 public:
97 Loader(const char* filename);
98 void launch();
99 Glib::Dispatcher& signal_progress();
100 Glib::Dispatcher& signal_finished();
101 void progress_callback(float fraction);
102 float get_progress();
103 const char* filename;
104 gig::File* gig;
105
106 private:
107 Glib::Thread* thread;
108 void thread_function();
109 Glib::Dispatcher finished_dispatcher;
110 Glib::Dispatcher progress_dispatcher;
111 Glib::Mutex progressMutex;
112 float progress;
113 };
114
115 class MainWindow : public Gtk::Window {
116 public:
117 MainWindow();
118 virtual ~MainWindow();
119 void load_file(const char* name);
120 void load_instrument(gig::Instrument* instr);
121 void file_changed();
122 sigc::signal<void, gig::File*>& signal_file_structure_to_be_changed();
123 sigc::signal<void, gig::File*>& signal_file_structure_changed();
124 sigc::signal<void, std::list<gig::Sample*> >& signal_samples_to_be_removed();
125 sigc::signal<void>& signal_samples_removed();
126 sigc::signal<void, gig::Region*>& signal_region_to_be_changed();
127 sigc::signal<void, gig::Region*>& signal_region_changed();
128 sigc::signal<void, gig::DimensionRegion*>& signal_dimreg_to_be_changed();
129 sigc::signal<void, gig::DimensionRegion*>& signal_dimreg_changed();
130 sigc::signal<void, gig::Sample*/*old*/, gig::Sample*/*new*/>& signal_sample_ref_changed();
131
132 protected:
133 Glib::RefPtr<Gtk::ActionGroup> actionGroup;
134 Glib::RefPtr<Gtk::UIManager> uiManager;
135
136 Gtk::Statusbar m_StatusBar;
137 Gtk::Label m_AttachedStateLabel;
138 Gtk::Image m_AttachedStateImage;
139
140 RegionChooser m_RegionChooser;
141 DimRegionChooser m_DimRegionChooser;
142
143 PropDialog propDialog;
144 InstrumentProps instrumentProps;
145
146 sigc::signal<void, gig::File*> file_structure_to_be_changed_signal;
147 sigc::signal<void, gig::File*> file_structure_changed_signal;
148 sigc::signal<void, std::list<gig::Sample*> > samples_to_be_removed_signal;
149 sigc::signal<void> samples_removed_signal;
150 sigc::signal<void, gig::Region*> region_to_be_changed_signal;
151 sigc::signal<void, gig::Region*> region_changed_signal;
152 sigc::signal<void, gig::DimensionRegion*> dimreg_to_be_changed_signal;
153 sigc::signal<void, gig::DimensionRegion*> dimreg_changed_signal;
154 sigc::signal<void, gig::Sample*/*old*/, gig::Sample*/*new*/> sample_ref_changed_signal;
155
156 void on_instrument_selection_change(int index);
157 void on_sel_change();
158 void region_changed();
159 void dimreg_changed();
160 void on_loader_progress();
161 void on_loader_finished();
162
163 class ModelColumns : public Gtk::TreeModel::ColumnRecord {
164 public:
165 ModelColumns() {
166 add(m_col_name);
167 add(m_col_instr);
168 }
169
170 Gtk::TreeModelColumn<Glib::ustring> m_col_name;
171 Gtk::TreeModelColumn<gig::Instrument*> m_col_instr;
172 } m_Columns;
173
174 Gtk::VBox m_VBox;
175 Gtk::HPaned m_HPaned;
176
177 Gtk::ScrolledWindow m_ScrolledWindow;
178
179 Gtk::TreeView m_TreeView;
180 Glib::RefPtr<Gtk::ListStore> m_refTreeModel;
181
182 class SamplesModel : public Gtk::TreeModel::ColumnRecord {
183 public:
184 SamplesModel() {
185 add(m_col_name);
186 add(m_col_sample);
187 add(m_col_group);
188 }
189
190 Gtk::TreeModelColumn<Glib::ustring> m_col_name;
191 Gtk::TreeModelColumn<gig::Sample*> m_col_sample;
192 Gtk::TreeModelColumn<gig::Group*> m_col_group;
193 } m_SamplesModel;
194
195 class SamplesTreeStore : public Gtk::TreeStore {
196 public:
197 static Glib::RefPtr<SamplesTreeStore> create(const SamplesModel& columns) {
198 return Glib::RefPtr<SamplesTreeStore>( new SamplesTreeStore(columns) );
199 }
200 protected:
201 SamplesTreeStore(const SamplesModel& columns) : Gtk::TreeStore(columns) {}
202 };
203
204 Gtk::ScrolledWindow m_ScrolledWindowSamples;
205 Gtk::TreeView m_TreeViewSamples;
206 Glib::RefPtr<SamplesTreeStore> m_refSamplesTreeModel;
207
208 DimRegionEdit dimreg_edit;
209
210 Gtk::Notebook m_Notebook;
211 Gtk::Notebook m_TreeViewNotebook;
212
213 struct SampleImportItem {
214 gig::Sample* gig_sample; // pointer to the gig::Sample to
215 // which the sample data should be
216 // imported to
217 Glib::ustring sample_path; // file name of the sample to be
218 // imported
219 };
220 std::list<SampleImportItem> m_SampleImportQueue;
221
222
223 void on_action_file_new();
224 void on_action_file_open();
225 void on_action_file_save();
226 void on_action_file_save_as();
227 void on_action_file_properties();
228 void on_action_quit();
229 void show_instr_props();
230 void on_action_help_about();
231
232 // sample right-click popup actions
233 void on_sample_treeview_button_release(GdkEventButton* button);
234 void on_action_sample_properties();
235 void on_action_add_group();
236 void on_action_add_sample();
237 void on_action_remove_sample();
238
239 void on_action_add_instrument();
240 void on_action_remove_instrument();
241
242 LoadDialog* load_dialog;
243 Loader* loader;
244 void load_gig(gig::File* gig, const char* filename, bool isSharedInstrument = false);
245
246 gig::File* file;
247 bool file_is_shared;
248 bool file_has_name;
249 bool file_is_changed;
250 std::string filename;
251 std::string current_dir;
252
253 void set_file_is_shared(bool);
254
255 bool file_save();
256 bool file_save_as();
257 bool check_if_savable();
258
259 void on_button_release(GdkEventButton* button);
260 void on_sample_treeview_drag_begin(const Glib::RefPtr<Gdk::DragContext>& context);
261 void on_sample_treeview_drag_data_get(const Glib::RefPtr<Gdk::DragContext>&,
262 Gtk::SelectionData& selection_data, guint, guint);
263 void on_sample_label_drop_drag_data_received(const Glib::RefPtr<Gdk::DragContext>& context,
264 int, int,
265 const Gtk::SelectionData& selection_data,
266 guint, guint time);
267
268 void sample_name_changed(const Gtk::TreeModel::Path& path,
269 const Gtk::TreeModel::iterator& iter);
270 void instrument_name_changed(const Gtk::TreeModel::Path& path,
271 const Gtk::TreeModel::iterator& iter);
272
273 void __import_queued_samples();
274 void __clear();
275
276 bool close_confirmation_dialog();
277 bool leaving_shared_mode_dialog();
278
279 Gtk::Menu* popup_menu;
280
281 bool on_delete_event(GdkEventAny* event);
282
283 bool first_call_to_drag_data_get;
284 };
285
286 #endif

  ViewVC Help
Powered by ViewVC