pub struct Overlay(/* private fields */);
Implementations§
Source§impl Overlay
impl Overlay
Sourcepub fn new<M>(widget: M) -> Overlaywhere
M: WidgetBuilder + 'static + Clone,
pub fn new<M>(widget: M) -> Overlaywhere
M: WidgetBuilder + 'static + Clone,
Create overlay from Clone able widget.
§Example
use ribir::prelude::*;
let w = fn_widget! {
let overlay = Overlay::new(
fn_widget! {
@Text {
h_align: HAlign::Center,
v_align: VAlign::Center,
text: "Hello"
}
}
);
@FilledButton{
on_tap: move |e| overlay.show(e.window()),
@{ Label::new("Click to show overlay") }
}
};
App::run(w);
Sourcepub fn new_with_handle<O, M>(builder: M) -> Overlay
pub fn new_with_handle<O, M>(builder: M) -> Overlay
Create overlay from a builder with a close_handle
§Example
popup a widget of a button which will close when clicked.
use ribir::prelude::*;
let w = fn_widget! {
let overlay = Overlay::new_with_handle(
move |ctrl: OverlayCloseHandle| {
let ctrl = ctrl.clone();
fn_widget! {
@FilledButton {
h_align: HAlign::Center,
v_align: VAlign::Center,
on_tap: move |_| ctrl.close(),
@{ Label::new("Click to close") }
}
}
}
);
@FilledButton {
on_tap: move |e| overlay.show(e.window()),
@{ Label::new("Click to show overlay") }
}
};
App::run(w).with_size(Size::new(200., 200.));
Sourcepub fn with_style(&self, style: OverlayStyle)
pub fn with_style(&self, style: OverlayStyle)
Overlay will show with the given style, if the overlay have not been set with style, the default style will be get from the theme.
Sourcepub fn show(&self, wnd: Rc<Window>)
pub fn show(&self, wnd: Rc<Window>)
the Overlay widget will be show at the top level of all widget. if the overlay is showing, nothing will happen.
Sourcepub fn show_map<O, F>(&self, f: F, wnd: Rc<Window>)where
F: Fn(Box<dyn for<'a, 'b> FnOnce(&'a BuildCtx<'b>) -> Widget>, OverlayCloseHandle) -> O + 'static,
O: WidgetBuilder + 'static,
pub fn show_map<O, F>(&self, f: F, wnd: Rc<Window>)where
F: Fn(Box<dyn for<'a, 'b> FnOnce(&'a BuildCtx<'b>) -> Widget>, OverlayCloseHandle) -> O + 'static,
O: WidgetBuilder + 'static,
User can make transform before the widget show at the top level of all widget. if the overlay is showing, nothing will happen.
§Example
Overlay widget which auto align horizontal position to the src button even when window’s size changed
use ribir::prelude::*;
let w = fn_widget! {
let overlay = Overlay::new(
fn_widget! { @Text { text: "overlay" } }
);
let button = @FilledButton{};
let wid = button.lazy_host_id();
@$button {
h_align: HAlign::Center,
v_align: VAlign::Center,
on_tap: move |e| {
let wid = wid.clone();
overlay.show_map(
move |w, _| {
let wid = wid.clone();
fn_widget! {
let mut w = @$w {};
w.left_align_to(&wid, 0., ctx!());
w
}
},
e.window()
);
},
@{ Label::new("Click to show overlay") }
}
};
App::run(w);
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Overlay
impl !RefUnwindSafe for Overlay
impl !Send for Overlay
impl !Sync for Overlay
impl Unpin for Overlay
impl !UnwindSafe for Overlay
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more