2023-01-05 13:25:55 +01:00
|
|
|
/**************************************************************************/
|
|
|
|
/* viewport.h */
|
|
|
|
/**************************************************************************/
|
|
|
|
/* This file is part of: */
|
|
|
|
/* GODOT ENGINE */
|
|
|
|
/* https://godotengine.org */
|
|
|
|
/**************************************************************************/
|
|
|
|
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
|
|
|
|
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
|
|
|
|
/* */
|
|
|
|
/* 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
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
#ifndef VIEWPORT_H
|
|
|
|
#define VIEWPORT_H
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
#include "scene/main/node.h"
|
2014-02-10 02:10:30 +01:00
|
|
|
#include "scene/resources/texture.h"
|
|
|
|
|
2021-07-04 03:43:23 +02:00
|
|
|
#ifndef _3D_DISABLED
|
2020-03-26 22:49:16 +01:00
|
|
|
class Camera3D;
|
2021-08-13 01:05:59 +02:00
|
|
|
class CollisionObject3D;
|
2021-09-16 21:28:20 +02:00
|
|
|
class AudioListener3D;
|
2021-08-13 01:05:59 +02:00
|
|
|
class World3D;
|
2021-07-04 03:43:23 +02:00
|
|
|
#endif // _3D_DISABLED
|
2021-08-13 01:05:59 +02:00
|
|
|
|
2021-09-16 21:28:20 +02:00
|
|
|
class AudioListener2D;
|
2021-08-13 01:05:59 +02:00
|
|
|
class Camera2D;
|
2016-01-17 02:41:10 +01:00
|
|
|
class CanvasItem;
|
2018-08-25 00:03:26 +02:00
|
|
|
class CanvasLayer;
|
2021-08-13 01:05:59 +02:00
|
|
|
class Control;
|
2016-01-17 02:41:10 +01:00
|
|
|
class Label;
|
2021-02-27 00:37:20 +01:00
|
|
|
class SceneTreeTimer;
|
2021-08-13 01:05:59 +02:00
|
|
|
class Viewport;
|
|
|
|
class Window;
|
|
|
|
class World2D;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2019-06-11 20:43:37 +02:00
|
|
|
class ViewportTexture : public Texture2D {
|
|
|
|
GDCLASS(ViewportTexture, Texture2D);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-01-10 05:04:31 +01:00
|
|
|
NodePath path;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
friend class Viewport;
|
2021-02-09 18:24:36 +01:00
|
|
|
Viewport *vp = nullptr;
|
2023-04-06 14:47:49 +02:00
|
|
|
bool vp_pending = false;
|
2023-05-18 16:49:10 +02:00
|
|
|
bool vp_changed = false;
|
2023-04-06 14:47:49 +02:00
|
|
|
|
|
|
|
void _setup_local_to_scene(const Node *p_loc_scene);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2019-06-24 21:13:06 +02:00
|
|
|
mutable RID proxy_ph;
|
|
|
|
mutable RID proxy;
|
2017-12-04 19:55:20 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
protected:
|
2017-01-10 05:04:31 +01:00
|
|
|
static void _bind_methods();
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2023-07-08 13:38:27 +02:00
|
|
|
virtual void reset_local_to_scene() override;
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
public:
|
|
|
|
void set_viewport_path_in_scene(const NodePath &p_path);
|
2017-01-10 05:04:31 +01:00
|
|
|
NodePath get_viewport_path_in_scene() const;
|
|
|
|
|
2020-07-10 12:34:39 +02:00
|
|
|
virtual void setup_local_to_scene() override;
|
2017-01-10 05:04:31 +01:00
|
|
|
|
2020-07-10 12:34:39 +02: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 02:10:30 +01:00
|
|
|
|
2020-07-10 12:34:39 +02:00
|
|
|
virtual bool has_alpha() const override;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2021-03-28 13:32:17 +02:00
|
|
|
virtual Ref<Image> get_image() const override;
|
2017-06-09 05:23:50 +02:00
|
|
|
|
2017-01-10 05:04:31 +01:00
|
|
|
ViewportTexture();
|
|
|
|
~ViewportTexture();
|
2014-02-10 02:10:30 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
class Viewport : public Node {
|
2017-03-05 16:44:50 +01:00
|
|
|
GDCLASS(Viewport, Node);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
public:
|
2021-11-23 22:16:03 +01:00
|
|
|
enum Scaling3DMode {
|
|
|
|
SCALING_3D_MODE_BILINEAR,
|
|
|
|
SCALING_3D_MODE_FSR,
|
2023-09-22 23:38:02 +02:00
|
|
|
SCALING_3D_MODE_FSR2,
|
2021-11-23 22:16:03 +01:00
|
|
|
SCALING_3D_MODE_MAX
|
|
|
|
};
|
|
|
|
|
2022-05-01 01:40:30 +02:00
|
|
|
enum PositionalShadowAtlasQuadrantSubdiv {
|
2016-11-10 03:55:06 +01:00
|
|
|
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 02:16:52 +01:00
|
|
|
enum MSAA {
|
|
|
|
MSAA_DISABLED,
|
|
|
|
MSAA_2X,
|
|
|
|
MSAA_4X,
|
|
|
|
MSAA_8X,
|
2021-05-25 16:25:10 +02:00
|
|
|
// 16x MSAA is not supported due to its high cost and driver bugs.
|
2020-04-12 06:49:10 +02:00
|
|
|
MSAA_MAX
|
|
|
|
};
|
|
|
|
|
|
|
|
enum ScreenSpaceAA {
|
|
|
|
SCREEN_SPACE_AA_DISABLED,
|
|
|
|
SCREEN_SPACE_AA_FXAA,
|
|
|
|
SCREEN_SPACE_AA_MAX
|
2014-02-10 02:10:30 +01:00
|
|
|
};
|
|
|
|
|
2017-06-11 20:52:03 +02:00
|
|
|
enum RenderInfo {
|
|
|
|
RENDER_INFO_OBJECTS_IN_FRAME,
|
2021-07-03 01:14:19 +02:00
|
|
|
RENDER_INFO_PRIMITIVES_IN_FRAME,
|
2017-06-11 20:52:03 +02:00
|
|
|
RENDER_INFO_DRAW_CALLS_IN_FRAME,
|
|
|
|
RENDER_INFO_MAX
|
|
|
|
};
|
|
|
|
|
2021-07-03 01:14:19 +02:00
|
|
|
enum RenderInfoType {
|
|
|
|
RENDER_INFO_TYPE_VISIBLE,
|
|
|
|
RENDER_INFO_TYPE_SHADOW,
|
2024-03-23 14:02:59 +01:00
|
|
|
RENDER_INFO_TYPE_CANVAS,
|
2021-07-03 01:14:19 +02:00
|
|
|
RENDER_INFO_TYPE_MAX
|
|
|
|
};
|
|
|
|
|
2017-06-11 20:52:03 +02:00
|
|
|
enum DebugDraw {
|
|
|
|
DEBUG_DRAW_DISABLED,
|
|
|
|
DEBUG_DRAW_UNSHADED,
|
2019-10-03 22:39:08 +02:00
|
|
|
DEBUG_DRAW_LIGHTING,
|
2017-06-11 20:52:03 +02:00
|
|
|
DEBUG_DRAW_OVERDRAW,
|
|
|
|
DEBUG_DRAW_WIREFRAME,
|
2020-01-27 00:09:40 +01:00
|
|
|
DEBUG_DRAW_NORMAL_BUFFER,
|
2021-06-05 00:47:26 +02:00
|
|
|
DEBUG_DRAW_VOXEL_GI_ALBEDO,
|
|
|
|
DEBUG_DRAW_VOXEL_GI_LIGHTING,
|
|
|
|
DEBUG_DRAW_VOXEL_GI_EMISSION,
|
2019-10-03 22:39:08 +02:00
|
|
|
DEBUG_DRAW_SHADOW_ATLAS,
|
|
|
|
DEBUG_DRAW_DIRECTIONAL_SHADOW_ATLAS,
|
2020-01-12 02:26:52 +01:00
|
|
|
DEBUG_DRAW_SCENE_LUMINANCE,
|
2020-01-25 11:18:55 +01:00
|
|
|
DEBUG_DRAW_SSAO,
|
2021-08-03 09:07:32 +02:00
|
|
|
DEBUG_DRAW_SSIL,
|
2020-04-14 05:05:21 +02:00
|
|
|
DEBUG_DRAW_PSSM_SPLITS,
|
2020-06-25 15:33:28 +02:00
|
|
|
DEBUG_DRAW_DECAL_ATLAS,
|
|
|
|
DEBUG_DRAW_SDFGI,
|
|
|
|
DEBUG_DRAW_SDFGI_PROBES,
|
|
|
|
DEBUG_DRAW_GI_BUFFER,
|
2020-12-17 19:56:59 +01:00
|
|
|
DEBUG_DRAW_DISABLE_LOD,
|
2021-01-17 17:25:38 +01:00
|
|
|
DEBUG_DRAW_CLUSTER_OMNI_LIGHTS,
|
|
|
|
DEBUG_DRAW_CLUSTER_SPOT_LIGHTS,
|
|
|
|
DEBUG_DRAW_CLUSTER_DECALS,
|
|
|
|
DEBUG_DRAW_CLUSTER_REFLECTION_PROBES,
|
2021-04-20 18:40:24 +02:00
|
|
|
DEBUG_DRAW_OCCLUDERS,
|
2022-04-04 16:10:22 +02:00
|
|
|
DEBUG_DRAW_MOTION_VECTORS,
|
2023-09-22 23:38:02 +02:00
|
|
|
DEBUG_DRAW_INTERNAL_BUFFER,
|
2017-06-11 20:52:03 +02:00
|
|
|
};
|
|
|
|
|
2019-06-25 03:24:07 +02: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-20 00:31:43 +01:00
|
|
|
DEFAULT_CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS,
|
2019-06-25 03:24:07 +02: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 13:50:21 +01: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 17:06:39 +01:00
|
|
|
enum {
|
|
|
|
SUBWINDOW_CANVAS_LAYER = 1024
|
|
|
|
};
|
|
|
|
|
2022-02-11 12:33:54 +01:00
|
|
|
enum VRSMode {
|
|
|
|
VRS_DISABLED,
|
|
|
|
VRS_TEXTURE,
|
|
|
|
VRS_XR,
|
|
|
|
VRS_MAX
|
|
|
|
};
|
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
private:
|
2017-03-05 16:44:50 +01:00
|
|
|
friend class ViewportTexture;
|
2016-01-18 23:49:11 +01:00
|
|
|
|
2021-02-09 18:24:36 +01:00
|
|
|
Viewport *parent = nullptr;
|
2022-10-04 04:12:11 +02:00
|
|
|
Viewport *gui_parent = nullptr; // Whose gui.tooltip_popup it is.
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2022-05-19 17:00:06 +02:00
|
|
|
HashSet<CanvasLayer *> canvas_layers;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
RID viewport;
|
|
|
|
RID current_canvas;
|
2020-03-14 17:06:39 +01:00
|
|
|
RID subwindow_canvas;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2021-02-09 18:24:36 +01:00
|
|
|
bool override_canvas_transform = false;
|
2019-04-06 22:55:01 +02:00
|
|
|
|
|
|
|
Transform2D canvas_transform_override;
|
2017-01-11 04:52:51 +01:00
|
|
|
Transform2D canvas_transform;
|
|
|
|
Transform2D global_canvas_transform;
|
|
|
|
Transform2D stretch_transform;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2021-05-18 18:38:49 +02:00
|
|
|
Size2i size = Size2i(512, 512);
|
2020-04-01 05:47:58 +02:00
|
|
|
Size2i size_2d_override;
|
2021-02-09 18:24:36 +01:00
|
|
|
bool size_allocated = false;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2015-09-20 18:03:46 +02:00
|
|
|
RID contact_2d_debug;
|
|
|
|
RID contact_3d_debug_multimesh;
|
|
|
|
RID contact_3d_debug_instance;
|
|
|
|
|
2014-10-28 02:54:32 +01:00
|
|
|
Rect2 last_vp_rect;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2021-02-09 18:24:36 +01:00
|
|
|
bool transparent_bg = false;
|
2023-08-03 14:10:01 +02:00
|
|
|
bool use_hdr_2d = false;
|
2021-02-09 18:24:36 +01:00
|
|
|
bool gen_mipmaps = false;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2021-02-09 18:24:36 +01:00
|
|
|
bool snap_controls_to_pixels = true;
|
|
|
|
bool snap_2d_transforms_to_pixel = false;
|
|
|
|
bool snap_2d_vertices_to_pixel = false;
|
2017-09-07 16:22:07 +02:00
|
|
|
|
2021-02-09 18:24:36 +01:00
|
|
|
bool physics_object_picking = false;
|
2022-11-10 22:55:57 +01:00
|
|
|
bool physics_object_picking_sort = false;
|
2023-04-04 19:04:49 +02:00
|
|
|
bool physics_object_picking_first_only = false;
|
2020-03-17 07:33:00 +01:00
|
|
|
List<Ref<InputEvent>> physics_picking_events;
|
2014-09-15 16:33:30 +02:00
|
|
|
ObjectID physics_object_capture;
|
|
|
|
ObjectID physics_object_over;
|
2020-10-17 07:08:21 +02:00
|
|
|
Transform3D physics_last_object_transform;
|
|
|
|
Transform3D physics_last_camera_transform;
|
2018-11-15 17:54:26 +01:00
|
|
|
ObjectID physics_last_id;
|
|
|
|
|
2021-02-09 18:24:36 +01:00
|
|
|
bool handle_input_locally = true;
|
|
|
|
bool local_input_handled = false;
|
2018-11-15 17:54:26 +01:00
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
Ref<World2D> world_2d;
|
|
|
|
|
2014-04-10 05:18:27 +02:00
|
|
|
StringName input_group;
|
2022-01-11 14:59:52 +01:00
|
|
|
StringName shortcut_input_group;
|
2014-04-10 05:18:27 +02:00
|
|
|
StringName unhandled_input_group;
|
|
|
|
StringName unhandled_key_input_group;
|
|
|
|
|
2021-09-16 21:28:20 +02:00
|
|
|
void _update_audio_listener_2d();
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2021-06-29 18:36:32 +02:00
|
|
|
bool disable_3d = false;
|
|
|
|
|
2016-05-11 16:46:08 +02:00
|
|
|
void _propagate_viewport_notification(Node *p_node, int p_what);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
void _update_global_transform();
|
|
|
|
|
2016-10-03 21:33:42 +02:00
|
|
|
RID texture_rid;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2021-02-09 18:24:36 +01:00
|
|
|
DebugDraw debug_draw = DEBUG_DRAW_DISABLED;
|
2017-06-11 20:52:03 +02:00
|
|
|
|
2022-05-01 01:40:30 +02:00
|
|
|
int positional_shadow_atlas_size = 2048;
|
|
|
|
bool positional_shadow_atlas_16_bits = true;
|
|
|
|
PositionalShadowAtlasQuadrantSubdiv positional_shadow_atlas_quadrant_subdiv[4];
|
2016-11-10 03:55:06 +01:00
|
|
|
|
2022-08-13 01:02:32 +02:00
|
|
|
MSAA msaa_2d = MSAA_DISABLED;
|
|
|
|
MSAA msaa_3d = MSAA_DISABLED;
|
2021-02-09 18:24:36 +01:00
|
|
|
ScreenSpaceAA screen_space_aa = SCREEN_SPACE_AA_DISABLED;
|
2022-04-04 16:10:22 +02:00
|
|
|
bool use_taa = false;
|
2021-11-23 22:16:03 +01:00
|
|
|
|
|
|
|
Scaling3DMode scaling_3d_mode = SCALING_3D_MODE_BILINEAR;
|
|
|
|
float scaling_3d_scale = 1.0;
|
|
|
|
float fsr_sharpness = 0.2f;
|
2022-06-12 01:49:59 +02:00
|
|
|
float texture_mipmap_bias = 0.0f;
|
2020-10-26 21:37:33 +01:00
|
|
|
bool use_debanding = false;
|
2021-12-29 00:10:41 +01:00
|
|
|
float mesh_lod_threshold = 1.0;
|
2021-04-20 18:40:24 +02:00
|
|
|
bool use_occlusion_culling = false;
|
2020-12-17 19:56:59 +01:00
|
|
|
|
2017-01-10 22:02:19 +01:00
|
|
|
Ref<ViewportTexture> default_texture;
|
2022-05-19 17:00:06 +02:00
|
|
|
HashSet<ViewportTexture *> viewport_textures;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2022-08-14 13:17:45 +02:00
|
|
|
void _update_viewport_path();
|
|
|
|
|
2021-02-09 18:24:36 +01:00
|
|
|
SDFOversize sdf_oversize = SDF_OVERSIZE_120_PERCENT;
|
|
|
|
SDFScale sdf_scale = SDF_SCALE_50_PERCENT;
|
2020-11-26 13:50:21 +01:00
|
|
|
|
2021-09-02 20:07:04 +02:00
|
|
|
uint32_t canvas_cull_mask = 0xffffffff; // by default show everything
|
|
|
|
|
2020-03-14 17:06:39 +01: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 {
|
2021-02-09 18:24:36 +01:00
|
|
|
Window *window = nullptr;
|
2020-03-14 17:06:39 +01:00
|
|
|
RID canvas_item;
|
2023-06-20 15:50:44 +02:00
|
|
|
Rect2i parent_safe_rect;
|
2020-03-14 17:06:39 +01:00
|
|
|
};
|
|
|
|
|
2022-02-11 12:33:54 +01:00
|
|
|
// VRS
|
|
|
|
VRSMode vrs_mode = VRS_DISABLED;
|
|
|
|
Ref<Texture2D> vrs_texture;
|
|
|
|
|
2016-01-17 02:41:10 +01:00
|
|
|
struct GUI {
|
2021-02-09 18:24:36 +01:00
|
|
|
bool forced_mouse_focus = false; //used for menu buttons
|
2024-02-29 00:54:37 +01:00
|
|
|
bool mouse_in_viewport = false;
|
2021-02-09 18:24:36 +01:00
|
|
|
bool key_event_accepted = false;
|
2022-11-14 01:09:03 +01:00
|
|
|
HashMap<int, ObjectID> touch_focus;
|
2021-02-09 18:24:36 +01:00
|
|
|
Control *mouse_focus = nullptr;
|
|
|
|
Control *last_mouse_focus = nullptr;
|
|
|
|
Control *mouse_click_grabber = nullptr;
|
2023-01-08 00:55:54 +01:00
|
|
|
BitField<MouseButtonMask> mouse_focus_mask;
|
2021-02-09 18:24:36 +01:00
|
|
|
Control *key_focus = nullptr;
|
|
|
|
Control *mouse_over = nullptr;
|
2023-10-31 18:55:34 +01:00
|
|
|
LocalVector<Control *> mouse_over_hierarchy;
|
2023-11-24 04:38:34 +01:00
|
|
|
bool sending_mouse_enter_exit_notifications = false;
|
2023-01-06 21:48:20 +01:00
|
|
|
Window *subwindow_over = nullptr; // mouse_over and subwindow_over are mutually exclusive. At all times at least one of them is nullptr.
|
|
|
|
Window *windowmanager_window_over = nullptr; // Only used in root Viewport.
|
2021-02-09 18:24:36 +01:00
|
|
|
Control *drag_mouse_over = nullptr;
|
2020-03-25 00:15:35 +01:00
|
|
|
Vector2 drag_mouse_over_pos;
|
2021-02-09 18:24:36 +01:00
|
|
|
Control *tooltip_control = nullptr;
|
|
|
|
Window *tooltip_popup = nullptr;
|
|
|
|
Label *tooltip_label = nullptr;
|
2023-09-24 07:18:17 +02:00
|
|
|
String tooltip_text;
|
2016-01-17 02:41:10 +01:00
|
|
|
Point2 tooltip_pos;
|
|
|
|
Point2 last_mouse_pos;
|
|
|
|
Point2 drag_accum;
|
2021-02-09 18:24:36 +01:00
|
|
|
bool drag_attempted = false;
|
2016-01-17 02:41:10 +01:00
|
|
|
Variant drag_data;
|
2021-02-24 12:47:14 +01:00
|
|
|
ObjectID drag_preview_id;
|
2021-02-27 00:37:20 +01:00
|
|
|
Ref<SceneTreeTimer> tooltip_timer;
|
2021-02-02 03:16:37 +01:00
|
|
|
double tooltip_delay = 0.0;
|
2021-02-09 18:24:36 +01:00
|
|
|
bool roots_order_dirty = false;
|
2017-03-05 16:44:50 +01:00
|
|
|
List<Control *> roots;
|
2023-04-05 18:53:32 +02:00
|
|
|
HashSet<ObjectID> canvas_parents_with_dirty_order;
|
2021-02-09 18:24:36 +01:00
|
|
|
int canvas_sort_index = 0; //for sorting items with canvas as root
|
|
|
|
bool dragging = false;
|
2021-10-28 09:07:18 +02:00
|
|
|
bool drag_successful = false;
|
2021-02-09 18:24:36 +01:00
|
|
|
bool embed_subwindows_hint = false;
|
2020-03-14 17:06:39 +01:00
|
|
|
|
2021-02-09 18:24:36 +01:00
|
|
|
Window *subwindow_focused = nullptr;
|
2023-06-04 19:09:54 +02:00
|
|
|
Window *currently_dragged_subwindow = nullptr;
|
2021-02-09 18:24:36 +01:00
|
|
|
SubWindowDrag subwindow_drag = SUB_WINDOW_DRAG_DISABLED;
|
2020-03-14 17:06:39 +01:00
|
|
|
Vector2 subwindow_drag_from;
|
|
|
|
Vector2 subwindow_drag_pos;
|
|
|
|
Rect2i subwindow_drag_close_rect;
|
2021-02-09 18:24:36 +01:00
|
|
|
bool subwindow_drag_close_inside = false;
|
2020-03-14 17:06:39 +01:00
|
|
|
SubWindowResize subwindow_resize_mode;
|
|
|
|
Rect2i subwindow_resize_from_rect;
|
|
|
|
|
2021-11-30 00:36:47 +01:00
|
|
|
Vector<SubWindow> sub_windows; // Don't obtain references or pointers to the elements, as their location can change.
|
2016-01-17 02:41:10 +01:00
|
|
|
} gui;
|
|
|
|
|
2021-02-09 18:24:36 +01:00
|
|
|
DefaultCanvasItemTextureFilter default_canvas_item_texture_filter = DEFAULT_CANVAS_ITEM_TEXTURE_FILTER_LINEAR;
|
|
|
|
DefaultCanvasItemTextureRepeat default_canvas_item_texture_repeat = DEFAULT_CANVAS_ITEM_TEXTURE_REPEAT_DISABLED;
|
2019-06-25 03:24:07 +02:00
|
|
|
|
2021-02-09 18:24:36 +01:00
|
|
|
bool disable_input = false;
|
2016-01-17 02:41:10 +01:00
|
|
|
|
2022-05-16 15:10:30 +02:00
|
|
|
bool _gui_call_input(Control *p_control, const Ref<InputEvent> &p_input);
|
2019-01-18 21:53:36 +01:00
|
|
|
void _gui_call_notification(Control *p_control, int p_what);
|
|
|
|
|
2016-01-17 02:41:10 +01:00
|
|
|
void _gui_sort_roots();
|
2022-12-05 10:41:32 +01:00
|
|
|
Control *_gui_find_control_at_pos(CanvasItem *p_node, const Point2 &p_global, const Transform2D &p_xform);
|
2016-01-17 02:41:10 +01:00
|
|
|
|
2017-05-20 17:38:03 +02:00
|
|
|
void _gui_input_event(Ref<InputEvent> p_event);
|
2022-11-08 19:02:47 +01:00
|
|
|
void _perform_drop(Control *p_control = nullptr, Point2 p_pos = Point2());
|
2022-03-13 23:54:13 +01:00
|
|
|
void _gui_cleanup_internal_state(Ref<InputEvent> p_event);
|
2016-01-17 02:41:10 +01:00
|
|
|
|
2023-05-10 21:51:50 +02:00
|
|
|
void _push_unhandled_input_internal(const Ref<InputEvent> &p_event);
|
|
|
|
|
2017-05-20 17:38:03 +02:00
|
|
|
Ref<InputEvent> _make_input_local(const Ref<InputEvent> &ev);
|
2016-01-17 02:41:10 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
friend class Control;
|
2016-01-17 02:41:10 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
List<Control *>::Element *_gui_add_root_control(Control *p_control);
|
2016-01-17 02:41:10 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
void _gui_remove_root_control(List<Control *>::Element *RI);
|
2016-01-17 02:41:10 +01:00
|
|
|
|
2020-11-02 17:18:29 +01:00
|
|
|
String _gui_get_tooltip(Control *p_control, const Vector2 &p_pos, Control **r_tooltip_owner = nullptr);
|
2016-01-17 02:41:10 +01:00
|
|
|
void _gui_cancel_tooltip();
|
|
|
|
void _gui_show_tooltip();
|
|
|
|
|
|
|
|
void _gui_remove_control(Control *p_control);
|
2020-09-09 03:08:21 +02:00
|
|
|
void _gui_hide_control(Control *p_control);
|
2023-10-31 18:55:34 +01:00
|
|
|
void _gui_update_mouse_over();
|
2016-01-17 02:41:10 +01:00
|
|
|
|
2017-03-05 16:44:50 +01: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);
|
2021-02-24 12:47:14 +01:00
|
|
|
Control *_gui_get_drag_preview();
|
2016-01-17 02:41:10 +01:00
|
|
|
|
2020-07-01 15:59:42 +02:00
|
|
|
void _gui_remove_focus_for_window(Node *p_window);
|
2016-01-17 02:41:10 +01:00
|
|
|
void _gui_unfocus_control(Control *p_control);
|
2017-03-05 16:44:50 +01:00
|
|
|
bool _gui_control_has_focus(const Control *p_control);
|
|
|
|
void _gui_control_grab_focus(Control *p_control);
|
2016-01-17 02:41:10 +01:00
|
|
|
void _gui_grab_click_focus(Control *p_control);
|
2018-03-27 23:41:27 +02:00
|
|
|
void _post_gui_grab_click_focus();
|
2016-01-17 02:41:10 +01:00
|
|
|
void _gui_accept_event();
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
bool _gui_drop(Control *p_at_control, Point2 p_at_pos, bool p_just_check);
|
2017-01-24 03:12:08 +01:00
|
|
|
|
2018-08-25 00:03:26 +02:00
|
|
|
friend class CanvasLayer;
|
|
|
|
void _canvas_layer_add(CanvasLayer *p_canvas_layer);
|
|
|
|
void _canvas_layer_remove(CanvasLayer *p_canvas_layer);
|
|
|
|
|
2023-10-31 18:55:34 +01:00
|
|
|
void _drop_mouse_over(Control *p_until_control = nullptr);
|
2018-11-28 13:31:17 +01:00
|
|
|
void _drop_mouse_focus();
|
2021-02-06 21:14:35 +01:00
|
|
|
void _drop_physics_mouseover(bool p_paused_only = false);
|
2018-11-28 13:31:17 +01:00
|
|
|
|
2019-01-26 18:56:22 +01:00
|
|
|
void _update_canvas_items(Node *p_node);
|
|
|
|
|
2020-03-14 17:06:39 +01: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);
|
2023-06-20 15:50:44 +02:00
|
|
|
int _sub_window_find(Window *p_window) const;
|
2020-03-14 17:06:39 +01:00
|
|
|
bool _sub_windows_forward_input(const Ref<InputEvent> &p_event);
|
|
|
|
SubWindowResize _sub_window_get_resize_margin(Window *p_subwindow, const Point2 &p_point);
|
|
|
|
|
2023-01-06 21:48:20 +01:00
|
|
|
void _update_mouse_over();
|
2023-08-06 13:07:28 +02:00
|
|
|
virtual void _update_mouse_over(Vector2 p_pos);
|
|
|
|
virtual void _mouse_leave_viewport();
|
2023-01-06 21:48:20 +01:00
|
|
|
|
2020-07-01 14:27:43 +02:00
|
|
|
virtual bool _can_consume_input_events() const { return true; }
|
2020-07-01 15:59:42 +02:00
|
|
|
uint64_t event_count = 0;
|
2020-07-01 14:27:43 +02:00
|
|
|
|
2023-04-05 18:53:32 +02:00
|
|
|
void _process_dirty_canvas_parent_orders();
|
2023-07-08 05:57:31 +02:00
|
|
|
void _propagate_world_2d_changed(Node *p_node);
|
2023-04-05 18:53:32 +02:00
|
|
|
|
2016-03-09 00:00:52 +01:00
|
|
|
protected:
|
2023-02-02 19:00:07 +01:00
|
|
|
void _set_size(const Size2i &p_size, const Size2i &p_size_2d_override, bool p_allocated);
|
2020-03-04 02:51:12 +01:00
|
|
|
|
|
|
|
Size2i _get_size() const;
|
2020-04-01 05:47:58 +02:00
|
|
|
Size2i _get_size_2d_override() const;
|
2020-03-04 02:51:12 +01:00
|
|
|
bool _is_size_allocated() const;
|
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
void _notification(int p_what);
|
2021-02-06 21:14:35 +01:00
|
|
|
void _process_picking();
|
2014-02-10 02:10:30 +01:00
|
|
|
static void _bind_methods();
|
2023-07-08 05:57:31 +02:00
|
|
|
void _validate_property(PropertyInfo &p_property) const;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
public:
|
2023-04-05 18:53:32 +02:00
|
|
|
void canvas_parent_mark_dirty(Node *p_node);
|
2023-10-31 18:55:34 +01:00
|
|
|
void canvas_item_top_level_changed();
|
2023-04-05 18:53:32 +02:00
|
|
|
|
2020-07-01 15:59:42 +02:00
|
|
|
uint64_t get_processed_events_count() const { return event_count; }
|
|
|
|
|
2019-01-26 18:56:22 +01:00
|
|
|
void update_canvas_items();
|
2016-10-03 21:33:42 +02:00
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
Rect2 get_visible_rect() const;
|
2017-01-14 15:07:57 +01:00
|
|
|
RID get_viewport_rid() const;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
void set_world_2d(const Ref<World2D> &p_world_2d);
|
2016-07-13 20:51:38 +02:00
|
|
|
Ref<World2D> get_world_2d() const;
|
2014-02-10 02:10:30 +01:00
|
|
|
Ref<World2D> find_world_2d() const;
|
|
|
|
|
2019-04-06 22:55:01 +02:00
|
|
|
void enable_canvas_transform_override(bool p_enable);
|
2023-08-07 12:59:23 +02:00
|
|
|
bool is_canvas_transform_override_enabled() const;
|
2019-04-06 22:55:01 +02:00
|
|
|
|
|
|
|
void set_canvas_transform_override(const Transform2D &p_transform);
|
|
|
|
Transform2D get_canvas_transform_override() const;
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
void set_canvas_transform(const Transform2D &p_transform);
|
2017-01-11 04:52:51 +01:00
|
|
|
Transform2D get_canvas_transform() const;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
void set_global_canvas_transform(const Transform2D &p_transform);
|
2017-01-11 04:52:51 +01:00
|
|
|
Transform2D get_global_canvas_transform() const;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2023-02-02 19:28:14 +01:00
|
|
|
virtual Transform2D get_final_transform() const;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2022-04-01 21:18:16 +02:00
|
|
|
void gui_set_root_order_dirty();
|
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
void set_transparent_background(bool p_enable);
|
|
|
|
bool has_transparent_background() const;
|
|
|
|
|
2023-08-03 14:10:01 +02:00
|
|
|
void set_use_hdr_2d(bool p_enable);
|
|
|
|
bool is_using_hdr_2d() const;
|
|
|
|
|
2016-10-05 06:26:35 +02:00
|
|
|
Ref<ViewportTexture> get_texture() const;
|
2015-02-21 10:35:06 +01:00
|
|
|
|
2022-05-01 01:40:30 +02:00
|
|
|
void set_positional_shadow_atlas_size(int p_size);
|
|
|
|
int get_positional_shadow_atlas_size() const;
|
2014-05-14 06:22:15 +02:00
|
|
|
|
2022-05-01 01:40:30 +02:00
|
|
|
void set_positional_shadow_atlas_16_bits(bool p_16_bits);
|
|
|
|
bool get_positional_shadow_atlas_16_bits() const;
|
2021-01-24 20:00:20 +01:00
|
|
|
|
2022-05-01 01:40:30 +02:00
|
|
|
void set_positional_shadow_atlas_quadrant_subdiv(int p_quadrant, PositionalShadowAtlasQuadrantSubdiv p_subdiv);
|
|
|
|
PositionalShadowAtlasQuadrantSubdiv get_positional_shadow_atlas_quadrant_subdiv(int p_quadrant) const;
|
2014-08-14 15:31:38 +02:00
|
|
|
|
2022-08-13 01:02:32 +02:00
|
|
|
void set_msaa_2d(MSAA p_msaa);
|
|
|
|
MSAA get_msaa_2d() const;
|
|
|
|
|
|
|
|
void set_msaa_3d(MSAA p_msaa);
|
|
|
|
MSAA get_msaa_3d() const;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2020-04-12 06:49:10 +02:00
|
|
|
void set_screen_space_aa(ScreenSpaceAA p_screen_space_aa);
|
|
|
|
ScreenSpaceAA get_screen_space_aa() const;
|
|
|
|
|
2022-04-04 16:10:22 +02:00
|
|
|
void set_use_taa(bool p_use_taa);
|
|
|
|
bool is_using_taa() const;
|
|
|
|
|
2021-11-23 22:16:03 +01:00
|
|
|
void set_scaling_3d_mode(Scaling3DMode p_scaling_3d_mode);
|
|
|
|
Scaling3DMode get_scaling_3d_mode() const;
|
|
|
|
|
|
|
|
void set_scaling_3d_scale(float p_scaling_3d_scale);
|
|
|
|
float get_scaling_3d_scale() const;
|
|
|
|
|
|
|
|
void set_fsr_sharpness(float p_fsr_sharpness);
|
|
|
|
float get_fsr_sharpness() const;
|
|
|
|
|
2022-06-12 01:49:59 +02:00
|
|
|
void set_texture_mipmap_bias(float p_texture_mipmap_bias);
|
|
|
|
float get_texture_mipmap_bias() const;
|
2021-11-23 22:16:03 +01:00
|
|
|
|
2020-04-20 23:34:47 +02:00
|
|
|
void set_use_debanding(bool p_use_debanding);
|
|
|
|
bool is_using_debanding() const;
|
|
|
|
|
2021-12-29 00:10:41 +01:00
|
|
|
void set_mesh_lod_threshold(float p_pixels);
|
|
|
|
float get_mesh_lod_threshold() const;
|
2020-12-17 19:56:59 +01:00
|
|
|
|
2021-04-20 18:40:24 +02:00
|
|
|
void set_use_occlusion_culling(bool p_us_occlusion_culling);
|
|
|
|
bool is_using_occlusion_culling() const;
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
Vector2 get_camera_coords(const Vector2 &p_viewport_coords) const;
|
2014-10-28 02:54:32 +01:00
|
|
|
Vector2 get_camera_rect_size() const;
|
|
|
|
|
2021-08-22 17:37:22 +02:00
|
|
|
void push_text_input(const String &p_text);
|
|
|
|
void push_input(const Ref<InputEvent> &p_event, bool p_local_coords = false);
|
2023-05-10 21:51:50 +02:00
|
|
|
#ifndef DISABLE_DEPRECATED
|
2021-08-22 17:37:22 +02:00
|
|
|
void push_unhandled_input(const Ref<InputEvent> &p_event, bool p_local_coords = false);
|
2023-05-10 21:51:50 +02:00
|
|
|
#endif // DISABLE_DEPRECATED
|
2014-04-10 05:18:27 +02:00
|
|
|
|
2016-01-17 02:41:10 +01:00
|
|
|
void set_disable_input(bool p_disable);
|
|
|
|
bool is_input_disabled() const;
|
|
|
|
|
2017-03-29 17:29:38 +02:00
|
|
|
Vector2 get_mouse_position() const;
|
2022-09-07 19:31:57 +02:00
|
|
|
void warp_mouse(const Vector2 &p_position);
|
2022-09-29 23:45:51 +02:00
|
|
|
virtual void update_mouse_cursor_state();
|
2015-02-14 23:22:06 +01:00
|
|
|
|
2014-09-15 16:33:30 +02:00
|
|
|
void set_physics_object_picking(bool p_enable);
|
|
|
|
bool get_physics_object_picking();
|
2022-11-10 22:55:57 +01:00
|
|
|
void set_physics_object_picking_sort(bool p_enable);
|
|
|
|
bool get_physics_object_picking_sort();
|
2023-04-04 19:04:49 +02:00
|
|
|
void set_physics_object_picking_first_only(bool p_enable);
|
|
|
|
bool get_physics_object_picking_first_only();
|
2014-09-15 16:33:30 +02:00
|
|
|
|
2016-05-11 16:46:08 +02:00
|
|
|
Variant gui_get_drag_data() const;
|
2016-01-17 02:41:10 +01:00
|
|
|
|
2016-10-03 21:33:42 +02:00
|
|
|
void gui_reset_canvas_sort_index();
|
|
|
|
int gui_get_canvas_sort_index();
|
|
|
|
|
2022-02-01 15:07:22 +01:00
|
|
|
void gui_release_focus();
|
2023-06-02 16:57:10 +02:00
|
|
|
Control *gui_get_focus_owner() const;
|
2023-12-18 14:50:21 +01:00
|
|
|
Control *gui_get_hovered_control() const;
|
2022-02-01 15:07:22 +01:00
|
|
|
|
2024-02-17 19:03:21 +01:00
|
|
|
PackedStringArray get_configuration_warnings() const override;
|
2016-05-17 23:27:15 +02:00
|
|
|
|
2017-06-11 20:52:03 +02:00
|
|
|
void set_debug_draw(DebugDraw p_debug_draw);
|
|
|
|
DebugDraw get_debug_draw() const;
|
|
|
|
|
2021-07-03 01:14:19 +02:00
|
|
|
int get_render_info(RenderInfoType p_type, RenderInfo p_info);
|
2017-06-11 20:52:03 +02:00
|
|
|
|
2017-09-07 16:22:07 +02:00
|
|
|
void set_snap_controls_to_pixels(bool p_enable);
|
|
|
|
bool is_snap_controls_to_pixels_enabled() const;
|
|
|
|
|
2020-10-29 22:09:16 +01: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 17:54:26 +01: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 15:29:27 +02:00
|
|
|
bool gui_is_dragging() const;
|
2021-10-28 09:07:18 +02:00
|
|
|
bool gui_is_drag_successful() const;
|
2018-08-24 15:29:27 +02:00
|
|
|
|
2021-07-19 22:09:23 +02:00
|
|
|
Control *gui_find_control(const Point2 &p_global);
|
|
|
|
|
2020-11-26 13:50:21 +01: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 03:24:07 +02: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;
|
|
|
|
|
2022-02-11 12:33:54 +01:00
|
|
|
// VRS
|
|
|
|
|
|
|
|
void set_vrs_mode(VRSMode p_vrs_mode);
|
|
|
|
VRSMode get_vrs_mode() const;
|
|
|
|
|
|
|
|
void set_vrs_texture(Ref<Texture2D> p_texture);
|
|
|
|
Ref<Texture2D> get_vrs_texture() const;
|
|
|
|
|
2020-03-04 02:51:12 +01:00
|
|
|
virtual DisplayServer::WindowID get_window_id() const = 0;
|
|
|
|
|
2022-03-13 16:18:44 +01:00
|
|
|
void set_embedding_subwindows(bool p_embed);
|
2020-03-04 02:51:12 +01:00
|
|
|
bool is_embedding_subwindows() const;
|
2023-08-16 03:06:15 +02:00
|
|
|
TypedArray<Window> get_embedded_subwindows() const;
|
2023-06-20 15:50:44 +02:00
|
|
|
void subwindow_set_popup_safe_rect(Window *p_window, const Rect2i &p_rect);
|
|
|
|
Rect2i subwindow_get_popup_safe_rect(Window *p_window) const;
|
2020-03-03 14:36:29 +01:00
|
|
|
|
2020-03-04 02:51:12 +01:00
|
|
|
Viewport *get_parent_viewport() const;
|
2020-07-01 15:59:42 +02:00
|
|
|
Window *get_base_window() const;
|
2020-03-20 03:32:09 +01:00
|
|
|
|
|
|
|
void pass_mouse_focus_to(Viewport *p_viewport, Control *p_control);
|
|
|
|
|
2021-09-02 20:07:04 +02:00
|
|
|
void set_canvas_cull_mask(uint32_t p_layers);
|
|
|
|
uint32_t get_canvas_cull_mask() const;
|
|
|
|
|
|
|
|
void set_canvas_cull_mask_bit(uint32_t p_layer, bool p_enable);
|
|
|
|
bool get_canvas_cull_mask_bit(uint32_t p_layer) const;
|
|
|
|
|
2022-10-13 02:17:04 +02:00
|
|
|
virtual bool is_size_2d_override_stretch_enabled() const { return true; }
|
|
|
|
|
2023-01-20 22:33:05 +01:00
|
|
|
Transform2D get_screen_transform() const;
|
|
|
|
virtual Transform2D get_screen_transform_internal(bool p_absolute_position = false) const;
|
2022-11-13 21:38:29 +01:00
|
|
|
virtual Transform2D get_popup_base_transform() const { return Transform2D(); }
|
2023-06-06 20:42:41 +02:00
|
|
|
virtual bool is_directly_attached_to_screen() const { return false; };
|
2023-01-06 21:48:20 +01:00
|
|
|
virtual bool is_attached_in_viewport() const { return false; };
|
|
|
|
virtual bool is_sub_viewport() const { return false; };
|
2022-03-28 11:01:29 +02:00
|
|
|
|
2023-07-08 05:57:31 +02:00
|
|
|
private:
|
|
|
|
// 2D audio, camera, and physics. (don't put World2D here because World2D is needed for Control nodes).
|
|
|
|
friend class AudioListener2D; // Needs _audio_listener_2d_set and _audio_listener_2d_remove
|
|
|
|
AudioListener2D *audio_listener_2d = nullptr;
|
|
|
|
void _audio_listener_2d_set(AudioListener2D *p_audio_listener);
|
|
|
|
void _audio_listener_2d_remove(AudioListener2D *p_audio_listener);
|
|
|
|
bool is_audio_listener_2d_enabled = false;
|
|
|
|
RID internal_audio_listener_2d;
|
|
|
|
|
|
|
|
friend class Camera2D; // Needs _camera_2d_set
|
|
|
|
Camera2D *camera_2d = nullptr;
|
|
|
|
void _camera_2d_set(Camera2D *p_camera_2d);
|
|
|
|
|
|
|
|
// Collider to frame
|
|
|
|
HashMap<ObjectID, uint64_t> physics_2d_mouseover;
|
|
|
|
// Collider & shape to frame
|
|
|
|
HashMap<Pair<ObjectID, int>, uint64_t, PairHash<ObjectID, int>> physics_2d_shape_mouseover;
|
|
|
|
// Cleans up colliders corresponding to old frames or all of them.
|
|
|
|
void _cleanup_mouseover_colliders(bool p_clean_all_frames, bool p_paused_only, uint64_t p_frame_reference = 0);
|
|
|
|
|
|
|
|
public:
|
|
|
|
AudioListener2D *get_audio_listener_2d() const;
|
|
|
|
void set_as_audio_listener_2d(bool p_enable);
|
|
|
|
bool is_audio_listener_2d() const;
|
|
|
|
|
|
|
|
Camera2D *get_camera_2d() const;
|
|
|
|
void assign_next_enabled_camera_2d(const StringName &p_camera_group);
|
|
|
|
|
2021-07-04 03:43:23 +02:00
|
|
|
#ifndef _3D_DISABLED
|
2023-07-08 05:57:31 +02:00
|
|
|
private:
|
|
|
|
// 3D audio, camera, physics, and world.
|
2021-08-02 19:31:51 +02:00
|
|
|
bool use_xr = false;
|
2021-09-16 21:28:20 +02:00
|
|
|
friend class AudioListener3D;
|
|
|
|
AudioListener3D *audio_listener_3d = nullptr;
|
2022-05-19 17:00:06 +02:00
|
|
|
HashSet<AudioListener3D *> audio_listener_3d_set;
|
2021-09-16 21:28:20 +02:00
|
|
|
bool is_audio_listener_3d_enabled = false;
|
|
|
|
RID internal_audio_listener_3d;
|
|
|
|
void _update_audio_listener_3d();
|
2021-08-02 19:31:51 +02:00
|
|
|
void _listener_transform_3d_changed_notify();
|
2021-09-16 21:28:20 +02:00
|
|
|
void _audio_listener_3d_set(AudioListener3D *p_listener);
|
|
|
|
bool _audio_listener_3d_add(AudioListener3D *p_listener); //true if first
|
|
|
|
void _audio_listener_3d_remove(AudioListener3D *p_listener);
|
|
|
|
void _audio_listener_3d_make_next_current(AudioListener3D *p_exclude);
|
2021-08-02 19:31:51 +02:00
|
|
|
|
|
|
|
void _collision_object_3d_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);
|
|
|
|
|
|
|
|
struct Camera3DOverrideData {
|
|
|
|
Transform3D transform;
|
|
|
|
enum Projection {
|
|
|
|
PROJECTION_PERSPECTIVE,
|
|
|
|
PROJECTION_ORTHOGONAL
|
|
|
|
};
|
|
|
|
Projection projection = Projection::PROJECTION_PERSPECTIVE;
|
|
|
|
real_t fov = 0.0;
|
|
|
|
real_t size = 0.0;
|
|
|
|
real_t z_near = 0.0;
|
|
|
|
real_t z_far = 0.0;
|
|
|
|
RID rid;
|
|
|
|
|
|
|
|
operator bool() const {
|
|
|
|
return rid != RID();
|
|
|
|
}
|
|
|
|
} camera_3d_override;
|
|
|
|
|
|
|
|
friend class Camera3D;
|
|
|
|
Camera3D *camera_3d = nullptr;
|
2022-05-19 17:00:06 +02:00
|
|
|
HashSet<Camera3D *> camera_3d_set;
|
2021-08-02 19:31:51 +02:00
|
|
|
void _camera_3d_transform_changed_notify();
|
|
|
|
void _camera_3d_set(Camera3D *p_camera);
|
|
|
|
bool _camera_3d_add(Camera3D *p_camera); //true if first
|
|
|
|
void _camera_3d_remove(Camera3D *p_camera);
|
|
|
|
void _camera_3d_make_next_current(Camera3D *p_exclude);
|
|
|
|
|
2023-07-08 05:57:31 +02:00
|
|
|
Ref<World3D> world_3d;
|
|
|
|
Ref<World3D> own_world_3d;
|
|
|
|
void _own_world_3d_changed();
|
|
|
|
void _propagate_enter_world_3d(Node *p_node);
|
|
|
|
void _propagate_exit_world_3d(Node *p_node);
|
|
|
|
|
|
|
|
public:
|
|
|
|
AudioListener3D *get_audio_listener_3d() const;
|
|
|
|
void set_as_audio_listener_3d(bool p_enable);
|
|
|
|
bool is_audio_listener_3d() const;
|
|
|
|
|
|
|
|
Camera3D *get_camera_3d() const;
|
2021-08-02 19:31:51 +02:00
|
|
|
void enable_camera_3d_override(bool p_enable);
|
|
|
|
bool is_camera_3d_override_enabled() const;
|
|
|
|
|
|
|
|
void set_camera_3d_override_transform(const Transform3D &p_transform);
|
|
|
|
Transform3D get_camera_3d_override_transform() const;
|
|
|
|
|
|
|
|
void set_camera_3d_override_perspective(real_t p_fovy_degrees, real_t p_z_near, real_t p_z_far);
|
|
|
|
void set_camera_3d_override_orthogonal(real_t p_size, real_t p_z_near, real_t p_z_far);
|
|
|
|
|
|
|
|
void set_disable_3d(bool p_disable);
|
|
|
|
bool is_3d_disabled() const;
|
|
|
|
|
|
|
|
void set_world_3d(const Ref<World3D> &p_world_3d);
|
|
|
|
Ref<World3D> get_world_3d() const;
|
|
|
|
Ref<World3D> find_world_3d() const;
|
2022-06-06 15:34:40 +02:00
|
|
|
void set_use_own_world_3d(bool p_use_own_world_3d);
|
2021-08-02 19:31:51 +02:00
|
|
|
bool is_using_own_world_3d() const;
|
|
|
|
|
|
|
|
void set_use_xr(bool p_use_xr);
|
|
|
|
bool is_using_xr();
|
2021-07-04 03:43:23 +02:00
|
|
|
#endif // _3D_DISABLED
|
2021-08-02 19:31:51 +02:00
|
|
|
|
2016-03-09 00:00:52 +01:00
|
|
|
Viewport();
|
2014-02-10 02:10:30 +01:00
|
|
|
~Viewport();
|
|
|
|
};
|
|
|
|
|
2020-03-04 02:51:12 +01:00
|
|
|
class SubViewport : public Viewport {
|
|
|
|
GDCLASS(SubViewport, Viewport);
|
|
|
|
|
|
|
|
public:
|
|
|
|
enum ClearMode {
|
|
|
|
CLEAR_MODE_ALWAYS,
|
|
|
|
CLEAR_MODE_NEVER,
|
2020-12-10 13:19:04 +01:00
|
|
|
CLEAR_MODE_ONCE
|
2020-03-04 02:51:12 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
enum UpdateMode {
|
|
|
|
UPDATE_DISABLED,
|
|
|
|
UPDATE_ONCE, //then goes to disabled
|
|
|
|
UPDATE_WHEN_VISIBLE, // default
|
2020-03-14 17:06:39 +01:00
|
|
|
UPDATE_WHEN_PARENT_VISIBLE,
|
2020-03-04 02:51:12 +01:00
|
|
|
UPDATE_ALWAYS
|
|
|
|
};
|
|
|
|
|
|
|
|
private:
|
2021-02-09 18:24:36 +01:00
|
|
|
UpdateMode update_mode = UPDATE_WHEN_VISIBLE;
|
|
|
|
ClearMode clear_mode = CLEAR_MODE_ALWAYS;
|
|
|
|
bool size_2d_override_stretch = false;
|
2020-03-04 02:51:12 +01:00
|
|
|
|
2022-10-04 21:53:18 +02:00
|
|
|
void _internal_set_size(const Size2i &p_size, bool p_force = false);
|
|
|
|
|
2020-03-04 02:51:12 +01:00
|
|
|
protected:
|
|
|
|
static void _bind_methods();
|
2020-07-10 12:34:39 +02:00
|
|
|
virtual DisplayServer::WindowID get_window_id() const override;
|
2020-03-14 17:06:39 +01:00
|
|
|
void _notification(int p_what);
|
2020-03-04 02:51:12 +01:00
|
|
|
|
|
|
|
public:
|
|
|
|
void set_size(const Size2i &p_size);
|
|
|
|
Size2i get_size() const;
|
2022-10-04 21:53:18 +02:00
|
|
|
void set_size_force(const Size2i &p_size);
|
2020-03-04 02:51:12 +01:00
|
|
|
|
2020-04-01 05:47:58 +02:00
|
|
|
void set_size_2d_override(const Size2i &p_size);
|
|
|
|
Size2i get_size_2d_override() const;
|
|
|
|
|
|
|
|
void set_size_2d_override_stretch(bool p_enable);
|
2022-10-13 02:17:04 +02:00
|
|
|
bool is_size_2d_override_stretch_enabled() const override;
|
2020-04-01 05:47:58 +02:00
|
|
|
|
2020-03-04 02:51:12 +01: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;
|
|
|
|
|
2023-01-20 22:33:05 +01:00
|
|
|
virtual Transform2D get_screen_transform_internal(bool p_absolute_position = false) const override;
|
2022-11-13 21:38:29 +01:00
|
|
|
virtual Transform2D get_popup_base_transform() const override;
|
2023-06-06 20:42:41 +02:00
|
|
|
virtual bool is_directly_attached_to_screen() const override;
|
2023-01-06 21:48:20 +01:00
|
|
|
virtual bool is_attached_in_viewport() const override;
|
|
|
|
virtual bool is_sub_viewport() const override { return true; };
|
2022-03-28 11:01:29 +02:00
|
|
|
|
2023-02-13 00:34:16 +01:00
|
|
|
void _validate_property(PropertyInfo &p_property) const;
|
2020-03-04 02:51:12 +01:00
|
|
|
SubViewport();
|
|
|
|
~SubViewport();
|
|
|
|
};
|
2021-11-23 22:16:03 +01:00
|
|
|
VARIANT_ENUM_CAST(Viewport::Scaling3DMode);
|
2020-03-04 02:51:12 +01:00
|
|
|
VARIANT_ENUM_CAST(SubViewport::UpdateMode);
|
2022-05-01 01:40:30 +02:00
|
|
|
VARIANT_ENUM_CAST(Viewport::PositionalShadowAtlasQuadrantSubdiv);
|
2017-03-05 16:44:50 +01:00
|
|
|
VARIANT_ENUM_CAST(Viewport::MSAA);
|
2020-04-12 06:49:10 +02:00
|
|
|
VARIANT_ENUM_CAST(Viewport::ScreenSpaceAA);
|
2017-06-11 20:52:03 +02:00
|
|
|
VARIANT_ENUM_CAST(Viewport::DebugDraw);
|
2020-11-26 13:50:21 +01:00
|
|
|
VARIANT_ENUM_CAST(Viewport::SDFScale);
|
|
|
|
VARIANT_ENUM_CAST(Viewport::SDFOversize);
|
2022-02-11 12:33:54 +01:00
|
|
|
VARIANT_ENUM_CAST(Viewport::VRSMode);
|
2020-03-04 02:51:12 +01:00
|
|
|
VARIANT_ENUM_CAST(SubViewport::ClearMode);
|
2017-06-11 20:52:03 +02:00
|
|
|
VARIANT_ENUM_CAST(Viewport::RenderInfo);
|
2021-07-03 01:14:19 +02:00
|
|
|
VARIANT_ENUM_CAST(Viewport::RenderInfoType);
|
2019-06-25 03:24:07 +02:00
|
|
|
VARIANT_ENUM_CAST(Viewport::DefaultCanvasItemTextureFilter);
|
|
|
|
VARIANT_ENUM_CAST(Viewport::DefaultCanvasItemTextureRepeat);
|
2016-11-10 03:55:06 +01:00
|
|
|
|
2022-07-23 23:41:51 +02:00
|
|
|
#endif // VIEWPORT_H
|