forked from slint-ui/slint
-
Notifications
You must be signed in to change notification settings - Fork 0
/
carousel_demo.slint
41 lines (35 loc) · 1.38 KB
/
carousel_demo.slint
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
// Copyright © SixtyFPS GmbH <[email protected]>
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial
import { Carousel } from "carousel.slint";
import { Card } from "card.slint";
import { Theme } from "theme.slint";
export component MainWindow inherits Window {
private property<[{ title: string, image: image}]> navigation-items: [
{ title: "Settings", image: @image-url("svg/settings_black.svg") },
{ title: "Home", image: @image-url("svg/home_black.svg") },
{ title: "About", image: @image-url("svg/info_black.svg") },
];
private property <int> selected-index: 1;
title: "Carousel example";
width: 320px;
height: 240px;
background: Theme.window-background;
padding: Theme.spacing-regular;
forward-focus: carousel;
default-font-family: Theme.font-family;
carousel := Carousel {
y: (root.height - self.height) / 2;
height: 100%;
itemWidth: Theme.size-medium;
count: root.navigation-items.length;
selected-index <=> root.selected-index;
spacing: Theme.spacing-medium;
for item[index] in root.navigation-items : Card {
is-selected: index == root.selected-index;
title: item.title;
image-source: item.image;
y: (parent.height - self.height) / 2;
clicked => { root.selected-index = index; }
}
}
}