[][src]Struct orbtk::prelude::Context

pub struct Context<'a> {
    pub entity: Entity,
    pub theme: Theme,
    // some fields omitted
}

The Context is provides access for the states to objects they could work with.

Fields

entity: Entitytheme: Theme

Implementations

impl<'a> Context<'a>[src]

pub fn new(
    ecs: (Entity, &'a mut EntityComponentManager<Tree, StringComponentStore>),
    theme: &Theme,
    provider: &'a ContextProvider,
    render_context: &'a mut RenderContext2D
) -> Context<'a>
[src]

Creates a new container.

pub fn get_widget(&mut self, entity: Entity) -> WidgetContainer<'_>[src]

Returns a specific widget.

pub fn widget(&mut self) -> WidgetContainer<'_>[src]

Returns the widget of the current state ctx.

pub fn window(&mut self) -> WidgetContainer<'_>[src]

Returns the window widget.

pub fn child<'b>(&mut self, id: impl Into<&'b str>) -> WidgetContainer<'_>[src]

Returns a child of the widget of the current state referenced by css id. If there is no id defined, it will panic.

pub fn try_child<'b>(
    &mut self,
    id: impl Into<&'b str>
) -> Option<WidgetContainer<'_>>
[src]

Returns a child of the widget of the current state referenced by css id. If there is no id defined, None will returned.

pub fn parent(&mut self) -> WidgetContainer<'_>[src]

Returns the parent of the current widget. Panics if the parent does not exists.

pub fn try_parent(&mut self) -> Option<WidgetContainer<'_>>[src]

Returns the parent of the current widget. If the current widget is the root None will be returned.

pub fn parent_from_id<'b>(
    &mut self,
    id: impl Into<&'b str>
) -> WidgetContainer<'_>
[src]

Returns a parent of the widget of the current state referenced by css id. Panics if a parent with the given id could not be found

pub fn try_parent_from_id<'b>(
    &mut self,
    id: impl Into<&'b str>
) -> Option<WidgetContainer<'_>>
[src]

Returns a parent of the widget of the current state referenced by css id. If there is no id defined None will be returned.

pub fn child_from_index(&mut self, index: usize) -> WidgetContainer<'_>[src]

Returns the child of the current widget. Panics if a child on the given index could not be found.

pub fn try_child_from_index(
    &mut self,
    index: usize
) -> Option<WidgetContainer<'_>>
[src]

Returns the child of the current widget. If the index is out of the children index bounds or the widget has no children None will be returned.

pub fn build_context(&mut self) -> BuildContext<'_>[src]

Returns the current build ctx.

pub fn append_child_to<W>(&mut self, child: W, parent: Entity) where
    W: Widget
[src]

Appends a child widget to the given parent.

pub fn append_child_to_overlay<W>(&mut self, child: W) -> Result<(), String> where
    W: Widget
[src]

Appends a child widget to overlay (on the top of the main tree). If the overlay does not exists an error will be returned.

pub fn append_child_entity_to(&mut self, child: Entity, parent: Entity)[src]

Appends a child widget by entity to the given parent.

pub fn append_child_entity_to_overlay(
    &mut self,
    child: Entity
) -> Result<(), String>
[src]

Appends a child entity to overlay (on the top of the main tree). If the overlay does not exists an error will be returned.

pub fn append_child<W>(&mut self, child: W) where
    W: Widget
[src]

Appends a child to the current widget.

pub fn append_child_entity(&mut self, child: Entity)[src]

Appends a child widget by entity to the current widget.

pub fn remove_child(&mut self, child: Entity)[src]

Removes a child from the current widget. If the given entity is not a child of the given parent nothing will happen.

pub fn remove_child_from_overlay(&mut self, child: Entity) -> Result<(), String>[src]

Removes a child from the overlay. If the given entity is not a child of the given parent nothing will happen.

pub fn remove_child_from(&mut self, remove_entity: Entity, parent: Entity)[src]

Removes (recursive) a child from the given parent. If the given entity is not a child of the given parent nothing will happen.

pub fn remove_widget_list(&mut self) -> &mut Vec<Entity>[src]

Returns a mutable reference of the children that should be removed.

pub fn clear_children(&mut self)[src]

Clears all children of the current widget.

pub fn clear_children_of(&mut self, parent: Entity)[src]

Clears all children of the given widget.

pub fn entity_of_child<'b>(&mut self, id: impl Into<&'b str>) -> Option<Entity>[src]

Returns the entity id of an child by the given name.

pub fn parent_entity_by_style<'b>(
    &mut self,
    element: impl Into<&'b str>
) -> Option<Entity>
[src]

Returns the entity of the parent referenced by css element. If there is no id defined None will be returned.

pub fn entity_of_parent(&mut self) -> Option<Entity>[src]

Returns the entity of the parent.

pub fn index_as_child(&mut self, entity: Entity) -> Option<usize>[src]

Returns the child index of the current entity.

pub fn push_event_strategy<E>(&mut self, event: E, strategy: EventStrategy) where
    E: Event
[src]

Pushes an event to the event queue with the given strategy.

pub fn push_event<E>(&mut self, event: E) where
    E: Event
[src]

Pushes an event to the event queue.

pub fn push_event_by_entity<E>(&mut self, event: E, entity: Entity) where
    E: Event
[src]

Pushes an event to the event queue.

pub fn push_event_by_window<E>(&mut self, event: E) where
    E: Event
[src]

Pushes an event to the event queue.

pub fn push_event_strategy_by_entity<E>(
    &mut self,
    event: E,
    entity: Entity,
    strategy: EventStrategy
) where
    E: Event
[src]

Pushes an event to the event queue.

pub fn show_window<F>(&mut self, create_fn: F) where
    F: 'static + Fn(&mut BuildContext<'_>) -> Entity
[src]

Creates and show a new window.

pub fn render_context_2_d(&mut self) -> &mut RenderContext2D[src]

Returns a mutable reference of the 2d render ctx.

pub fn send_window_request(&self, request: WindowRequest)[src]

Gets a new sender that allows to communicate with the window shell.

pub fn window_sender(&self) -> Sender<WindowRequest>[src]

Gets a window request sender.

pub fn new_states_keys(&self) -> Vec<Entity>[src]

Returns a keys collection of new added states.

pub fn switch_theme(&mut self, theme: Theme)[src]

Switch the current theme.

Trait Implementations

impl<'a> Drop for Context<'a>[src]

Auto Trait Implementations

impl<'a> !RefUnwindSafe for Context<'a>

impl<'a> !Send for Context<'a>

impl<'a> !Sync for Context<'a>

impl<'a> Unpin for Context<'a>

impl<'a> !UnwindSafe for Context<'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<E> Component for E where
    E: Any
[src]

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

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

impl<T> SetParameter for T

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.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,