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

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

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

Fields

entity: Entitytheme: &'a Theme

Methods

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

pub fn new(
    ecs: (Entity, &'a mut EntityComponentManager<Tree, StringComponentStore>),
    window_shell: &'a mut WindowShell<WindowAdapter>,
    theme: &'a Theme,
    render_objects: Rc<RefCell<BTreeMap<Entity, Box<dyn RenderObject + 'static>>>>,
    layouts: Rc<RefCell<BTreeMap<Entity, Box<dyn Layout + 'static>>>>,
    handlers: Rc<RefCell<BTreeMap<Entity, Vec<Rc<dyn EventHandler + 'static>>>>>,
    states: Rc<RefCell<BTreeMap<Entity, Rc<dyn State + 'static>>>>
) -> 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 the no id is defined its panics.

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 the no id is 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]

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 the no id is defined None will 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<W>(&mut self, child: W) where
    W: Widget
[src]

Appends a child to the current widget.

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_element<'b>(
    &mut self,
    element: impl Into<&'b str>
) -> Option<Entity>
[src]

Returns the entity of the parent referenced by css element. If the no id is defined None will 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 send_message(
    &mut self,
    target_widget: &str,
    message: impl Into<MessageBox>
)
[src]

Sends a message to the widget with the given id over the message channel.

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 render_context_2_d(&mut self) -> &mut RenderContext2D[src]

Returns a mutable reference of the 2d render ctx.

Trait Implementations

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

Auto Trait Implementations

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

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

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

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

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

Blanket Implementations

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

impl<T> From<T> for 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.

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

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

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<E> Component for E where
    E: Any
[src]

impl<T> SetParameter for T