pub struct DataFormat {
pub alignments: HashMap<DataType, Align>,
pub auto_col_width: bool,
pub decimal: usize,
pub header_padding: f32,
pub use_enhanced_header: bool,
}Expand description
Holds user-configurable settings for data presentation in the table.
§State Management & Interaction:
- UI State: An instance is held in
PolarsViewApp(layout.rs) asapplied_format, representing the current UI configuration.render_formatmodifies this instance directly. - Data State: An
Arc<DataFormat>is stored within eachDataFrameContainer(container.rs), capturing the format settings active when that data state was created (e.g., after load or sort). - Update Flow: Changes in
render_formatare detected, triggering an asyncDataFrameContainer::update_formatcall inlayout.rs. This creates a newDataFrameContainerwith the updatedArc<DataFormat>, ensuring the table re-renders with the new settings.
Fields§
§alignments: HashMap<DataType, Align>Stores the current alignment setting for each DataType, overriding DEFAULT_ALIGNMENTS.
- Modified by UI widgets rendered by
render_alignment_panel. - Read by
get_decimal_and_layoutto determineegui::Layoutfor table cells.
auto_col_width: boolControls the table column sizing strategy (container.rs::build_table).
true:Column::auto()(content-based, potentially slower).false(Default):Column::initial()(uniform fixed widths, faster).- Important: Toggling this changes the
TableBuilderID salt incontainer.rs::build_table, forcing egui to discard cached column widths and apply the new strategy.
decimal: usizeNumber of decimal places for displaying floats (Float32, Float64).
- Modified by the
DragValueinrender_decimal_input. - Used by
get_decimal_and_layout/data_container.rs::format_cell_value. (Note:decimal_and_layout_v2might override for specific columns).
header_padding: f32User-configurable additional vertical padding for the table header row.
- Applied in
container.rs::build_tablewhen calculating header height. - Modified by
DragValueinrender_header_padding_input(ifuse_enhanced_header).
use_enhanced_header: boolToggles the table header’s visual style and click behavior.
- Modified by checkbox in
render_header. - Read by
container.rs::render_table_headerto choose between:true(Default): Enhanced (styled text, wrapping, icon-only sort click).false: Simple (plain button, non-wrapping, full button sort click).
Implementations§
Source§impl DataFormat
impl DataFormat
Sourcepub fn get_default_padding(&self) -> f32
pub fn get_default_padding(&self) -> f32
Gets the default header padding value defined in DataFormat::default().
Used internally, e.g., by container.rs when use_enhanced_header is false.
Sourcepub fn render_format(&mut self, ui: &mut Ui) -> Option<DataFormat>
pub fn render_format(&mut self, ui: &mut Ui) -> Option<DataFormat>
Renders UI controls for modifying format settings in the side panel (“Format” section).
§Change Detection & Update Flow:
- Capture Initial State: Clones
selfbefore rendering widgets (format_former). - Render Widgets: Widgets (
checkbox,radio_value,DragValue) bind to&mut selfand modify its fields directly based on user interaction within this frame. - Compare States: After rendering all widgets, compares the potentially modified
selfwithformat_former. - Signal Change: If
self != format_former, returnsSome(self.clone()).layout.rsuses this signal to trigger an asynchronousDataFrameContainer::update_formattask, applying the changes efficiently without reloading data. If no change, returnsNone.
§Arguments
ui: Mutable reference to theegui::Uicontext for drawing.
§Returns
Option<DataFormat>:Some(updated_format)if a setting was changed, otherwiseNone.
Trait Implementations§
Source§impl Clone for DataFormat
impl Clone for DataFormat
Source§fn clone(&self) -> DataFormat
fn clone(&self) -> DataFormat
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for DataFormat
impl Debug for DataFormat
Source§impl Default for DataFormat
impl Default for DataFormat
Source§impl PartialEq for DataFormat
impl PartialEq for DataFormat
impl StructuralPartialEq for DataFormat
Auto Trait Implementations§
impl Freeze for DataFormat
impl RefUnwindSafe for DataFormat
impl Send for DataFormat
impl Sync for DataFormat
impl Unpin for DataFormat
impl UnwindSafe for DataFormat
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more