added scroll offset to ComputedNode and update it in ui_layout_system

This commit is contained in:
ickshonpe 2025-07-11 16:39:14 +01:00
parent f4aacc8583
commit 8e0e47d9d1
2 changed files with 7 additions and 0 deletions

View File

@ -333,6 +333,8 @@ with UI components as a child of an entity without UI components, your UI layout
let physical_scroll_position = clamped_scroll_position.floor(); let physical_scroll_position = clamped_scroll_position.floor();
node.bypass_change_detection().scroll_offset = physical_scroll_position;
for child_uinode in ui_children.iter_ui_children(entity) { for child_uinode in ui_children.iter_ui_children(entity) {
update_uinode_geometry_recursive( update_uinode_geometry_recursive(
commands, commands,

View File

@ -46,6 +46,10 @@ pub struct ComputedNode {
/// ///
/// Automatically calculated by [`super::layout::ui_layout_system`]. /// Automatically calculated by [`super::layout::ui_layout_system`].
pub scrollbar_size: Vec2, pub scrollbar_size: Vec2,
/// Offset of scrolled content
///
/// Automatically calculated by [`super::layout::ui_layout_system`].
pub scroll_offset: Vec2,
/// The width of this node's outline. /// The width of this node's outline.
/// If this value is `Auto`, negative or `0.` then no outline will be rendered. /// If this value is `Auto`, negative or `0.` then no outline will be rendered.
/// Outline updates bypass change detection. /// Outline updates bypass change detection.
@ -310,6 +314,7 @@ impl ComputedNode {
size: Vec2::ZERO, size: Vec2::ZERO,
content_size: Vec2::ZERO, content_size: Vec2::ZERO,
scrollbar_size: Vec2::ZERO, scrollbar_size: Vec2::ZERO,
scroll_offset: Vec2::ZERO,
outline_width: 0., outline_width: 0.,
outline_offset: 0., outline_offset: 0.,
unrounded_size: Vec2::ZERO, unrounded_size: Vec2::ZERO,