SortableHeaderRenderer

Trait SortableHeaderRenderer 

Source
pub trait SortableHeaderRenderer {
    // Required method
    fn render_sortable_header(
        &mut self,
        column_name: &str,
        interaction_state: &HeaderSortState,
        sort_index: Option<usize>,
        use_enhanced_style: bool,
    ) -> Response;
}
Expand description

Trait defining a widget for rendering a sortable table header cell. Provides a consistent interface for container.rs::render_table_header.

Required Methods§

Source

fn render_sortable_header( &mut self, column_name: &str, interaction_state: &HeaderSortState, sort_index: Option<usize>, use_enhanced_style: bool, ) -> Response

Renders a table header cell with sort indicator (including index if sorted) and name.

§Arguments
  • column_name: The text label for the column.
  • interaction_state: The HeaderSortState for this column (NotSorted, Ascending, Descending).
  • sort_index: Option<usize> (0-based) indicating sort precedence if this column is currently sorted.
  • use_enhanced_style: Controls visual appearance (wrapping, color).
§Returns
  • egui::Response: Interaction response from the clickable sort icon/indicator. The caller handles clicks.

Implementations on Foreign Types§

Source§

impl SortableHeaderRenderer for Ui

Source§

fn render_sortable_header( &mut self, column_name: &str, interaction_state: &HeaderSortState, sort_index: Option<usize>, use_enhanced_style: bool, ) -> Response

Implements header rendering for egui::Ui. Displays icon (with optional index) and text label horizontally. Icon/index is drawn centered within a pre-calculated sized container to minimize text shifting.

§Logic
  1. Get styling info: text color based on theme, combined icon/index string using interaction_state.get_icon(sort_index). Define base TextStyle.
  2. Calculate size needed for the icon/index container using calculate_icon_container_size_for_string with a sample wide string (e.g., “10↕”).
  3. Use ui.horizontal for the overall cell layout.
  4. Add a sized container (ui.add_sized) for the icon/index:
    • Inside the closure, draw a centered, clickable Label using the icon/index string from step 1.
    • Return the Label’s Response from the closure.
  5. Add hover text to the Response captured from add_sized.
  6. Add the column name Label (styling depends on use_enhanced_style).
  7. Return the icon/index label’s Response.

Implementors§