import { Nine, Label, Theme } from "widgets/base.slint";
import { Pieces } from "widgets/pieces.slint";
import { InsetPanel, SubheaderFrame, TabbedPaneFrame } from "widgets/frame.slint";
import { Tabs, TabItem } from "widgets/tabs.slint";
import { Dropdown } from "widgets/dropdown.slint";
import { Scrollbar } from "widgets/scrollbar.slint";
import { FrameActionButton } from "widgets/frame-action-button.slint";
export component ChangelogView {
in property <string> text;
in property <string> date;
in property <[string]> versions;
in property <[string]> subversions;
in property <int> version;
in property <int> subversion;
in property <int> category: 3;
callback filter(int, int);
property <bool> version-open;
property <bool> subversion-open;
property <[TabItem]> tabs: [{text: "Features", badge: false, enabled: true}, {text: "Changes", badge: false, enabled: true}, {text: "Bugfixes", badge: false, enabled: true}, {text: "All", badge: false, enabled: true}];
InsetPanel { width: root.width; height: root.height; }
SubheaderFrame { width: root.width; height: 36px; }
Tabs { x: 12px; y: 48px; width: 336px; height: 40px; items: root.tabs; current: root.category; part: "others"; selected(i) => { content.content-y = 0px; root.filter(2, i); } }
TabbedPaneFrame { y: 84px; width: root.width; height: root.height - 84px; }
Tabs { x: 12px; y: 48px; width: 336px; height: 40px; items: root.tabs; current: root.category; part: "selected"; selected(i) => { content.content-y = 0px; root.filter(2, i); } }
// changelog_textbox uses the same default_background as textbox (A(248,0)), black default font, padding 8/4.
Nine { x: 12px; y: 96px; width: root.width - 24px; height: root.height - 108px; source: Pieces.textbox-default-base; }
content := Flickable {
// Reserve the scrollbar lane: deriving width from wrapped text height creates a layout cycle.
x: 20px; y: 100px; width: root.width - 52px; height: root.height - 116px;
content-width: self.width; content-height: max(self.height, log.preferred-height);
log := Label { x: 0px; y: 0px; width: parent.width; height: self.preferred-height; text: root.text == "" ? "No changelog entries." : root.text; color: Theme.black; wrap: word-wrap; line-height-factor: 20 / 21.294; }
}
if content.content-height > content.height: Scrollbar {
x: root.width - 24px; y: content.y; width: 12px; height: content.height;
thumb-height: max(24px, self.height * content.height / content.content-height);
thumb-position: -content.content-y / max(1px, content.content-height - content.height) * (self.height - self.thumb-height);
moved(y) => { content.content-y = -clamp((y - self.thumb-height / 2) / (self.height - self.thumb-height), 0, 1) * (content.content-height - content.height); }
}
// The window title bar owns the top-right corner: the 24 px search action button sits above this view (reference: game-changelog.png). Visual only.
FrameActionButton { x: root.width - 28px; y: -32px; width: 24px; height: 24px; }
// Dropdowns paint last so their lists cover the tabs and text panel.
if root.version-open || root.subversion-open: TouchArea { clicked => { root.version-open = false; root.subversion-open = false; } }
Label { x: 12px; y: 6px; height: 24px; text: "Version:"; vertical-alignment: center; }
Label { x: 152px; y: 6px; height: 24px; text: "Sub-version:"; vertical-alignment: center; }
Label { x: 368px; y: 6px; height: 24px; text: "Release date: " + root.date; vertical-alignment: center; }
Dropdown { x: 66px; y: 4px; width: 66px; height: 28px; items: root.versions; current: root.version; open: root.version-open; toggled => { root.version-open = !root.version-open; root.subversion-open = false; } selected(i) => { root.version-open = false; content.content-y = 0px; root.filter(0, i); } }
Dropdown { x: 232px; y: 4px; width: 116px; height: 28px; items: root.subversions; current: root.subversion; open: root.subversion-open; toggled => { root.subversion-open = !root.subversion-open; root.version-open = false; } selected(i) => { root.subversion-open = false; content.content-y = 0px; root.filter(1, i); } }
}