pub struct ElementContext {
pub mouse_buttons: MouseButtonState,
pub scroll: f32,
pub cursor_pos: Vec2,
pub cursor_delta: Vec2,
pub hot_active: HotActiveElement,
}Fields§
§scroll: f32§cursor_pos: Vec2§cursor_delta: Vec2§hot_active: HotActiveElementImplementations§
Source§impl ElementContext
impl ElementContext
pub fn hot_active(&self, id: impl Into<ElementId>) -> HotActive
pub fn btn_hot_active(&mut self, id: impl Into<ElementId>) -> (HotActive, bool)
pub fn is_hovered(&self, id: impl Into<ElementId>) -> bool
Sourcepub fn any_element_with_id_hovered(&self) -> bool
pub fn any_element_with_id_hovered(&self) -> bool
useful for overlay ui in games, to not check for camera click raycasts into the scene ] if some part of the ui is hovered in front of it
pub fn get_computed_bounds( &self, id: impl Into<ElementId>, ) -> Option<ComputedBounds>
pub fn new() -> Self
pub fn set_input(&mut self, input: &Input)
Sourcepub fn set_input_scaled_to_fixed_height(
&mut self,
input: &Input,
screen_size: PhysicalSize<u32>,
fixed_height: f32,
)
pub fn set_input_scaled_to_fixed_height( &mut self, input: &Input, screen_size: PhysicalSize<u32>, fixed_height: f32, )
Use this, if we layout the UI always at a fixed height, but scale it up by some factor in the shader to match the actual screen resolution
input is taken at screen resolution.
screen_size is the actual screen resolution.
fixed_height is the height of our ui layout. (width is calculated to be proportional to the screen_size, both scaled up to screen_size in rendering later).
pub fn set_cursor_delta(&mut self, cursor_delta: Vec2)
pub fn set_cursor_pos(&mut self, cursor_pos: Vec2)
pub fn set_hot_active(&mut self, id: ElementId, state: HotActive)
Trait Implementations§
Source§impl Clone for ElementContext
impl Clone for ElementContext
Source§fn clone(&self) -> ElementContext
fn clone(&self) -> ElementContext
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ElementContext
impl Debug for ElementContext
Auto Trait Implementations§
impl Freeze for ElementContext
impl RefUnwindSafe for ElementContext
impl Send for ElementContext
impl Sync for ElementContext
impl Unpin for ElementContext
impl UnwindSafe for ElementContext
Blanket Implementations§
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
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>
Converts
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>
Converts
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
Read this value from the supplied reader. Same as
ReadEndian::read_from_little_endian().