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