Skip to main content

WidgetBar

Struct WidgetBar 

Source
pub struct WidgetBar {
    pub config: WidgetBarConfig,
    pub icons: Vec<RightBarIcon>,
    pub active_icon: Option<RightBarIcon>,
    pub widgets: Vec<WidgetBarWidget>,
    pub active_widget: Option<u64>,
    pub notification_counts: HashMap<RightBarIcon, u32>,
    /* private fields */
}
Expand description

Right Edge Icon Bar

Fields§

§config: WidgetBarConfig

Display and layout options for this component.

§icons: Vec<RightBarIcon>

Built-in entries shown, drawn in RightBarIcon order.

§active_icon: Option<RightBarIcon>

Currently open built-in panel. Clicks toggle this value; the host must keep it in step with panels opened or closed elsewhere before calling show.

§widgets: Vec<WidgetBarWidget>

Host widget entries, empty until the host supplies them.

§active_widget: Option<u64>

Active host widget. Selecting a built-in entry clears it, and vice versa.

§notification_counts: HashMap<RightBarIcon, u32>

Badge counts keyed by built-in bar entry.

Implementations§

Source§

impl WidgetBar

Source

pub fn new() -> Self

Create a WidgetBar with default settings.

Source

pub fn with_config(self, config: WidgetBarConfig) -> Self

Use the supplied display and layout options.

Source

pub fn register_panel( &mut self, widget: WidgetBarWidget, content: impl FnMut(&mut Ui) + 'static, )

Register a host panel, using the widget tooltip as its title and accessible name.

Replacing an existing id preserves its position in the strip and its active state. The callback may capture host state and runs only while this panel is open. Call Self::show_panel after Self::show and before the central chart panel. Hosts own the contents, data sources and persistence.

use egui_charts::icons::icons;
use egui_charts::ui::widget_bar::{WidgetBar, WidgetBarSection, WidgetBarWidget};
let mut bar = WidgetBar::new();
let mut notes = String::new();
bar.register_panel(WidgetBarWidget {
    id: 42, icon: icons::WATCHLIST, tooltip: "Session notes".into(),
    section: WidgetBarSection::Top,
}, move |ui| { ui.text_edit_multiline(&mut notes); });
// In each frame: bar.show(rail_ui); bar.show_panel(root_ui); then show the chart.
Source

pub fn show_panel(&mut self, ui: &mut Ui)

Show the active registered panel beside the strip, with a themed title and close button.

Clicking the same strip entry or the close button closes it. Built-in selections clear the active host panel. Widget entries without a registered callback remain host-rendered. Panel width is resizable and retained by egui under the widget’s stable id.

Source

pub fn set_control_visible(&mut self, control: Control, visible: bool)

Shows or hides Alerts, ObjectTree or Help and clears a hidden active entry. Other controls are ignored. Hosts close any corresponding panel they render.

Source

pub fn set_notification_cnt(&mut self, icon: RightBarIcon, count: u32)

Set the badge count for a built-in bar entry.

Source

pub fn show(&mut self, ui: &mut Ui) -> WidgetBarAction

Show the bar, keeping the bottom section at the foot and scrolling if it cannot fit. Host widget clicks return their id; the host owns the corresponding panel contents.

Trait Implementations§

Source§

impl Default for WidgetBar

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

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
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

§

fn simd_from(_simd: S, value: T) -> T

§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

§

fn simd_into(self, simd: S) -> T

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.