+ virtual void set_data(const ListData &) = 0;
+ virtual std::unique_ptr<Item> create_item(std::size_t) const = 0;
+ };
+
+ template<typename I>
+ class TypedItemFactory: public ItemFactory
+ {
+ private:
+ typedef typename I::ValueType ValueType;
+
+ const ListDataStore<ValueType> *data;
+
+ public:
+ TypedItemFactory(const ListData &d) { set_data(d); }
+
+ void set_data(const ListData &d) override
+ {
+ if(const ListDataStore<ValueType> *ds = dynamic_cast<const ListDataStore<ValueType> *>(&d))
+ data = ds;
+ else
+ throw incompatible_data(typeid(ValueType));
+ }
+
+ std::unique_ptr<Item> create_item(std::size_t i) const override
+ {
+ return std::make_unique<I>(data->get(i));
+ }
+ };
+
+ struct Row
+ {
+ std::size_t first;
+ unsigned height;
+
+ Row(std::size_t f): first(f), height(0) { }
+ };
+
+public:
+ sigc::signal<void, std::size_t> signal_item_selected;
+ sigc::signal<void> signal_selection_cleared;
+
+private:
+ std::unique_ptr<ListData> own_data;
+ ListData *data = nullptr;
+ std::unique_ptr<DataObserver> observer = nullptr;
+ std::unique_ptr<ItemFactory> item_factory = nullptr;
+ ViewMode view_mode = LIST;
+ std::size_t sel_index = INVALID_INDEX;
+ std::size_t focus_index = INVALID_INDEX;
+ std::size_t first_row = 0;
+ std::size_t max_scroll = 0;
+ unsigned view_rows = 5;
+ unsigned view_columns = 5;
+ const Part *items_part = nullptr;
+ bool ignore_slider_change = false;
+ bool dragging = false;
+ int drag_start_x = 0;
+ int drag_start_y = 0;