pub fn update_state(
        &self,
        state: &mut key_value::State,
        timer: &Snapshot<'_>,
        layout_settings: &GeneralLayoutSettings,
    ) {
        let mut time_change = None;
        let mut previous_possible = None;
        let resolved_comparison = comparison::resolve(&self.settings.comparison_override, timer);
        let comparison = comparison::or_current(resolved_comparison, timer);
        let live_segment =
            analysis::check_live_delta(timer, false, comparison, timer.current_timing_method());

        let phase = timer.current_phase();
        let method = timer.current_timing_method();
        let semantic_color = if phase != TimerPhase::NotRunning {
            let split_index = timer.current_split_index().unwrap();
            if live_segment.is_some() {
                time_change = analysis::live_segment_delta(timer, split_index, comparison, method);
                if self.settings.show_possible_time_save {
                    previous_possible = analysis::possible_time_save::calculate(
                        timer,
                        split_index,
                        comparison,
                        false,
                    );
                }
            } else if let Some(prev_split_index) = split_index.checked_sub(1) {
                time_change =
                    analysis::previous_segment_delta(timer, prev_split_index, comparison, method);
                if self.settings.show_possible_time_save {
                    previous_possible = analysis::possible_time_save::calculate(
                        timer,
                        prev_split_index,
                        comparison,
                        false,
                    );
                }
            };

            if let Some(time_change) = time_change {
                if live_segment.is_some() {
                    analysis::split_color(
                        timer,
                        time_change.into(),
                        split_index,
                        false,
                        false,
                        comparison,
                        method,
                    )
                } else if let Some(prev_split_index) = split_index.checked_sub(1) {
                    analysis::split_color(
                        timer,
                        time_change.into(),
                        prev_split_index,
                        false,
                        true,
                        comparison,
                        method,
                    )
                } else {
                    SemanticColor::Default
                }
            } else if let Some(prev_split_index) = split_index.checked_sub(1) {
                analysis::split_color(
                    timer,
                    None,
                    prev_split_index,
                    true,
                    true,
                    comparison,
                    method,
                )
            } else {
                SemanticColor::Default
            }
        } else {
            SemanticColor::Default
        };

        let value_color = Some(semantic_color.visualize(layout_settings));

        let text = self.text(live_segment.is_some(), resolved_comparison);

        state.background = self.settings.background;
        state.key_color = self.settings.label_color;
        state.value_color = value_color;
        state.semantic_color = semantic_color;

        state.key.clear();
        state.key.push_str(&text); // FIXME: Uncow

        state.value.clear();
        let _ = write!(
            state.value,
            "{}",
            Delta::custom(self.settings.drop_decimals, self.settings.accuracy).format(time_change),
        );

        if self.settings.show_possible_time_save {
            let _ = write!(
                state.value,
                " / {}",
                SegmentTime::with_accuracy(self.settings.accuracy).format(previous_possible),
            );
        }

        state.key_abbreviations.clear();
        if live_segment.is_some() {
            state.key_abbreviations.push("Live Segment".into());
            state.key_abbreviations.push("Live Seg.".into());
        } else {
            state.key_abbreviations.push("Previous Segment".into());
            state.key_abbreviations.push("Prev. Segment".into());
            state.key_abbreviations.push("Prev. Seg.".into());
        }

        state.display_two_rows = self.settings.display_two_rows;
        state.updates_frequently = live_segment.is_some();
    }
/// Updates the component's state based on the timer and layout settings
/// provided.
Updates the component's state based on the timer and layout settings
provided.
Updates the component ' s state based on the timer and layout settings provided .
pub fn update_state(
        &self,
        state: &mut key_value::State,
        timer: &Snapshot<'_>,
        layout_settings: &GeneralLayoutSettings,
    ) {
        let mut time_change = None;
        let mut previous_possible = None;
        let resolved_comparison = comparison::resolve(&self.settings.comparison_override, timer);
        let comparison = comparison::or_current(resolved_comparison, timer);
        let live_segment =
            analysis::check_live_delta(timer, false, comparison, timer.current_timing_method());
        let phase = timer.current_phase();
        let method = timer.current_timing_method();
        let semantic_color = if phase != TimerPhase::NotRunning {
            let split_index = timer.current_split_index().unwrap();
            if live_segment.is_some() {
                time_change = analysis::live_segment_delta(timer, split_index, comparison, method);
                if self.settings.show_possible_time_save {
                    previous_possible = analysis::possible_time_save::calculate(
                        timer,
                        split_index,
                        comparison,
                        false,
                    );
                }
            } else if let Some(prev_split_index) = split_index.checked_sub(1) {
                time_change =
                    analysis::previous_segment_delta(timer, prev_split_index, comparison, method);
                if self.settings.show_possible_time_save {
                    previous_possible = analysis::possible_time_save::calculate(
                        timer,
                        prev_split_index,
                        comparison,
                        false,
                    );
                }
            };
            if let Some(time_change) = time_change {
                if live_segment.is_some() {
                    analysis::split_color(
                        timer,
                        time_change.into(),
                        split_index,
                        false,
                        false,
                        comparison,
                        method,
                    )
                } else if let Some(prev_split_index) = split_index.checked_sub(1) {
                    analysis::split_color(
                        timer,
                        time_change.into(),
                        prev_split_index,
                        false,
                        true,
                        comparison,
                        method,
                    )
                } else {
                    SemanticColor::Default
                }
            } else if let Some(prev_split_index) = split_index.checked_sub(1) {
                analysis::split_color(
                    timer,
                    None,
                    prev_split_index,
                    true,
                    true,
                    comparison,
                    method,
                )
            } else {
                SemanticColor::Default
            }
        } else {
            SemanticColor::Default
        };
        let value_color = Some(semantic_color.visualize(layout_settings));
        let text = self.text(live_segment.is_some(), resolved_comparison);
        state.background = self.settings.background;
        state.key_color = self.settings.label_color;
        state.value_color = value_color;
        state.semantic_color = semantic_color;
        state.key.clear();
        state.key.push_str(&text); // FIXME: Uncow
        state.value.clear();
        let _ = write!(
            state.value,
            "{}",
            Delta::custom(self.settings.drop_decimals, self.settings.accuracy).format(time_change),
        );
        if self.settings.show_possible_time_save {
            let _ = write!(
                state.value,
                " / {}",
                SegmentTime::with_accuracy(self.settings.accuracy).format(previous_possible),
            );
        }
        state.key_abbreviations.clear();
        if live_segment.is_some() {
            state.key_abbreviations.push("Live Segment".into());
            state.key_abbreviations.push("Live Seg.".into());
        } else {
            state.key_abbreviations.push("Previous Segment".into());
            state.key_abbreviations.push("Prev. Segment".into());
            state.key_abbreviations.push("Prev. Seg.".into());
        }
        state.display_two_rows = self.settings.display_two_rows;
        state.updates_frequently = live_segment.is_some();
    }
pub fn update_state ( & self , state : & mut key_value :: State , timer : & Snapshot < ' _ > , layout_settings : & GeneralLayoutSettings , ) { let mut time_change = None ; let mut previous_possible = None ; let resolved_comparison = comparison :: resolve ( & self . settings . comparison_override , timer ) ; let comparison = comparison :: or_current ( resolved_comparison , timer ) ; let live_segment = analysis :: check_live_delta ( timer , false , comparison , timer . current_timing_method ( ) ) ; let phase = timer . current_phase ( ) ; let method = timer . current_timing_method ( ) ; let semantic_color = if phase != TimerPhase :: NotRunning { let split_index = timer . current_split_index ( ) . unwrap ( ) ; if live_segment . is_some ( ) { time_change = analysis :: live_segment_delta ( timer , split_index , comparison , method ) ; if self . settings . show_possible_time_save { previous_possible = analysis :: possible_time_save :: calculate ( timer , split_index , comparison , false , ) ; } } else if let Some ( prev_split_index ) = split_index . checked_sub ( 1 ) { time_change = analysis :: previous_segment_delta ( timer , prev_split_index , comparison , method ) ; if self . settings . show_possible_time_save { previous_possible = analysis :: possible_time_save :: calculate ( timer , prev_split_index , comparison , false , ) ; } } ; if let Some ( time_change ) = time_change { if live_segment . is_some ( ) { analysis :: split_color ( timer , time_change . into ( ) , split_index , false , false , comparison , method , ) } else if let Some ( prev_split_index ) = split_index . checked_sub ( 1 ) { analysis :: split_color ( timer , time_change . into ( ) , prev_split_index , false , true , comparison , method , ) } else { SemanticColor :: Default } } else if let Some ( prev_split_index ) = split_index . checked_sub ( 1 ) { analysis :: split_color ( timer , None , prev_split_index , true , true , comparison , method , ) } else { SemanticColor :: Default } } else { SemanticColor :: Default } ; let value_color = Some ( semantic_color . visualize ( layout_settings ) ) ; let text = self . text ( live_segment . is_some ( ) , resolved_comparison ) ; state . background = self . settings . background ; state . key_color = self . settings . label_color ; state . value_color = value_color ; state . semantic_color = semantic_color ; state . key . clear ( ) ; state . key . push_str ( & text ) ; // FIXME: Uncow state . value . clear ( ) ; let _ = write ! ( state value " " Delta custom ( self settings drop_decimals self settings accuracy ) format ( time_change ) ) ; if self . settings . show_possible_time_save { let _ = write ! ( state value " " SegmentTime with_accuracy ( self settings accuracy ) format ( previous_possible ) ) ; } state . key_abbreviations . clear ( ) ; if live_segment . is_some ( ) { state . key_abbreviations . push ( " " . into ( ) ) ; state . key_abbreviations . push ( " " . into ( ) ) ; } else { state . key_abbreviations . push ( " " . into ( ) ) ; state . key_abbreviations . push ( " " . into ( ) ) ; state . key_abbreviations . push ( " " . into ( ) ) ; } state . display_two_rows = self . settings . display_two_rows ; state . updates_frequently = live_segment . is_some ( ) ; }
Updates the component's state based on the timer and layout settings
provided.
Updates the component ' s state based on the timer and layout settings provided .
&self
state
&mut key_value::State
timer
&Snapshot<'_>
layout_settings
&GeneralLayoutSettings
&self
state
&mut key_value::State
timer
&Snapshot<'_>
layout_settings
&GeneralLayoutSettings