Struct gemgui::ui_ref::UiRef

source ·
pub struct UiRef { /* private fields */ }
Expand description

Refence to UI

Implementations§

source§

impl UiRef

source

pub async fn device_pixel_ratio(&self) -> Result<f32>

Get UI native pixel ratio

Return

ratio

source

pub async fn exists(&self, id: &str) -> Result<bool>

Whether an control with a name exists

Return

boolean

source

pub async fn by_class(&self, class_name: &str) -> Result<Elements>

Get elements by their class

Arguments

class_name - class name

Return

Vector of elements

source

pub async fn by_name<Str: Into<String>>(&self, name: Str) -> Result<Elements>

Get elements by their name

Arguments

cname - name

Return

Vector of elements

source

pub fn add_element<OptCB, CB>( &self, html_element: &str, parent: &Element, element_ready: OptCB ) -> Result<Element>where CB: FnMut(UiRef, Element) + Send + Clone + 'static, OptCB: Into<Option<CB>>,

Create a new element

Example
  fn some_function(ui: UiRef) {
    ui.add_element("div", &ui.root(), |_, el: Element| el.set_html("foo"));
}
Arguments

html_element - refer to HTML id

parent - parent of element

element_ready - callback called upon element is created

Return

Element created, please note that element creation may not be completed yet.

source

pub async fn add_element_async( &self, html_element: &str, parent: &Element ) -> Result<Element>

Create a new element

Example
  async fn some_function(ui: UiRef) {
   let el =  ui.add_element_async("div", &ui.root()).await.unwrap();
    el.set_html("foo")
}
Arguments

id - id of element - is expexted to be unique in the application context

html_element - refer to HTML id

parent - parent of element

Return

Element created

source

pub fn add_element_with_id<OptCB, CB>( &self, id: &str, html_element: &str, parent: &Element, element_ready: OptCB ) -> Result<Element>where CB: FnMut(UiRef, Element) + Clone + Send + 'static, OptCB: Into<Option<CB>>,

Create a new element

See more information add_element

Arguments

id - id of element - is expexted to be unique in the application context

html_element - refer to HTML id

parent - parent of element

element_ready - callback called upon element is created

Return

Element created, please note that element creation may not be completed yet.

source

pub async fn add_element_with_id_async( &self, id: &str, html_element: &str, parent: &Element ) -> Result<Element>

Create a new element

See more information add_element

Arguments

id - id of element - is expexted to be unique in the application context

html_element - refer to HTML id

parent - parent of element

Return

Element created

Trait Implementations§

source§

impl Ui for UiRef

source§

fn root(&self) -> Element

Root element HTML really does not have a root element, but this helps to refer <body> level
source§

fn eval(&self, eval: &str)

Execute Javascript on UI environment Read more
source§

fn batch_begin(&self)

Start a batch Batches let collect multiple commands as singe request. That may speed up their processing and avoid UI flickering on complex UI modification sequences.
source§

fn batch_end(&self)

End a batch The collected batch is immediately sent to UI.
source§

fn set_logging(&self, logging: bool)

Set logging Read more
source§

fn debug(&self, msg: &str)

Send a message to UI that is bounced back as a log Read more
source§

fn alert(&self, msg: &str)

Show a alert dialog with a message Read more
source§

fn open(&self, url: &str, target: Target)

Open an page on UI Read more
source§

fn resource(&self, resource_name: &str) -> Option<Box<[u8]>>

Get an application resource Read more
source§

fn add_resource<PathStr>(&self, path: PathStr) -> Result<String>where PathStr: AsRef<Path>,

Add a file content as an application resources Read more
source§

fn exit(&self)

Exit event loop
source§

fn element(&self, id: &str) -> Element

Instantiate an element It is expected that element is defined in HTML or added by add_element, see UiRef::add_element_async or UiRef::add_element_async how to create a non-exiting element. Please note that this function always success event there is no such element as this creates a light weight Rust side struct. You have to call some query function to get error or call some function to get an error callback. Read more
source§

fn cancel_timer(&self, id: TimerId) -> Result<()>

Cancel timer Read more
source§

fn after<CB>(&self, after: Duration, callback: CB) -> TimerIdwhere CB: FnMut(UiRef, TimerId) + Send + 'static,

One shot timer Read more
source§

fn after_async<CB, Fut>(&self, after: Duration, async_func: CB) -> TimerIdwhere CB: FnOnce(UiRef, TimerId) -> Fut + Send + Clone + 'static, Fut: Future<Output = ()> + Send + 'static,

One shot timer Read more
source§

fn periodic<CB>(&self, period: Duration, callback: CB) -> TimerIdwhere CB: FnMut(UiRef, TimerId) + Send + 'static,

Periodic timer Read more
source§

fn periodic_async<CB, Fut>(&self, period: Duration, async_func: CB) -> TimerIdwhere CB: FnOnce(UiRef, TimerId) -> Fut + Send + Clone + 'static, Fut: Future<Output = ()> + Send + 'static,

Periodic timer Read more

Auto Trait Implementations§

§

impl RefUnwindSafe for UiRef

§

impl Send for UiRef

§

impl Sync for UiRef

§

impl Unpin for UiRef

§

impl UnwindSafe for UiRef

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Pointable for T

§

const ALIGN: usize = mem::align_of::<T>()

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

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

§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more