Path: blob/master/editor/docks/editor_dock_manager.h
21212 views
/**************************************************************************/1/* editor_dock_manager.h */2/**************************************************************************/3/* This file is part of: */4/* GODOT ENGINE */5/* https://godotengine.org */6/**************************************************************************/7/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */8/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */9/* */10/* Permission is hereby granted, free of charge, to any person obtaining */11/* a copy of this software and associated documentation files (the */12/* "Software"), to deal in the Software without restriction, including */13/* without limitation the rights to use, copy, modify, merge, publish, */14/* distribute, sublicense, and/or sell copies of the Software, and to */15/* permit persons to whom the Software is furnished to do so, subject to */16/* the following conditions: */17/* */18/* The above copyright notice and this permission notice shall be */19/* included in all copies or substantial portions of the Software. */20/* */21/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */22/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */23/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */24/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */25/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */26/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */27/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */28/**************************************************************************/2930#pragma once3132#include "editor/docks/editor_dock.h"33#include "scene/gui/popup.h"34#include "scene/gui/split_container.h"3536class Button;37class ConfigFile;38class Control;39class EditorDock;40class PopupMenu;41class TabBar;42class TabContainer;43class VBoxContainer;44class WindowWrapper;45class StyleBoxFlat;4647class DockSplitContainer : public SplitContainer {48GDCLASS(DockSplitContainer, SplitContainer);4950private:51bool is_updating = false;5253protected:54void _update_visibility();5556virtual void add_child_notify(Node *p_child) override;57virtual void remove_child_notify(Node *p_child) override;5859public:60DockSplitContainer();61};6263class DockShortcutHandler : public Node {64GDCLASS(DockShortcutHandler, Node);6566protected:67virtual void shortcut_input(const Ref<InputEvent> &p_event) override;6869public:70DockShortcutHandler() { set_process_shortcut_input(true); }71};7273class DockContextPopup;74class EditorDockDragHint;75class DockTabContainer;7677class EditorDockManager : public Object {78GDCLASS(EditorDockManager, Object);7980private:81friend class DockContextPopup;82friend class EditorDockDragHint;83friend class DockShortcutHandler;8485static inline EditorDockManager *singleton = nullptr;8687// To access splits easily by index.88Vector<DockSplitContainer *> vsplits;89DockSplitContainer *main_hsplit = nullptr;9091DockTabContainer *dock_slots[EditorDock::DOCK_SLOT_MAX];92Vector<WindowWrapper *> dock_windows;93LocalVector<EditorDock *> all_docks;94HashSet<EditorDock *> dirty_docks;9596EditorDock *dock_tab_dragged = nullptr;97bool docks_visible = true;9899DockContextPopup *dock_context_popup = nullptr;100PopupMenu *docks_menu = nullptr;101LocalVector<EditorDock *> docks_menu_docks;102Control *closed_dock_parent = nullptr;103104EditorDock *_get_dock_tab_dragged();105void _dock_drag_stopped();106void _dock_split_dragged(int p_offset);107void _update_layout();108109void _docks_menu_option(int p_id);110111void _window_close_request(WindowWrapper *p_wrapper);112EditorDock *_close_window(WindowWrapper *p_wrapper);113void _open_dock_in_window(EditorDock *p_dock, bool p_show_window = true, bool p_reset_size = false);114void _restore_dock_to_saved_window(EditorDock *p_dock, const Dictionary &p_window_dump);115116void _make_dock_visible(EditorDock *p_dock, bool p_grab_focus);117void _move_dock(EditorDock *p_dock, Control *p_target, int p_tab_index = -1, bool p_set_current = true);118119void _queue_update_tab_style(EditorDock *p_dock);120void _update_dirty_dock_tabs();121122public:123static EditorDockManager *get_singleton() { return singleton; }124125void update_docks_menu();126void update_tab_styles();127void set_tab_icon_max_width(int p_max_width);128129void add_vsplit(DockSplitContainer *p_split);130void set_hsplit(DockSplitContainer *p_split);131void register_dock_slot(DockTabContainer *p_tab_container);132int get_vsplit_count() const;133PopupMenu *get_docks_menu();134135void save_docks_to_config(Ref<ConfigFile> p_layout, const String &p_section) const;136void load_docks_from_config(Ref<ConfigFile> p_layout, const String &p_section, bool p_first_load = false);137138void set_dock_enabled(EditorDock *p_dock, bool p_enabled);139void close_dock(EditorDock *p_dock);140void open_dock(EditorDock *p_dock, bool p_set_current = true);141void focus_dock(EditorDock *p_dock);142void make_dock_floating(EditorDock *p_dock);143144void set_docks_visible(bool p_show);145bool are_docks_visible() const;146147void add_dock(EditorDock *p_dock);148void remove_dock(EditorDock *p_dock);149150EditorDockManager();151};152153class DockContextPopup : public PopupPanel {154GDCLASS(DockContextPopup, PopupPanel);155156private:157VBoxContainer *dock_select_popup_vb = nullptr;158159Button *make_float_button = nullptr;160Button *tab_move_left_button = nullptr;161Button *tab_move_right_button = nullptr;162Button *close_button = nullptr;163164Control *dock_select = nullptr;165Rect2 dock_select_rects[EditorDock::DOCK_SLOT_MAX];166int dock_select_rect_over_idx = -1;167168EditorDock *context_dock = nullptr;169170EditorDockManager *dock_manager = nullptr;171172void _tab_move_left();173void _tab_move_right();174void _close_dock();175void _float_dock();176177void _dock_select_input(const Ref<InputEvent> &p_input);178void _dock_select_mouse_exited();179void _dock_select_draw();180181void _update_buttons();182183protected:184void _notification(int p_what);185186public:187void set_dock(EditorDock *p_dock);188void docks_updated();189190DockContextPopup();191};192193194