pub struct UiMessage {
pub handled: Cell<bool>,
pub data: Rc<dyn MessageData>,
pub destination: Handle<UiNode>,
pub direction: MessageDirection,
pub perform_layout: Cell<bool>,
pub flags: u64,
}
Expand description
Message is basic communication element that is used to deliver information to UI nodes or to user code.
§Threading
UiMessage is nor Send or Sync. User interface is a single-thread thing, as well as its messages.
Fields§
§handled: Cell<bool>
Useful flag to check if a message was already handled.
data: Rc<dyn MessageData>
Actual message data.
destination: Handle<UiNode>
Handle of node that will receive message. Please note that all nodes in hierarchy will also receive this message, order is “up-on-tree”.
direction: MessageDirection
Indicates the direction of the message.
See MessageDirection for details.
perform_layout: Cell<bool>
Whether or not message requires layout to be calculated first.
Some of message handling routines uses layout info, but message loop performed right after layout pass, but some of messages may change layout and this flag tells UI to perform layout before passing message further. In ideal case we’d perform layout after each message, but since layout pass is super heavy we should do it only when it is actually needed.
flags: u64
A custom user flags.
Implementations§
Source§impl UiMessage
impl UiMessage
pub fn with_data<T>(data: T) -> UiMessagewhere
T: MessageData,
pub fn with_destination(self, destination: Handle<UiNode>) -> UiMessage
pub fn with_direction(self, direction: MessageDirection) -> UiMessage
pub fn with_perform_layout(self, perform_layout: bool) -> UiMessage
Sourcepub fn reverse(&self) -> UiMessage
pub fn reverse(&self) -> UiMessage
Creates a new copy of the message with reversed direction. Typical use case is to re-send messages to create “response” in widget. For example you have a float input field and it has Value message. When the input field receives Value message with MessageDirection::ToWidget it checks if value needs to be changed and if it does, it re-sends same message but with reversed direction back to message queue so every “listener” can reach properly. The input field won’t react at MessageDirection::FromWidget message so there will be no infinite message loop.
pub fn destination(&self) -> Handle<UiNode>
pub fn data<T>(&self) -> Option<&T>where
T: MessageData,
pub fn set_handled(&self, handled: bool)
pub fn handled(&self) -> bool
pub fn direction(&self) -> MessageDirection
pub fn set_perform_layout(&self, value: bool)
pub fn need_perform_layout(&self) -> bool
pub fn has_flags(&self, flags: u64) -> bool
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for UiMessage
impl !RefUnwindSafe for UiMessage
impl !Send for UiMessage
impl !Sync for UiMessage
impl Unpin for UiMessage
impl !UnwindSafe for UiMessage
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
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>
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>
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)
&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)
&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> 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 moreSource§impl<T> MessageData for T
impl<T> MessageData for T
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PropertyValue for Twhere
T: Debug + 'static,
impl<T> PropertyValue for Twhere
T: Debug + 'static,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self
is actually part of its subset T
(and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.