Debian Codegraph @

gram/CubeGridEditor.h

raw
1 #ifndef _CubeGridEditor_h_
2 #define _CubeGridEditor_h_
3 /* CubeGridEditor.h
4 *
5 * Copyright (C) 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 "CubeGridArea.h"
23 #include "SoundArea.h"
24
25 Thing_define (CubeGridEditor, FunctionEditor) {
26 DEFINE_FunctionArea (1, CubeGridArea, cubeGridArea)
27 DEFINE_FunctionArea (2, SoundArea, soundArea)
28 CubeGrid cubeGrid () { return static_cast <CubeGrid> (our data()); }
29
30 void v1_dataChanged (Editor sender) override {
31 CubeGridEditor_Parent :: v1_dataChanged (sender);
32 our cubeGridArea() -> functionChanged (static_cast <CubeGrid> (our data()));
33 if (our soundArea())
34 our soundArea() -> functionChanged (nullptr);
35 }
36 void v_distributeAreas () override {
37 if (our soundArea()) {
38 our cubeGridArea() -> setGlobalYRange_fraction (0.0, 0.8);
39 our soundArea() -> setGlobalYRange_fraction (0.8, 1.0);
40 } else {
41 our cubeGridArea() -> setGlobalYRange_fraction (0.0, 1.0);
42 }
43 }
44 void v_play (double startTime, double endTime) override {
45 if (our soundArea())
46 Sound_playPart (our soundArea() -> sound(), startTime, endTime, theFunctionEditor_playCallback, this);
47 }
48 void v_drawLegends () override {
49 FunctionArea_drawLegend (our cubeGridArea().get(),
50 U" CubeGrid",
51 DataGui_defaultForegroundColour (our cubeGridArea().get(), false)
52 );
53 if (our soundArea())
54 FunctionArea_drawLegend (our soundArea().get(),
55 FunctionArea_legend_WAVEFORM U" %%non-modifiable copy of sound",
56 DataGui_defaultForegroundColour (our soundArea().get(), false)
57 );
58 }
59 bool v_hasSelectionViewer ()
60 override { return true; }
61 void v_drawSelectionViewer ()
62 override;
63 void v_drawRealTimeSelectionViewer (double time)
64 override;
65
66 #include "CubeGridEditor_prefs.h"
67 };
68
69 autoCubeGridEditor CubeGridEditor_create (conststring32 title, CubeGrid grid, Sound optionalSoundToCopy);
70
71 /* End of file CubeGridEditor.h */
72 #endif