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§
Sourcefn render_sortable_header(
&mut self,
column_name: &str,
interaction_state: &HeaderSortState,
sort_index: Option<usize>,
use_enhanced_style: bool,
) -> Response
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: TheHeaderSortStatefor 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
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
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
- Get styling info: text color based on theme, combined icon/index string using
interaction_state.get_icon(sort_index). Define baseTextStyle. - Calculate size needed for the icon/index container using
calculate_icon_container_size_for_stringwith a sample wide string (e.g., “10↕”). - Use
ui.horizontalfor the overall cell layout. - Add a sized container (
ui.add_sized) for the icon/index:- Inside the closure, draw a centered, clickable
Labelusing the icon/index string from step 1. - Return the
Label’sResponsefrom the closure.
- Inside the closure, draw a centered, clickable
- Add hover text to the
Responsecaptured fromadd_sized. - Add the column name
Label(styling depends onuse_enhanced_style). - Return the icon/index label’s
Response.