1 |
/* |
/* |
2 |
* Copyright (C) 2007 Andreas Persson |
* Copyright (C) 2007, 2008 Andreas Persson |
3 |
* |
* |
4 |
* This program is free software; you can redistribute it and/or |
* This program is free software; you can redistribute it and/or |
5 |
* modify it under the terms of the GNU General Public License as |
* modify it under the terms of the GNU General Public License as |
20 |
#include "gigedit.h" |
#include "gigedit.h" |
21 |
|
|
22 |
#include <gtkmm/main.h> |
#include <gtkmm/main.h> |
23 |
|
#include <glibmm/main.h> |
24 |
#include "mainwindow.h" |
#include "mainwindow.h" |
25 |
|
|
26 |
#include "global.h" |
#include "global.h" |
40 |
GigEditState(GigEdit* parent) : parent(parent) { } |
GigEditState(GigEdit* parent) : parent(parent) { } |
41 |
void run(gig::Instrument* pInstrument); |
void run(gig::Instrument* pInstrument); |
42 |
|
|
43 |
|
MainWindow* window; |
44 |
|
|
45 |
private: |
private: |
46 |
|
|
47 |
// simple condition variable abstraction |
// simple condition variable abstraction |
74 |
Cond open; |
Cond open; |
75 |
Cond close; |
Cond close; |
76 |
gig::Instrument* instrument; |
gig::Instrument* instrument; |
|
MainWindow* window; |
|
77 |
|
|
78 |
void open_window(); |
void open_window(); |
79 |
void close_window(); |
void close_window(); |
130 |
mainwindow->signal_sample_ref_changed().connect( |
mainwindow->signal_sample_ref_changed().connect( |
131 |
gigedit->signal_sample_ref_changed().make_slot() |
gigedit->signal_sample_ref_changed().make_slot() |
132 |
); |
); |
133 |
|
mainwindow->signal_keyboard_key_hit().connect( |
134 |
|
gigedit->signal_keyboard_key_hit().make_slot() |
135 |
|
); |
136 |
|
mainwindow->signal_keyboard_key_released().connect( |
137 |
|
gigedit->signal_keyboard_key_released().make_slot() |
138 |
|
); |
139 |
} |
} |
140 |
|
|
141 |
} |
} // namespace |
142 |
|
|
143 |
|
GigEdit::GigEdit() { |
144 |
|
state = NULL; |
145 |
|
} |
146 |
|
|
147 |
int GigEdit::run(int argc, char* argv[]) { |
int GigEdit::run(int argc, char* argv[]) { |
148 |
init_app(); |
init_app(); |
159 |
init_app(); |
init_app(); |
160 |
|
|
161 |
GigEditState state(this); |
GigEditState state(this); |
162 |
|
this->state = &state; |
163 |
state.run(pInstrument); |
state.run(pInstrument); |
164 |
|
this->state = NULL; |
165 |
return 0; |
return 0; |
166 |
} |
} |
167 |
|
|
168 |
|
void GigEdit::on_note_on_event(int key, int velocity) { |
169 |
|
if (!this->state) return; |
170 |
|
GigEditState* state = (GigEditState*) this->state; |
171 |
|
state->window->signal_note_on().emit(key, velocity); |
172 |
|
} |
173 |
|
|
174 |
|
void GigEdit::on_note_off_event(int key, int velocity) { |
175 |
|
if (!this->state) return; |
176 |
|
GigEditState* state = (GigEditState*) this->state; |
177 |
|
state->window->signal_note_off().emit(key, velocity); |
178 |
|
} |
179 |
|
|
180 |
sigc::signal<void, gig::File*>& GigEdit::signal_file_structure_to_be_changed() { |
sigc::signal<void, gig::File*>& GigEdit::signal_file_structure_to_be_changed() { |
181 |
return file_structure_to_be_changed_signal; |
return file_structure_to_be_changed_signal; |
182 |
} |
} |
213 |
return sample_ref_changed_signal; |
return sample_ref_changed_signal; |
214 |
} |
} |
215 |
|
|
216 |
|
sigc::signal<void, int/*key*/, int/*velocity*/>& GigEdit::signal_keyboard_key_hit() { |
217 |
|
return keyboard_key_hit_signal; |
218 |
|
} |
219 |
|
|
220 |
|
sigc::signal<void, int/*key*/, int/*velocity*/>& GigEdit::signal_keyboard_key_released() { |
221 |
|
return keyboard_key_released_signal; |
222 |
|
} |
223 |
|
|
224 |
Glib::StaticMutex GigEditState::mutex = GLIBMM_STATIC_MUTEX_INIT; |
Glib::StaticMutex GigEditState::mutex = GLIBMM_STATIC_MUTEX_INIT; |
225 |
Glib::Dispatcher* GigEditState::dispatcher = 0; |
Glib::Dispatcher* GigEditState::dispatcher = 0; |