1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139
|
#if defined(Hiro_ListView)
mListView::mListView() {
mTableView::onActivate([&](auto) { doActivate(); });
mTableView::onChange([&] { doChange(); });
mTableView::onContext([&](auto cell) { doContext(); });
mTableView::onToggle([&](TableViewCell cell) {
if(auto item = cell->parentTableViewItem()) {
if(auto shared = item->instance.acquire()) {
doToggle(ListViewItem{shared});
}
}
});
append(TableViewColumn().setExpandable());
}
auto mListView::batched() const -> vector<ListViewItem> {
auto batched = mTableView::batched();
vector<ListViewItem> result;
for(auto item : batched) result.append(ListViewItem{item});
return result;
}
auto mListView::doActivate() const -> void {
if(state.onActivate) state.onActivate();
}
auto mListView::doChange() const -> void {
if(state.onChange) state.onChange();
}
auto mListView::doContext() const -> void {
if(state.onContext) state.onContext();
}
auto mListView::doToggle(ListViewItem item) const -> void {
if(state.onToggle) state.onToggle(item);
}
auto mListView::item(u32 position) const -> ListViewItem {
return ListViewItem{mTableView::item(position)};
}
auto mListView::items() const -> vector<ListViewItem> {
auto items = mTableView::items();
vector<ListViewItem> result;
for(auto item : items) result.append(ListViewItem{item});
return result;
}
auto mListView::onActivate(const function<void ()>& callback) -> type& {
state.onActivate = callback;
return *this;
}
auto mListView::onChange(const function<void ()>& callback) -> type& {
state.onChange = callback;
return *this;
}
auto mListView::onContext(const function<void ()>& callback) -> type& {
state.onContext = callback;
return *this;
}
auto mListView::onToggle(const function<void (ListViewItem)>& callback) -> type& {
state.onToggle = callback;
return *this;
}
auto mListView::reset() -> type& {
mTableView::reset();
append(TableViewColumn().setExpandable());
return *this;
}
auto mListView::resizeColumn() -> type& {
mTableView::resizeColumns();
return *this;
}
auto mListView::selected() const -> ListViewItem {
return ListViewItem{mTableView::selected()};
}
auto mListView::setVisible(bool visible) -> type& {
mTableView::setVisible(visible);
return *this;
}
//
mListViewItem::mListViewItem() {
append(TableViewCell());
}
auto mListViewItem::checkable() const -> bool {
return cell(0).checkable();
}
auto mListViewItem::checked() const -> bool {
return cell(0).checked();
}
auto mListViewItem::icon() const -> multiFactorImage {
return cell(0).icon();
}
auto mListViewItem::reset() -> type& {
mTableViewItem::reset();
append(TableViewCell());
return *this;
}
auto mListViewItem::setCheckable(bool checkable) -> type& {
cell(0).setCheckable(checkable);
return *this;
}
auto mListViewItem::setChecked(bool checked) -> type& {
cell(0).setChecked(checked);
return *this;
}
auto mListViewItem::setIcon(const multiFactorImage& icon) -> type& {
cell(0).setIcon(icon);
return *this;
}
auto mListViewItem::setText(const string& text) -> type& {
cell(0).setText(text);
return *this;
}
auto mListViewItem::text() const -> string {
return cell(0).text();
}
#endif
|