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 |
protected: |
59 |
Gtk::VBox vbox; |
60 |
Gtk::HButtonBox buttonBox; |
61 |
Gtk::Button quitButton; |
62 |
Gtk::Table table; |
63 |
Gtk::Label label[10]; |
64 |
Gtk::Entry entry[8]; |
65 |
Gtk::CheckButton check[2]; |
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(LabelWidget& prop); |
80 |
void key_range_low_changed(); |
81 |
void key_range_high_changed(); |
82 |
}; |
83 |
|
84 |
class LoadDialog : public Gtk::Dialog { |
85 |
public: |
86 |
LoadDialog(const Glib::ustring& title, Gtk::Window& parent); |
87 |
void set_fraction(float fraction) { progressBar.set_fraction(fraction); } |
88 |
protected: |
89 |
Gtk::ProgressBar progressBar; |
90 |
}; |
91 |
|
92 |
class Loader : public sigc::trackable { |
93 |
public: |
94 |
Loader(const char* filename); |
95 |
void launch(); |
96 |
Glib::Dispatcher& signal_progress(); |
97 |
Glib::Dispatcher& signal_finished(); |
98 |
void progress_callback(float fraction); |
99 |
float get_progress(); |
100 |
const char* filename; |
101 |
gig::File* gig; |
102 |
|
103 |
private: |
104 |
Glib::Thread* thread; |
105 |
void thread_function(); |
106 |
Glib::Dispatcher finished_dispatcher; |
107 |
Glib::Dispatcher progress_dispatcher; |
108 |
Glib::Mutex progressMutex; |
109 |
float progress; |
110 |
}; |
111 |
|
112 |
class MainWindow : public Gtk::Window { |
113 |
public: |
114 |
MainWindow(); |
115 |
virtual ~MainWindow(); |
116 |
void load_file(const char* name); |
117 |
void load_instrument(gig::Instrument* instr); |
118 |
|
119 |
protected: |
120 |
Glib::RefPtr<Gtk::ActionGroup> actionGroup; |
121 |
Glib::RefPtr<Gtk::UIManager> uiManager; |
122 |
|
123 |
RegionChooser m_RegionChooser; |
124 |
DimRegionChooser m_DimRegionChooser; |
125 |
|
126 |
PropDialog propDialog; |
127 |
InstrumentProps instrumentProps; |
128 |
|
129 |
void on_instrument_selection_change(int index); |
130 |
void on_sel_change(); |
131 |
void region_changed(); |
132 |
void dimreg_changed(); |
133 |
void on_loader_progress(); |
134 |
void on_loader_finished(); |
135 |
|
136 |
class ModelColumns : public Gtk::TreeModel::ColumnRecord { |
137 |
public: |
138 |
ModelColumns() { |
139 |
add(m_col_name); |
140 |
add(m_col_instr); |
141 |
} |
142 |
|
143 |
Gtk::TreeModelColumn<Glib::ustring> m_col_name; |
144 |
Gtk::TreeModelColumn<gig::Instrument*> m_col_instr; |
145 |
} m_Columns; |
146 |
|
147 |
Gtk::VBox m_VBox; |
148 |
Gtk::HPaned m_HPaned; |
149 |
|
150 |
Gtk::ScrolledWindow m_ScrolledWindow; |
151 |
|
152 |
Gtk::TreeView m_TreeView; |
153 |
Glib::RefPtr<Gtk::ListStore> m_refTreeModel; |
154 |
|
155 |
class SamplesModel : public Gtk::TreeModel::ColumnRecord { |
156 |
public: |
157 |
SamplesModel() { |
158 |
add(m_col_name); |
159 |
add(m_col_sample); |
160 |
add(m_col_group); |
161 |
} |
162 |
|
163 |
Gtk::TreeModelColumn<Glib::ustring> m_col_name; |
164 |
Gtk::TreeModelColumn<gig::Sample*> m_col_sample; |
165 |
Gtk::TreeModelColumn<gig::Group*> m_col_group; |
166 |
} m_SamplesModel; |
167 |
|
168 |
class SamplesTreeStore : public Gtk::TreeStore { |
169 |
public: |
170 |
static Glib::RefPtr<SamplesTreeStore> create(const SamplesModel& columns) { |
171 |
return Glib::RefPtr<SamplesTreeStore>( new SamplesTreeStore(columns) ); |
172 |
} |
173 |
protected: |
174 |
SamplesTreeStore(const SamplesModel& columns) : Gtk::TreeStore(columns) {} |
175 |
}; |
176 |
|
177 |
Gtk::ScrolledWindow m_ScrolledWindowSamples; |
178 |
Gtk::TreeView m_TreeViewSamples; |
179 |
Glib::RefPtr<SamplesTreeStore> m_refSamplesTreeModel; |
180 |
|
181 |
DimRegionEdit dimreg_edit; |
182 |
|
183 |
Gtk::Notebook m_Notebook; |
184 |
Gtk::Notebook m_TreeViewNotebook; |
185 |
|
186 |
struct SampleImportItem { |
187 |
gig::Sample* gig_sample; // pointer to the gig::Sample to |
188 |
// which the sample data should be |
189 |
// imported to |
190 |
Glib::ustring sample_path; // file name of the sample to be |
191 |
// imported |
192 |
}; |
193 |
std::list<SampleImportItem> m_SampleImportQueue; |
194 |
|
195 |
|
196 |
void on_action_file_new(); |
197 |
void on_action_file_open(); |
198 |
void on_action_file_save(); |
199 |
void on_action_file_save_as(); |
200 |
void on_action_file_properties(); |
201 |
void show_instr_props(); |
202 |
void on_action_help_about(); |
203 |
|
204 |
// sample right-click popup actions |
205 |
void on_sample_treeview_button_release(GdkEventButton* button); |
206 |
void on_action_sample_properties(); |
207 |
void on_action_add_group(); |
208 |
void on_action_add_sample(); |
209 |
void on_action_remove_sample(); |
210 |
|
211 |
void on_action_add_instrument(); |
212 |
void on_action_remove_instrument(); |
213 |
|
214 |
LoadDialog* load_dialog; |
215 |
Loader* loader; |
216 |
void load_gig(gig::File* gig, const char* filename); |
217 |
|
218 |
gig::File* file; |
219 |
|
220 |
void on_button_release(GdkEventButton* button); |
221 |
void on_sample_treeview_drag_data_get(const Glib::RefPtr<Gdk::DragContext>&, |
222 |
Gtk::SelectionData& selection_data, guint, guint); |
223 |
void on_sample_label_drop_drag_data_received(const Glib::RefPtr<Gdk::DragContext>& context, |
224 |
int, int, |
225 |
const Gtk::SelectionData& selection_data, |
226 |
guint, guint time); |
227 |
void sample_name_changed(const Gtk::TreeModel::Path& path, |
228 |
const Gtk::TreeModel::iterator& iter); |
229 |
void instrument_name_changed(const Gtk::TreeModel::Path& path, |
230 |
const Gtk::TreeModel::iterator& iter); |
231 |
|
232 |
void __import_queued_samples(); |
233 |
void __clear(); |
234 |
|
235 |
Gtk::Menu* popup_menu; |
236 |
}; |
237 |
|
238 |
#endif |