| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
#pragma once |
| 32 |
|
| 33 |
#include "scene/main/node.h" |
| 34 |
#include "scene/resources/texture.h" |
| 35 |
#include "servers/display/display_server.h" |
| 36 |
|
| 37 |
#ifndef _3D_DISABLED |
| 38 |
class Camera3D; |
| 39 |
class CollisionObject3D; |
| 40 |
class AudioListener3D; |
| 41 |
class World3D; |
| 42 |
#endif |
| 43 |
|
| 44 |
class AudioListener2D; |
| 45 |
class Camera2D; |
| 46 |
class CanvasItem; |
| 47 |
class CanvasLayer; |
| 48 |
class Control; |
| 49 |
class Label; |
| 50 |
class SceneTreeTimer; |
| 51 |
class Viewport; |
| 52 |
class Window; |
| 53 |
class World2D; |
| 54 |
|
| 55 |
class ViewportTexture : public Texture2D { |
| 56 |
GDCLASS(ViewportTexture, Texture2D); |
| 57 |
|
| 58 |
NodePath path; |
| 59 |
|
| 60 |
friend class Viewport; |
| 61 |
Viewport *vp = nullptr; |
| 62 |
bool vp_pending = false; |
| 63 |
bool vp_changed = false; |
| 64 |
|
| 65 |
void _setup_local_to_scene(const Node *p_loc_scene); |
| 66 |
void _err_print_viewport_not_set() const; |
| 67 |
|
| 68 |
mutable RID proxy_ph; |
| 69 |
mutable RID proxy; |
| 70 |
|
| 71 |
protected: |
| 72 |
static void _bind_methods(); |
| 73 |
|
| 74 |
virtual void reset_local_to_scene() override; |
| 75 |
|
| 76 |
public: |
| 77 |
void set_viewport_path_in_scene(const NodePath &p_path); |
| 78 |
NodePath get_viewport_path_in_scene() const; |
| 79 |
|
| 80 |
virtual void setup_local_to_scene() override; |
| 81 |
|
| 82 |
virtual int get_width() const override; |
| 83 |
virtual int get_height() const override; |
| 84 |
virtual Size2 get_size() const override; |
| 85 |
virtual RID get_rid() const override; |
| 86 |
|
| 87 |
virtual bool has_alpha() const override; |
| 88 |
|
| 89 |
virtual Ref<Image> get_image() const override; |
| 90 |
|
| 91 |
ViewportTexture(); |
| 92 |
~ViewportTexture(); |
| 93 |
}; |
| 94 |
|
| 95 |
class Viewport : public Node { |
| 96 |
GDCLASS(Viewport, Node); |
| 97 |
|
| 98 |
public: |
| 99 |
enum Scaling3DMode { |
| 100 |
SCALING_3D_MODE_BILINEAR, |
| 101 |
SCALING_3D_MODE_FSR, |
| 102 |
SCALING_3D_MODE_FSR2, |
| 103 |
SCALING_3D_MODE_METALFX_SPATIAL, |
| 104 |
SCALING_3D_MODE_METALFX_TEMPORAL, |
| 105 |
SCALING_3D_MODE_MAX |
| 106 |
}; |
| 107 |
|
| 108 |
enum PositionalShadowAtlasQuadrantSubdiv { |
| 109 |
SHADOW_ATLAS_QUADRANT_SUBDIV_DISABLED, |
| 110 |
SHADOW_ATLAS_QUADRANT_SUBDIV_1, |
| 111 |
SHADOW_ATLAS_QUADRANT_SUBDIV_4, |
| 112 |
SHADOW_ATLAS_QUADRANT_SUBDIV_16, |
| 113 |
SHADOW_ATLAS_QUADRANT_SUBDIV_64, |
| 114 |
SHADOW_ATLAS_QUADRANT_SUBDIV_256, |
| 115 |
SHADOW_ATLAS_QUADRANT_SUBDIV_1024, |
| 116 |
SHADOW_ATLAS_QUADRANT_SUBDIV_MAX, |
| 117 |
}; |
| 118 |
|
| 119 |
enum MSAA { |
| 120 |
MSAA_DISABLED, |
| 121 |
MSAA_2X, |
| 122 |
MSAA_4X, |
| 123 |
MSAA_8X, |
| 124 |
|
| 125 |
MSAA_MAX |
| 126 |
}; |
| 127 |
|
| 128 |
enum AnisotropicFiltering { |
| 129 |
ANISOTROPY_DISABLED, |
| 130 |
ANISOTROPY_2X, |
| 131 |
ANISOTROPY_4X, |
| 132 |
ANISOTROPY_8X, |
| 133 |
ANISOTROPY_16X, |
| 134 |
ANISOTROPY_MAX |
| 135 |
}; |
| 136 |
|
| 137 |
enum ScreenSpaceAA { |
| 138 |
SCREEN_SPACE_AA_DISABLED, |
| 139 |
SCREEN_SPACE_AA_FXAA, |
| 140 |
SCREEN_SPACE_AA_SMAA, |
| 141 |
SCREEN_SPACE_AA_MAX |
| 142 |
}; |
| 143 |
|
| 144 |
enum RenderInfo { |
| 145 |
RENDER_INFO_OBJECTS_IN_FRAME, |
| 146 |
RENDER_INFO_PRIMITIVES_IN_FRAME, |
| 147 |
RENDER_INFO_DRAW_CALLS_IN_FRAME, |
| 148 |
RENDER_INFO_MAX |
| 149 |
}; |
| 150 |
|
| 151 |
enum RenderInfoType { |
| 152 |
RENDER_INFO_TYPE_VISIBLE, |
| 153 |
RENDER_INFO_TYPE_SHADOW, |
| 154 |
RENDER_INFO_TYPE_CANVAS, |
| 155 |
RENDER_INFO_TYPE_MAX |
| 156 |
}; |
| 157 |
|
| 158 |
enum DebugDraw { |
| 159 |
DEBUG_DRAW_DISABLED, |
| 160 |
DEBUG_DRAW_UNSHADED, |
| 161 |
DEBUG_DRAW_LIGHTING, |
| 162 |
DEBUG_DRAW_OVERDRAW, |
| 163 |
DEBUG_DRAW_WIREFRAME, |
| 164 |
DEBUG_DRAW_NORMAL_BUFFER, |
| 165 |
DEBUG_DRAW_VOXEL_GI_ALBEDO, |
| 166 |
DEBUG_DRAW_VOXEL_GI_LIGHTING, |
| 167 |
DEBUG_DRAW_VOXEL_GI_EMISSION, |
| 168 |
DEBUG_DRAW_SHADOW_ATLAS, |
| 169 |
DEBUG_DRAW_DIRECTIONAL_SHADOW_ATLAS, |
| 170 |
DEBUG_DRAW_SCENE_LUMINANCE, |
| 171 |
DEBUG_DRAW_SSAO, |
| 172 |
DEBUG_DRAW_SSIL, |
| 173 |
DEBUG_DRAW_PSSM_SPLITS, |
| 174 |
DEBUG_DRAW_DECAL_ATLAS, |
| 175 |
DEBUG_DRAW_SDFGI, |
| 176 |
DEBUG_DRAW_SDFGI_PROBES, |
| 177 |
DEBUG_DRAW_GI_BUFFER, |
| 178 |
DEBUG_DRAW_DISABLE_LOD, |
| 179 |
DEBUG_DRAW_CLUSTER_OMNI_LIGHTS, |
| 180 |
DEBUG_DRAW_CLUSTER_SPOT_LIGHTS, |
| 181 |
DEBUG_DRAW_CLUSTER_DECALS, |
| 182 |
DEBUG_DRAW_CLUSTER_REFLECTION_PROBES, |
| 183 |
DEBUG_DRAW_OCCLUDERS, |
| 184 |
DEBUG_DRAW_MOTION_VECTORS, |
| 185 |
DEBUG_DRAW_INTERNAL_BUFFER, |
| 186 |
}; |
| 187 |
|
| 188 |
enum DefaultCanvasItemTextureFilter { |
| 189 |
DEFAULT_CANVAS_ITEM_TEXTURE_FILTER_NEAREST, |
| 190 |
DEFAULT_CANVAS_ITEM_TEXTURE_FILTER_LINEAR, |
| 191 |
DEFAULT_CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS, |
| 192 |
DEFAULT_CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS, |
| 193 |
DEFAULT_CANVAS_ITEM_TEXTURE_FILTER_MAX |
| 194 |
}; |
| 195 |
|
| 196 |
enum DefaultCanvasItemTextureRepeat { |
| 197 |
DEFAULT_CANVAS_ITEM_TEXTURE_REPEAT_DISABLED, |
| 198 |
DEFAULT_CANVAS_ITEM_TEXTURE_REPEAT_ENABLED, |
| 199 |
DEFAULT_CANVAS_ITEM_TEXTURE_REPEAT_MIRROR, |
| 200 |
DEFAULT_CANVAS_ITEM_TEXTURE_REPEAT_MAX, |
| 201 |
}; |
| 202 |
|
| 203 |
enum SDFOversize { |
| 204 |
SDF_OVERSIZE_100_PERCENT, |
| 205 |
SDF_OVERSIZE_120_PERCENT, |
| 206 |
SDF_OVERSIZE_150_PERCENT, |
| 207 |
SDF_OVERSIZE_200_PERCENT, |
| 208 |
SDF_OVERSIZE_MAX |
| 209 |
}; |
| 210 |
|
| 211 |
enum SDFScale { |
| 212 |
SDF_SCALE_100_PERCENT, |
| 213 |
SDF_SCALE_50_PERCENT, |
| 214 |
SDF_SCALE_25_PERCENT, |
| 215 |
SDF_SCALE_MAX |
| 216 |
}; |
| 217 |
|
| 218 |
enum { |
| 219 |
SUBWINDOW_CANVAS_LAYER = 1024 |
| 220 |
}; |
| 221 |
|
| 222 |
enum VRSMode { |
| 223 |
VRS_DISABLED, |
| 224 |
VRS_TEXTURE, |
| 225 |
VRS_XR, |
| 226 |
VRS_MAX |
| 227 |
}; |
| 228 |
|
| 229 |
enum VRSUpdateMode { |
| 230 |
VRS_UPDATE_DISABLED, |
| 231 |
VRS_UPDATE_ONCE, |
| 232 |
VRS_UPDATE_ALWAYS, |
| 233 |
VRS_UPDATE_MAX |
| 234 |
}; |
| 235 |
|
| 236 |
private: |
| 237 |
friend class ViewportTexture; |
| 238 |
|
| 239 |
Viewport *parent = nullptr; |
| 240 |
Viewport *gui_parent = nullptr; |
| 241 |
|
| 242 |
HashSet<CanvasLayer *> canvas_layers; |
| 243 |
|
| 244 |
bool use_font_oversampling = true; |
| 245 |
float font_oversampling = 1.0; |
| 246 |
float font_oversampling_override = 0.0; |
| 247 |
|
| 248 |
RID viewport; |
| 249 |
RID current_canvas; |
| 250 |
RID subwindow_canvas; |
| 251 |
|
| 252 |
Transform2D canvas_transform; |
| 253 |
Transform2D global_canvas_transform; |
| 254 |
Transform2D stretch_transform; |
| 255 |
|
| 256 |
Size2i size = Size2i(512, 512); |
| 257 |
Size2 size_2d_override; |
| 258 |
bool size_allocated = false; |
| 259 |
|
| 260 |
RID contact_2d_debug; |
| 261 |
RID contact_3d_debug_multimesh; |
| 262 |
RID contact_3d_debug_instance; |
| 263 |
|
| 264 |
bool transparent_bg = false; |
| 265 |
bool use_hdr_2d = false; |
| 266 |
|
| 267 |
bool snap_controls_to_pixels = true; |
| 268 |
bool snap_2d_transforms_to_pixel = false; |
| 269 |
bool snap_2d_vertices_to_pixel = false; |
| 270 |
|
| 271 |
#if !defined(PHYSICS_2D_DISABLED) || !defined(PHYSICS_3D_DISABLED) |
| 272 |
bool physics_object_picking = false; |
| 273 |
bool physics_object_picking_sort = false; |
| 274 |
bool physics_object_picking_first_only = false; |
| 275 |
List<Ref<InputEvent>> physics_picking_events; |
| 276 |
ObjectID physics_object_capture; |
| 277 |
ObjectID physics_object_over; |
| 278 |
Transform3D physics_last_object_transform; |
| 279 |
Transform3D physics_last_camera_transform; |
| 280 |
ObjectID physics_last_id; |
| 281 |
#endif |
| 282 |
|
| 283 |
bool handle_input_locally = true; |
| 284 |
bool local_input_handled = false; |
| 285 |
|
| 286 |
Ref<World2D> world_2d; |
| 287 |
|
| 288 |
StringName input_group; |
| 289 |
StringName shortcut_input_group; |
| 290 |
StringName unhandled_input_group; |
| 291 |
StringName unhandled_key_input_group; |
| 292 |
|
| 293 |
void _update_audio_listener_2d(); |
| 294 |
|
| 295 |
bool disable_3d = false; |
| 296 |
|
| 297 |
static void _propagate_drag_notification(Node *p_node, int p_what); |
| 298 |
|
| 299 |
void _update_global_transform(); |
| 300 |
|
| 301 |
RID texture_rid; |
| 302 |
|
| 303 |
DebugDraw debug_draw = DEBUG_DRAW_DISABLED; |
| 304 |
|
| 305 |
int positional_shadow_atlas_size = 2048; |
| 306 |
bool positional_shadow_atlas_16_bits = true; |
| 307 |
PositionalShadowAtlasQuadrantSubdiv positional_shadow_atlas_quadrant_subdiv[4]; |
| 308 |
|
| 309 |
MSAA msaa_2d = MSAA_DISABLED; |
| 310 |
MSAA msaa_3d = MSAA_DISABLED; |
| 311 |
ScreenSpaceAA screen_space_aa = SCREEN_SPACE_AA_DISABLED; |
| 312 |
bool use_taa = false; |
| 313 |
|
| 314 |
Scaling3DMode scaling_3d_mode = SCALING_3D_MODE_BILINEAR; |
| 315 |
float scaling_3d_scale = 1.0; |
| 316 |
float fsr_sharpness = 0.2f; |
| 317 |
float texture_mipmap_bias = 0.0f; |
| 318 |
AnisotropicFiltering anisotropic_filtering_level = ANISOTROPY_4X; |
| 319 |
bool use_debanding = false; |
| 320 |
float mesh_lod_threshold = 1.0; |
| 321 |
bool use_occlusion_culling = false; |
| 322 |
|
| 323 |
Ref<ViewportTexture> default_texture; |
| 324 |
HashSet<ViewportTexture *> viewport_textures; |
| 325 |
|
| 326 |
void _update_viewport_path(); |
| 327 |
|
| 328 |
bool _can_hide_focus_state(); |
| 329 |
void _on_settings_changed(); |
| 330 |
|
| 331 |
SDFOversize sdf_oversize = SDF_OVERSIZE_120_PERCENT; |
| 332 |
SDFScale sdf_scale = SDF_SCALE_50_PERCENT; |
| 333 |
|
| 334 |
uint32_t canvas_cull_mask = 0xffffffff; |
| 335 |
|
| 336 |
enum SubWindowDrag { |
| 337 |
SUB_WINDOW_DRAG_DISABLED, |
| 338 |
SUB_WINDOW_DRAG_MOVE, |
| 339 |
SUB_WINDOW_DRAG_CLOSE, |
| 340 |
SUB_WINDOW_DRAG_RESIZE, |
| 341 |
}; |
| 342 |
|
| 343 |
enum SubWindowResize { |
| 344 |
SUB_WINDOW_RESIZE_DISABLED, |
| 345 |
SUB_WINDOW_RESIZE_TOP_LEFT, |
| 346 |
SUB_WINDOW_RESIZE_TOP, |
| 347 |
SUB_WINDOW_RESIZE_TOP_RIGHT, |
| 348 |
SUB_WINDOW_RESIZE_LEFT, |
| 349 |
SUB_WINDOW_RESIZE_RIGHT, |
| 350 |
SUB_WINDOW_RESIZE_BOTTOM_LEFT, |
| 351 |
SUB_WINDOW_RESIZE_BOTTOM, |
| 352 |
SUB_WINDOW_RESIZE_BOTTOM_RIGHT, |
| 353 |
SUB_WINDOW_RESIZE_MAX |
| 354 |
}; |
| 355 |
|
| 356 |
struct SubWindow { |
| 357 |
Window *window = nullptr; |
| 358 |
RID canvas_item; |
| 359 |
Rect2i parent_safe_rect; |
| 360 |
bool pending_window_update = false; |
| 361 |
}; |
| 362 |
|
| 363 |
|
| 364 |
VRSMode vrs_mode = VRS_DISABLED; |
| 365 |
VRSUpdateMode vrs_update_mode = VRS_UPDATE_ONCE; |
| 366 |
Ref<Texture2D> vrs_texture; |
| 367 |
|
| 368 |
struct GUI { |
| 369 |
bool mouse_in_viewport = false; |
| 370 |
HashMap<int, ObjectID> touch_focus; |
| 371 |
Control *mouse_focus = nullptr; |
| 372 |
Control *mouse_click_grabber = nullptr; |
| 373 |
BitField<MouseButtonMask> mouse_focus_mask = MouseButtonMask::NONE; |
| 374 |
Control *key_focus = nullptr; |
| 375 |
bool hide_focus = false; |
| 376 |
ObjectID mouse_over; |
| 377 |
LocalVector<ObjectID> mouse_over_hierarchy; |
| 378 |
bool sending_mouse_enter_exit_notifications = false; |
| 379 |
Window *subwindow_over = nullptr; |
| 380 |
Window *windowmanager_window_over = nullptr; |
| 381 |
Control *drag_mouse_over = nullptr; |
| 382 |
Control *tooltip_control = nullptr; |
| 383 |
Window *tooltip_popup = nullptr; |
| 384 |
Label *tooltip_label = nullptr; |
| 385 |
String tooltip_text; |
| 386 |
Point2 tooltip_pos; |
| 387 |
Point2 last_mouse_pos; |
| 388 |
Point2 drag_accum; |
| 389 |
bool drag_attempted = false; |
| 390 |
Variant drag_data; |
| 391 |
ObjectID drag_preview_id; |
| 392 |
String drag_description; |
| 393 |
Ref<SceneTreeTimer> tooltip_timer; |
| 394 |
double tooltip_delay = 0.0; |
| 395 |
bool roots_order_dirty = false; |
| 396 |
List<Control *> roots; |
| 397 |
HashSet<ObjectID> canvas_parents_with_dirty_order; |
| 398 |
int canvas_sort_index = 0; |
| 399 |
bool dragging = false; |
| 400 |
bool global_dragging = false; |
| 401 |
bool drag_successful = false; |
| 402 |
Control *target_control = nullptr; |
| 403 |
bool embed_subwindows_hint = false; |
| 404 |
int drag_threshold = 10; |
| 405 |
|
| 406 |
Window *subwindow_focused = nullptr; |
| 407 |
Window *currently_dragged_subwindow = nullptr; |
| 408 |
SubWindowDrag subwindow_drag = SUB_WINDOW_DRAG_DISABLED; |
| 409 |
Vector2 subwindow_drag_from; |
| 410 |
Vector2 subwindow_drag_pos; |
| 411 |
Rect2i subwindow_drag_close_rect; |
| 412 |
bool subwindow_drag_close_inside = false; |
| 413 |
SubWindowResize subwindow_resize_mode; |
| 414 |
Rect2i subwindow_resize_from_rect; |
| 415 |
|
| 416 |
Vector<SubWindow> sub_windows; |
| 417 |
} gui; |
| 418 |
|
| 419 |
DefaultCanvasItemTextureFilter default_canvas_item_texture_filter = DEFAULT_CANVAS_ITEM_TEXTURE_FILTER_LINEAR; |
| 420 |
DefaultCanvasItemTextureRepeat default_canvas_item_texture_repeat = DEFAULT_CANVAS_ITEM_TEXTURE_REPEAT_DISABLED; |
| 421 |
|
| 422 |
bool disable_input = false; |
| 423 |
bool disable_input_override = false; |
| 424 |
|
| 425 |
void _gui_call_input(Control *p_control, const Ref<InputEvent> &p_input); |
| 426 |
void _gui_call_notification(Control *p_control, int p_what); |
| 427 |
|
| 428 |
void _gui_sort_roots(); |
| 429 |
Control *_gui_find_control_at_pos(CanvasItem *p_node, const Point2 &p_global, const Transform2D &p_xform); |
| 430 |
|
| 431 |
void _gui_input_event(Ref<InputEvent> p_event); |
| 432 |
void _perform_drop(Control *p_control = nullptr); |
| 433 |
void _gui_cleanup_internal_state(Ref<InputEvent> p_event); |
| 434 |
|
| 435 |
void _push_unhandled_input_internal(const Ref<InputEvent> &p_event); |
| 436 |
|
| 437 |
Ref<InputEvent> _make_input_local(const Ref<InputEvent> &ev); |
| 438 |
|
| 439 |
friend class Control; |
| 440 |
|
| 441 |
List<Control *>::Element *_gui_add_root_control(Control *p_control); |
| 442 |
|
| 443 |
void _gui_remove_root_control(List<Control *>::Element *RI); |
| 444 |
|
| 445 |
String _gui_get_tooltip(Control *p_control, const Vector2 &p_pos, Control **r_tooltip_owner = nullptr); |
| 446 |
void _gui_cancel_tooltip(); |
| 447 |
void _gui_show_tooltip(); |
| 448 |
void _gui_show_tooltip_at(const Point2i &p_pos); |
| 449 |
|
| 450 |
void _gui_remove_control(Control *p_control); |
| 451 |
void _gui_hide_control(Control *p_control); |
| 452 |
void _gui_update_mouse_over(); |
| 453 |
|
| 454 |
void _gui_force_drag_start(); |
| 455 |
void _gui_force_drag_cancel(); |
| 456 |
void _gui_force_drag(Control *p_base, const Variant &p_data, Control *p_control); |
| 457 |
void _gui_set_drag_preview(Control *p_base, Control *p_control); |
| 458 |
Control *_gui_get_drag_preview(); |
| 459 |
|
| 460 |
void _gui_remove_focus_for_window(Node *p_window); |
| 461 |
void _gui_unfocus_control(Control *p_control); |
| 462 |
bool _gui_control_has_focus(const Control *p_control, bool p_ignore_hidden_focus = false); |
| 463 |
void _gui_control_grab_focus(Control *p_control, bool p_hide_focus = false); |
| 464 |
void _gui_grab_click_focus(Control *p_control); |
| 465 |
void _post_gui_grab_click_focus(); |
| 466 |
void _gui_accept_event(); |
| 467 |
|
| 468 |
bool _gui_drop(Control *p_at_control, Point2 p_at_pos, bool p_just_check); |
| 469 |
|
| 470 |
friend class CanvasLayer; |
| 471 |
void _canvas_layer_add(CanvasLayer *p_canvas_layer); |
| 472 |
void _canvas_layer_remove(CanvasLayer *p_canvas_layer); |
| 473 |
|
| 474 |
void _drop_mouse_over(Control *p_until_control = nullptr); |
| 475 |
void _drop_mouse_focus(); |
| 476 |
void _drop_physics_mouseover(bool p_paused_only = false); |
| 477 |
|
| 478 |
void _update_canvas_items(Node *p_node); |
| 479 |
|
| 480 |
friend class Window; |
| 481 |
|
| 482 |
void _sub_window_update_order(); |
| 483 |
void _sub_window_register(Window *p_window); |
| 484 |
void _sub_window_update(Window *p_window); |
| 485 |
void _sub_window_grab_focus(Window *p_window); |
| 486 |
void _sub_window_remove(Window *p_window); |
| 487 |
int _sub_window_find(Window *p_window) const; |
| 488 |
bool _sub_windows_forward_input(const Ref<InputEvent> &p_event); |
| 489 |
SubWindowResize _sub_window_get_resize_margin(Window *p_subwindow, const Point2 &p_point); |
| 490 |
|
| 491 |
void _update_mouse_over(const Ref<InputEventMouse> &p_mm); |
| 492 |
virtual void _update_mouse_over(Vector2 p_pos); |
| 493 |
virtual void _mouse_leave_viewport(); |
| 494 |
|
| 495 |
virtual bool _can_consume_input_events() const { return true; } |
| 496 |
uint64_t event_count = 0; |
| 497 |
|
| 498 |
void _process_dirty_canvas_parent_orders(); |
| 499 |
void _propagate_world_2d_changed(Node *p_node); |
| 500 |
|
| 501 |
void _window_start_drag(Window *p_window); |
| 502 |
void _window_start_resize(SubWindowResize p_edge, Window *p_window); |
| 503 |
|
| 504 |
protected: |
| 505 |
bool _set_size(const Size2i &p_size, const Size2 &p_size_2d_override, bool p_allocated); |
| 506 |
|
| 507 |
Size2i _get_size() const; |
| 508 |
Size2 _get_size_2d_override() const; |
| 509 |
bool _is_size_allocated() const; |
| 510 |
|
| 511 |
void _notification(int p_what); |
| 512 |
#if !defined(PHYSICS_2D_DISABLED) || !defined(PHYSICS_3D_DISABLED) |
| 513 |
void _process_picking(); |
| 514 |
#endif |
| 515 |
static void _bind_methods(); |
| 516 |
void _validate_property(PropertyInfo &p_property) const; |
| 517 |
|
| 518 |
public: |
| 519 |
void canvas_parent_mark_dirty(Node *p_node); |
| 520 |
void canvas_item_top_level_changed(); |
| 521 |
|
| 522 |
uint64_t get_processed_events_count() const { return event_count; } |
| 523 |
|
| 524 |
void cancel_tooltip(); |
| 525 |
void show_tooltip(Control *p_control); |
| 526 |
|
| 527 |
void update_canvas_items(); |
| 528 |
|
| 529 |
Rect2 get_visible_rect() const; |
| 530 |
RID get_viewport_rid() const; |
| 531 |
|
| 532 |
void set_world_2d(const Ref<World2D> &p_world_2d); |
| 533 |
Ref<World2D> get_world_2d() const; |
| 534 |
Ref<World2D> find_world_2d() const; |
| 535 |
|
| 536 |
void set_canvas_transform(const Transform2D &p_transform); |
| 537 |
Transform2D get_canvas_transform() const; |
| 538 |
|
| 539 |
void set_global_canvas_transform(const Transform2D &p_transform); |
| 540 |
Transform2D get_global_canvas_transform() const; |
| 541 |
|
| 542 |
Transform2D get_stretch_transform() const; |
| 543 |
virtual Transform2D get_final_transform() const; |
| 544 |
|
| 545 |
void gui_set_root_order_dirty(); |
| 546 |
|
| 547 |
void set_transparent_background(bool p_enable); |
| 548 |
bool has_transparent_background() const; |
| 549 |
|
| 550 |
void set_use_hdr_2d(bool p_enable); |
| 551 |
bool is_using_hdr_2d() const; |
| 552 |
|
| 553 |
Ref<ViewportTexture> get_texture() const; |
| 554 |
|
| 555 |
void set_positional_shadow_atlas_size(int p_size); |
| 556 |
int get_positional_shadow_atlas_size() const; |
| 557 |
|
| 558 |
void set_positional_shadow_atlas_16_bits(bool p_16_bits); |
| 559 |
bool get_positional_shadow_atlas_16_bits() const; |
| 560 |
|
| 561 |
void set_positional_shadow_atlas_quadrant_subdiv(int p_quadrant, PositionalShadowAtlasQuadrantSubdiv p_subdiv); |
| 562 |
PositionalShadowAtlasQuadrantSubdiv get_positional_shadow_atlas_quadrant_subdiv(int p_quadrant) const; |
| 563 |
|
| 564 |
void set_msaa_2d(MSAA p_msaa); |
| 565 |
MSAA get_msaa_2d() const; |
| 566 |
|
| 567 |
void set_msaa_3d(MSAA p_msaa); |
| 568 |
MSAA get_msaa_3d() const; |
| 569 |
|
| 570 |
void set_screen_space_aa(ScreenSpaceAA p_screen_space_aa); |
| 571 |
ScreenSpaceAA get_screen_space_aa() const; |
| 572 |
|
| 573 |
void set_use_taa(bool p_use_taa); |
| 574 |
bool is_using_taa() const; |
| 575 |
|
| 576 |
void set_use_oversampling(bool p_oversampling); |
| 577 |
bool is_using_oversampling() const; |
| 578 |
|
| 579 |
void set_oversampling_override(float p_oversampling); |
| 580 |
float get_oversampling_override() const; |
| 581 |
|
| 582 |
float get_oversampling() const { return font_oversampling; } |
| 583 |
|
| 584 |
void set_scaling_3d_mode(Scaling3DMode p_scaling_3d_mode); |
| 585 |
Scaling3DMode get_scaling_3d_mode() const; |
| 586 |
|
| 587 |
void set_scaling_3d_scale(float p_scaling_3d_scale); |
| 588 |
float get_scaling_3d_scale() const; |
| 589 |
|
| 590 |
void set_fsr_sharpness(float p_fsr_sharpness); |
| 591 |
float get_fsr_sharpness() const; |
| 592 |
|
| 593 |
void set_texture_mipmap_bias(float p_texture_mipmap_bias); |
| 594 |
float get_texture_mipmap_bias() const; |
| 595 |
|
| 596 |
void set_anisotropic_filtering_level(AnisotropicFiltering p_anisotropic_filtering_level); |
| 597 |
AnisotropicFiltering get_anisotropic_filtering_level() const; |
| 598 |
|
| 599 |
void set_use_debanding(bool p_use_debanding); |
| 600 |
bool is_using_debanding() const; |
| 601 |
|
| 602 |
void set_mesh_lod_threshold(float p_pixels); |
| 603 |
float get_mesh_lod_threshold() const; |
| 604 |
|
| 605 |
void set_use_occlusion_culling(bool p_us_occlusion_culling); |
| 606 |
bool is_using_occlusion_culling() const; |
| 607 |
|
| 608 |
Vector2 get_camera_coords(const Vector2 &p_viewport_coords) const; |
| 609 |
Vector2 get_camera_rect_size() const; |
| 610 |
|
| 611 |
void _push_text_input(const String &p_text, bool p_emit_text_changed_signal = false); |
| 612 |
void push_text_input(const String &p_text); |
| 613 |
void push_input(RequiredParam<InputEvent> rp_event, bool p_local_coords = false); |
| 614 |
#ifndef DISABLE_DEPRECATED |
| 615 |
void push_unhandled_input(RequiredParam<InputEvent> rp_event, bool p_local_coords = false); |
| 616 |
#endif |
| 617 |
void notify_mouse_entered(); |
| 618 |
void notify_mouse_exited(); |
| 619 |
|
| 620 |
void set_disable_input(bool p_disable); |
| 621 |
bool is_input_disabled() const; |
| 622 |
|
| 623 |
void set_disable_input_override(bool p_disable); |
| 624 |
|
| 625 |
Vector2 get_mouse_position() const; |
| 626 |
void warp_mouse(const Vector2 &p_position); |
| 627 |
Point2 wrap_mouse_in_rect(const Vector2 &p_relative, const Rect2 &p_rect); |
| 628 |
virtual void update_mouse_cursor_state(); |
| 629 |
|
| 630 |
#if !defined(PHYSICS_2D_DISABLED) || !defined(PHYSICS_3D_DISABLED) |
| 631 |
void set_physics_object_picking(bool p_enable); |
| 632 |
bool get_physics_object_picking(); |
| 633 |
void set_physics_object_picking_sort(bool p_enable); |
| 634 |
bool get_physics_object_picking_sort(); |
| 635 |
void set_physics_object_picking_first_only(bool p_enable); |
| 636 |
bool get_physics_object_picking_first_only(); |
| 637 |
#endif |
| 638 |
|
| 639 |
Variant gui_get_drag_data() const; |
| 640 |
String gui_get_drag_description() const; |
| 641 |
void gui_set_drag_description(const String &p_description); |
| 642 |
|
| 643 |
void gui_reset_canvas_sort_index(); |
| 644 |
int gui_get_canvas_sort_index(); |
| 645 |
|
| 646 |
void gui_release_focus(); |
| 647 |
Control *gui_get_focus_owner() const; |
| 648 |
Control *gui_get_hovered_control() const; |
| 649 |
Window *get_focused_subwindow() const { return gui.subwindow_focused; } |
| 650 |
|
| 651 |
PackedStringArray get_configuration_warnings() const override; |
| 652 |
|
| 653 |
void set_debug_draw(DebugDraw p_debug_draw); |
| 654 |
DebugDraw get_debug_draw() const; |
| 655 |
|
| 656 |
int get_render_info(RenderInfoType p_type, RenderInfo p_info); |
| 657 |
|
| 658 |
void set_snap_controls_to_pixels(bool p_enable); |
| 659 |
bool is_snap_controls_to_pixels_enabled() const; |
| 660 |
|
| 661 |
void set_snap_2d_transforms_to_pixel(bool p_enable); |
| 662 |
bool is_snap_2d_transforms_to_pixel_enabled() const; |
| 663 |
|
| 664 |
void set_snap_2d_vertices_to_pixel(bool p_enable); |
| 665 |
bool is_snap_2d_vertices_to_pixel_enabled() const; |
| 666 |
|
| 667 |
void set_input_as_handled(); |
| 668 |
bool is_input_handled() const; |
| 669 |
|
| 670 |
void set_handle_input_locally(bool p_enable); |
| 671 |
bool is_handling_input_locally() const; |
| 672 |
|
| 673 |
bool gui_is_dragging() const; |
| 674 |
bool gui_is_drag_successful() const; |
| 675 |
void gui_cancel_drag(); |
| 676 |
void gui_perform_drop_at(const Point2 &p_pos, Control *p_control = nullptr); |
| 677 |
|
| 678 |
Control *gui_find_control(const Point2 &p_global); |
| 679 |
|
| 680 |
void set_sdf_oversize(SDFOversize p_sdf_oversize); |
| 681 |
SDFOversize get_sdf_oversize() const; |
| 682 |
|
| 683 |
void set_sdf_scale(SDFScale p_sdf_scale); |
| 684 |
SDFScale get_sdf_scale() const; |
| 685 |
|
| 686 |
void set_default_canvas_item_texture_filter(DefaultCanvasItemTextureFilter p_filter); |
| 687 |
DefaultCanvasItemTextureFilter get_default_canvas_item_texture_filter() const; |
| 688 |
|
| 689 |
void set_default_canvas_item_texture_repeat(DefaultCanvasItemTextureRepeat p_repeat); |
| 690 |
DefaultCanvasItemTextureRepeat get_default_canvas_item_texture_repeat() const; |
| 691 |
|
| 692 |
|
| 693 |
|
| 694 |
void set_vrs_mode(VRSMode p_vrs_mode); |
| 695 |
VRSMode get_vrs_mode() const; |
| 696 |
|
| 697 |
void set_vrs_update_mode(VRSUpdateMode p_vrs_update_mode); |
| 698 |
VRSUpdateMode get_vrs_update_mode() const; |
| 699 |
|
| 700 |
void set_vrs_texture(Ref<Texture2D> p_texture); |
| 701 |
Ref<Texture2D> get_vrs_texture() const; |
| 702 |
|
| 703 |
virtual DisplayServer::WindowID get_window_id() const = 0; |
| 704 |
|
| 705 |
void set_embedding_subwindows(bool p_embed); |
| 706 |
bool is_embedding_subwindows() const; |
| 707 |
TypedArray<Window> get_embedded_subwindows() const; |
| 708 |
void subwindow_set_popup_safe_rect(Window *p_window, const Rect2i &p_rect); |
| 709 |
Rect2i subwindow_get_popup_safe_rect(Window *p_window) const; |
| 710 |
|
| 711 |
void set_drag_threshold(int p_threshold); |
| 712 |
int get_drag_threshold() const; |
| 713 |
|
| 714 |
Viewport *get_parent_viewport() const; |
| 715 |
Window *get_base_window(); |
| 716 |
|
| 717 |
void set_canvas_cull_mask(uint32_t p_layers); |
| 718 |
uint32_t get_canvas_cull_mask() const; |
| 719 |
|
| 720 |
void set_canvas_cull_mask_bit(uint32_t p_layer, bool p_enable); |
| 721 |
bool get_canvas_cull_mask_bit(uint32_t p_layer) const; |
| 722 |
|
| 723 |
#ifdef TOOLS_ENABLED |
| 724 |
bool is_visible_subviewport() const; |
| 725 |
#endif |
| 726 |
|
| 727 |
virtual bool is_size_2d_override_stretch_enabled() const { return true; } |
| 728 |
|
| 729 |
Transform2D get_screen_transform() const; |
| 730 |
virtual Transform2D get_screen_transform_internal(bool p_absolute_position = false) const; |
| 731 |
virtual Transform2D get_popup_base_transform_native() const { return Transform2D(); } |
| 732 |
virtual Transform2D get_popup_base_transform() const { return Transform2D(); } |
| 733 |
virtual Viewport *get_section_root_viewport() const { return nullptr; } |
| 734 |
virtual bool is_attached_in_viewport() const { return false; } |
| 735 |
virtual bool is_sub_viewport() const { return false; } |
| 736 |
|
| 737 |
private: |
| 738 |
#if DEBUG_ENABLED |
| 739 |
template <class T> |
| 740 |
class CameraOverride { |
| 741 |
private: |
| 742 |
bool enabled = false; |
| 743 |
ObjectID overridden_camera_id; |
| 744 |
|
| 745 |
public: |
| 746 |
bool is_enabled() const; |
| 747 |
void enable(Viewport *p_viewport, const T *p_current_camera); |
| 748 |
void disable(T *p_current_camera); |
| 749 |
|
| 750 |
void set_overridden_camera(const T *p_camera); |
| 751 |
T *get_overridden_camera() const; |
| 752 |
}; |
| 753 |
#endif |
| 754 |
|
| 755 |
|
| 756 |
friend class AudioListener2D; |
| 757 |
AudioListener2D *audio_listener_2d = nullptr; |
| 758 |
void _audio_listener_2d_set(AudioListener2D *p_audio_listener); |
| 759 |
void _audio_listener_2d_remove(AudioListener2D *p_audio_listener); |
| 760 |
bool is_audio_listener_2d_enabled = false; |
| 761 |
RID internal_audio_listener_2d; |
| 762 |
|
| 763 |
friend class Camera2D; |
| 764 |
Camera2D *camera_2d = nullptr; |
| 765 |
void _camera_2d_set(Camera2D *p_camera_2d); |
| 766 |
#if DEBUG_ENABLED |
| 767 |
CameraOverride<Camera2D> camera_2d_override; |
| 768 |
|
| 769 |
public: |
| 770 |
void enable_camera_2d_override(bool p_enable); |
| 771 |
bool is_camera_2d_override_enabled() const; |
| 772 |
Camera2D *get_overridden_camera_2d() const; |
| 773 |
Camera2D *get_override_camera_2d() const; |
| 774 |
#endif |
| 775 |
|
| 776 |
private: |
| 777 |
#ifndef PHYSICS_2D_DISABLED |
| 778 |
|
| 779 |
HashMap<ObjectID, uint64_t> physics_2d_mouseover; |
| 780 |
|
| 781 |
HashMap<Pair<ObjectID, int>, uint64_t> physics_2d_shape_mouseover; |
| 782 |
|
| 783 |
void _cleanup_mouseover_colliders(bool p_clean_all_frames, bool p_paused_only, uint64_t p_frame_reference = 0); |
| 784 |
#endif |
| 785 |
|
| 786 |
public: |
| 787 |
AudioListener2D *get_audio_listener_2d() const; |
| 788 |
void set_as_audio_listener_2d(bool p_enable); |
| 789 |
bool is_audio_listener_2d() const; |
| 790 |
|
| 791 |
Camera2D *get_camera_2d() const; |
| 792 |
void assign_next_enabled_camera_2d(const StringName &p_camera_group); |
| 793 |
|
| 794 |
#ifndef _3D_DISABLED |
| 795 |
private: |
| 796 |
|
| 797 |
#ifndef XR_DISABLED |
| 798 |
bool use_xr = false; |
| 799 |
#endif |
| 800 |
friend class AudioListener3D; |
| 801 |
AudioListener3D *audio_listener_3d = nullptr; |
| 802 |
HashSet<AudioListener3D *> audio_listener_3d_set; |
| 803 |
bool is_audio_listener_3d_enabled = false; |
| 804 |
RID internal_audio_listener_3d; |
| 805 |
void _update_audio_listener_3d(); |
| 806 |
void _listener_transform_3d_changed_notify(); |
| 807 |
void _audio_listener_3d_set(AudioListener3D *p_listener); |
| 808 |
bool _audio_listener_3d_add(AudioListener3D *p_listener); |
| 809 |
void _audio_listener_3d_remove(AudioListener3D *p_listener); |
| 810 |
void _audio_listener_3d_make_next_current(AudioListener3D *p_exclude); |
| 811 |
|
| 812 |
#ifndef PHYSICS_3D_DISABLED |
| 813 |
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); |
| 814 |
#endif |
| 815 |
|
| 816 |
friend class Camera3D; |
| 817 |
Camera3D *camera_3d = nullptr; |
| 818 |
#if DEBUG_ENABLED |
| 819 |
CameraOverride<Camera3D> camera_3d_override; |
| 820 |
#endif |
| 821 |
HashSet<Camera3D *> camera_3d_set; |
| 822 |
void _camera_3d_transform_changed_notify(); |
| 823 |
void _camera_3d_set(Camera3D *p_camera); |
| 824 |
bool _camera_3d_add(Camera3D *p_camera); |
| 825 |
void _camera_3d_remove(Camera3D *p_camera); |
| 826 |
void _camera_3d_make_next_current(Camera3D *p_exclude); |
| 827 |
|
| 828 |
Ref<World3D> world_3d; |
| 829 |
Ref<World3D> own_world_3d; |
| 830 |
void _own_world_3d_changed(); |
| 831 |
void _propagate_enter_world_3d(Node *p_node); |
| 832 |
void _propagate_exit_world_3d(Node *p_node); |
| 833 |
|
| 834 |
public: |
| 835 |
AudioListener3D *get_audio_listener_3d() const; |
| 836 |
void set_as_audio_listener_3d(bool p_enable); |
| 837 |
bool is_audio_listener_3d() const; |
| 838 |
|
| 839 |
Camera3D *get_camera_3d() const; |
| 840 |
|
| 841 |
#if DEBUG_ENABLED |
| 842 |
void enable_camera_3d_override(bool p_enable); |
| 843 |
bool is_camera_3d_override_enabled() const; |
| 844 |
Camera3D *get_overridden_camera_3d() const; |
| 845 |
Camera3D *get_override_camera_3d() const; |
| 846 |
#endif |
| 847 |
|
| 848 |
void set_disable_3d(bool p_disable); |
| 849 |
bool is_3d_disabled() const; |
| 850 |
|
| 851 |
void set_world_3d(const Ref<World3D> &p_world_3d); |
| 852 |
Ref<World3D> get_world_3d() const; |
| 853 |
Ref<World3D> find_world_3d() const; |
| 854 |
void set_use_own_world_3d(bool p_use_own_world_3d); |
| 855 |
bool is_using_own_world_3d() const; |
| 856 |
|
| 857 |
#ifndef XR_DISABLED |
| 858 |
void set_use_xr(bool p_use_xr); |
| 859 |
bool is_using_xr(); |
| 860 |
#endif |
| 861 |
#endif |
| 862 |
|
| 863 |
Viewport(); |
| 864 |
~Viewport(); |
| 865 |
}; |
| 866 |
|
| 867 |
class SubViewport : public Viewport { |
| 868 |
GDCLASS(SubViewport, Viewport); |
| 869 |
|
| 870 |
public: |
| 871 |
enum ClearMode { |
| 872 |
CLEAR_MODE_ALWAYS, |
| 873 |
CLEAR_MODE_NEVER, |
| 874 |
CLEAR_MODE_ONCE |
| 875 |
}; |
| 876 |
|
| 877 |
enum UpdateMode { |
| 878 |
UPDATE_DISABLED, |
| 879 |
UPDATE_ONCE, |
| 880 |
UPDATE_WHEN_VISIBLE, |
| 881 |
UPDATE_WHEN_PARENT_VISIBLE, |
| 882 |
UPDATE_ALWAYS |
| 883 |
}; |
| 884 |
|
| 885 |
private: |
| 886 |
UpdateMode update_mode = UPDATE_WHEN_VISIBLE; |
| 887 |
ClearMode clear_mode = CLEAR_MODE_ALWAYS; |
| 888 |
bool size_2d_override_stretch = false; |
| 889 |
|
| 890 |
void _internal_set_size(const Size2i &p_size, bool p_force = false); |
| 891 |
|
| 892 |
protected: |
| 893 |
static void _bind_methods(); |
| 894 |
virtual DisplayServer::WindowID get_window_id() const override; |
| 895 |
void _notification(int p_what); |
| 896 |
|
| 897 |
public: |
| 898 |
void set_size(const Size2i &p_size); |
| 899 |
Size2i get_size() const; |
| 900 |
void set_size_force(const Size2i &p_size); |
| 901 |
|
| 902 |
void set_size_2d_override(const Size2i &p_size); |
| 903 |
Size2i get_size_2d_override() const; |
| 904 |
|
| 905 |
void set_size_2d_override_stretch(bool p_enable); |
| 906 |
bool is_size_2d_override_stretch_enabled() const override; |
| 907 |
|
| 908 |
void set_update_mode(UpdateMode p_mode); |
| 909 |
UpdateMode get_update_mode() const; |
| 910 |
|
| 911 |
void set_clear_mode(ClearMode p_mode); |
| 912 |
ClearMode get_clear_mode() const; |
| 913 |
|
| 914 |
virtual Transform2D get_screen_transform_internal(bool p_absolute_position = false) const override; |
| 915 |
virtual Transform2D get_popup_base_transform() const override; |
| 916 |
virtual Viewport *get_section_root_viewport() const override; |
| 917 |
virtual bool is_attached_in_viewport() const override; |
| 918 |
virtual bool is_sub_viewport() const override { return true; } |
| 919 |
|
| 920 |
void _validate_property(PropertyInfo &p_property) const; |
| 921 |
SubViewport(); |
| 922 |
}; |
| 923 |
VARIANT_ENUM_CAST(Viewport::Scaling3DMode); |
| 924 |
VARIANT_ENUM_CAST(SubViewport::UpdateMode); |
| 925 |
VARIANT_ENUM_CAST(Viewport::PositionalShadowAtlasQuadrantSubdiv); |
| 926 |
VARIANT_ENUM_CAST(Viewport::MSAA); |
| 927 |
VARIANT_ENUM_CAST(Viewport::AnisotropicFiltering); |
| 928 |
VARIANT_ENUM_CAST(Viewport::ScreenSpaceAA); |
| 929 |
VARIANT_ENUM_CAST(Viewport::DebugDraw); |
| 930 |
VARIANT_ENUM_CAST(Viewport::SDFScale); |
| 931 |
VARIANT_ENUM_CAST(Viewport::SDFOversize); |
| 932 |
VARIANT_ENUM_CAST(Viewport::VRSMode); |
| 933 |
VARIANT_ENUM_CAST(Viewport::VRSUpdateMode); |
| 934 |
VARIANT_ENUM_CAST(SubViewport::ClearMode); |
| 935 |
VARIANT_ENUM_CAST(Viewport::RenderInfo); |
| 936 |
VARIANT_ENUM_CAST(Viewport::RenderInfoType); |
| 937 |
VARIANT_ENUM_CAST(Viewport::DefaultCanvasItemTextureFilter); |
| 938 |
VARIANT_ENUM_CAST(Viewport::DefaultCanvasItemTextureRepeat); |