Repository: bevyengine/bevy
File: crates/bevy_ui/src/ui_node.rs (Rust)

Code before:
#[reflect(Component, Default, Clone)]
pub struct ScrollPosition(pub Vec2);

impl ScrollPosition {
    pub const DEFAULT: Self = Self(Vec2::ZERO);
}

impl From<Vec2> for ScrollPosition {
    fn from(value: Vec2) -> Self {
        Self(value)
    }
}

/// Determines which axes of a node are *sticky* during scrolling.
///
/// A **sticky** node maintains its position along the specified axes
/// instead of moving with its scrolled parent content when [`ScrollPosition`] is applied.
#[derive(Component, Debug, Clone, Default, Deref, DerefMut, Reflect)]
#[reflect(Component, Default, Clone)]
pub struct ScrollSticky(pub BVec2);

impl From<BVec2> for ScrollSticky {
    fn from(value: BVec2) -> Self {
        Self(value)
    }
}

/// The base component for UI entities. It describes UI layout and style properties.
///
/// When defining new types of UI entities, require [`Node`] to make them behave like UI nodes.
///
/// Nodes can be laid out using either Flexbox or CSS Grid Layout.
///
/// See below for general learning resources and for documentation on the individual style properties.
///
/// ### Flexbox
///
/// - [MDN: Basic Concepts of Flexbox](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Flexible_Box_Layout/Basic_Concepts_of_Flexbox)
/// - [A Complete Guide To Flexbox](https://css-tricks.com/snippets/css/a-guide-to-flexbox/) by CSS Tricks. This is detailed guide with illustrations and comprehensive written explanation of the different Flexbox properties and how they work.
/// - [Flexbox Froggy](https://flexboxfroggy.com/). An interactive tutorial/game that teaches the essential parts of Flexbox in a fun engaging way.
///
/// ### CSS Grid
///
/// - [MDN: Basic Concepts of Grid Layout](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Grid_Layout/Basic_Concepts_of_Grid_Layout)
/// - [A Complete Guide To CSS Grid](https://css-tricks.com/snippets/css/complete-guide-grid/) by CSS Tricks. This is detailed guide with illustrations and comprehensive written explanation of the different CSS Grid properties and how they work.
/// - [CSS Grid Garden](https://cssgridgarden.com/). An interactive tutorial/game that teaches the essential parts of CSS Grid in a fun engaging way.
///
/// # See also
///
/// - [`RelativeCursorPosition`](crate::RelativeCursorPosition) to obtain the cursor position relative to this node
/// - [`Interaction`](crate::Interaction) to obtain the interaction state of this node

Review comment (refactor):
I don't like the plain `BVec2` here, I'd prefer named fields or some helpers like:
```rust
impl ScrollSticky {
    fn left() -> Self { 
        Self(BVec2::new(true, false))
    }
    
    // etc..
}
```




Code after:
#[reflect(Component, Default, Clone)]
pub struct ScrollPosition(pub Vec2);

impl ScrollPosition {
    pub const DEFAULT: Self = Self(Vec2::ZERO);
}

impl From<Vec2> for ScrollPosition {
    fn from(value: Vec2) -> Self {
        Self(value)
    }
}

/// Controls whether a UI element ignores its parent's [`ScrollPosition`] along specific axes.
///
/// When an axis is set to `true`, the node will not have the parent’s scroll position applied
/// on that axis. This can be used to keep an element visually fixed along one or both axes
/// even when its parent UI element is scrolled.
#[derive(Component, Debug, Clone, Default, Deref, DerefMut, Reflect)]
#[reflect(Component, Default, Clone)]
pub struct IgnoreScroll(pub BVec2);

impl From<BVec2> for IgnoreScroll {
    fn from(value: BVec2) -> Self {
        Self(value)
    }
}

/// The base component for UI entities. It describes UI layout and style properties.
///
/// When defining new types of UI entities, require [`Node`] to make them behave like UI nodes.
///
/// Nodes can be laid out using either Flexbox or CSS Grid Layout.
///
/// See below for general learning resources and for documentation on the individual style properties.
///
/// ### Flexbox
///
/// - [MDN: Basic Concepts of Flexbox](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Flexible_Box_Layout/Basic_Concepts_of_Flexbox)
/// - [A Complete Guide To Flexbox](https://css-tricks.com/snippets/css/a-guide-to-flexbox/) by CSS Tricks. This is detailed guide with illustrations and comprehensive written explanation of the different Flexbox properties and how they work.
/// - [Flexbox Froggy](https://flexboxfroggy.com/). An interactive tutorial/game that teaches the essential parts of Flexbox in a fun engaging way.
///
/// ### CSS Grid
///
/// - [MDN: Basic Concepts of Grid Layout](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Grid_Layout/Basic_Concepts_of_Grid_Layout)
/// - [A Complete Guide To CSS Grid](https://css-tricks.com/snippets/css/complete-guide-grid/) by CSS Tricks. This is detailed guide with illustrations and comprehensive written explanation of the different CSS Grid properties and how they work.
/// - [CSS Grid Garden](https://cssgridgarden.com/). An interactive tutorial/game that teaches the essential parts of CSS Grid in a fun engaging way.
///
/// # See also
///
/// - [`RelativeCursorPosition`](crate::RelativeCursorPosition) to obtain the cursor position relative to this node