2014-02-10 01:10:30 +00:00
|
|
|
/*************************************************************************/
|
|
|
|
/* viewport.h */
|
|
|
|
/*************************************************************************/
|
|
|
|
/* This file is part of: */
|
|
|
|
/* GODOT ENGINE */
|
2017-08-27 12:16:55 +00:00
|
|
|
/* https://godotengine.org */
|
2014-02-10 01:10:30 +00:00
|
|
|
/*************************************************************************/
|
2020-01-01 10:16:22 +00:00
|
|
|
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
|
|
|
|
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
|
2014-02-10 01:10:30 +00: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-04 23:50:27 +00:00
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
#ifndef VIEWPORT_H
|
|
|
|
#define VIEWPORT_H
|
|
|
|
|
2018-09-11 16:13:45 +00:00
|
|
|
#include "core/math/transform_2d.h"
|
2017-03-05 15:44:50 +00:00
|
|
|
#include "scene/main/node.h"
|
2014-02-10 01:10:30 +00:00
|
|
|
#include "scene/resources/texture.h"
|
2017-03-05 15:44:50 +00:00
|
|
|
#include "scene/resources/world_2d.h"
|
2020-03-03 13:36:29 +00:00
|
|
|
#include "servers/display_server.h"
|
2020-03-27 18:21:27 +00:00
|
|
|
#include "servers/rendering_server.h"
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2020-03-26 21:49:16 +00:00
|
|
|
class Camera3D;
|
2016-07-06 23:35:49 +00:00
|
|
|
class Camera2D;
|
2020-03-26 21:49:16 +00:00
|
|
|
class Listener3D;
|
2016-01-17 01:41:10 +00:00
|
|
|
class Control;
|
|
|
|
class CanvasItem;
|
2018-08-24 22:03:26 +00:00
|
|
|
class CanvasLayer;
|
2016-01-17 01:41:10 +00:00
|
|
|
class Panel;
|
|
|
|
class Label;
|
|
|
|
class Timer;
|
2014-02-10 01:10:30 +00:00
|
|
|
class Viewport;
|
2020-03-26 21:49:16 +00:00
|
|
|
class CollisionObject3D;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2019-06-11 18:43:37 +00:00
|
|
|
class ViewportTexture : public Texture2D {
|
|
|
|
GDCLASS(ViewportTexture, Texture2D);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-01-10 04:04:31 +00:00
|
|
|
NodePath path;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
friend class Viewport;
|
|
|
|
Viewport *vp;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2019-06-24 19:13:06 +00:00
|
|
|
mutable RID proxy_ph;
|
|
|
|
mutable RID proxy;
|
2017-12-04 18:55:20 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
protected:
|
2017-01-10 04:04:31 +00:00
|
|
|
static void _bind_methods();
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
public:
|
|
|
|
void set_viewport_path_in_scene(const NodePath &p_path);
|
2017-01-10 04:04:31 +00:00
|
|
|
NodePath get_viewport_path_in_scene() const;
|
|
|
|
|
2020-07-10 10:34:39 +00:00
|
|
|
virtual void setup_local_to_scene() override;
|
2017-01-10 04:04:31 +00:00
|
|
|
|
2020-07-10 10:34:39 +00:00
|
|
|
virtual int get_width() const override;
|
|
|
|
virtual int get_height() const override;
|
|
|
|
virtual Size2 get_size() const override;
|
|
|
|
virtual RID get_rid() const override;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2020-07-10 10:34:39 +00:00
|
|
|
virtual bool has_alpha() const override;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2020-07-10 10:34:39 +00:00
|
|
|
virtual Ref<Image> get_data() const override;
|
2017-06-09 03:23:50 +00:00
|
|
|
|
2017-01-10 04:04:31 +00:00
|
|
|
ViewportTexture();
|
|
|
|
~ViewportTexture();
|
2014-02-10 01:10:30 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class Viewport : public Node {
|
2017-03-05 15:44:50 +00:00
|
|
|
GDCLASS(Viewport, Node);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
public:
|
2016-11-10 02:55:06 +00:00
|
|
|
enum ShadowAtlasQuadrantSubdiv {
|
|
|
|
SHADOW_ATLAS_QUADRANT_SUBDIV_DISABLED,
|
|
|
|
SHADOW_ATLAS_QUADRANT_SUBDIV_1,
|
|
|
|
SHADOW_ATLAS_QUADRANT_SUBDIV_4,
|
|
|
|
SHADOW_ATLAS_QUADRANT_SUBDIV_16,
|
|
|
|
SHADOW_ATLAS_QUADRANT_SUBDIV_64,
|
|
|
|
SHADOW_ATLAS_QUADRANT_SUBDIV_256,
|
|
|
|
SHADOW_ATLAS_QUADRANT_SUBDIV_1024,
|
|
|
|
SHADOW_ATLAS_QUADRANT_SUBDIV_MAX,
|
|
|
|
};
|
|
|
|
|
2017-01-02 01:16:52 +00:00
|
|
|
enum MSAA {
|
|
|
|
MSAA_DISABLED,
|
|
|
|
MSAA_2X,
|
|
|
|
MSAA_4X,
|
|
|
|
MSAA_8X,
|
|
|
|
MSAA_16X,
|
2020-04-12 04:49:10 +00:00
|
|
|
MSAA_MAX
|
|
|
|
};
|
|
|
|
|
|
|
|
enum ScreenSpaceAA {
|
|
|
|
SCREEN_SPACE_AA_DISABLED,
|
|
|
|
SCREEN_SPACE_AA_FXAA,
|
|
|
|
SCREEN_SPACE_AA_MAX
|
2014-02-10 01:10:30 +00:00
|
|
|
};
|
|
|
|
|
2017-06-11 18:52:03 +00:00
|
|
|
enum RenderInfo {
|
|
|
|
RENDER_INFO_OBJECTS_IN_FRAME,
|
|
|
|
RENDER_INFO_VERTICES_IN_FRAME,
|
|
|
|
RENDER_INFO_MATERIAL_CHANGES_IN_FRAME,
|
|
|
|
RENDER_INFO_SHADER_CHANGES_IN_FRAME,
|
|
|
|
RENDER_INFO_SURFACE_CHANGES_IN_FRAME,
|
|
|
|
RENDER_INFO_DRAW_CALLS_IN_FRAME,
|
|
|
|
RENDER_INFO_MAX
|
|
|
|
};
|
|
|
|
|
|
|
|
enum DebugDraw {
|
|
|
|
DEBUG_DRAW_DISABLED,
|
|
|
|
DEBUG_DRAW_UNSHADED,
|
2019-10-03 20:39:08 +00:00
|
|
|
DEBUG_DRAW_LIGHTING,
|
2017-06-11 18:52:03 +00:00
|
|
|
DEBUG_DRAW_OVERDRAW,
|
|
|
|
DEBUG_DRAW_WIREFRAME,
|
2020-01-26 23:09:40 +00:00
|
|
|
DEBUG_DRAW_NORMAL_BUFFER,
|
2019-10-03 20:39:08 +00:00
|
|
|
DEBUG_DRAW_GI_PROBE_ALBEDO,
|
|
|
|
DEBUG_DRAW_GI_PROBE_LIGHTING,
|
2019-10-05 13:27:43 +00:00
|
|
|
DEBUG_DRAW_GI_PROBE_EMISSION,
|
2019-10-03 20:39:08 +00:00
|
|
|
DEBUG_DRAW_SHADOW_ATLAS,
|
|
|
|
DEBUG_DRAW_DIRECTIONAL_SHADOW_ATLAS,
|
2020-01-12 01:26:52 +00:00
|
|
|
DEBUG_DRAW_SCENE_LUMINANCE,
|
2020-01-25 10:18:55 +00:00
|
|
|
DEBUG_DRAW_SSAO,
|
2020-04-14 03:05:21 +00:00
|
|
|
DEBUG_DRAW_PSSM_SPLITS,
|
2020-06-25 13:33:28 +00:00
|
|
|
DEBUG_DRAW_DECAL_ATLAS,
|
|
|
|
DEBUG_DRAW_SDFGI,
|
|
|
|
DEBUG_DRAW_SDFGI_PROBES,
|
|
|
|
DEBUG_DRAW_GI_BUFFER,
|
2020-12-17 18:56:59 +00:00
|
|
|
DEBUG_DRAW_DISABLE_LOD,
|
2017-06-11 18:52:03 +00:00
|
|
|
};
|
|
|
|
|
2019-06-25 01:24:07 +00:00
|
|
|
enum DefaultCanvasItemTextureFilter {
|
|
|
|
DEFAULT_CANVAS_ITEM_TEXTURE_FILTER_NEAREST,
|
|
|
|
DEFAULT_CANVAS_ITEM_TEXTURE_FILTER_LINEAR,
|
|
|
|
DEFAULT_CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS,
|
2020-02-19 23:31:43 +00:00
|
|
|
DEFAULT_CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS,
|
2019-06-25 01:24:07 +00:00
|
|
|
DEFAULT_CANVAS_ITEM_TEXTURE_FILTER_MAX
|
|
|
|
};
|
|
|
|
|
|
|
|
enum DefaultCanvasItemTextureRepeat {
|
|
|
|
DEFAULT_CANVAS_ITEM_TEXTURE_REPEAT_DISABLED,
|
|
|
|
DEFAULT_CANVAS_ITEM_TEXTURE_REPEAT_ENABLED,
|
|
|
|
DEFAULT_CANVAS_ITEM_TEXTURE_REPEAT_MIRROR,
|
|
|
|
DEFAULT_CANVAS_ITEM_TEXTURE_REPEAT_MAX,
|
|
|
|
};
|
|
|
|
|
2020-11-26 12:50:21 +00:00
|
|
|
enum SDFOversize {
|
|
|
|
SDF_OVERSIZE_100_PERCENT,
|
|
|
|
SDF_OVERSIZE_120_PERCENT,
|
|
|
|
SDF_OVERSIZE_150_PERCENT,
|
|
|
|
SDF_OVERSIZE_200_PERCENT,
|
|
|
|
SDF_OVERSIZE_MAX
|
|
|
|
};
|
|
|
|
|
|
|
|
enum SDFScale {
|
|
|
|
SDF_SCALE_100_PERCENT,
|
|
|
|
SDF_SCALE_50_PERCENT,
|
|
|
|
SDF_SCALE_25_PERCENT,
|
|
|
|
SDF_SCALE_MAX
|
|
|
|
};
|
|
|
|
|
2020-03-14 16:06:39 +00:00
|
|
|
enum {
|
|
|
|
SUBWINDOW_CANVAS_LAYER = 1024
|
|
|
|
};
|
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
private:
|
2017-03-05 15:44:50 +00:00
|
|
|
friend class ViewportTexture;
|
2016-01-18 22:49:11 +00:00
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
Viewport *parent;
|
|
|
|
|
2020-03-26 21:49:16 +00:00
|
|
|
Listener3D *listener;
|
|
|
|
Set<Listener3D *> listeners;
|
2016-03-20 02:10:04 +00:00
|
|
|
|
2019-04-06 20:55:01 +00:00
|
|
|
struct CameraOverrideData {
|
|
|
|
Transform transform;
|
|
|
|
enum Projection {
|
|
|
|
PROJECTION_PERSPECTIVE,
|
|
|
|
PROJECTION_ORTHOGONAL
|
|
|
|
};
|
|
|
|
Projection projection;
|
|
|
|
float fov;
|
|
|
|
float size;
|
|
|
|
float z_near;
|
|
|
|
float z_far;
|
|
|
|
RID rid;
|
|
|
|
|
|
|
|
operator bool() const {
|
|
|
|
return rid != RID();
|
|
|
|
}
|
|
|
|
} camera_override;
|
|
|
|
|
2020-03-26 21:49:16 +00:00
|
|
|
Camera3D *camera;
|
|
|
|
Set<Camera3D *> cameras;
|
2018-08-24 22:03:26 +00:00
|
|
|
Set<CanvasLayer *> canvas_layers;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
RID viewport;
|
|
|
|
RID current_canvas;
|
2020-03-14 16:06:39 +00:00
|
|
|
RID subwindow_canvas;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
bool audio_listener;
|
2016-03-20 02:10:04 +00:00
|
|
|
RID internal_listener;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
bool audio_listener_2d;
|
2016-03-20 02:10:04 +00:00
|
|
|
RID internal_listener_2d;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2019-04-06 20:55:01 +00:00
|
|
|
bool override_canvas_transform;
|
|
|
|
|
|
|
|
Transform2D canvas_transform_override;
|
2017-01-11 03:52:51 +00:00
|
|
|
Transform2D canvas_transform;
|
|
|
|
Transform2D global_canvas_transform;
|
|
|
|
Transform2D stretch_transform;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2020-03-04 01:51:12 +00:00
|
|
|
Size2i size;
|
2020-04-01 03:47:58 +00:00
|
|
|
Size2i size_2d_override;
|
2020-03-04 01:51:12 +00:00
|
|
|
bool size_allocated;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2015-09-20 16:03:46 +00:00
|
|
|
RID contact_2d_debug;
|
|
|
|
RID contact_3d_debug_multimesh;
|
|
|
|
RID contact_3d_debug_instance;
|
|
|
|
|
2014-10-28 01:54:32 +00:00
|
|
|
Rect2 last_vp_rect;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
bool transparent_bg;
|
2016-10-03 19:33:42 +00:00
|
|
|
bool filter;
|
|
|
|
bool gen_mipmaps;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-09-07 14:22:07 +00:00
|
|
|
bool snap_controls_to_pixels;
|
2020-10-29 21:09:16 +00:00
|
|
|
bool snap_2d_transforms_to_pixel;
|
|
|
|
bool snap_2d_vertices_to_pixel;
|
2017-09-07 14:22:07 +00:00
|
|
|
|
2014-09-15 14:33:30 +00:00
|
|
|
bool physics_object_picking;
|
2020-03-17 06:33:00 +00:00
|
|
|
List<Ref<InputEvent>> physics_picking_events;
|
2014-09-15 14:33:30 +00:00
|
|
|
ObjectID physics_object_capture;
|
|
|
|
ObjectID physics_object_over;
|
2018-11-15 16:54:26 +00:00
|
|
|
Transform physics_last_object_transform;
|
|
|
|
Transform physics_last_camera_transform;
|
|
|
|
ObjectID physics_last_id;
|
2018-12-18 07:11:13 +00:00
|
|
|
bool physics_has_last_mousepos;
|
2014-09-15 14:33:30 +00:00
|
|
|
Vector2 physics_last_mousepos;
|
2018-11-15 16:54:26 +00:00
|
|
|
struct {
|
|
|
|
bool alt;
|
|
|
|
bool control;
|
|
|
|
bool shift;
|
|
|
|
bool meta;
|
|
|
|
int mouse_mask;
|
|
|
|
|
|
|
|
} physics_last_mouse_state;
|
|
|
|
|
2020-03-26 21:49:16 +00:00
|
|
|
void _collision_object_input_event(CollisionObject3D *p_object, Camera3D *p_camera, const Ref<InputEvent> &p_input_event, const Vector3 &p_pos, const Vector3 &p_normal, int p_shape);
|
2018-11-15 16:54:26 +00:00
|
|
|
|
|
|
|
bool handle_input_locally;
|
|
|
|
bool local_input_handled;
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
Map<ObjectID, uint64_t> physics_2d_mouseover;
|
2014-09-15 14:33:30 +00:00
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
Ref<World2D> world_2d;
|
2020-04-18 09:00:51 +00:00
|
|
|
Ref<World3D> world_3d;
|
|
|
|
Ref<World3D> own_world_3d;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2020-03-04 01:51:12 +00:00
|
|
|
Rect2i to_screen_rect;
|
2014-04-10 03:18:27 +00:00
|
|
|
StringName input_group;
|
|
|
|
StringName gui_input_group;
|
|
|
|
StringName unhandled_input_group;
|
|
|
|
StringName unhandled_key_input_group;
|
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
void _update_listener();
|
|
|
|
void _update_listener_2d();
|
|
|
|
|
|
|
|
void _propagate_enter_world(Node *p_node);
|
|
|
|
void _propagate_exit_world(Node *p_node);
|
2016-05-11 14:46:08 +00:00
|
|
|
void _propagate_viewport_notification(Node *p_node, int p_what);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
void _update_global_transform();
|
|
|
|
|
2016-10-03 19:33:42 +00:00
|
|
|
RID texture_rid;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-06-11 18:52:03 +00:00
|
|
|
DebugDraw debug_draw;
|
|
|
|
|
2016-11-10 02:55:06 +00:00
|
|
|
int shadow_atlas_size;
|
|
|
|
ShadowAtlasQuadrantSubdiv shadow_atlas_quadrant_subdiv[4];
|
|
|
|
|
2017-01-02 01:16:52 +00:00
|
|
|
MSAA msaa;
|
2020-04-12 04:49:10 +00:00
|
|
|
ScreenSpaceAA screen_space_aa;
|
2020-10-26 20:37:33 +00:00
|
|
|
bool use_debanding = false;
|
2020-12-17 18:56:59 +00:00
|
|
|
float lod_threshold = 1.0;
|
|
|
|
|
2017-01-10 21:02:19 +00:00
|
|
|
Ref<ViewportTexture> default_texture;
|
2017-03-05 15:44:50 +00:00
|
|
|
Set<ViewportTexture *> viewport_textures;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2020-11-26 12:50:21 +00:00
|
|
|
SDFOversize sdf_oversize;
|
|
|
|
SDFScale sdf_scale;
|
|
|
|
|
2020-03-14 16:06:39 +00:00
|
|
|
enum SubWindowDrag {
|
|
|
|
SUB_WINDOW_DRAG_DISABLED,
|
|
|
|
SUB_WINDOW_DRAG_MOVE,
|
|
|
|
SUB_WINDOW_DRAG_CLOSE,
|
|
|
|
SUB_WINDOW_DRAG_RESIZE,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum SubWindowResize {
|
|
|
|
SUB_WINDOW_RESIZE_DISABLED,
|
|
|
|
SUB_WINDOW_RESIZE_TOP_LEFT,
|
|
|
|
SUB_WINDOW_RESIZE_TOP,
|
|
|
|
SUB_WINDOW_RESIZE_TOP_RIGHT,
|
|
|
|
SUB_WINDOW_RESIZE_LEFT,
|
|
|
|
SUB_WINDOW_RESIZE_RIGHT,
|
|
|
|
SUB_WINDOW_RESIZE_BOTTOM_LEFT,
|
|
|
|
SUB_WINDOW_RESIZE_BOTTOM,
|
|
|
|
SUB_WINDOW_RESIZE_BOTTOM_RIGHT,
|
|
|
|
SUB_WINDOW_RESIZE_MAX
|
|
|
|
};
|
|
|
|
|
|
|
|
struct SubWindow {
|
|
|
|
Window *window;
|
|
|
|
RID canvas_item;
|
|
|
|
};
|
|
|
|
|
2016-01-17 01:41:10 +00:00
|
|
|
struct GUI {
|
|
|
|
// info used when this is a window
|
|
|
|
|
2020-03-20 02:32:09 +00:00
|
|
|
bool forced_mouse_focus; //used for menu buttons
|
2016-01-17 01:41:10 +00:00
|
|
|
bool key_event_accepted;
|
|
|
|
Control *mouse_focus;
|
2018-10-26 19:23:47 +00:00
|
|
|
Control *last_mouse_focus;
|
2018-03-27 21:41:27 +00:00
|
|
|
Control *mouse_click_grabber;
|
2018-11-28 12:31:17 +00:00
|
|
|
int mouse_focus_mask;
|
2016-01-17 01:41:10 +00:00
|
|
|
Control *key_focus;
|
|
|
|
Control *mouse_over;
|
2020-03-24 23:15:35 +00:00
|
|
|
Control *drag_mouse_over;
|
|
|
|
Vector2 drag_mouse_over_pos;
|
2020-11-02 16:18:29 +00:00
|
|
|
Control *tooltip_control;
|
2020-03-20 20:51:53 +00:00
|
|
|
Window *tooltip_popup;
|
2016-01-17 01:41:10 +00:00
|
|
|
Label *tooltip_label;
|
|
|
|
Point2 tooltip_pos;
|
|
|
|
Point2 last_mouse_pos;
|
|
|
|
Point2 drag_accum;
|
|
|
|
bool drag_attempted;
|
|
|
|
Variant drag_data;
|
|
|
|
Control *drag_preview;
|
2016-01-25 13:30:03 +00:00
|
|
|
float tooltip_timer;
|
|
|
|
float tooltip_delay;
|
2017-01-11 03:52:51 +00:00
|
|
|
Transform2D focus_inv_xform;
|
2016-01-17 01:41:10 +00:00
|
|
|
bool roots_order_dirty;
|
2017-03-05 15:44:50 +00:00
|
|
|
List<Control *> roots;
|
2016-10-03 19:33:42 +00:00
|
|
|
int canvas_sort_index; //for sorting items with canvas as root
|
2018-08-24 13:29:27 +00:00
|
|
|
bool dragging;
|
2020-03-04 01:51:12 +00:00
|
|
|
bool embed_subwindows_hint;
|
2020-03-14 16:06:39 +00:00
|
|
|
bool embedding_subwindows;
|
|
|
|
|
|
|
|
Window *subwindow_focused;
|
|
|
|
SubWindowDrag subwindow_drag;
|
|
|
|
Vector2 subwindow_drag_from;
|
|
|
|
Vector2 subwindow_drag_pos;
|
|
|
|
Rect2i subwindow_drag_close_rect;
|
|
|
|
bool subwindow_drag_close_inside;
|
|
|
|
SubWindowResize subwindow_resize_mode;
|
|
|
|
Rect2i subwindow_resize_from_rect;
|
|
|
|
|
|
|
|
Vector<SubWindow> sub_windows;
|
2016-01-17 01:41:10 +00:00
|
|
|
|
|
|
|
GUI();
|
|
|
|
} gui;
|
|
|
|
|
2019-06-25 01:24:07 +00:00
|
|
|
DefaultCanvasItemTextureFilter default_canvas_item_texture_filter;
|
|
|
|
DefaultCanvasItemTextureRepeat default_canvas_item_texture_repeat;
|
|
|
|
|
2016-01-17 01:41:10 +00:00
|
|
|
bool disable_input;
|
|
|
|
|
2017-05-20 15:38:03 +00:00
|
|
|
void _gui_call_input(Control *p_control, const Ref<InputEvent> &p_input);
|
2019-01-18 20:53:36 +00:00
|
|
|
void _gui_call_notification(Control *p_control, int p_what);
|
|
|
|
|
2016-01-17 01:41:10 +00:00
|
|
|
void _gui_sort_roots();
|
2017-03-05 15:44:50 +00:00
|
|
|
Control *_gui_find_control(const Point2 &p_global);
|
|
|
|
Control *_gui_find_control_at_pos(CanvasItem *p_node, const Point2 &p_global, const Transform2D &p_xform, Transform2D &r_inv_xform);
|
2016-01-17 01:41:10 +00:00
|
|
|
|
2017-05-20 15:38:03 +00:00
|
|
|
void _gui_input_event(Ref<InputEvent> p_event);
|
2016-01-17 01:41:10 +00:00
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
void update_worlds();
|
|
|
|
|
2017-01-11 03:52:51 +00:00
|
|
|
_FORCE_INLINE_ Transform2D _get_input_pre_xform() const;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-05-20 15:38:03 +00:00
|
|
|
Ref<InputEvent> _make_input_local(const Ref<InputEvent> &ev);
|
2016-01-17 01:41:10 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
friend class Control;
|
2016-01-17 01:41:10 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
List<Control *>::Element *_gui_add_root_control(Control *p_control);
|
2016-01-17 01:41:10 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
void _gui_remove_root_control(List<Control *>::Element *RI);
|
2016-01-17 01:41:10 +00:00
|
|
|
|
2020-11-02 16:18:29 +00:00
|
|
|
String _gui_get_tooltip(Control *p_control, const Vector2 &p_pos, Control **r_tooltip_owner = nullptr);
|
2016-01-17 01:41:10 +00:00
|
|
|
void _gui_cancel_tooltip();
|
|
|
|
void _gui_show_tooltip();
|
|
|
|
|
|
|
|
void _gui_remove_control(Control *p_control);
|
2020-09-09 01:08:21 +00:00
|
|
|
void _gui_hide_control(Control *p_control);
|
2016-01-17 01:41:10 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
void _gui_force_drag(Control *p_base, const Variant &p_data, Control *p_control);
|
|
|
|
void _gui_set_drag_preview(Control *p_base, Control *p_control);
|
2016-01-17 01:41:10 +00:00
|
|
|
|
2020-07-01 13:59:42 +00:00
|
|
|
void _gui_remove_focus_for_window(Node *p_window);
|
2016-01-17 01:41:10 +00:00
|
|
|
void _gui_remove_focus();
|
|
|
|
void _gui_unfocus_control(Control *p_control);
|
2017-03-05 15:44:50 +00:00
|
|
|
bool _gui_control_has_focus(const Control *p_control);
|
|
|
|
void _gui_control_grab_focus(Control *p_control);
|
2016-01-17 01:41:10 +00:00
|
|
|
void _gui_grab_click_focus(Control *p_control);
|
2018-03-27 21:41:27 +00:00
|
|
|
void _post_gui_grab_click_focus();
|
2016-01-17 01:41:10 +00:00
|
|
|
void _gui_accept_event();
|
|
|
|
|
|
|
|
Control *_gui_get_focus_owner();
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
bool _gui_drop(Control *p_at_control, Point2 p_at_pos, bool p_just_check);
|
2017-01-24 02:12:08 +00:00
|
|
|
|
2020-03-26 21:49:16 +00:00
|
|
|
friend class Listener3D;
|
2016-03-20 02:10:04 +00:00
|
|
|
void _listener_transform_changed_notify();
|
2020-03-26 21:49:16 +00:00
|
|
|
void _listener_set(Listener3D *p_listener);
|
|
|
|
bool _listener_add(Listener3D *p_listener); //true if first
|
|
|
|
void _listener_remove(Listener3D *p_listener);
|
|
|
|
void _listener_make_next_current(Listener3D *p_exclude);
|
2016-03-20 02:10:04 +00:00
|
|
|
|
2020-03-26 21:49:16 +00:00
|
|
|
friend class Camera3D;
|
2014-02-10 01:10:30 +00:00
|
|
|
void _camera_transform_changed_notify();
|
2020-03-26 21:49:16 +00:00
|
|
|
void _camera_set(Camera3D *p_camera);
|
|
|
|
bool _camera_add(Camera3D *p_camera); //true if first
|
|
|
|
void _camera_remove(Camera3D *p_camera);
|
|
|
|
void _camera_make_next_current(Camera3D *p_exclude);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2018-08-24 22:03:26 +00:00
|
|
|
friend class CanvasLayer;
|
|
|
|
void _canvas_layer_add(CanvasLayer *p_canvas_layer);
|
|
|
|
void _canvas_layer_remove(CanvasLayer *p_canvas_layer);
|
|
|
|
|
2018-11-28 12:31:17 +00:00
|
|
|
void _drop_mouse_focus();
|
2019-03-11 00:18:21 +00:00
|
|
|
void _drop_physics_mouseover();
|
2018-11-28 12:31:17 +00:00
|
|
|
|
2019-01-26 17:56:22 +00:00
|
|
|
void _update_canvas_items(Node *p_node);
|
|
|
|
|
2020-03-14 16:06:39 +00:00
|
|
|
void _gui_set_root_order_dirty();
|
|
|
|
|
2020-04-18 09:00:51 +00:00
|
|
|
void _own_world_3d_changed();
|
2019-11-29 06:41:25 +00:00
|
|
|
|
2020-03-14 16:06:39 +00:00
|
|
|
friend class Window;
|
|
|
|
|
|
|
|
void _sub_window_update_order();
|
|
|
|
void _sub_window_register(Window *p_window);
|
|
|
|
void _sub_window_update(Window *p_window);
|
|
|
|
void _sub_window_grab_focus(Window *p_window);
|
|
|
|
void _sub_window_remove(Window *p_window);
|
|
|
|
bool _sub_windows_forward_input(const Ref<InputEvent> &p_event);
|
|
|
|
SubWindowResize _sub_window_get_resize_margin(Window *p_subwindow, const Point2 &p_point);
|
|
|
|
|
2020-07-01 12:27:43 +00:00
|
|
|
virtual bool _can_consume_input_events() const { return true; }
|
2020-07-01 13:59:42 +00:00
|
|
|
uint64_t event_count = 0;
|
2020-07-01 12:27:43 +00:00
|
|
|
|
2016-03-08 23:00:52 +00:00
|
|
|
protected:
|
2020-04-01 03:47:58 +00:00
|
|
|
void _set_size(const Size2i &p_size, const Size2i &p_size_2d_override, const Rect2i &p_to_screen_rect, const Transform2D &p_stretch_transform, bool p_allocated);
|
2020-03-04 01:51:12 +00:00
|
|
|
|
|
|
|
Size2i _get_size() const;
|
2020-04-01 03:47:58 +00:00
|
|
|
Size2i _get_size_2d_override() const;
|
2020-03-04 01:51:12 +00:00
|
|
|
bool _is_size_allocated() const;
|
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
void _notification(int p_what);
|
|
|
|
static void _bind_methods();
|
2020-07-10 10:34:39 +00:00
|
|
|
virtual void _validate_property(PropertyInfo &property) const override;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
public:
|
2020-07-01 13:59:42 +00:00
|
|
|
uint64_t get_processed_events_count() const { return event_count; }
|
|
|
|
|
2020-03-26 21:49:16 +00:00
|
|
|
Listener3D *get_listener() const;
|
|
|
|
Camera3D *get_camera() const;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2019-04-06 20:55:01 +00:00
|
|
|
void enable_camera_override(bool p_enable);
|
|
|
|
bool is_camera_override_enabled() const;
|
|
|
|
|
|
|
|
void set_camera_override_transform(const Transform &p_transform);
|
|
|
|
Transform get_camera_override_transform() const;
|
|
|
|
|
|
|
|
void set_camera_override_perspective(float p_fovy_degrees, float p_z_near, float p_z_far);
|
|
|
|
void set_camera_override_orthogonal(float p_size, float p_z_near, float p_z_far);
|
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
void set_as_audio_listener(bool p_enable);
|
|
|
|
bool is_audio_listener() const;
|
|
|
|
|
|
|
|
void set_as_audio_listener_2d(bool p_enable);
|
|
|
|
bool is_audio_listener_2d() const;
|
|
|
|
|
2019-01-26 17:56:22 +00:00
|
|
|
void update_canvas_items();
|
2016-10-03 19:33:42 +00:00
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
Rect2 get_visible_rect() const;
|
2017-01-14 14:07:57 +00:00
|
|
|
RID get_viewport_rid() const;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2020-04-18 09:00:51 +00:00
|
|
|
void set_world_3d(const Ref<World3D> &p_world_3d);
|
2017-03-05 15:44:50 +00:00
|
|
|
void set_world_2d(const Ref<World2D> &p_world_2d);
|
2020-04-18 09:00:51 +00:00
|
|
|
Ref<World3D> get_world_3d() const;
|
|
|
|
Ref<World3D> find_world_3d() const;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2016-07-13 18:51:38 +00:00
|
|
|
Ref<World2D> get_world_2d() const;
|
2014-02-10 01:10:30 +00:00
|
|
|
Ref<World2D> find_world_2d() const;
|
|
|
|
|
2019-04-06 20:55:01 +00:00
|
|
|
void enable_canvas_transform_override(bool p_enable);
|
|
|
|
bool is_canvas_transform_override_enbled() const;
|
|
|
|
|
|
|
|
void set_canvas_transform_override(const Transform2D &p_transform);
|
|
|
|
Transform2D get_canvas_transform_override() const;
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
void set_canvas_transform(const Transform2D &p_transform);
|
2017-01-11 03:52:51 +00:00
|
|
|
Transform2D get_canvas_transform() const;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
void set_global_canvas_transform(const Transform2D &p_transform);
|
2017-01-11 03:52:51 +00:00
|
|
|
Transform2D get_global_canvas_transform() const;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-01-11 03:52:51 +00:00
|
|
|
Transform2D get_final_transform() const;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
void set_transparent_background(bool p_enable);
|
|
|
|
bool has_transparent_background() const;
|
|
|
|
|
2016-10-05 04:26:35 +00:00
|
|
|
Ref<ViewportTexture> get_texture() const;
|
2015-02-21 09:35:06 +00:00
|
|
|
|
2016-11-10 02:55:06 +00:00
|
|
|
void set_shadow_atlas_size(int p_size);
|
|
|
|
int get_shadow_atlas_size() const;
|
2014-05-14 04:22:15 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
void set_shadow_atlas_quadrant_subdiv(int p_quadrant, ShadowAtlasQuadrantSubdiv p_subdiv);
|
2016-11-10 02:55:06 +00:00
|
|
|
ShadowAtlasQuadrantSubdiv get_shadow_atlas_quadrant_subdiv(int p_quadrant) const;
|
2014-08-14 13:31:38 +00:00
|
|
|
|
2017-01-02 01:16:52 +00:00
|
|
|
void set_msaa(MSAA p_msaa);
|
|
|
|
MSAA get_msaa() const;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2020-04-12 04:49:10 +00:00
|
|
|
void set_screen_space_aa(ScreenSpaceAA p_screen_space_aa);
|
|
|
|
ScreenSpaceAA get_screen_space_aa() const;
|
|
|
|
|
2020-04-20 21:34:47 +00:00
|
|
|
void set_use_debanding(bool p_use_debanding);
|
|
|
|
bool is_using_debanding() const;
|
|
|
|
|
2020-12-17 18:56:59 +00:00
|
|
|
void set_lod_threshold(float p_pixels);
|
|
|
|
float get_lod_threshold() const;
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
Vector2 get_camera_coords(const Vector2 &p_viewport_coords) const;
|
2014-10-28 01:54:32 +00:00
|
|
|
Vector2 get_camera_rect_size() const;
|
|
|
|
|
2020-04-18 09:00:51 +00:00
|
|
|
void set_use_own_world_3d(bool p_world_3d);
|
|
|
|
bool is_using_own_world_3d() const;
|
2014-04-15 01:43:44 +00:00
|
|
|
|
2020-03-04 16:36:09 +00:00
|
|
|
void input_text(const String &p_text);
|
|
|
|
void input(const Ref<InputEvent> &p_event, bool p_local_coords = false);
|
|
|
|
void unhandled_input(const Ref<InputEvent> &p_event, bool p_local_coords = false);
|
2014-04-10 03:18:27 +00:00
|
|
|
|
2016-01-17 01:41:10 +00:00
|
|
|
void set_disable_input(bool p_disable);
|
|
|
|
bool is_input_disabled() const;
|
|
|
|
|
2017-03-29 15:29:38 +00:00
|
|
|
Vector2 get_mouse_position() const;
|
2017-03-05 15:44:50 +00:00
|
|
|
void warp_mouse(const Vector2 &p_pos);
|
2015-02-14 22:22:06 +00:00
|
|
|
|
2014-09-15 14:33:30 +00:00
|
|
|
void set_physics_object_picking(bool p_enable);
|
|
|
|
bool get_physics_object_picking();
|
|
|
|
|
2016-05-11 14:46:08 +00:00
|
|
|
Variant gui_get_drag_data() const;
|
2016-01-17 01:41:10 +00:00
|
|
|
|
2016-10-03 19:33:42 +00:00
|
|
|
void gui_reset_canvas_sort_index();
|
|
|
|
int gui_get_canvas_sort_index();
|
|
|
|
|
2020-07-10 10:34:39 +00:00
|
|
|
virtual String get_configuration_warning() const override;
|
2016-05-17 21:27:15 +00:00
|
|
|
|
2017-06-11 18:52:03 +00:00
|
|
|
void set_debug_draw(DebugDraw p_debug_draw);
|
|
|
|
DebugDraw get_debug_draw() const;
|
|
|
|
|
|
|
|
int get_render_info(RenderInfo p_info);
|
|
|
|
|
2017-09-07 14:22:07 +00:00
|
|
|
void set_snap_controls_to_pixels(bool p_enable);
|
|
|
|
bool is_snap_controls_to_pixels_enabled() const;
|
|
|
|
|
2020-10-29 21:09:16 +00:00
|
|
|
void set_snap_2d_transforms_to_pixel(bool p_enable);
|
|
|
|
bool is_snap_2d_transforms_to_pixel_enabled() const;
|
|
|
|
|
|
|
|
void set_snap_2d_vertices_to_pixel(bool p_enable);
|
|
|
|
bool is_snap_2d_vertices_to_pixel_enabled() const;
|
|
|
|
|
2018-11-15 16:54:26 +00:00
|
|
|
void set_input_as_handled();
|
|
|
|
bool is_input_handled() const;
|
|
|
|
|
|
|
|
void set_handle_input_locally(bool p_enable);
|
|
|
|
bool is_handling_input_locally() const;
|
|
|
|
|
2018-08-24 13:29:27 +00:00
|
|
|
bool gui_is_dragging() const;
|
|
|
|
|
2020-11-26 12:50:21 +00:00
|
|
|
void set_sdf_oversize(SDFOversize p_sdf_oversize);
|
|
|
|
SDFOversize get_sdf_oversize() const;
|
|
|
|
|
|
|
|
void set_sdf_scale(SDFScale p_sdf_scale);
|
|
|
|
SDFScale get_sdf_scale() const;
|
|
|
|
|
2019-06-25 01:24:07 +00:00
|
|
|
void set_default_canvas_item_texture_filter(DefaultCanvasItemTextureFilter p_filter);
|
|
|
|
DefaultCanvasItemTextureFilter get_default_canvas_item_texture_filter() const;
|
|
|
|
|
|
|
|
void set_default_canvas_item_texture_repeat(DefaultCanvasItemTextureRepeat p_repeat);
|
|
|
|
DefaultCanvasItemTextureRepeat get_default_canvas_item_texture_repeat() const;
|
|
|
|
|
2020-03-04 01:51:12 +00:00
|
|
|
virtual DisplayServer::WindowID get_window_id() const = 0;
|
|
|
|
|
|
|
|
void set_embed_subwindows_hint(bool p_embed);
|
|
|
|
bool get_embed_subwindows_hint() const;
|
|
|
|
bool is_embedding_subwindows() const;
|
2020-03-03 13:36:29 +00:00
|
|
|
|
2020-03-04 01:51:12 +00:00
|
|
|
Viewport *get_parent_viewport() const;
|
2020-07-01 13:59:42 +00:00
|
|
|
Window *get_base_window() const;
|
2020-03-20 02:32:09 +00:00
|
|
|
|
|
|
|
void pass_mouse_focus_to(Viewport *p_viewport, Control *p_control);
|
|
|
|
|
2016-03-08 23:00:52 +00:00
|
|
|
Viewport();
|
2014-02-10 01:10:30 +00:00
|
|
|
~Viewport();
|
|
|
|
};
|
|
|
|
|
2020-03-04 01:51:12 +00:00
|
|
|
class SubViewport : public Viewport {
|
|
|
|
GDCLASS(SubViewport, Viewport);
|
|
|
|
|
|
|
|
public:
|
|
|
|
enum ClearMode {
|
|
|
|
CLEAR_MODE_ALWAYS,
|
|
|
|
CLEAR_MODE_NEVER,
|
2020-12-10 12:19:04 +00:00
|
|
|
CLEAR_MODE_ONCE
|
2020-03-04 01:51:12 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum UpdateMode {
|
|
|
|
UPDATE_DISABLED,
|
|
|
|
UPDATE_ONCE, //then goes to disabled
|
|
|
|
UPDATE_WHEN_VISIBLE, // default
|
2020-03-14 16:06:39 +00:00
|
|
|
UPDATE_WHEN_PARENT_VISIBLE,
|
2020-03-04 01:51:12 +00:00
|
|
|
UPDATE_ALWAYS
|
|
|
|
};
|
|
|
|
|
|
|
|
private:
|
|
|
|
UpdateMode update_mode;
|
|
|
|
ClearMode clear_mode;
|
2020-04-08 14:47:36 +00:00
|
|
|
bool xr;
|
2020-04-01 03:47:58 +00:00
|
|
|
bool size_2d_override_stretch;
|
2020-03-04 01:51:12 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
static void _bind_methods();
|
2020-07-10 10:34:39 +00:00
|
|
|
virtual DisplayServer::WindowID get_window_id() const override;
|
2020-04-01 03:47:58 +00:00
|
|
|
Transform2D _stretch_transform();
|
2020-03-14 16:06:39 +00:00
|
|
|
void _notification(int p_what);
|
2020-03-04 01:51:12 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
void set_size(const Size2i &p_size);
|
|
|
|
Size2i get_size() const;
|
|
|
|
|
2020-04-01 03:47:58 +00:00
|
|
|
void set_size_2d_override(const Size2i &p_size);
|
|
|
|
Size2i get_size_2d_override() const;
|
|
|
|
|
2020-04-08 14:47:36 +00:00
|
|
|
void set_use_xr(bool p_use_xr);
|
|
|
|
bool is_using_xr();
|
2020-03-04 01:51:12 +00:00
|
|
|
|
2020-04-01 03:47:58 +00:00
|
|
|
void set_size_2d_override_stretch(bool p_enable);
|
|
|
|
bool is_size_2d_override_stretch_enabled() const;
|
|
|
|
|
2020-03-04 01:51:12 +00:00
|
|
|
void set_update_mode(UpdateMode p_mode);
|
|
|
|
UpdateMode get_update_mode() const;
|
|
|
|
|
|
|
|
void set_clear_mode(ClearMode p_mode);
|
|
|
|
ClearMode get_clear_mode() const;
|
|
|
|
|
|
|
|
SubViewport();
|
|
|
|
~SubViewport();
|
|
|
|
};
|
|
|
|
VARIANT_ENUM_CAST(SubViewport::UpdateMode);
|
2017-03-05 15:44:50 +00:00
|
|
|
VARIANT_ENUM_CAST(Viewport::ShadowAtlasQuadrantSubdiv);
|
|
|
|
VARIANT_ENUM_CAST(Viewport::MSAA);
|
2020-04-12 04:49:10 +00:00
|
|
|
VARIANT_ENUM_CAST(Viewport::ScreenSpaceAA);
|
2017-06-11 18:52:03 +00:00
|
|
|
VARIANT_ENUM_CAST(Viewport::DebugDraw);
|
2020-11-26 12:50:21 +00:00
|
|
|
VARIANT_ENUM_CAST(Viewport::SDFScale);
|
|
|
|
VARIANT_ENUM_CAST(Viewport::SDFOversize);
|
2020-03-04 01:51:12 +00:00
|
|
|
VARIANT_ENUM_CAST(SubViewport::ClearMode);
|
2017-06-11 18:52:03 +00:00
|
|
|
VARIANT_ENUM_CAST(Viewport::RenderInfo);
|
2019-06-25 01:24:07 +00:00
|
|
|
VARIANT_ENUM_CAST(Viewport::DefaultCanvasItemTextureFilter);
|
|
|
|
VARIANT_ENUM_CAST(Viewport::DefaultCanvasItemTextureRepeat);
|
2016-11-10 02:55:06 +00:00
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
#endif
|