etui/widgets/scroll_view

Types

pub type ScrollView {
  ScrollView(virtual_width: Int, virtual_height: Int)
}

Constructors

  • ScrollView(virtual_width: Int, virtual_height: Int)
pub type ScrollViewState {
  ScrollViewState(scroll_x: Int, scroll_y: Int)
}

Constructors

  • ScrollViewState(scroll_x: Int, scroll_y: Int)

Values

pub fn clamp(
  state: ScrollViewState,
  sv: ScrollView,
  visible_w: Int,
  visible_h: Int,
) -> ScrollViewState

Clamp scroll offsets so the viewport never goes past the virtual canvas.

pub fn render(
  buf: buffer.Buffer,
  area: geometry.Rect,
  sv: ScrollView,
  state: ScrollViewState,
  render_inner: fn(buffer.Buffer, geometry.Rect) -> buffer.Buffer,
) -> buffer.Buffer

Render the scroll view.

render_inner is called with a virtual buffer sized to (sv.virtual_width × sv.virtual_height). The visible window at (state.scroll_x, state.scroll_y) is then blitted into buf at area.

pub fn scroll_down(
  state: ScrollViewState,
  lines: Int,
) -> ScrollViewState
pub fn scroll_left(
  state: ScrollViewState,
  cols: Int,
) -> ScrollViewState
pub fn scroll_pct_x(
  state: ScrollViewState,
  sv: ScrollView,
  visible_w: Int,
) -> Int
pub fn scroll_pct_y(
  state: ScrollViewState,
  sv: ScrollView,
  visible_h: Int,
) -> Int

How far into the virtual canvas is the viewport (0.0–1.0 × 100). Returns an integer percentage (0–100). Useful for driving scrollbar widgets.

pub fn scroll_right(
  state: ScrollViewState,
  cols: Int,
) -> ScrollViewState
pub fn scroll_to(
  state: ScrollViewState,
  x: Int,
  y: Int,
) -> ScrollViewState
pub fn scroll_up(
  state: ScrollViewState,
  lines: Int,
) -> ScrollViewState
pub fn scroll_view_new(
  virtual_width: Int,
  virtual_height: Int,
) -> ScrollView
pub fn sv_state_new() -> ScrollViewState
Search Document