pub struct HitRegion {Show 13 fields
pub x: f32,
pub y: f32,
pub width: f32,
pub height: f32,
pub label: Option<AssetId>,
pub hover_color: Option<[f32; 3]>,
pub hover_scale: Option<f32>,
pub action: String,
pub drag_handle: Option<AssetId>,
pub screen: Option<AssetId>,
pub disabled: bool,
pub follow_label: bool,
pub fit: SpriteFit,
}Expand description
A responsive invisible rectangular region in screen space.
When clicked, fires an action. When hovered, it optionally restyles a
referenced TextLabel (colour and/or scale).
The cursor must be free (not captured for camera control) for events to fire.
HitRegion {
x: 430.0,
y: 330.0,
width: 220.0,
height: 40.0,
hover_color: Some([1.0, 0.85, 0.3]),
hover_scale: Some(1.08),
..Default::default()
};Fields§
§x: f32Left edge of the region in window pixels.
y: f32Top edge of the region in window pixels.
width: f32Width of the region in window pixels.
height: f32Height of the region in window pixels.
label: Option<AssetId>A TextLabel to style on hover. None = no label effect.
hover_color: Option<[f32; 3]>RGB colour applied to the label while hovered. None = no change.
hover_scale: Option<f32>Scale applied to the label while hovered. None = no change.
action: StringAction to fire on click. Recognised forms:
"scene:<name>", "quit", "screen:show:<name>", "screen:hide",
"screen:toggle:<name>".
drag_handle: Option<AssetId>The Sprite a Slider drag region moves along its
track. None for ordinary regions. Set automatically when a Slider
expands; you don’t set this directly.
screen: Option<AssetId>Screen this region belongs to. Resolved automatically from the
naming convention (a region named <screen>_* belongs to screen
<screen>); you don’t set this directly. While a screen is active,
only the top capturing screen’s regions fire; with no screen active,
only screen-less regions fire.
disabled: boolWhether this region is inert. A disabled region never hovers or fires. Set by the engine at runtime (e.g. a settings row whose feature the GPU cannot provide is disabled and grayed out); you don’t set this directly.
follow_label: boolWhen set, this region tracks its referenced label: it
follows the label’s vertical position (so a menu the engine lays out at
runtime keeps its buttons clickable) and is inert while the label’s text
is empty (so a hidden menu entry does not catch clicks). Requires
label.
fit: SpriteFitHow a screen-owned region maps from the reference canvas to the window
when their aspect ratios differ (matches Sprite’s fit).
Bottom keeps a region aligned with bottom-anchored furniture it
covers. A region spanning the whole reference canvas always covers the
full window regardless of fit.
Trait Implementations§
Source§impl Component for HitRegion
impl Component for HitRegion
Source§const NAME: &'static str = "HitRegion"
const NAME: &'static str = "HitRegion"
Source§fn from_baked(bytes: &[u8]) -> Result<Self, CnResult>
fn from_baked(bytes: &[u8]) -> Result<Self, CnResult>
Source§fn inject_locator(&mut self, _locator: PayloadLocator)
fn inject_locator(&mut self, _locator: PayloadLocator)
Source§fn inject_name(&mut self, _id: AssetId)
fn inject_name(&mut self, _id: AssetId)
Source§impl ComponentSlot for HitRegion
impl ComponentSlot for HitRegion
Source§const DISCRIMINANT: u8
const DISCRIMINANT: u8
ComponentId.