4#include "freertos/FreeRTOS.h"
5#include "freertos/semphr.h"
62 int x,
int y,
int w,
int h,
72 void init(
const char* title,
const ListItem* items, uint16_t count);
99 itemRenderer_ = callback;
100 itemRendererCtx_ = userCtx;
106 void setHint(
const char* hint) { customHint_ = hint; }
186 void render(
bool partial)
override;
189 const char*
getName()
const override {
return "ListView"; }
193 const char*
title_ =
nullptr;
194 const char* customHint_ =
nullptr;
195 const char* emptyText_ =
nullptr;
197 uint16_t itemCount_ = 0;
198 uint16_t selection_ = 0;
199 uint16_t scrollPos_ = 0;
203 void* itemRendererCtx_ =
nullptr;
204 bool preservePosition_ =
false;
208 SemaphoreHandle_t editMutex_ =
nullptr;
211 uint8_t visibleItems_ = 4;
213 void navigate(
bool down);
214 void ensureVisible();
215 void drawRow(Gdey029T94* gfx, uint16_t itemIndex,
int y,
int rowWidth);
237ListView*
showListView(
const char* title,
const ListItem* items, uint16_t count,
void repaintPartial()
Requests a redraw; the actual repaint happens once per render cycle.
void setEditMutex(SemaphoreHandle_t mutex)
void setItemHeight(uint8_t height)
const char * getFooterHint() const override
Returns footer hint text for this list.
static constexpr uint8_t DEFAULT_ITEM_HEIGHT
void(*)(uint16_t index, void *userData) MenuCallback
uint16_t getSelection() const
bool(*)(Gdey029T94 *gfx, const ListItem &item, uint16_t index, int x, int y, int w, int h, bool selected, void *userCtx) ItemRenderCallback
void(*)(uint16_t index, void *userData) SelectCallback
const ListItem * getSelectedItem() const
Returns the currently selected item.
void setEmptyText(const char *text)
static constexpr uint16_t MAX_ITEMS
InputResult onKey(char key) override
Handles key input for list navigation and actions.
void insertItem(uint16_t index)
Reflects a caller-side insertion at index and marks dirty.
uint16_t getItemCount() const
const char * getName() const override
void setOnMenu(MenuCallback callback)
void setSelection(uint16_t index)
Sets the selected item index.
InputResult onLongPress(char key) override
void setOnSelect(SelectCallback callback)
void init(const char *title, const ListItem *items, uint16_t count)
Initializes list data and selection state.
void setItemRenderer(ItemRenderCallback callback, void *userCtx=nullptr)
void removeItem(uint16_t index)
Reflects a caller-side removal at index and marks dirty.
void setHint(const char *hint)
void updateItem(uint16_t index)
Marks the list dirty after the caller updated a backing item.
Centralized key-code constants for cdc_views.
ListView * showListView(const char *title, const ListItem *items, uint16_t count, ListView::SelectCallback onSelect, const char *hint=nullptr)
Shows a shared list view instance with selection callback.