[][src]Struct azul_core::callbacks::CallbackInfo

pub struct CallbackInfo<'a> {
    pub state: &'a RefAny,
    pub current_window_state: &'a FullWindowState,
    pub modifiable_window_state: &'a mut WindowState,
    pub layout_result: &'a BTreeMap<DomId, LayoutResult>,
    pub scrolled_nodes: &'a BTreeMap<DomId, ScrolledNodes>,
    pub cached_display_list: &'a CachedDisplayList,
    pub gl_context: Rc<dyn Gl>,
    pub resources: &'a mut AppResources,
    pub timers: &'a mut FastHashMap<TimerId, Timer>,
    pub tasks: &'a mut Vec<Task>,
    pub ui_state: &'a BTreeMap<DomId, UiState>,
    pub stop_propagation: &'a mut bool,
    pub focus_target: &'a mut Option<FocusTarget>,
    pub current_scroll_states: &'a BTreeMap<DomId, BTreeMap<NodeId, ScrollPosition>>,
    pub nodes_scrolled_in_callback: &'a mut BTreeMap<DomId, BTreeMap<NodeId, LayoutPoint>>,
    pub hit_dom_node: (DomId, NodeId),
    pub cursor_relative_to_item: Option<(f32, f32)>,
    pub cursor_in_viewport: Option<(f32, f32)>,
}

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 OpenGL context, in order to be able to render to OpenGL textures

resources: &'a mut AppResourcestimers: &'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]

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]

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]

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]

pub fn get_current_scroll_position(
    &self,
    (dom_id, node_id): &(DomId, NodeId)
) -> Option<ScrollPosition>
[src]

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]

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]

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]

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]

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

impl<'a> Debug for CallbackInfo<'a>[src]

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]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.