Trait penrose_ui::bar::widgets::Widget

source ·
pub trait Widget<X>
where X: XConn,
{ // Required methods fn draw( &mut self, ctx: &mut Context<'_>, screen: usize, screen_has_focus: bool, w: u32, h: u32, ) -> Result<()>; fn current_extent( &mut self, ctx: &mut Context<'_>, h: u32, ) -> Result<(u32, u32)>; fn require_draw(&self) -> bool; fn is_greedy(&self) -> bool; // Provided methods fn update_schedule(&mut self) -> Option<UpdateSchedule> { ... } fn on_startup(&mut self, state: &mut State<X>, x: &X) -> Result<()> { ... } fn on_event( &mut self, event: &XEvent, state: &mut State<X>, x: &X, ) -> Result<()> { ... } fn on_refresh(&mut self, state: &mut State<X>, x: &X) -> Result<()> { ... } fn on_new_client( &mut self, id: Xid, state: &mut State<X>, x: &X, ) -> Result<()> { ... } }
Expand description

A status bar widget that can be rendered using a Context

Required Methods§

source

fn draw( &mut self, ctx: &mut Context<'_>, screen: usize, screen_has_focus: bool, w: u32, h: u32, ) -> Result<()>

Render the current state of the widget to the status bar window.

source

fn current_extent( &mut self, ctx: &mut Context<'_>, h: u32, ) -> Result<(u32, u32)>

Current required width and height for this widget due to its content

source

fn require_draw(&self) -> bool

Does this widget currently require re-rendering? (should be reset to false when ‘draw’ is called)

source

fn is_greedy(&self) -> bool

If true, this widget will expand to fill remaining available space after layout has been computed. If multiple greedy widgets are present in a given StatusBar then the available space will be split evenly between all widgets.

Provided Methods§

source

fn update_schedule(&mut self) -> Option<UpdateSchedule>

An UpdateSchedule to allow for external updates to this Widget’s state independently of the window manager event loop.

source

fn on_startup(&mut self, state: &mut State<X>, x: &X) -> Result<()>

A startup hook to be run in order to initialise this Widget

source

fn on_event( &mut self, event: &XEvent, state: &mut State<X>, x: &X, ) -> Result<()>

An event hook to be run in order to update this Widget

source

fn on_refresh(&mut self, state: &mut State<X>, x: &X) -> Result<()>

A refresh hook to be run in order to update this Widget

source

fn on_new_client(&mut self, id: Xid, state: &mut State<X>, x: &X) -> Result<()>

A manage hook to be run in order to update this Widget

Implementors§