Loading files
c730ec352This file is pinned to the selected release. Download the original to open it in your design tool.
import { ComboBox, ScrollView } from "../../widgets.slint";
import { Data, DevicePinoutData } from "../../api.slint";
export component DevicePinoutListView inherits ScrollView {
in-out property <[DevicePinoutData]> model;
in-out property <[string]> signal-names;
in property <bool> read-only;
in property <length> window-height;
property <length> row-height: 25px;
preferred-width: l.preferred-width;
preferred-height: l.preferred-height;
mouse-drag-pan-enabled: true;
l := HorizontalLayout {
spacing: 8px;
padding-left: 8px;
padding-right: 8px; // Reserve space for the scrollbar
VerticalLayout {
horizontal-stretch: 0;
spacing: 2px;
for item in model: pad-name-txt := Text {
height: row-height;
horizontal-alignment: right;
vertical-alignment: center;
overflow: elide;
text: item.pad-name + ":";
color: Data.theme.control-text;
accessible-role: none;
}
}
VerticalLayout {
horizontal-stretch: 1;
spacing: 2px;
for item[index] in model: Rectangle {
height: row-height;
signal-cbx := ComboBox {
height: row-height;
window-height: window-height;
model: signal-names;
current-index: item.signal-index;
editable-only-when-focused: true;
enabled: self.model.length > 1; // If component signals available
read-only: read-only;
accessible-label: "signal of pad " + item.pad-name;
current-index-changed(idx) => {
model[index].signal-index = idx;
}
}
// If the selected signal is invalid (unknown UUID), show
// the UUID as a red overlay over the combobox. But the
// combobox is still operational, so the user can fix the
// error by assigning a valid signal.
if (item.signal-index < 0) || (item.signal-index >= signal-names.length): HorizontalLayout {
padding-top: 1px;
padding-left: 8px;
padding-right: 15px; // Skip the drop-down arrow
signal-uuid-txt := Text {
color: Data.theme.base-text-error;
horizontal-alignment: left;
vertical-alignment: center;
font-family: "Noto Sans Mono";
overflow: elide;
text: item.signal-uuid;
accessible-role: none;
}
}
}
}
}
}