| 1 |
#ifndef _NoulliGridEditor_h_ |
| 2 |
#define _NoulliGridEditor_h_ |
| 3 |
/* NoulliGridEditor.h |
| 4 |
* |
| 5 |
* Copyright (C) 2018,2020-2023 Paul Boersma |
| 6 |
* |
| 7 |
* This code is free software; you can redistribute it and/or modify |
| 8 |
* it under the terms of the GNU General Public License as published by |
| 9 |
* the Free Software Foundation; either version 2 of the License, or (at |
| 10 |
* your option) any later version. |
| 11 |
* |
| 12 |
* This code is distributed in the hope that it will be useful, but |
| 13 |
* WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| 15 |
* See the GNU General Public License for more details. |
| 16 |
* |
| 17 |
* You should have received a copy of the GNU General Public License |
| 18 |
* along with this work. If not, see <http://www.gnu.org/licenses/>. |
| 19 |
*/ |
| 20 |
|
| 21 |
#include "FunctionEditor.h" |
| 22 |
#include "NoulliGridArea.h" |
| 23 |
#include "SoundArea.h" |
| 24 |
|
| 25 |
#include "NoulliGridEditor_enums.h" |
| 26 |
|
| 27 |
Thing_define (NoulliGridEditor, FunctionEditor) { |
| 28 |
DEFINE_FunctionArea (1, NoulliGridArea, noulliGridArea) |
| 29 |
DEFINE_FunctionArea (2, SoundArea, soundArea) |
| 30 |
NoulliGrid noulliGrid () { return static_cast <NoulliGrid> (our data()); } |
| 31 |
|
| 32 |
void v1_dataChanged (Editor sender) override { |
| 33 |
NoulliGridEditor_Parent :: v1_dataChanged (sender); |
| 34 |
our noulliGridArea() -> functionChanged (static_cast <NoulliGrid> (our data())); |
| 35 |
if (our soundArea()) |
| 36 |
our soundArea() -> functionChanged (nullptr); |
| 37 |
} |
| 38 |
void v_distributeAreas () override { |
| 39 |
if (our soundArea()) { |
| 40 |
our noulliGridArea() -> setGlobalYRange_fraction (0.0, 0.8); |
| 41 |
our soundArea() -> setGlobalYRange_fraction (0.8, 1.0); |
| 42 |
} else { |
| 43 |
our noulliGridArea() -> setGlobalYRange_fraction (0.0, 1.0); |
| 44 |
} |
| 45 |
} |
| 46 |
void v_play (double startTime, double endTime) override { |
| 47 |
if (our soundArea()) |
| 48 |
Sound_playPart (our soundArea() -> sound(), startTime, endTime, theFunctionEditor_playCallback, this); |
| 49 |
} |
| 50 |
void v_drawLegends () override { |
| 51 |
FunctionArea_drawLegend (our noulliGridArea().get(), |
| 52 |
U" NoulliGrid", |
| 53 |
DataGui_defaultForegroundColour (our noulliGridArea().get(), false) |
| 54 |
); |
| 55 |
if (our soundArea()) |
| 56 |
FunctionArea_drawLegend (our soundArea().get(), |
| 57 |
FunctionArea_legend_WAVEFORM U" %%non-modifiable copy of sound", |
| 58 |
DataGui_defaultForegroundColour (our soundArea().get(), false) |
| 59 |
); |
| 60 |
} |
| 61 |
void v_prefs_addFields (EditorCommand cmd) |
| 62 |
override; |
| 63 |
void v_prefs_setValues (EditorCommand cmd) |
| 64 |
override; |
| 65 |
void v_prefs_getValues (EditorCommand cmd) |
| 66 |
override; |
| 67 |
bool v_hasSelectionViewer () |
| 68 |
override { return true; } |
| 69 |
void v_drawSelectionViewer () |
| 70 |
override; |
| 71 |
void v_drawRealTimeSelectionViewer (double time) |
| 72 |
override; |
| 73 |
|
| 74 |
#include "NoulliGridEditor_prefs.h" |
| 75 |
}; |
| 76 |
|
| 77 |
autoNoulliGridEditor NoulliGridEditor_create (conststring32 title, NoulliGrid grid, Sound optionalSoundToCopy); |
| 78 |
|
| 79 |
/* End of file NoulliGridEditor.h */ |
| 80 |
#endif |