[−][src]Struct azul_core::callbacks::CallbackInfo
Information about the callback that is passed to the callback whenever a callback is invoked
Fields
state: &'a RefAny
Your data (the global struct which all callbacks will have access to)
current_window_state: &'a FullWindowState
State of the current window that the callback was called on (read only!)
modifiable_window_state: &'a mut WindowState
User-modifiable state of the window that the callback was called on
layout_result: &'a BTreeMap<DomId, LayoutResult>
Currently active, layouted rectangles
scrolled_nodes: &'a BTreeMap<DomId, ScrolledNodes>
Nodes that overflow their parents and are able to scroll
cached_display_list: &'a CachedDisplayList
Current display list active in this window (useful for debugging)
gl_context: Rc<dyn Gl>
An Rc to the original WindowContext - this is only so that the user can create textures and other OpenGL content in the window but not change any window properties from underneath - this would lead to mismatch between the
resources: &'a mut AppResources
timers: &'a mut FastHashMap<TimerId, Timer>
Currently running timers (polling functions, run on the main thread)
tasks: &'a mut Vec<Task>
Currently running tasks (asynchronous functions running each on a different thread)
ui_state: &'a BTreeMap<DomId, UiState>
UiState containing the necessary data for testing what
stop_propagation: &'a mut bool
Sets whether the event should be propagated to the parent hit node or not
focus_target: &'a mut Option<FocusTarget>
The callback can change the focus_target - note that the focus_target is set before the next frames' layout() function is invoked, but the current frames callbacks are not affected.
current_scroll_states: &'a BTreeMap<DomId, BTreeMap<NodeId, ScrollPosition>>
Immutable (!) reference to where the nodes are currently scrolled (current position)
nodes_scrolled_in_callback: &'a mut BTreeMap<DomId, BTreeMap<NodeId, LayoutPoint>>
Mutable map where a user can set where he wants the nodes to be scrolled to (for the next frame)
hit_dom_node: (DomId, NodeId)
The ID of the DOM + the node that was hit. You can use this to query
information about the node, but please don't hard-code any if / else
statements based on the NodeId
cursor_relative_to_item: Option<(f32, f32)>
The (x, y) position of the mouse cursor, relative to top left of the element that was hit.
cursor_in_viewport: Option<(f32, f32)>
The (x, y) position of the mouse cursor, relative to top left of the window.
Implementations
impl<'a> CallbackInfo<'a>
[src]
pub fn stop_propagation(&mut self)
[src]
Sets whether the event should be propagated to the parent hit node or not
Similar to e.stopPropagation()
in JavaScript
impl<'a> CallbackInfo<'a>
[src]
pub fn window_state(&self) -> &FullWindowState
[src]
pub fn window_state_mut(&mut self) -> &mut WindowState
[src]
pub fn get_keyboard_state(&self) -> &KeyboardState
[src]
pub fn get_mouse_state(&self) -> &MouseState
[src]
pub fn get_bounds(
&self,
(dom_id, node_id): &(DomId, NodeId)
) -> Option<&PositionedRectangle>
[src]
&self,
(dom_id, node_id): &(DomId, NodeId)
) -> Option<&PositionedRectangle>
Returns the bounds (width / height / position / margins / border) for any given NodeId, useful for calculating scroll positions / offsets
pub fn get_words(&self, (dom_id, node_id): &(DomId, NodeId)) -> Option<&Words>
[src]
If the node is a text node, return the text of the node
pub fn get_scaled_words(
&self,
(dom_id, node_id): &(DomId, NodeId)
) -> Option<&ScaledWords>
[src]
&self,
(dom_id, node_id): &(DomId, NodeId)
) -> Option<&ScaledWords>
If the node is a text node, return the shaped glyphs (on a per-word basis, unpositioned)
pub fn get_word_positions(
&self,
(dom_id, node_id): &(DomId, NodeId)
) -> Option<&WordPositions>
[src]
&self,
(dom_id, node_id): &(DomId, NodeId)
) -> Option<&WordPositions>
If the node is a text node, return the shaped glyphs (on a per-word basis, unpositioned)
pub fn get_layouted_glyphs(
&self,
(dom_id, node_id): &(DomId, NodeId)
) -> Option<&LayoutedGlyphs>
[src]
&self,
(dom_id, node_id): &(DomId, NodeId)
) -> Option<&LayoutedGlyphs>
pub fn get_current_scroll_position(
&self,
(dom_id, node_id): &(DomId, NodeId)
) -> Option<ScrollPosition>
[src]
&self,
(dom_id, node_id): &(DomId, NodeId)
) -> Option<ScrollPosition>
Returns information about the current scroll position of a node, such as the size of the scroll frame, the position of the scroll in the parent (how far the node has been scrolled), as well as the size of the parent node (so that things like "scroll to left edge", etc. are easy to calculate).
pub fn get_index_in_parent(
&self,
node_id: &(DomId, NodeId)
) -> Option<(usize, (DomId, NodeId))>
[src]
&self,
node_id: &(DomId, NodeId)
) -> Option<(usize, (DomId, NodeId))>
For any node ID, returns what the position in its parent it is, plus the parent itself.
Returns None
on the root ID (because the root has no parent, therefore it's the 1st item)
Note: Index is 0-based (first item has the index of 0)
pub fn get_node(&self, (dom_id, node_id): &(DomId, NodeId)) -> Option<&Node>
[src]
Returns the hierarchy of the given node ID
pub fn get_parent_node_id(
&self,
node_id: &(DomId, NodeId)
) -> Option<(DomId, NodeId)>
[src]
&self,
node_id: &(DomId, NodeId)
) -> Option<(DomId, NodeId)>
Returns the parent of the given NodeId
or None if the target is the root node.
pub fn get_node_hierarchy(&self) -> &NodeHierarchy
[src]
Returns the node hierarchy (DOM tree order)
pub fn get_node_content(
&self,
(dom_id, node_id): &(DomId, NodeId)
) -> Option<&NodeData>
[src]
&self,
(dom_id, node_id): &(DomId, NodeId)
) -> Option<&NodeData>
Returns the node content of a specific node
pub fn target_index_in_parent(&self) -> Option<usize>
[src]
Returns the index of the target NodeId (the target that received the event) in the targets parent or None if the target is the root node
pub fn target_parent_node_id(&self) -> Option<(DomId, NodeId)>
[src]
Returns the parent of the current target or None if the target is the root node.
pub fn target_is_node_type(&self, node_type: NodeType) -> bool
[src]
Checks whether the target of the CallbackInfo has a certain node type
pub fn target_has_id(&self, id: &str) -> bool
[src]
Checks whether the target of the CallbackInfo has a certain ID
pub fn target_has_class(&self, class: &str) -> bool
[src]
Checks whether the target of the CallbackInfo has a certain class
pub fn any_parent_has_id(&self, id: &str) -> Option<(DomId, NodeId)>
[src]
Traverses up the hierarchy, checks whether any parent has a certain ID, the returns that parent
pub fn any_parent_has_class(&self, class: &str) -> Option<(DomId, NodeId)>
[src]
Traverses up the hierarchy, checks whether any parent has a certain class
pub fn scroll_node(
&mut self,
(dom_id, node_id): &(DomId, NodeId),
scroll_location: LayoutPoint
)
[src]
&mut self,
(dom_id, node_id): &(DomId, NodeId),
scroll_location: LayoutPoint
)
Scrolls a node to a certain position
pub fn scroll_target(&mut self, scroll_location: LayoutPoint)
[src]
Scrolls a node to a certain position
pub fn parent_nodes<'c>(&'c self) -> ParentNodesIterator<'c>
[src]
Creates an iterator that starts at the current DOM node and continouusly
returns the parent (DomId, NodeId)
, until the iterator gets to the root DOM node.
pub fn set_focus_from_path(&mut self, path: CssPath)
[src]
Sets the focus_target by using an already-parsed CssPath
.
pub fn set_focus_from_node_id(&mut self, id: (DomId, NodeId))
[src]
Set the focus_target of the window to a specific div using a NodeId
.
Note that this ID will be dependent on the position in the DOM and therefore the next frames UI must be the exact same as the current one, otherwise the focus_target will be cleared or shifted (depending on apps setting).
pub fn clear_focus(&mut self)
[src]
Clears the focus_target for the next frame.
pub fn add_timer(&mut self, id: TimerId, timer: Timer)
[src]
Insert a timer into the list of active timers. Replaces the existing timer if called with the same TimerId.
pub fn has_timer(&self, timer_id: &TimerId) -> bool
[src]
Returns if a timer with the given ID is currently running
pub fn get_timer(&self, timer_id: &TimerId) -> Option<&Timer>
[src]
Returns a reference to an existing timer (if the TimerId
is valid)
pub fn delete_timer(&mut self, timer_id: &TimerId) -> Option<Timer>
[src]
Deletes a timer and returns it (if the TimerId
is valid)
pub fn add_task(&mut self, task: Task)
[src]
Adds a (thread-safe) Task
to the app that runs on a different thread
pub fn get_gl_context(&self) -> Rc<dyn Gl>
[src]
Returns a reference-counted pointer to the OpenGL context
Trait Implementations
Auto Trait Implementations
impl<'a> !RefUnwindSafe for CallbackInfo<'a>
impl<'a> !Send for CallbackInfo<'a>
impl<'a> !Sync for CallbackInfo<'a>
impl<'a> Unpin for CallbackInfo<'a>
impl<'a> !UnwindSafe for CallbackInfo<'a>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,