summaryrefslogtreecommitdiff
path: root/editor/editor_resource_picker.h
diff options
context:
space:
mode:
Diffstat (limited to 'editor/editor_resource_picker.h')
-rw-r--r--editor/editor_resource_picker.h45
1 files changed, 38 insertions, 7 deletions
diff --git a/editor/editor_resource_picker.h b/editor/editor_resource_picker.h
index cd7e507984..d36e742bcd 100644
--- a/editor/editor_resource_picker.h
+++ b/editor/editor_resource_picker.h
@@ -45,7 +45,7 @@ class EditorResourcePicker : public HBoxContainer {
static HashMap<StringName, List<StringName>> allowed_types_cache;
String base_type;
- RES edited_resource;
+ Ref<Resource> edited_resource;
bool editable = true;
bool dropping = false;
@@ -58,6 +58,8 @@ class EditorResourcePicker : public HBoxContainer {
EditorFileDialog *file_dialog = nullptr;
EditorQuickOpen *quick_open = nullptr;
+ Size2i assign_button_min_size = Size2i(1, 1);
+
enum MenuOption {
OBJ_MENU_LOAD,
OBJ_MENU_QUICKLOAD,
@@ -75,7 +77,6 @@ class EditorResourcePicker : public HBoxContainer {
PopupMenu *edit_menu = nullptr;
- void _update_resource();
void _update_resource_preview(const String &p_path, const Ref<Texture2D> &p_preview, const Ref<Texture2D> &p_small_preview, ObjectID p_obj);
void _resource_selected();
@@ -89,9 +90,9 @@ class EditorResourcePicker : public HBoxContainer {
void _button_draw();
void _button_input(const Ref<InputEvent> &p_event);
- void _get_allowed_types(bool p_with_convert, Set<String> *p_vector) const;
+ void _get_allowed_types(bool p_with_convert, HashSet<String> *p_vector) const;
bool _is_drop_valid(const Dictionary &p_drag_data) const;
- bool _is_type_valid(const String p_type_name, Set<String> p_allowed_types) const;
+ bool _is_type_valid(const String p_type_name, HashSet<String> p_allowed_types) const;
Variant get_drag_data_fw(const Point2 &p_point, Control *p_from);
bool can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const;
@@ -100,9 +101,17 @@ class EditorResourcePicker : public HBoxContainer {
void _ensure_resource_menu();
protected:
+ virtual void _update_resource();
+
+ Button *get_assign_button() { return assign_button; }
static void _bind_methods();
void _notification(int p_what);
+ void set_assign_button_min_size(const Size2i &p_size) {
+ assign_button_min_size = p_size;
+ assign_button->set_custom_minimum_size(assign_button_min_size);
+ }
+
GDVIRTUAL1(_set_create_options, Object *)
GDVIRTUAL1R(bool, _handle_menu_selected, int)
@@ -113,8 +122,8 @@ public:
String get_base_type() const;
Vector<String> get_allowed_types() const;
- void set_edited_resource(RES p_resource);
- RES get_edited_resource();
+ void set_edited_resource(Ref<Resource> p_resource);
+ Ref<Resource> get_edited_resource();
void set_toggle_mode(bool p_enable);
bool is_toggle_mode() const;
@@ -126,7 +135,7 @@ public:
virtual void set_create_options(Object *p_menu_node);
virtual bool handle_menu_selected(int p_which);
- EditorResourcePicker();
+ EditorResourcePicker(bool p_hide_assign_button_controls = false);
};
class EditorScriptPicker : public EditorResourcePicker {
@@ -173,4 +182,26 @@ public:
EditorShaderPicker();
};
+class EditorAudioStreamPicker : public EditorResourcePicker {
+ GDCLASS(EditorAudioStreamPicker, EditorResourcePicker);
+
+ uint64_t last_preview_version = 0;
+ Control *stream_preview_rect = nullptr;
+
+ enum {
+ MAX_TAGGED_FRAMES = 8
+ };
+ float tagged_frame_offsets[MAX_TAGGED_FRAMES];
+ uint32_t tagged_frame_offset_count = 0;
+
+ void _preview_draw();
+ virtual void _update_resource() override;
+
+protected:
+ void _notification(int p_what);
+
+public:
+ EditorAudioStreamPicker();
+};
+
#endif // EDITOR_RESOURCE_PICKER_H