/[svn]/gigedit/trunk/src/gigedit/mainwindow.h
ViewVC logotype

Annotation of /gigedit/trunk/src/gigedit/mainwindow.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1261 - (hide annotations) (download) (as text)
Thu Jul 5 17:12:20 2007 UTC (16 years, 8 months ago) by persson
File MIME type: text/x-c++hdr
File size: 7506 byte(s)
* a changed file is now marked with an asterisk in the window title
* added close confirmation dialog, shown if file is changed
* "save" means "save as" for new files
* enabled acceleration keys
* add .gig to filename in "save as" if it's not already there
* filename character encodings other than utf-8 supported

1 schoenebeck 1225 /* -*- 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 persson 1261 sigc::signal<void> signal_instrument_changed();
59 schoenebeck 1225 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(LabelWidget& prop);
78     void key_range_low_changed();
79     void key_range_high_changed();
80 persson 1261 sigc::signal<void> instrument_changed;
81 schoenebeck 1225 };
82    
83     class LoadDialog : public Gtk::Dialog {
84     public:
85     LoadDialog(const Glib::ustring& title, Gtk::Window& parent);
86     void set_fraction(float fraction) { progressBar.set_fraction(fraction); }
87     protected:
88     Gtk::ProgressBar progressBar;
89     };
90    
91     class Loader : public sigc::trackable {
92     public:
93     Loader(const char* filename);
94     void launch();
95     Glib::Dispatcher& signal_progress();
96     Glib::Dispatcher& signal_finished();
97     void progress_callback(float fraction);
98     float get_progress();
99     const char* filename;
100     gig::File* gig;
101    
102     private:
103     Glib::Thread* thread;
104     void thread_function();
105     Glib::Dispatcher finished_dispatcher;
106     Glib::Dispatcher progress_dispatcher;
107     Glib::Mutex progressMutex;
108     float progress;
109     };
110    
111     class MainWindow : public Gtk::Window {
112     public:
113     MainWindow();
114     virtual ~MainWindow();
115     void load_file(const char* name);
116     void load_instrument(gig::Instrument* instr);
117 persson 1261 void file_changed();
118 schoenebeck 1225
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 persson 1261 void on_action_quit();
202 schoenebeck 1225 void show_instr_props();
203     void on_action_help_about();
204    
205     // sample right-click popup actions
206     void on_sample_treeview_button_release(GdkEventButton* button);
207     void on_action_sample_properties();
208     void on_action_add_group();
209     void on_action_add_sample();
210     void on_action_remove_sample();
211    
212     void on_action_add_instrument();
213     void on_action_remove_instrument();
214    
215     LoadDialog* load_dialog;
216     Loader* loader;
217     void load_gig(gig::File* gig, const char* filename);
218    
219     gig::File* file;
220 persson 1261 bool file_has_name;
221     bool file_is_changed;
222     std::string filename;
223     std::string current_dir;
224 schoenebeck 1225
225 persson 1261 bool file_save();
226     bool file_save_as();
227    
228 schoenebeck 1225 void on_button_release(GdkEventButton* button);
229     void on_sample_treeview_drag_data_get(const Glib::RefPtr<Gdk::DragContext>&,
230     Gtk::SelectionData& selection_data, guint, guint);
231     void on_sample_label_drop_drag_data_received(const Glib::RefPtr<Gdk::DragContext>& context,
232     int, int,
233     const Gtk::SelectionData& selection_data,
234     guint, guint time);
235     void sample_name_changed(const Gtk::TreeModel::Path& path,
236     const Gtk::TreeModel::iterator& iter);
237     void instrument_name_changed(const Gtk::TreeModel::Path& path,
238     const Gtk::TreeModel::iterator& iter);
239    
240     void __import_queued_samples();
241     void __clear();
242    
243 persson 1261 bool close_confirmation_dialog();
244    
245 schoenebeck 1225 Gtk::Menu* popup_menu;
246 persson 1261
247     bool on_delete_event(GdkEventAny* event);
248 schoenebeck 1225 };
249    
250     #endif

  ViewVC Help
Powered by ViewVC