2015-05-31 06:59:42 +02:00
|
|
|
/*************************************************************************/
|
2016-06-18 14:46:12 +02:00
|
|
|
/* editor_file_dialog.h */
|
2015-05-31 06:59:42 +02:00
|
|
|
/*************************************************************************/
|
|
|
|
/* This file is part of: */
|
|
|
|
/* GODOT ENGINE */
|
2017-08-27 14:16:55 +02:00
|
|
|
/* https://godotengine.org */
|
2015-05-31 06:59:42 +02:00
|
|
|
/*************************************************************************/
|
2019-01-01 12:53:14 +01:00
|
|
|
/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
|
|
|
|
/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
|
2015-05-31 06:59:42 +02:00
|
|
|
/* */
|
|
|
|
/* Permission is hereby granted, free of charge, to any person obtaining */
|
|
|
|
/* a copy of this software and associated documentation files (the */
|
|
|
|
/* "Software"), to deal in the Software without restriction, including */
|
|
|
|
/* without limitation the rights to use, copy, modify, merge, publish, */
|
|
|
|
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
|
|
|
/* permit persons to whom the Software is furnished to do so, subject to */
|
|
|
|
/* the following conditions: */
|
|
|
|
/* */
|
|
|
|
/* The above copyright notice and this permission notice shall be */
|
|
|
|
/* included in all copies or substantial portions of the Software. */
|
|
|
|
/* */
|
|
|
|
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
|
|
|
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
|
|
|
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
|
|
|
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
|
|
|
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
|
|
|
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
|
|
|
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
|
|
|
/*************************************************************************/
|
2018-01-05 00:50:27 +01:00
|
|
|
|
2015-05-31 06:59:42 +02:00
|
|
|
#ifndef EDITORFILEDIALOG_H
|
|
|
|
#define EDITORFILEDIALOG_H
|
|
|
|
|
2018-09-11 18:13:45 +02:00
|
|
|
#include "core/os/dir_access.h"
|
2017-03-05 16:44:50 +01:00
|
|
|
#include "scene/gui/box_container.h"
|
2015-05-31 06:59:42 +02:00
|
|
|
#include "scene/gui/dialogs.h"
|
2015-06-06 14:44:38 +02:00
|
|
|
#include "scene/gui/item_list.h"
|
2015-05-31 06:59:42 +02:00
|
|
|
#include "scene/gui/line_edit.h"
|
|
|
|
#include "scene/gui/option_button.h"
|
2017-12-25 05:29:00 +01:00
|
|
|
#include "scene/gui/separator.h"
|
2017-09-27 21:44:48 +02:00
|
|
|
#include "scene/gui/split_container.h"
|
2017-01-14 10:52:54 +01:00
|
|
|
#include "scene/gui/texture_rect.h"
|
2015-06-06 14:44:38 +02:00
|
|
|
#include "scene/gui/tool_button.h"
|
2017-12-02 01:37:32 +01:00
|
|
|
|
|
|
|
class DependencyRemoveDialog;
|
|
|
|
|
2015-05-31 06:59:42 +02:00
|
|
|
class EditorFileDialog : public ConfirmationDialog {
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
GDCLASS(EditorFileDialog, ConfirmationDialog);
|
2015-05-31 06:59:42 +02:00
|
|
|
|
|
|
|
public:
|
2015-06-06 14:44:38 +02:00
|
|
|
enum DisplayMode {
|
|
|
|
DISPLAY_THUMBNAILS,
|
|
|
|
DISPLAY_LIST
|
|
|
|
};
|
|
|
|
|
2015-05-31 06:59:42 +02:00
|
|
|
enum Access {
|
|
|
|
ACCESS_RESOURCES,
|
|
|
|
ACCESS_USERDATA,
|
|
|
|
ACCESS_FILESYSTEM
|
|
|
|
};
|
|
|
|
|
|
|
|
enum Mode {
|
|
|
|
MODE_OPEN_FILE,
|
|
|
|
MODE_OPEN_FILES,
|
|
|
|
MODE_OPEN_DIR,
|
2016-03-14 16:03:18 +01:00
|
|
|
MODE_OPEN_ANY,
|
|
|
|
MODE_SAVE_FILE
|
2015-05-31 06:59:42 +02:00
|
|
|
};
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
typedef Ref<Texture> (*GetIconFunc)(const String &);
|
|
|
|
typedef void (*RegisterFunc)(EditorFileDialog *);
|
2015-05-31 06:59:42 +02:00
|
|
|
|
|
|
|
static GetIconFunc get_icon_func;
|
|
|
|
static GetIconFunc get_large_icon_func;
|
|
|
|
static RegisterFunc register_func;
|
|
|
|
static RegisterFunc unregister_func;
|
|
|
|
|
|
|
|
private:
|
2017-12-02 01:37:32 +01:00
|
|
|
enum ItemMenu {
|
|
|
|
ITEM_MENU_COPY_PATH,
|
|
|
|
ITEM_MENU_DELETE,
|
|
|
|
ITEM_MENU_REFRESH,
|
|
|
|
ITEM_MENU_NEW_FOLDER,
|
|
|
|
ITEM_MENU_SHOW_IN_EXPLORER
|
|
|
|
};
|
|
|
|
|
2015-05-31 06:59:42 +02:00
|
|
|
ConfirmationDialog *makedialog;
|
|
|
|
LineEdit *makedirname;
|
|
|
|
|
|
|
|
Button *makedir;
|
|
|
|
Access access;
|
|
|
|
//Button *action;
|
|
|
|
VBoxContainer *vbox;
|
|
|
|
Mode mode;
|
2017-12-02 01:37:32 +01:00
|
|
|
bool can_create_dir;
|
2015-05-31 06:59:42 +02:00
|
|
|
LineEdit *dir;
|
2015-06-06 14:44:38 +02:00
|
|
|
|
|
|
|
ToolButton *dir_prev;
|
|
|
|
ToolButton *dir_next;
|
|
|
|
ToolButton *dir_up;
|
|
|
|
|
2015-05-31 06:59:42 +02:00
|
|
|
OptionButton *drives;
|
2015-06-06 14:44:38 +02:00
|
|
|
ItemList *item_list;
|
2017-12-02 01:37:32 +01:00
|
|
|
PopupMenu *item_menu;
|
2017-01-12 22:27:27 +01:00
|
|
|
TextureRect *preview;
|
2015-05-31 06:59:42 +02:00
|
|
|
VBoxContainer *preview_vb;
|
2017-09-27 21:44:48 +02:00
|
|
|
HSplitContainer *list_hb;
|
2019-10-26 17:29:22 +02:00
|
|
|
HBoxContainer *file_box;
|
2015-05-31 06:59:42 +02:00
|
|
|
LineEdit *file;
|
2019-10-26 17:29:22 +02:00
|
|
|
OptionButton *filter;
|
2015-05-31 06:59:42 +02:00
|
|
|
AcceptDialog *mkdirerr;
|
|
|
|
AcceptDialog *exterr;
|
|
|
|
DirAccess *dir_access;
|
|
|
|
ConfirmationDialog *confirm_save;
|
2017-12-02 01:37:32 +01:00
|
|
|
DependencyRemoveDialog *remove_dialog;
|
2019-06-09 20:00:30 +02:00
|
|
|
|
2015-06-06 14:44:38 +02:00
|
|
|
ToolButton *mode_thumbnails;
|
|
|
|
ToolButton *mode_list;
|
|
|
|
|
2015-12-04 19:33:30 +01:00
|
|
|
ToolButton *refresh;
|
2015-06-06 14:44:38 +02:00
|
|
|
ToolButton *favorite;
|
2019-06-09 20:00:30 +02:00
|
|
|
ToolButton *show_hidden;
|
2015-06-06 14:44:38 +02:00
|
|
|
|
|
|
|
ToolButton *fav_up;
|
|
|
|
ToolButton *fav_down;
|
|
|
|
|
|
|
|
ItemList *favorites;
|
|
|
|
ItemList *recent;
|
|
|
|
|
|
|
|
Vector<String> local_history;
|
|
|
|
int local_history_pos;
|
|
|
|
void _push_history();
|
2015-05-31 06:59:42 +02:00
|
|
|
|
|
|
|
Vector<String> filters;
|
|
|
|
|
|
|
|
bool preview_waiting;
|
|
|
|
int preview_wheel_index;
|
|
|
|
float preview_wheel_timeout;
|
|
|
|
static bool default_show_hidden_files;
|
2015-12-15 17:39:13 +01:00
|
|
|
static DisplayMode default_display_mode;
|
2015-05-31 06:59:42 +02:00
|
|
|
bool show_hidden_files;
|
2015-06-06 14:44:38 +02:00
|
|
|
DisplayMode display_mode;
|
2015-05-31 06:59:42 +02:00
|
|
|
|
2016-06-20 05:38:13 +02:00
|
|
|
bool disable_overwrite_warning;
|
2015-05-31 06:59:42 +02:00
|
|
|
bool invalidated;
|
|
|
|
|
|
|
|
void update_dir();
|
2019-06-28 09:29:50 +02:00
|
|
|
void update_file_name();
|
2015-05-31 06:59:42 +02:00
|
|
|
void update_file_list();
|
|
|
|
void update_filters();
|
|
|
|
|
2015-06-06 14:44:38 +02:00
|
|
|
void _update_favorites();
|
2019-06-09 17:27:28 +02:00
|
|
|
void _favorite_pressed();
|
2015-06-06 14:44:38 +02:00
|
|
|
void _favorite_selected(int p_idx);
|
|
|
|
void _favorite_move_up();
|
|
|
|
void _favorite_move_down();
|
|
|
|
|
|
|
|
void _recent_selected(int p_idx);
|
|
|
|
|
|
|
|
void _item_selected(int p_item);
|
2018-01-31 19:25:42 +01:00
|
|
|
void _multi_selected(int p_item, bool p_selected);
|
2017-11-24 19:12:18 +01:00
|
|
|
void _items_clear_selection();
|
2015-06-06 14:44:38 +02:00
|
|
|
void _item_dc_selected(int p_item);
|
2015-05-31 06:59:42 +02:00
|
|
|
|
2017-12-02 01:37:32 +01:00
|
|
|
void _item_list_item_rmb_selected(int p_item, const Vector2 &p_pos);
|
|
|
|
void _item_list_rmb_clicked(const Vector2 &p_pos);
|
|
|
|
void _item_menu_id_pressed(int p_option);
|
|
|
|
|
2015-05-31 06:59:42 +02:00
|
|
|
void _select_drive(int p_idx);
|
|
|
|
void _dir_entered(String p_dir);
|
2017-03-05 16:44:50 +01:00
|
|
|
void _file_entered(const String &p_file);
|
2015-05-31 06:59:42 +02:00
|
|
|
void _action_pressed();
|
|
|
|
void _save_confirm_pressed();
|
|
|
|
void _cancel_pressed();
|
|
|
|
void _filter_selected(int);
|
|
|
|
void _make_dir();
|
|
|
|
void _make_dir_confirm();
|
|
|
|
|
2017-12-02 01:37:32 +01:00
|
|
|
void _delete_items();
|
|
|
|
|
2015-05-31 06:59:42 +02:00
|
|
|
void _update_drives();
|
|
|
|
|
2015-06-06 14:44:38 +02:00
|
|
|
void _go_up();
|
|
|
|
void _go_back();
|
|
|
|
void _go_forward();
|
2015-05-31 06:59:42 +02:00
|
|
|
|
2015-06-06 14:44:38 +02:00
|
|
|
virtual void _post_popup();
|
2015-05-31 06:59:42 +02:00
|
|
|
|
2015-06-06 14:44:38 +02:00
|
|
|
void _save_to_recent();
|
2017-03-24 21:45:31 +01:00
|
|
|
//callback function is callback(String p_path,Ref<Texture> preview,Variant udata) preview null if could not load
|
2015-05-31 06:59:42 +02:00
|
|
|
|
2018-09-12 13:10:49 +02:00
|
|
|
void _thumbnail_result(const String &p_path, const Ref<Texture> &p_preview, const Ref<Texture> &p_small_preview, const Variant &p_udata);
|
|
|
|
void _thumbnail_done(const String &p_path, const Ref<Texture> &p_preview, const Ref<Texture> &p_small_preview, const Variant &p_udata);
|
2017-03-05 16:44:50 +01:00
|
|
|
void _request_single_thumbnail(const String &p_path);
|
2015-05-31 06:59:42 +02:00
|
|
|
|
2017-05-20 17:38:03 +02:00
|
|
|
void _unhandled_input(const Ref<InputEvent> &p_event);
|
2015-12-29 00:36:48 +01:00
|
|
|
|
2017-11-24 19:12:18 +01:00
|
|
|
bool _is_open_should_be_disabled();
|
|
|
|
|
2015-05-31 06:59:42 +02:00
|
|
|
protected:
|
|
|
|
void _notification(int p_what);
|
|
|
|
static void _bind_methods();
|
|
|
|
//bind helpers
|
|
|
|
public:
|
|
|
|
void clear_filters();
|
2017-03-05 16:44:50 +01:00
|
|
|
void add_filter(const String &p_filter);
|
2015-05-31 06:59:42 +02:00
|
|
|
|
|
|
|
void set_enable_multiple_selection(bool p_enable);
|
|
|
|
Vector<String> get_selected_files() const;
|
|
|
|
|
|
|
|
String get_current_dir() const;
|
|
|
|
String get_current_file() const;
|
|
|
|
String get_current_path() const;
|
2017-03-05 16:44:50 +01:00
|
|
|
void set_current_dir(const String &p_dir);
|
|
|
|
void set_current_file(const String &p_file);
|
|
|
|
void set_current_path(const String &p_path);
|
2015-05-31 06:59:42 +02:00
|
|
|
|
2015-06-06 14:44:38 +02:00
|
|
|
void set_display_mode(DisplayMode p_mode);
|
|
|
|
DisplayMode get_display_mode() const;
|
|
|
|
|
2015-05-31 06:59:42 +02:00
|
|
|
void set_mode(Mode p_mode);
|
|
|
|
Mode get_mode() const;
|
|
|
|
|
|
|
|
VBoxContainer *get_vbox();
|
|
|
|
LineEdit *get_line_edit() { return file; }
|
|
|
|
|
|
|
|
void set_access(Access p_access);
|
|
|
|
Access get_access() const;
|
|
|
|
|
|
|
|
void set_show_hidden_files(bool p_show);
|
|
|
|
bool is_showing_hidden_files() const;
|
|
|
|
|
|
|
|
static void set_default_show_hidden_files(bool p_show);
|
2015-12-15 17:39:13 +01:00
|
|
|
static void set_default_display_mode(DisplayMode p_mode);
|
2015-05-31 06:59:42 +02:00
|
|
|
|
|
|
|
void invalidate();
|
|
|
|
|
2016-06-20 05:38:13 +02:00
|
|
|
void set_disable_overwrite_warning(bool p_disable);
|
|
|
|
bool is_overwrite_warning_disabled() const;
|
|
|
|
|
2015-05-31 06:59:42 +02:00
|
|
|
EditorFileDialog();
|
|
|
|
~EditorFileDialog();
|
|
|
|
};
|
|
|
|
|
|
|
|
class EditorLineEditFileChooser : public HBoxContainer {
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
GDCLASS(EditorLineEditFileChooser, HBoxContainer);
|
2015-05-31 06:59:42 +02:00
|
|
|
Button *button;
|
|
|
|
LineEdit *line_edit;
|
|
|
|
EditorFileDialog *dialog;
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
void _chosen(const String &p_text);
|
2015-05-31 06:59:42 +02:00
|
|
|
void _browse();
|
2017-03-05 16:44:50 +01:00
|
|
|
|
2015-05-31 06:59:42 +02:00
|
|
|
protected:
|
2018-12-13 22:37:19 +01:00
|
|
|
void _notification(int p_what);
|
2015-05-31 06:59:42 +02:00
|
|
|
static void _bind_methods();
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
public:
|
2015-05-31 06:59:42 +02:00
|
|
|
Button *get_button() { return button; }
|
|
|
|
LineEdit *get_line_edit() { return line_edit; }
|
|
|
|
EditorFileDialog *get_file_dialog() { return dialog; }
|
|
|
|
|
|
|
|
EditorLineEditFileChooser();
|
|
|
|
};
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
VARIANT_ENUM_CAST(EditorFileDialog::Mode);
|
|
|
|
VARIANT_ENUM_CAST(EditorFileDialog::Access);
|
|
|
|
VARIANT_ENUM_CAST(EditorFileDialog::DisplayMode);
|
2015-05-31 06:59:42 +02:00
|
|
|
|
|
|
|
#endif // EDITORFILEDIALOG_H
|