1
0
Fork 0
mirror of synced 2024-06-01 18:19:46 +12:00
czkawka/czkawka_slint_gui/ui/selectable_tree_view.slint
Rafał Mikrut ac636dfdad Updated
2023-10-19 21:39:48 +02:00

87 lines
3.3 KiB
Plaintext

import { Button, VerticalBox , HorizontalBox, TabWidget, ListView, StandardListView, StandardTableView, CheckBox} from "std-widgets.slint";
export component SelectableTableView inherits Rectangle {
in property <[string]> columns;
in property <[{checked: bool, selected_row: bool, val:[string]}]> values;
private property <[length]> column_sizes: [30px, 100px, 100px, 100px];
private property <int> column_number: 4;
VerticalBox {
padding: 5px;
// Widgets
HorizontalLayout {
padding: 5px;
spacing: 5px;
vertical-stretch: 0;
for title[idx] in root.columns : HorizontalLayout {
width: root.column_sizes[idx];
Text { overflow: elide; text: title; }
Rectangle {
width: 1px;
background: gray;
TouchArea {
width: 5px;
x: (parent.width - self.width) / 2;
property <length> cached;
pointer-event(event) => {
if (event.button == PointerEventButton.left && event.kind == PointerEventKind.down) {
self.cached = root.column_sizes[idx];
}
}
moved => {
if (self.pressed) {
root.column_sizes[idx] += (self.mouse-x - self.pressed-x);
if (root.column_sizes[idx] < 20px) {
root.column_sizes[idx] = 20px;
}
}
}
mouse-cursor: ew-resize;
}
}
}
}
list_view:= ListView {
for r[idx] in root.values : Rectangle {
background: touch-area.has-hover ? (r.selected_row ? #cccccc : #dddddd) : (r.selected_row ? #cccccc: #dddddd);
// background: touch-area.has-hover ? (selected ? #333333 : #222222) : (selected ? #333333: #222222);
touch_area:= TouchArea {
clicked => {
r.selected_row = !r.selected_row
}
}
HorizontalLayout {
padding: 5px;
spacing: 5px;
//width: root.column_sizes[idx];
CheckBox {
//min-width: 200px;
checked: r.checked;
width: root.column-sizes[0];
toggled => {
r.checked = self.checked;
}
// preferred-width: root.column-sizes[0];
}
HorizontalLayout {
padding: 5px;
spacing: 5px;
for f[idx] in r.val : Text {
width: root.column-sizes[idx + 1];
text: f;
vertical-alignment: center;
overflow: elide;
}
}
}
}
}
}
}