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§
sourcefn draw(
&mut self,
ctx: &mut Context<'_>,
screen: usize,
screen_has_focus: bool,
w: u32,
h: u32,
) -> Result<()>
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.
sourcefn current_extent(
&mut self,
ctx: &mut Context<'_>,
h: u32,
) -> Result<(u32, u32)>
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
sourcefn require_draw(&self) -> bool
fn require_draw(&self) -> bool
Does this widget currently require re-rendering? (should be reset to false when ‘draw’ is called)
Provided Methods§
sourcefn update_schedule(&mut self) -> Option<UpdateSchedule>
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.
sourcefn on_startup(&mut self, state: &mut State<X>, x: &X) -> Result<()>
fn on_startup(&mut self, state: &mut State<X>, x: &X) -> Result<()>
A startup hook to be run in order to initialise this Widget
sourcefn on_event(
&mut self,
event: &XEvent,
state: &mut State<X>,
x: &X,
) -> Result<()>
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