pub struct RenderContext<'a> {
pub buffer: &'a mut Buffer,
pub area: Rect,
pub style: Option<&'a Style>,
pub state: Option<&'a NodeState>,
/* private fields */
}Expand description
Render context passed to widgets
Fields§
§buffer: &'a mut BufferBuffer to render into
area: RectAvailable area for rendering
style: Option<&'a Style>Computed style from CSS cascade
state: Option<&'a NodeState>Current widget state
Implementations§
Source§impl RenderContext<'_>
impl RenderContext<'_>
Sourcepub fn css_color(&self, default: Color) -> Color
pub fn css_color(&self, default: Color) -> Color
Get foreground color from CSS style or use default
Sourcepub fn css_background(&self, default: Color) -> Color
pub fn css_background(&self, default: Color) -> Color
Get background color from CSS style or use default
Sourcepub fn css_border_color(&self, default: Color) -> Color
pub fn css_border_color(&self, default: Color) -> Color
Get border color from CSS style or use default
Sourcepub fn css_opacity(&self) -> f32
pub fn css_opacity(&self) -> f32
Get opacity from CSS style (1.0 = fully opaque)
Sourcepub fn css_visible(&self) -> bool
pub fn css_visible(&self) -> bool
Check if visible according to CSS
Sourcepub fn css_padding(&self) -> Spacing
pub fn css_padding(&self) -> Spacing
Get padding from CSS style
Sourcepub fn css_margin(&self) -> Spacing
pub fn css_margin(&self) -> Spacing
Get margin from CSS style
Sourcepub fn css_height(&self) -> Size
pub fn css_height(&self) -> Size
Get height from CSS style
Sourcepub fn css_border_style(&self) -> BorderStyle
pub fn css_border_style(&self) -> BorderStyle
Get border style from CSS
Source§impl RenderContext<'_>
impl RenderContext<'_>
Sourcepub fn draw_focus_ring(
&mut self,
x: u16,
y: u16,
w: u16,
h: u16,
color: Color,
style: FocusStyle,
)
pub fn draw_focus_ring( &mut self, x: u16, y: u16, w: u16, h: u16, color: Color, style: FocusStyle, )
Draw a focus ring around an area
Sourcepub fn draw_focus_ring_auto(
&mut self,
x: u16,
y: u16,
w: u16,
h: u16,
color: Color,
)
pub fn draw_focus_ring_auto( &mut self, x: u16, y: u16, w: u16, h: u16, color: Color, )
Draw a focus ring with automatic style based on context
Sourcepub fn draw_focus_underline(&mut self, x: u16, y: u16, w: u16, color: Color)
pub fn draw_focus_underline(&mut self, x: u16, y: u16, w: u16, color: Color)
Draw a focus underline (for inline elements)
Sourcepub fn draw_focus_marker(&mut self, x: u16, y: u16, color: Color)
pub fn draw_focus_marker(&mut self, x: u16, y: u16, color: Color)
Draw a focus indicator at a specific position
Sourcepub fn draw_focus_marker_left(&mut self, y: u16, color: Color)
pub fn draw_focus_marker_left(&mut self, y: u16, color: Color)
Draw a focus indicator on the left side of an item
Sourcepub fn invert_colors(&mut self, x: u16, y: u16, w: u16, h: u16)
pub fn invert_colors(&mut self, x: u16, y: u16, w: u16, h: u16)
Invert colors in a region (for high contrast focus indication)
Sourcepub fn draw_focus_reverse(&mut self, x: u16, y: u16, w: u16, h: u16)
pub fn draw_focus_reverse(&mut self, x: u16, y: u16, w: u16, h: u16)
Add reverse video effect to indicate focus
Sourcepub fn apply_focus_indicator(
&mut self,
focused: bool,
style: FocusStyle,
color: Color,
)
pub fn apply_focus_indicator( &mut self, focused: bool, style: FocusStyle, color: Color, )
Apply a focus indicator around the full area, opt-in per widget
Widgets call this at render start: ctx.apply_focus_indicator(self.focused, style, color)
Sourcepub fn apply_default_focus(&mut self, focused: bool)
pub fn apply_default_focus(&mut self, focused: bool)
Apply a default focus indicator (Rounded + Cyan)
Convenience method for the most common case.
Source§impl RenderContext<'_>
impl RenderContext<'_>
Sourcepub fn draw_progress_bar(&mut self, config: &ProgressBarConfig)
pub fn draw_progress_bar(&mut self, config: &ProgressBarConfig)
Draw a horizontal progress bar
Source§impl RenderContext<'_>
impl RenderContext<'_>
Sourcepub fn draw_segments(
&mut self,
x: u16,
y: u16,
segments: &[(&str, Color)],
) -> u16
pub fn draw_segments( &mut self, x: u16, y: u16, segments: &[(&str, Color)], ) -> u16
Draw multiple text segments with different colors on one line
Sourcepub fn draw_segments_sep(
&mut self,
x: u16,
y: u16,
segments: &[(&str, Color)],
sep: &str,
sep_color: Color,
) -> u16
pub fn draw_segments_sep( &mut self, x: u16, y: u16, segments: &[(&str, Color)], sep: &str, sep_color: Color, ) -> u16
Draw segments with a separator between them
Sourcepub fn draw_key_hints(
&mut self,
x: u16,
y: u16,
hints: &[(&str, &str)],
key_color: Color,
action_color: Color,
) -> u16
pub fn draw_key_hints( &mut self, x: u16, y: u16, hints: &[(&str, &str)], key_color: Color, action_color: Color, ) -> u16
Draw key hints (key in bold color, action in dim)
Source§impl RenderContext<'_>
impl RenderContext<'_>
Sourcepub fn draw_hline(&mut self, x: u16, y: u16, len: u16, ch: char, fg: Color)
pub fn draw_hline(&mut self, x: u16, y: u16, len: u16, ch: char, fg: Color)
Draw a horizontal line
Sourcepub fn draw_vline(&mut self, x: u16, y: u16, len: u16, ch: char, fg: Color)
pub fn draw_vline(&mut self, x: u16, y: u16, len: u16, ch: char, fg: Color)
Draw a vertical line
Sourcepub fn draw_box_rounded(&mut self, x: u16, y: u16, w: u16, h: u16, fg: Color)
pub fn draw_box_rounded(&mut self, x: u16, y: u16, w: u16, h: u16, fg: Color)
Draw a box with rounded corners
Sourcepub fn draw_box_no_top(&mut self, x: u16, y: u16, w: u16, h: u16, fg: Color)
pub fn draw_box_no_top(&mut self, x: u16, y: u16, w: u16, h: u16, fg: Color)
Draw a box without top border (for custom multi-color headers)
Sourcepub fn draw_header_line(
&mut self,
x: u16,
y: u16,
width: u16,
parts: &[(&str, Color)],
border_color: Color,
)
pub fn draw_header_line( &mut self, x: u16, y: u16, width: u16, parts: &[(&str, Color)], border_color: Color, )
Draw a complete header line with corners for use with draw_box_no_top
Sourcepub fn draw_box_single(&mut self, x: u16, y: u16, w: u16, h: u16, fg: Color)
pub fn draw_box_single(&mut self, x: u16, y: u16, w: u16, h: u16, fg: Color)
Draw a box with single border
Sourcepub fn draw_box_double(&mut self, x: u16, y: u16, w: u16, h: u16, fg: Color)
pub fn draw_box_double(&mut self, x: u16, y: u16, w: u16, h: u16, fg: Color)
Draw a box with double border
Sourcepub fn fill(&mut self, x: u16, y: u16, w: u16, h: u16, ch: char, fg: Color)
pub fn fill(&mut self, x: u16, y: u16, w: u16, h: u16, ch: char, fg: Color)
Fill a rectangular area with a character
Sourcepub fn fill_bg(&mut self, x: u16, y: u16, w: u16, h: u16, bg: Color)
pub fn fill_bg(&mut self, x: u16, y: u16, w: u16, h: u16, bg: Color)
Fill with background color
Sourcepub fn draw_box_titled(
&mut self,
x: u16,
y: u16,
w: u16,
h: u16,
title: &str,
fg: Color,
)
pub fn draw_box_titled( &mut self, x: u16, y: u16, w: u16, h: u16, title: &str, fg: Color, )
Draw a rounded box with a title on the top border
Source§impl RenderContext<'_>
impl RenderContext<'_>
Sourcepub fn draw_char(&mut self, x: u16, y: u16, ch: char, fg: Color)
pub fn draw_char(&mut self, x: u16, y: u16, ch: char, fg: Color)
Draw a single character at position
Sourcepub fn draw_char_bg(&mut self, x: u16, y: u16, ch: char, fg: Color, bg: Color)
pub fn draw_char_bg(&mut self, x: u16, y: u16, ch: char, fg: Color, bg: Color)
Draw a character with background color
Sourcepub fn draw_text_bg(&mut self, x: u16, y: u16, text: &str, fg: Color, bg: Color)
pub fn draw_text_bg(&mut self, x: u16, y: u16, text: &str, fg: Color, bg: Color)
Draw text with background color
Sourcepub fn draw_text_bg_bold(
&mut self,
x: u16,
y: u16,
text: &str,
fg: Color,
bg: Color,
)
pub fn draw_text_bg_bold( &mut self, x: u16, y: u16, text: &str, fg: Color, bg: Color, )
Draw bold text with background color
Sourcepub fn draw_text_clipped(
&mut self,
x: u16,
y: u16,
text: &str,
fg: Color,
max_width: u16,
)
pub fn draw_text_clipped( &mut self, x: u16, y: u16, text: &str, fg: Color, max_width: u16, )
Draw text clipped to max_width (stops drawing at boundary)
Sourcepub fn draw_text_clipped_bold(
&mut self,
x: u16,
y: u16,
text: &str,
fg: Color,
max_width: u16,
)
pub fn draw_text_clipped_bold( &mut self, x: u16, y: u16, text: &str, fg: Color, max_width: u16, )
Draw bold text clipped to max_width
Sourcepub fn draw_text_underline(&mut self, x: u16, y: u16, text: &str, fg: Color)
pub fn draw_text_underline(&mut self, x: u16, y: u16, text: &str, fg: Color)
Draw underlined text
Source§impl<'a> RenderContext<'a>
impl<'a> RenderContext<'a>
Sourcepub fn new(buffer: &'a mut Buffer, area: Rect) -> Self
pub fn new(buffer: &'a mut Buffer, area: Rect) -> Self
Create a basic render context (without style/state)
Sourcepub fn with_style(buffer: &'a mut Buffer, area: Rect, style: &'a Style) -> Self
pub fn with_style(buffer: &'a mut Buffer, area: Rect, style: &'a Style) -> Self
Create a render context with style
Sourcepub fn full(
buffer: &'a mut Buffer,
area: Rect,
style: &'a Style,
state: &'a NodeState,
) -> Self
pub fn full( buffer: &'a mut Buffer, area: Rect, style: &'a Style, state: &'a NodeState, ) -> Self
Create a full render context
Sourcepub fn with_transitions(self, transitions: &'a HashMap<String, f32>) -> Self
pub fn with_transitions(self, transitions: &'a HashMap<String, f32>) -> Self
Set transition values for this render context
Sourcepub fn transition(&self, property: &str) -> Option<f32>
pub fn transition(&self, property: &str) -> Option<f32>
Get current transition value for a property
Sourcepub fn transition_or(&self, property: &str, default: f32) -> f32
pub fn transition_or(&self, property: &str, default: f32) -> f32
Get transition value with a default fallback
Sourcepub fn is_focused(&self) -> bool
pub fn is_focused(&self) -> bool
Check if focused
Sourcepub fn is_hovered(&self) -> bool
pub fn is_hovered(&self) -> bool
Check if hovered
Sourcepub fn is_disabled(&self) -> bool
pub fn is_disabled(&self) -> bool
Check if disabled