1
0
Fork 0
mirror of synced 2024-06-27 02:21:05 +12:00
czkawka/czkawka_slint_gui/ui/selectable_tree_view.slint

87 lines
3.3 KiB
Plaintext
Raw Normal View History

2023-10-18 08:31:08 +13:00
import { Button, VerticalBox , HorizontalBox, TabWidget, ListView, StandardListView, StandardTableView, CheckBox} from "std-widgets.slint";
export component SelectableTableView inherits Rectangle {
in property <[string]> columns;
2023-10-20 08:39:48 +13:00
in property <[{checked: bool, selected_row: bool, val:[string]}]> values;
2023-10-18 08:31:08 +13:00
private property <[length]> column_sizes: [30px, 100px, 100px, 100px];
private property <int> column_number: 4;
VerticalBox {
padding: 5px;
// Widgets
HorizontalLayout {
2023-10-19 20:32:37 +13:00
padding: 5px;
spacing: 5px;
2023-10-18 08:31:08 +13:00
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);
2023-10-19 20:32:37 +13:00
if (root.column_sizes[idx] < 20px) {
root.column_sizes[idx] = 20px;
2023-10-18 08:31:08 +13:00
}
}
}
mouse-cursor: ew-resize;
}
}
}
}
list_view:= ListView {
for r[idx] in root.values : Rectangle {
2023-10-20 08:39:48 +13:00
background: touch-area.has-hover ? (r.selected_row ? #cccccc : #dddddd) : (r.selected_row ? #cccccc: #dddddd);
2023-10-19 20:32:37 +13:00
// background: touch-area.has-hover ? (selected ? #333333 : #222222) : (selected ? #333333: #222222);
2023-10-18 08:31:08 +13:00
touch_area:= TouchArea {
clicked => {
2023-10-20 08:39:48 +13:00
r.selected_row = !r.selected_row
2023-10-18 08:31:08 +13:00
}
}
HorizontalLayout {
padding: 5px;
spacing: 5px;
//width: root.column_sizes[idx];
CheckBox {
//min-width: 200px;
2023-10-20 08:39:48 +13:00
checked: r.checked;
2023-10-18 08:31:08 +13:00
width: root.column-sizes[0];
2023-10-20 08:39:48 +13:00
toggled => {
r.checked = self.checked;
}
2023-10-19 20:32:37 +13:00
// preferred-width: root.column-sizes[0];
2023-10-18 08:31:08 +13:00
}
HorizontalLayout {
padding: 5px;
spacing: 5px;
2023-10-20 08:39:48 +13:00
for f[idx] in r.val : Text {
2023-10-18 08:31:08 +13:00
width: root.column-sizes[idx + 1];
text: f;
vertical-alignment: center;
overflow: elide;
}
}
}
}
}
}
}