Make the Model/Repeater type safe in C++

This commit is contained in:
Olivier Goffart 2020-09-04 19:02:56 +02:00
parent 4c07fbfb3d
commit f6c8ea0f20
3 changed files with 58 additions and 48 deletions

View file

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