PokeMe64/include/widget/ListItemFiller.h
Philippe Symons e51726eef9 Initial import of the first (extremely early) functional version.
It doesn't look like much, but it's functional ;-)

It can inject distribution pokémon into gen 1 and gen 2 original
cartridges and inject the GS ball in Pokémon Crystal.

That's it. But that was the minimal feature set I had in mind for the
project. In the Readme.md you can find the ideas I have for expanding
the project.

But the first priority is the UI, because it really looks bad right now.
(as I was mostly focused on building blocks and transfer pak
functionality. Not on making it looks good)
2024-07-19 21:46:11 +02:00

54 lines
1.5 KiB
C++
Executable File

#ifndef _LISTITEMFILLER_H
#define _LISTITEMFILLER_H
#include <vector>
#include <libdragon.h>
/**
* This template class simply serves the purpose of filling the specified ListType with widgets of the given ListItemWidgetType by creating
* these list item widgets based on a list of ListDataType entries and a ListItemWidgetStyleType
*
* ListType must have a function called addWidget(ListItemWidgetType)
* ListItemWidgetStyleType must have a setData(ListDataType) function
* AND a setStyle(ListItemWidgetStyleType) function
*
* ... in order to be able to use the ListItemFiller template class
*/
template<typename ListType, typename ListDataType, typename ListItemWidgetType, typename ListItemWidgetStyleType>
class ListItemFiller
{
public:
ListItemFiller(ListType& list)
: list_(list)
, widgets_()
{
}
~ListItemFiller()
{
for(ListItemWidgetType* item : widgets_)
{
delete item;
}
widgets_.clear();
}
void addItems(ListDataType* dataList, size_t dataListSize, const MenuItemStyle& itemStyle)
{
ListItemWidgetType* itemWidget;
for(size_t i = 0; i < dataListSize; ++i)
{
itemWidget = new ListItemWidgetType();
itemWidget->setData(dataList[i]);
itemWidget->setStyle(itemStyle);
list_.addWidget(itemWidget);
}
}
protected:
private:
ListType& list_;
std::vector<ListItemWidgetType*> widgets_;
};
#endif