Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
godotengine
GitHub Repository: godotengine/godot
Path: blob/master/editor/import/audio_stream_import_settings.h
9903 views
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
void _audio_changed();
81
82
static AudioStreamImportSettingsDialog *singleton;
83
84
void _settings_changed();
85
86
void _reimport();
87
88
protected:
89
void _notification(int p_what);
90
void _preview_changed(ObjectID p_which);
91
void _preview_zoom_in();
92
void _preview_zoom_out();
93
void _preview_zoom_reset();
94
void _preview_zoom_offset_changed(double);
95
96
void _play();
97
void _stop();
98
void _on_finished();
99
void _draw_preview();
100
void _draw_indicator();
101
void _on_input_indicator(Ref<InputEvent> p_event);
102
void _seek_to(real_t p_x);
103
void _set_beat_len_to(real_t p_x);
104
void _on_indicator_mouse_exited();
105
int _get_beat_at_pos(real_t p_x);
106
107
public:
108
void edit(const String &p_path, const String &p_importer, const Ref<AudioStream> &p_stream);
109
110
static AudioStreamImportSettingsDialog *get_singleton() { return singleton; }
111
112
AudioStreamImportSettingsDialog();
113
};
114
115