/[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 1415 - (show annotations) (download) (as text)
Sat Oct 13 13:14:10 2007 UTC (16 years, 5 months ago) by schoenebeck
File MIME type: text/x-c++hdr
File size: 9360 byte(s)
* statusbar can be hidden by menu

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_view_status_bar();
231 void on_action_help_about();
232
233 // sample right-click popup actions
234 void on_sample_treeview_button_release(GdkEventButton* button);
235 void on_action_sample_properties();
236 void on_action_add_group();
237 void on_action_add_sample();
238 void on_action_remove_sample();
239
240 void on_action_add_instrument();
241 void on_action_remove_instrument();
242
243 LoadDialog* load_dialog;
244 Loader* loader;
245 void load_gig(gig::File* gig, const char* filename, bool isSharedInstrument = false);
246
247 gig::File* file;
248 bool file_is_shared;
249 bool file_has_name;
250 bool file_is_changed;
251 std::string filename;
252 std::string current_dir;
253
254 void set_file_is_shared(bool);
255
256 bool file_save();
257 bool file_save_as();
258 bool check_if_savable();
259
260 void on_button_release(GdkEventButton* button);
261 void on_sample_treeview_drag_begin(const Glib::RefPtr<Gdk::DragContext>& context);
262 void on_sample_treeview_drag_data_get(const Glib::RefPtr<Gdk::DragContext>&,
263 Gtk::SelectionData& selection_data, guint, guint);
264 void on_sample_label_drop_drag_data_received(const Glib::RefPtr<Gdk::DragContext>& context,
265 int, int,
266 const Gtk::SelectionData& selection_data,
267 guint, guint time);
268
269 void sample_name_changed(const Gtk::TreeModel::Path& path,
270 const Gtk::TreeModel::iterator& iter);
271 void instrument_name_changed(const Gtk::TreeModel::Path& path,
272 const Gtk::TreeModel::iterator& iter);
273
274 void __import_queued_samples();
275 void __clear();
276
277 bool close_confirmation_dialog();
278 bool leaving_shared_mode_dialog();
279
280 Gtk::Menu* popup_menu;
281
282 bool on_delete_event(GdkEventAny* event);
283
284 bool first_call_to_drag_data_get;
285 };
286
287 #endif

  ViewVC Help
Powered by ViewVC