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 |
|
121 |
protected: |
122 |
Glib::RefPtr<Gtk::ActionGroup> actionGroup; |
123 |
Glib::RefPtr<Gtk::UIManager> uiManager; |
124 |
|
125 |
RegionChooser m_RegionChooser; |
126 |
DimRegionChooser m_DimRegionChooser; |
127 |
|
128 |
PropDialog propDialog; |
129 |
InstrumentProps instrumentProps; |
130 |
|
131 |
void on_instrument_selection_change(int index); |
132 |
void on_sel_change(); |
133 |
void region_changed(); |
134 |
void dimreg_changed(); |
135 |
void on_loader_progress(); |
136 |
void on_loader_finished(); |
137 |
|
138 |
class ModelColumns : public Gtk::TreeModel::ColumnRecord { |
139 |
public: |
140 |
ModelColumns() { |
141 |
add(m_col_name); |
142 |
add(m_col_instr); |
143 |
} |
144 |
|
145 |
Gtk::TreeModelColumn<Glib::ustring> m_col_name; |
146 |
Gtk::TreeModelColumn<gig::Instrument*> m_col_instr; |
147 |
} m_Columns; |
148 |
|
149 |
Gtk::VBox m_VBox; |
150 |
Gtk::HPaned m_HPaned; |
151 |
|
152 |
Gtk::ScrolledWindow m_ScrolledWindow; |
153 |
|
154 |
Gtk::TreeView m_TreeView; |
155 |
Glib::RefPtr<Gtk::ListStore> m_refTreeModel; |
156 |
|
157 |
class SamplesModel : public Gtk::TreeModel::ColumnRecord { |
158 |
public: |
159 |
SamplesModel() { |
160 |
add(m_col_name); |
161 |
add(m_col_sample); |
162 |
add(m_col_group); |
163 |
} |
164 |
|
165 |
Gtk::TreeModelColumn<Glib::ustring> m_col_name; |
166 |
Gtk::TreeModelColumn<gig::Sample*> m_col_sample; |
167 |
Gtk::TreeModelColumn<gig::Group*> m_col_group; |
168 |
} m_SamplesModel; |
169 |
|
170 |
class SamplesTreeStore : public Gtk::TreeStore { |
171 |
public: |
172 |
static Glib::RefPtr<SamplesTreeStore> create(const SamplesModel& columns) { |
173 |
return Glib::RefPtr<SamplesTreeStore>( new SamplesTreeStore(columns) ); |
174 |
} |
175 |
protected: |
176 |
SamplesTreeStore(const SamplesModel& columns) : Gtk::TreeStore(columns) {} |
177 |
}; |
178 |
|
179 |
Gtk::ScrolledWindow m_ScrolledWindowSamples; |
180 |
Gtk::TreeView m_TreeViewSamples; |
181 |
Glib::RefPtr<SamplesTreeStore> m_refSamplesTreeModel; |
182 |
|
183 |
DimRegionEdit dimreg_edit; |
184 |
|
185 |
Gtk::Notebook m_Notebook; |
186 |
Gtk::Notebook m_TreeViewNotebook; |
187 |
|
188 |
struct SampleImportItem { |
189 |
gig::Sample* gig_sample; // pointer to the gig::Sample to |
190 |
// which the sample data should be |
191 |
// imported to |
192 |
Glib::ustring sample_path; // file name of the sample to be |
193 |
// imported |
194 |
}; |
195 |
std::list<SampleImportItem> m_SampleImportQueue; |
196 |
|
197 |
|
198 |
void on_action_file_new(); |
199 |
void on_action_file_open(); |
200 |
void on_action_file_save(); |
201 |
void on_action_file_save_as(); |
202 |
void on_action_file_properties(); |
203 |
void on_action_quit(); |
204 |
void show_instr_props(); |
205 |
void on_action_help_about(); |
206 |
|
207 |
// sample right-click popup actions |
208 |
void on_sample_treeview_button_release(GdkEventButton* button); |
209 |
void on_action_sample_properties(); |
210 |
void on_action_add_group(); |
211 |
void on_action_add_sample(); |
212 |
void on_action_remove_sample(); |
213 |
|
214 |
void on_action_add_instrument(); |
215 |
void on_action_remove_instrument(); |
216 |
|
217 |
LoadDialog* load_dialog; |
218 |
Loader* loader; |
219 |
void load_gig(gig::File* gig, const char* filename); |
220 |
|
221 |
gig::File* file; |
222 |
bool file_has_name; |
223 |
bool file_is_changed; |
224 |
std::string filename; |
225 |
std::string current_dir; |
226 |
|
227 |
bool file_save(); |
228 |
bool file_save_as(); |
229 |
|
230 |
void on_button_release(GdkEventButton* button); |
231 |
void on_sample_treeview_drag_data_get(const Glib::RefPtr<Gdk::DragContext>&, |
232 |
Gtk::SelectionData& selection_data, guint, guint); |
233 |
void on_sample_label_drop_drag_data_received(const Glib::RefPtr<Gdk::DragContext>& context, |
234 |
int, int, |
235 |
const Gtk::SelectionData& selection_data, |
236 |
guint, guint time); |
237 |
void sample_name_changed(const Gtk::TreeModel::Path& path, |
238 |
const Gtk::TreeModel::iterator& iter); |
239 |
void instrument_name_changed(const Gtk::TreeModel::Path& path, |
240 |
const Gtk::TreeModel::iterator& iter); |
241 |
|
242 |
void __import_queued_samples(); |
243 |
void __clear(); |
244 |
|
245 |
bool close_confirmation_dialog(); |
246 |
|
247 |
Gtk::Menu* popup_menu; |
248 |
|
249 |
bool on_delete_event(GdkEventAny* event); |
250 |
}; |
251 |
|
252 |
#endif |