Change the exaple to used named struct for models

This commit is contained in:
Olivier Goffart 2020-09-17 14:00:50 +02:00
parent bfe2bf2478
commit 221bb853d7
5 changed files with 26 additions and 19 deletions

View file

@ -9,15 +9,13 @@
LICENSE END */
#include "printerdemo.h"
// FIXME: Ideally it should be a better type in the generated code
using InkData = std::tuple<sixtyfps::Color, float>;
struct InkLevelModel : sixtyfps::Model<InkData>
struct InkLevelModel : sixtyfps::Model<InkLevel>
{
int row_count() const override { return m_data.size(); }
InkData row_data(int i) const override { return m_data[i]; }
InkLevel row_data(int i) const override { return m_data[i]; }
std::vector<InkData> m_data = { { sixtyfps::Color::from_rgb_uint8(255, 255, 0), 0.9 },
std::vector<InkLevel> m_data = { { sixtyfps::Color::from_rgb_uint8(255, 255, 0), 0.9 },
{ sixtyfps::Color::from_rgb_uint8(0, 255, 255), 0.5 },
{ sixtyfps::Color::from_rgb_uint8(255, 0, 255), 0.8 },
{ sixtyfps::Color::from_rgb_uint8(0, 0, 0), 0.1 } };