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<HitRegion, CnResult>
fn from_baked(bytes: &[u8]) -> Result<HitRegion, 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.Source§impl<'de> Deserialize<'de> for HitRegion
impl<'de> Deserialize<'de> for HitRegion
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<HitRegion, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<HitRegion, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
impl RuntimeComponent for HitRegion
Source§impl Serialize for HitRegion
impl Serialize for HitRegion
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Auto Trait Implementations§
impl Freeze for HitRegion
impl RefUnwindSafe for HitRegion
impl Send for HitRegion
impl Sync for HitRegion
impl Unpin for HitRegion
impl UnsafeUnpin for HitRegion
impl UnwindSafe for HitRegion
Blanket Implementations§
impl<T> AutoreleaseSafe for Twhere
T: ?Sized,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
impl<S, T> Duplex<S> for Twhere
T: FromSample<S> + ToSample<S>,
Source§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more