widgetry

Struct Panel

Source
pub struct Panel {
    top_level: Widget,
    cached_flexbox: Option<(Taffy, Vec<Node>, ScreenDims)>,
    horiz: HorizontalAlignment,
    vert: VerticalAlignment,
    dims_x: PanelDims,
    dims_y: PanelDims,
    scrollable_x: bool,
    scrollable_y: bool,
    contents_dims: ScreenDims,
    container_dims: ScreenDims,
    clip_rect: Option<ScreenRectangle>,
}

Fields§

§top_level: Widget§cached_flexbox: Option<(Taffy, Vec<Node>, ScreenDims)>§horiz: HorizontalAlignment§vert: VerticalAlignment§dims_x: PanelDims§dims_y: PanelDims§scrollable_x: bool§scrollable_y: bool§contents_dims: ScreenDims§container_dims: ScreenDims§clip_rect: Option<ScreenRectangle>

Implementations§

Source§

impl Panel

Source

pub fn new_builder(top_level: Widget) -> PanelBuilder

Source

pub fn empty(ctx: &mut EventCtx<'_>) -> Panel

Returns an empty panel. event and draw will have no effect.

Source

fn update_container_dims_for_canvas_dims(&mut self, canvas_dims: ScreenDims)

Source

fn recompute_scrollbar_layout(&mut self, ctx: &EventCtx<'_>)

Source

fn recompute_layout(&mut self, ctx: &EventCtx<'_>, recompute_bg: bool)

Source

fn invalidate_flexbox(&mut self)

Source

fn compute_flexbox(&self) -> (Taffy, Vec<Node>, ScreenDims)

Source

fn recompute_layout_if_needed(&mut self, ctx: &EventCtx<'_>, recompute_bg: bool)

Source

fn scroll_offset(&self) -> (f64, f64)

Source

fn update_scroll_sliders( &mut self, ctx: &EventCtx<'_>, offset: (f64, f64), ) -> bool

Source

fn set_scroll_offset(&mut self, ctx: &EventCtx<'_>, offset: (f64, f64))

Source

pub fn event(&mut self, ctx: &mut EventCtx<'_>) -> Outcome

Source

pub fn draw(&self, g: &mut GfxCtx<'_>)

Source

pub fn get_all_click_actions(&self) -> HashSet<String>

Source

pub fn restore(&mut self, ctx: &mut EventCtx<'_>, prev: &Panel)

Source

pub fn restore_scroll(&mut self, ctx: &mut EventCtx<'_>, prev: &Panel)

Source

pub fn scroll_to_member(&mut self, ctx: &EventCtx<'_>, name: String)

Source

pub fn has_widget(&self, name: &str) -> bool

Source

pub fn slider(&self, name: &str) -> &Slider

Source

pub fn slider_mut(&mut self, name: &str) -> &mut Slider

Source

pub fn take_menu_choice<T: 'static>(&mut self, name: &str) -> T

Source

pub fn is_checked(&self, name: &str) -> bool

Source

pub fn maybe_is_checked(&self, name: &str) -> Option<bool>

Source

pub fn set_checked(&mut self, name: &str, on_off: bool)

Source

pub fn text_box(&self, name: &str) -> String

Source

pub fn spinner<T: 'static + SpinnerValue>(&self, name: &str) -> T

Source

pub fn modify_spinner<T: 'static + SpinnerValue>( &mut self, ctx: &EventCtx<'_>, name: &str, delta: T, )

Source

pub fn dropdown_value<T: 'static + PartialEq + Clone, I: AsRef<str>>( &self, name: I, ) -> T

Source

pub fn maybe_dropdown_value<T: 'static + PartialEq + Clone, I: AsRef<str>>( &self, name: I, ) -> Option<T>

Source

pub fn persistent_split_value<T: 'static + PartialEq + Clone>( &self, name: &str, ) -> T

Source

pub fn autocomplete_done<T: 'static + Clone>( &mut self, name: &str, ) -> Option<Vec<T>>

Consumes the autocomplete widget. It’s fine if the panel survives past this event; the autocomplete just needs to be interacted with again to produce more values.

Source

pub fn stash<T: 'static>(&self, name: &str) -> Rc<RefCell<T>>

Grab a stashed value, with the ability to pass it around and modify it.

Source

pub fn clone_stashed<T: 'static + Clone>(&self, name: &str) -> T

Grab a stashed value and clone it.

Source

pub fn is_button_enabled(&self, name: &str) -> bool

Source

pub fn maybe_find_widget(&self, name: &str) -> Option<&Widget>

Source

pub fn maybe_find<T: WidgetImpl>(&self, name: &str) -> Option<&T>

Source

pub fn find<T: WidgetImpl>(&self, name: &str) -> &T

Source

pub fn find_mut<T: WidgetImpl>(&mut self, name: &str) -> &mut T

Source

pub(crate) fn swap_inner_content( &mut self, ctx: &EventCtx<'_>, container_name: &str, new_inner_content: &mut Widget, )

Swap the inner content of a container widget with new_inner_content.

Source

pub fn rect_of(&self, name: &str) -> &ScreenRectangle

Source

pub fn center_of(&self, name: &str) -> ScreenPt

Source

pub fn center_of_panel(&self) -> ScreenPt

Source

pub fn panel_rect(&self) -> &ScreenRectangle

Source

pub fn panel_dims(&self) -> ScreenDims

Source

pub fn align(&mut self, horiz: HorizontalAlignment, vert: VerticalAlignment)

Source

pub fn replace(&mut self, ctx: &mut EventCtx<'_>, id: &str, new: Widget)

All margins/padding/etc from the previous widget are retained. The ID is set on the new widget; no need to do that yourself.

Source

pub fn take(&mut self, id: &str) -> Widget

Removes a widget from the panel. Does not recalculate layout!

Source

pub fn clicked_outside(&self, ctx: &mut EventCtx<'_>) -> bool

Source

pub fn currently_hovering(&self) -> Option<&String>

Auto Trait Implementations§

§

impl Freeze for Panel

§

impl !RefUnwindSafe for Panel

§

impl !Send for Panel

§

impl !Sync for Panel

§

impl Unpin for Panel

§

impl !UnwindSafe for Panel

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
§

impl<T> Downcast for T
where T: 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.
§

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.
§

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.
§

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

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

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

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

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 T
where 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.

Source§

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

Source§

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 T
where U: TryFrom<T>,

Source§

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<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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

impl<G1, G2> Within<G2> for G1
where G2: Contains<G1>,

§

fn is_within(&self, b: &G2) -> bool