SmartTableScrollMove.h

The scroll a table drives itself: one smooth move to a row, and where the view goes when rows arrive or leave.

Source/SmartTables/Public/SmartTableScrollMove.h
Types
6
Of which
1 enum, 5 struct
Members
31

FSmartTableScrollMove struct

The scroll a table drives itself: one move, where the view sits, and whether the opening scroll is paid.

It takes numbers, a view of the drawn order, and a way to name a row. It holds no table, no list and no model, and every rule in here reads with no widget built.

Public functions 7

Aim
bool Aim( int32 PresentedRow, int32 PresentedCount, const FSmartTableKeptRow & Row, float RowsOnScreen, float From, float Seconds )

Works out the move to a row and stores it.

False on three counts: Seconds asks for a jump, the view is already there, or the row is the last one and the view sits at or past the target. All three leave the view to be placed on the row outright.

PresentedRow and Row are the same row in the two spaces, and both are known at the call site.

RowsOnScreen: the viewport height over the named row height. It counts too many the moment a row draws taller, which the last-row refusal above covers. Seconds: how long the whole move may take. Zero or less asks for a jump.

Step
int32 Step( float Current, float DeltaTime, float & OutOffset )

One step of the move, from the timer the table already runs.

Gives back the natural row the move arrived at, or INDEX_NONE while it is still going. Arrival stops the move. OutOffset is written on both answers.

The row comes back because the last step belongs to the list. The target splits the viewport by the named row height, so a table whose rows draw taller stops short of the row it aimed at.

Stop
void Stop()

Nothing is moving. The view and the opening scroll are left as they are, since neither belongs to the move that just ended.

Reset
void Reset()

A whole fresh value, for a new model or a new widget. One assignment, so a field added to this type is reset along with the rest.

IsHeadingTo
bool IsHeadingTo( int32 NaturalRow ) const

Whether the move going is aimed at this row.

IsViewAtEndstatic
static bool IsViewAtEnd( float RemainingFraction, int32 NumPresented )

Whether the view sits at the end of the list.

Within EndSlackRows of the bottom counts as the end. A list showing nothing counts as at the end too. Exactly zero would stop a table following over a drag that ended a pixel short. A whole row of slack pulls a reader who has just begun to scroll up back to the end as the next row arrives.

RemainingFraction is the scrollbar's own distance from the bottom, as a fraction of the list, so nothing here has to guess how many rows fit. NumPresented is the drawn count, since that fraction is over what the list shows.

ScrollAfterRowSetstatic
static FSmartTableRowSetScroll ScrollAfterRowSet( const FSmartTableRowSetFacts & Facts, const FSmartTableRowSetDiff & Diff, TFunctionRef< int32() > LastDrawnArrival )

What the view does after rows arrived or left, whichever route they took.

  • A replaced set scrolls nothing, and neither does a table that drew no row before. Their rows did not arrive one by one.
  • With bScrollToAddedRow on and rows arrived, bStickToEnd moves a view that sat at the end to the new last row, when the list grew. With bStickToEnd off the view moves to the arrived row drawn last.
  • Otherwise a view off the top and off the end holds its top row, when the diff names rows and no move is going. At the top the new rows above show, and at the end the list keeps its own bottom.

LastDrawnArrival: the drawn place of the arrived row drawn last, or INDEX_NONE when none is drawn. Asked only when the answer depends on it, since finding the rows can cost a walk.

Public variables 5

Move
TOptional< FSmartTableScrollTarget > Move

The move going on, or unset while nothing is moving. Step asserts that something is, so every caller tests this before it steps.

bViewAtEnd
bool bViewAtEnd = true

Where the view was as of the last tick, never a fresh read. Starts true, which is also what an empty list samples as, so the rows a fresh table gets before its first tick are followed.

bOpenedAtEnd
bool bOpenedAtEnd = false

Whether bStartAtEnd has had its one scroll. Cleared by a new widget and by a new model, and it covers the opening position and nothing after it.

LeftAtTop

The row at the top of the view as the table left it, after its last rebuild of the rows.

The rows on screen are built again only when the list draws. A second change in the same frame finds them still showing the rows from before the first. It reads the top row here instead, while the view has not moved since.

EndSlackRowsstatic
static constexpr float EndSlackRows = 0.25f

How far from the bottom a view still counts as at the end, in rows.

FSmartTableRowSetFacts struct

What ScrollAfterRowSet reads, gathered by the table around the rebuild of its rows.

Public variables 7

bScrollToAddedRow
bool bScrollToAddedRow = true
bStickToEnd
bool bStickToEnd = true
bViewAtEnd
bool bViewAtEnd = true

As sampled on the tick before the change, since the list has already grown by the time it lands. A move the table runs to its last row counts as at the end too.

bMoving
bool bMoving = false

Whether a move is still going once the rebuild has aimed it again. The move owns the offset then.

PresentedBeforepure virtual
int32 PresentedBefore = 0
PresentedAfterpure virtual
int32 PresentedAfter = 0
OffsetBefore
float OffsetBefore = 0.0f

The list offset before the change, in drawn places.

FSmartTableHeldRow struct

The row at the top of the view before a row set change, by the id the row on screen drew.

Never by asking the model. The model already holds the new rows when the table hears of the change, and the old number names a different row there.

Public functions 1

OffsetAt
float OffsetAt( int32 PresentedNow ) const

The offset that puts this row back at the top, now that it is drawn at PresentedNow.

Public variables 3

RowId
FName RowId

None when no built row sat at the top.

PresentedRow
int32 PresentedRow = INDEX_NONE
Offset
float Offset = 0.0f

The list offset, whose fraction past PresentedRow is kept.

ESmartTableRowSetScroll enum

What the view of a table does once rows arrived or left.

Values 3

StayStay
Stay

Nothing. The list keeps its offset.

To RowToRow
ToRow

A move to a drawn row.

HoldHold
Hold

The row that sat at the top of the view goes back to the top.

FSmartTableScrollTarget struct

Where one smooth scroll is heading, and how fast.

Public variables 3

Offset
float Offset = 0.0f

In drawn places, which is what a list scroll offset counts.

Row

The row it is heading to. Step hands its number back on arrival, for the list to place.

Kept, and not only a number. A move runs for ScrollToRowSeconds, and a live feed adds and drops several rows in that time.

ItemsPerSecond
float ItemsPerSecond = 0.0f

Items per second, worked out from the distance at the moment the move started.

FSmartTableRowSetScroll struct

The answer ScrollAfterRowSet gives. PresentedRow is set for ToRow and for nothing else.

Public variables 2

PresentedRow
int32 PresentedRow = INDEX_NONE

Next: SmartTableArrivals.h