Debian Codegraph @

editor/import/audio_stream_import_settings.h

raw symbols SCIP
1 /**************************************************************************/
2 /* audio_stream_import_settings.h */
3 /**************************************************************************/
4 /* This file is part of: */
5 /* GODOT ENGINE */
6 /* https://godotengine.org */
7 /**************************************************************************/
8 /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
9 /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
10 /* */
11 /* Permission is hereby granted, free of charge, to any person obtaining */
12 /* a copy of this software and associated documentation files (the */
13 /* "Software"), to deal in the Software without restriction, including */
14 /* without limitation the rights to use, copy, modify, merge, publish, */
15 /* distribute, sublicense, and/or sell copies of the Software, and to */
16 /* permit persons to whom the Software is furnished to do so, subject to */
17 /* the following conditions: */
18 /* */
19 /* The above copyright notice and this permission notice shall be */
20 /* included in all copies or substantial portions of the Software. */
21 /* */
22 /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
23 /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
24 /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
25 /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
26 /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
27 /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
28 /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
29 /**************************************************************************/
30
31 #pragma once
32
33 #include "editor/plugins/editor_plugin.h"
34 #include "scene/audio/audio_stream_player.h"
35 #include "scene/gui/color_rect.h"
36 #include "scene/gui/dialogs.h"
37 #include "scene/gui/spin_box.h"
38
39 class CheckBox;
40
41 class AudioStreamImportSettingsDialog : public ConfirmationDialog {
42 GDCLASS(AudioStreamImportSettingsDialog, ConfirmationDialog);
43
44 CheckBox *bpm_enabled = nullptr;
45 SpinBox *bpm_edit = nullptr;
46 CheckBox *beats_enabled = nullptr;
47 SpinBox *beats_edit = nullptr;
48 Label *bar_beats_label = nullptr;
49 SpinBox *bar_beats_edit = nullptr;
50 CheckBox *loop = nullptr;
51 SpinBox *loop_offset = nullptr;
52 ColorRect *color_rect = nullptr;
53 Ref<AudioStream> stream;
54 AudioStreamPlayer *_player = nullptr;
55 ColorRect *_preview = nullptr;
56 Control *_indicator = nullptr;
57 Label *_current_label = nullptr;
58 Label *_duration_label = nullptr;
59
60 HScrollBar *zoom_bar = nullptr;
61 Button *zoom_in = nullptr;
62 Button *zoom_reset = nullptr;
63 Button *zoom_out = nullptr;
64
65 Button *_play_button = nullptr;
66 Button *_stop_button = nullptr;
67
68 bool updating_settings = false;
69
70 float _current = 0;
71 bool _dragging = false;
72 bool _beat_len_dragging = false;
73 bool _pausing = false;
74 int _hovering_beat = -1;
75
76 HashMap<StringName, Variant> params;
77 String importer;
78 String path;
79
80 struct MasterState {
81 bool mute = false;
82 bool bypass = false;
83 float volume = 0;
84 } master_state;
85
86 void _reset_master();
87 void _load_master_state();
88
89 void _audio_changed();
90
91 static AudioStreamImportSettingsDialog *singleton;
92
93 void _settings_changed();
94
95 void _reimport();
96
97 protected:
98 void _notification(int p_what);
99 void _preview_changed(ObjectID p_which);
100 void _preview_zoom_in();
101 void _preview_zoom_out();
102 void _preview_zoom_reset();
103 void _preview_zoom_offset_changed(double);
104
105 void _play();
106 void _stop();
107 void _on_finished();
108 void _draw_preview();
109 void _draw_indicator();
110 void _on_input_indicator(Ref<InputEvent> p_event);
111 void _seek_to(real_t p_x);
112 void _set_beat_len_to(real_t p_x);
113 void _on_indicator_mouse_exited();
114 int _get_beat_at_pos(real_t p_x);
115
116 public:
117 void edit(const String &p_path, const String &p_importer, const Ref<AudioStream> &p_stream);
118
119 static AudioStreamImportSettingsDialog *get_singleton() { return singleton; }
120
121 AudioStreamImportSettingsDialog();
122 };