pub struct Custom {
pub title: String,
pub verb: String,
pub danger: bool,
pub command: Option<CommandId>,
pub args: Value,
pub size: Option<[f32; 2]>,
pub share: f32,
pub claims: Vec<ClaimKey>,
pub needs: Option<Mountable>,
pub footer: bool,
}Expand description
A dialog with a body of its own (ADR 0013), drawn by a closure
given to Dialogs::open_custom: a preview, a viewport, a curve.
use egui_pop_api::dialogs::Custom;
use egui_pop_model::ids::CommandId;
use egui_pop_model::mount::ClaimKey;
let preview = Custom::new("Export preview", "Export 3 images", CommandId::from_static("doc.export"))
.share(0.7)
.claims(&[ClaimKey::Escape]);
assert_eq!(preview.verb, "Export 3 images");
assert!(preview.claims_key(ClaimKey::Escape));Fields§
§title: String§verb: StringThe primary button: what it does (“Export 3 images”); empty with no command: a Close button only.
danger: boolDestructive: the danger style, the focus starts on Cancel, no key accepts.
command: Option<CommandId>What accepting runs, with args and the body’s values merged in;
None: accepting closes the dialog.
args: Value§size: Option<[f32; 2]>The body’s size in points (capped to the window); None: a
share of the window.
The share of the window the body takes without a size.
claims: Vec<ClaimKey>Keys the body claims: Enter (Ctrl+Enter then accepts), Escape (it goes to the body first).
needs: Option<Mountable>What the body’s component needs: checked against the custom dialog’s offer when it opens (a refusal opens nothing), and recorded as a mount while it is open.
The dialog draws its footer (the primary button and Cancel) and
accepts on Enter; false (Custom::own_footer): the body draws
its own buttons (a wizard’s Back, Next and Finish) and answers
through CustomPass::accept and CustomPass::cancel.
Implementations§
Source§impl Custom
impl Custom
Sourcepub fn new(title: &str, verb: &str, command: CommandId) -> Self
pub fn new(title: &str, verb: &str, command: CommandId) -> Self
A dialog whose primary button says what it does and runs
command.
pub fn danger(self) -> Self
The share of the window the body takes (0.2 to 1).
Sourcepub fn needs(self, needs: Mountable) -> Self
pub fn needs(self, needs: Mountable) -> Self
What the body’s component needs: its claimed keys become the dialog’s, and it is checked against the custom dialog’s offer.
The body draws its own buttons: no footer, and Enter is the
body’s (it claims it). It answers through CustomPass::accept
and CustomPass::cancel; Escape still cancels unless the body
claims it too.
Sourcepub fn claims_key(&self, key: ClaimKey) -> bool
pub fn claims_key(&self, key: ClaimKey) -> bool
Whether the body claims a key.
Trait Implementations§
Source§impl From<Custom> for DialogSpec
impl From<Custom> for DialogSpec
impl StructuralPartialEq for Custom
Auto Trait Implementations§
impl Freeze for Custom
impl RefUnwindSafe for Custom
impl Send for Custom
impl Sync for Custom
impl Unpin for Custom
impl UnsafeUnpin for Custom
impl UnwindSafe for Custom
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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>
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>
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