Skip to content

Conversation

@sunshowers
Copy link
Contributor

Model this with a new PendingScroll action stored on the view. This
action is resolved at draw time.

This ended up bundling several more changes (sorry!):

  • Fix an off-by-one issue in the inventory view -- the bottom row of text was getting cut
    off previously, whoops :(
  • Fix update pane popup scroll state to be more like the better model
    @jgallagher created while writing the rack setup screen. Previously,
    we were storing a single scroll state at the top. This was actually
    incorrect because when we moved from "waiting" to "failed", we weren't
    setting the scroll state to Some. The new model stores scroll state
    inline, and is correct as a result.
  • Put in a compile-time separation between scrollable and non-scrollable
    popups -- I made a couple of mistakes with unwrapping scroll popup
    state which this caught.

I tested all the screens which support scrolling, and it worked great
on all of them.

Closes #3653.

Created using spr 1.3.4
Comment on lines -204 to +227
/// Returns the effective, or actual, scroll kind after the text is laid
/// out.
///
/// If this is a `PopupScrollKind::Enabled` popup, the offset is is capped
/// to the maximum degree to which text can be scrolled.
pub fn actual_scroll_kind(&self) -> PopupScrollKind {
self.actual_scroll_kind
}
/// Returns the maximum width that this popup can have, including outer
/// borders.
///
/// This is currently 80% of screen width.
pub fn popup_max_width(full_screen_width: u16) -> u16 {
(full_screen_width as u32 * 4 / 5) as u16
}

/// Returns the maximum width that this popup can have, including outer
/// borders.
///
/// This is currently 80% of screen width.
pub fn max_width(full_screen_width: u16) -> u16 {
(full_screen_width as u32 * 4 / 5) as u16
}
/// Returns the maximum width that this popup can have, not including outer
/// borders.
pub fn popup_max_content_width(full_screen_width: u16) -> u16 {
// -2 for borders, -2 for padding
popup_max_width(full_screen_width).saturating_sub(4)
}

/// Returns the maximum width that this popup can have, not including outer
/// borders.
pub fn max_content_width(full_screen_width: u16) -> u16 {
// -2 for borders, -2 for padding
Self::max_width(full_screen_width).saturating_sub(4)
}
/// Returns the maximum height that this popup can have, including outer
/// borders.
///
/// This is currently 80% of screen height.
pub fn popup_max_height(full_screen_height: u16) -> u16 {
(full_screen_height as u32 * 4 / 5) as u16
}

/// Returns the maximum height that this popup can have, including outer
/// borders.
///
/// This is currently 80% of screen height.
pub fn max_height(full_screen_height: u16) -> u16 {
(full_screen_height as u32 * 4 / 5) as u16
/// Returns the wrap options that should be used in most cases for popups.
fn default_wrap_options(
full_screen_width: u16,
) -> crate::ui::wrap::Options<'static> {
crate::ui::wrap::Options {
width: popup_max_content_width(full_screen_width) as usize,
// The indent here is to add 1 character of padding.
initial_indent: Span::raw(" "),
subsequent_indent: Span::raw(" "),
break_words: true,
}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These were moved outside Popup since it gained a type parameter -- static methods are annoying on structs with type parameters since you have to specify a concrete type even though it isn't relevant.

Created using spr 1.3.4
Created using spr 1.3.4
Copy link
Contributor

@jgallagher jgallagher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the long delay on this review 😬


let popup_builder =
self.ignition.to_popup_builder(state.rack_state.selected);
// Scrolling in the ignition popup is always disabled.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit - this comment should probably be removed too, since the variant it was referencing is gone.

self.ignition.to_popup_builder(state.rack_state.selected);

// The scroll offset here should always be disabled, but make it a
// parameter for uniformity with the other popups.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice to be able to delete this 👍

Created using spr 1.3.4
@sunshowers sunshowers enabled auto-merge (squash) August 29, 2023 18:22
@sunshowers sunshowers merged commit eee942f into main Aug 29, 2023
@sunshowers sunshowers deleted the sunshowers/spr/wicket-add-page-uppage-downhomeend-to-the-keymap branch August 29, 2023 20:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[wicket] allow page up/down, home/end for quicker navigation

3 participants