Cavrnus Unreal API - UI/Pagination
The header files in the "Pagination" folder define the UI structure and interface for handling pagination of list elements within the Cavrnus Spatial Connector plugin.
Key Points:
The
IListElementInterface
ensures a consistent way for different types of list elements to be integrated into the pagination system.The
UPagination
class provides a flexible and reusable component for implementing pagination in various UI contexts within the Cavrnus plugin.The use of Unreal Engine's UMG (Unreal Motion Graphics) system allows for easy customization and integration of the pagination UI into the overall user interface.
General Workflow (How Pagination Works):
Setup: The
UPagination
widget is created and initialized with the class of the item widget that will be used to represent each list element.Content Loading: The content to be paginated (an array of objects implementing
IListElementInterface
) is provided to theUPagination
widget.Page Loading: The
LoadPage
function is called to display the initial page of items. It creates instances of the item widget for each element on the page and calls theirEntryBuilt
function to populate them.Navigation: The user can click the "Next" and "Previous" buttons to navigate between pages. The
Next
andPrevious
functions handle the logic of updating the displayed items and page number.
Header List:
IListElementInterface.h
:
Purpose: This file defines the
IListElementInterface
interface, which serves as a contract for classes representing list elements that can be paginated. It ensures that any class implementing this interface provides the necessary functionality for integration with the pagination system.Key Elements:
EntryBuilt(UUserWidget* Element)
: A pure virtual function that must be implemented by derived classes. It is called when a list entry (represented by aUUserWidget
) is built or initialized. This allows the list element to populate the widget with its specific content and behavior.
Pagination.h
:
Purpose: This file defines the
UPagination
class, which is responsible for managing the pagination of list elements in the UI. It handles the display of items per page, navigation between pages, and the overall logic of the pagination system.Key Elements:
Setup(TSubclassOf<UUserWidget>* InItemWidget)
: Initializes the pagination widget with the specified item widget class.NewPagination(TSubclassOf<UUserWidget>* InItemWidget, const TArray<IListElementInterface*>& InDisplayContent)
: Initializes a new pagination with the given item widget class and content to display.ResetPagination()
: Resets the pagination, clearing any current items and content.LoadPage(int Page)
: Loads the specified page of content.Next()
: Navigates to the next page.Previous()
: Navigates to the previous page.ItemsPerPage
: The number of items to display per page.UI elements like buttons (
ButtonPrevious
,ButtonNext
), text block (TextBlockCurrentPage
), and containers (NoResultsContainer
,ItemContainer
,FooterContainer
).