Imported from 073c3302d6
This commit is contained in:
Nigel Breslaw 2025-09-04 13:25:40 +03:00 committed by Olivier Goffart
parent a2edac554e
commit ae45308c58
16 changed files with 55 additions and 55 deletions

View file

@ -31,13 +31,13 @@ A `NavigationBar` is a bottom navigation component that displays a row of naviga
## Properties ## Properties
### current-item ### current-index
<SlintProperty propName="current-item" typeName="int" propertyVisibility="in-out"> <SlintProperty propName="current-index" typeName="int" propertyVisibility="in-out">
The index of the currently selected navigation item. The index of the currently selected navigation item.
```slint "current-item: 0;" ```slint "current-index: 0;"
NavigationBar { NavigationBar {
current-item: 0; current-index: 0;
} }
``` ```
</SlintProperty> </SlintProperty>

View file

@ -37,8 +37,8 @@ An optional avatar image displayed in the search bar.
The background color for the avatar. The background color for the avatar.
</SlintProperty> </SlintProperty>
### current-item ### current-index
<SlintProperty propName="current-item" typeName="int" propertyVisibility="in-out"> <SlintProperty propName="current-index" typeName="int" propertyVisibility="in-out">
The index of the currently selected search result item. The index of the currently selected search result item.
</SlintProperty> </SlintProperty>

View file

@ -30,8 +30,8 @@ A `TabBar` displays a row of tabs for navigation between different views or cont
## Properties ## Properties
### current-item ### current-index
<SlintProperty propName="current-item" typeName="int" propertyVisibility="in-out"> <SlintProperty propName="current-index" typeName="int" propertyVisibility="in-out">
The index of the currently selected tab. The index of the currently selected tab.
</SlintProperty> </SlintProperty>

View file

@ -19,7 +19,7 @@ export component Example inherits Window {
{ icon: @image-url("../icons/share.svg"), text: "Share" }, { icon: @image-url("../icons/share.svg"), text: "Share" },
{ icon: @image-url("../icons/music_note.svg"), text: "Music" } { icon: @image-url("../icons/music_note.svg"), text: "Music" }
]; ];
current-item: 0; current-index: 0;
} }
} }
``` ```
@ -29,8 +29,8 @@ A `SegmentedButton` displays a group of related options as a single control, whe
## Properties ## Properties
### current-item ### current-index
<SlintProperty propName="current-item" typeName="int" propertyVisibility="in-out"> <SlintProperty propName="current-index" typeName="int" propertyVisibility="in-out">
The index of the currently selected item. The index of the currently selected item.
</SlintProperty> </SlintProperty>

View file

@ -40,8 +40,8 @@ A `NavigationDrawer` is a side panel that contains navigation items organized in
The index of the currently selected navigation group. The index of the currently selected navigation group.
</SlintProperty> </SlintProperty>
### current-item ### current-index
<SlintProperty propName="current-item" typeName="int" propertyVisibility="in-out"> <SlintProperty propName="current-index" typeName="int" propertyVisibility="in-out">
The index of the currently selected navigation item within the current group. The index of the currently selected navigation item within the current group.
</SlintProperty> </SlintProperty>

View file

@ -35,8 +35,8 @@ A `NavigationRail` is a vertical navigation component that displays navigation i
The alignment of the navigation items within the rail. The alignment of the navigation items within the rail.
</SlintProperty> </SlintProperty>
### current-item ### current-index
<SlintProperty propName="current-item" typeName="int" propertyVisibility="in-out"> <SlintProperty propName="current-index" typeName="int" propertyVisibility="in-out">
The index of the currently selected navigation item. The index of the currently selected navigation item.
</SlintProperty> </SlintProperty>

View file

@ -52,7 +52,7 @@ The label text displayed above the drop down menu.
</SlintProperty> </SlintProperty>
### current_index ### current_index
<SlintProperty propName="current-item" typeName="int" propertyVisibility="in-out"> <SlintProperty propName="current-index" typeName="int" propertyVisibility="in-out">
The index of the currently selected menu item. The index of the currently selected menu item.
</SlintProperty> </SlintProperty>

View file

@ -301,7 +301,7 @@ export component ActionsView {
alignment: center; alignment: center;
SegmentedButton { SegmentedButton {
current_item: 4; current_index: 4;
model: [ model: [
{ text: "XS" }, { text: "XS" },

View file

@ -27,10 +27,10 @@ export component BaseNavigationItemTemplate {
export component BaseNavigation { export component BaseNavigation {
in property <[NavigationItem]> items; in property <[NavigationItem]> items;
in_out property <int> current_item; in_out property <int> current_index;
accessible-role: tab-list; accessible-role: tab-list;
// accessible-delegate-focus: root.current-focused >= 0 ? root.current-focused : root.current-item; // accessible-delegate-focus: root.current-focused >= 0 ? root.current-focused : root.current-index;
// accessible-label: root.title; // accessible-label: root.title;
accessible-item-count: root.items.length; accessible-item-count: root.items.length;
@ -41,6 +41,6 @@ export component BaseNavigation {
return; return;
} }
root.current_item = index; root.current_index = index;
} }
} }

View file

@ -137,7 +137,7 @@ export component NavigationBar inherits BaseNavigation {
icon_selected: item.icon_selected; icon_selected: item.icon_selected;
text: item.text; text: item.text;
index: index; index: index;
selected: index == root.current_item; selected: index == root.current_index;
empty_badge: item.empty_badge; empty_badge: item.empty_badge;
badge: item.badge; badge: item.badge;

View file

@ -105,7 +105,7 @@ component NavigationItemTempalte inherits BaseNavigationItemTemplate {
component NavigationGroupTemplate { component NavigationGroupTemplate {
in property <string> title; in property <string> title;
in property <[NavigationItem]> items; in property <[NavigationItem]> items;
in property <int> current_item: -1; in property <int> current_index: -1;
in property <bool> has_divider; in property <bool> has_divider;
callback select(index: int); callback select(index: int);
@ -123,7 +123,7 @@ component NavigationGroupTemplate {
icon_selected: item.icon_selected; icon_selected: item.icon_selected;
text: item.text; text: item.text;
badge: item.badge; badge: item.badge;
selected: index == root.current_item; selected: index == root.current_index;
index: index; index: index;
clicked => { clicked => {
@ -146,17 +146,17 @@ export component NavigationDrawer inherits Drawer {
callback item_pointer_event(group_index: int, item_index: int, event: PointerEvent, position: Point); callback item_pointer_event(group_index: int, item_index: int, event: PointerEvent, position: Point);
in property <[NavigationGroup]> groups; in property <[NavigationGroup]> groups;
in_out property <int> current_group; in_out property <int> current_group;
in_out property <int> current_item; in_out property <int> current_index;
accessible-role: tab-list; accessible-role: tab-list;
// accessible-delegate-focus: root.current-focused >= 0 ? root.current-focused : root.current-item; // accessible-delegate-focus: root.current-focused >= 0 ? root.current-focused : root.current-index;
// accessible-label: root.title; // accessible-label: root.title;
accessible-item-count: root.groups.length; accessible-item-count: root.groups.length;
for group[group_index] in root.groups : NavigationGroupTemplate { for group[group_index] in root.groups : NavigationGroupTemplate {
title: group.title; title: group.title;
items: group.items; items: group.items;
current_item: group_index == root.current_group ? root.current_item : -1; current_index: group_index == root.current_group ? root.current_index : -1;
has_divider: root.groups.length > 1 && group_index < root.groups.length - 1; has_divider: root.groups.length > 1 && group_index < root.groups.length - 1;
select(index) => { select(index) => {
@ -173,7 +173,7 @@ export component NavigationDrawer inherits Drawer {
} }
root.current_group = group_index; root.current_group = group_index;
root.current_item = item_index; root.current_index = item_index;
root.selected(group_index, item_index); root.selected(group_index, item_index);
} }
} }
@ -181,17 +181,17 @@ export component NavigationDrawer inherits Drawer {
export component ModalNavigationDrawer inherits ModalDrawer { export component ModalNavigationDrawer inherits ModalDrawer {
in property <[NavigationGroup]> groups; in property <[NavigationGroup]> groups;
in_out property <int> current_group; in_out property <int> current_group;
in_out property <int> current_item; in_out property <int> current_index;
accessible-role: tab-list; accessible-role: tab-list;
// accessible-delegate-focus: root.current-focused >= 0 ? root.current-focused : root.current-item; // accessible-delegate-focus: root.current-focused >= 0 ? root.current-focused : root.current-index;
// accessible-label: root.title; // accessible-label: root.title;
accessible-item-count: root.groups.length; accessible-item-count: root.groups.length;
for group[group_index] in root.groups : NavigationGroupTemplate { for group[group_index] in root.groups : NavigationGroupTemplate {
title: group.title; title: group.title;
items: group.items; items: group.items;
current_item: group_index == root.current_group ? root.current_item : -1; current_index: group_index == root.current_group ? root.current_index : -1;
has_divider: root.groups.length > 1 && group_index < root.groups.length - 1; has_divider: root.groups.length > 1 && group_index < root.groups.length - 1;
select(index) => { select(index) => {
@ -205,7 +205,7 @@ export component ModalNavigationDrawer inherits ModalDrawer {
} }
root.current_group = group_index; root.current_group = group_index;
root.current_item = item_index; root.current_index = item_index;
root.close(); root.close();
} }
} }

View file

@ -67,7 +67,7 @@ export component NavigationRail inherits BaseNavigation {
icon_selected: item.icon_selected; icon_selected: item.icon_selected;
text: item.text; text: item.text;
index: index; index: index;
selected: index == root.current_item; selected: index == root.current_index;
empty_badge: item.empty_badge; empty_badge: item.empty_badge;
badge: item.badge; badge: item.badge;
padding_top: 0; padding_top: 0;

View file

@ -124,7 +124,7 @@ export component SearchBar {
in property <string> placeholder; in property <string> placeholder;
in property <string> empty_text; in property <string> empty_text;
in_out property <string> text; in_out property <string> text;
in_out property <int> current_item; in_out property <int> current_index;
in property <[ListItem]> items; in property <[ListItem]> items;
callback accepted(text: string); callback accepted(text: string);

View file

@ -61,7 +61,7 @@ component SegmentedItemTemplate {
export component SegmentedButton { export component SegmentedButton {
in property <[SegmentedItem]> model; in property <[SegmentedItem]> model;
in_out property <int> current_item; in_out property <int> current_index;
min_width: max(2 * MaterialStyleMetrics.size_40, layout.min_width); min_width: max(2 * MaterialStyleMetrics.size_40, layout.min_width);
min_height: max(MaterialStyleMetrics.size_40, layout.min_height); min_height: max(MaterialStyleMetrics.size_40, layout.min_height);
@ -81,7 +81,7 @@ export component SegmentedButton {
text: item.text; text: item.text;
index: index; index: index;
last: index == root.model.length - 1; last: index == root.model.length - 1;
selected: index == root.current_item; selected: index == root.current_index;
clicked => { clicked => {
root.select(index); root.select(index);
@ -95,6 +95,6 @@ export component SegmentedButton {
return; return;
} }
root.current_item = index; root.current_index = index;
} }
} }

View file

@ -111,7 +111,7 @@ component SecondaryTabItemTemplate inherits BaseNavigationItemTemplate {
export component TabBar inherits BaseNavigation { export component TabBar inherits BaseNavigation {
property <length> indicator_width; property <length> indicator_width;
property <length> item_width: root.width / root.items.length; property <length> item_width: root.width / root.items.length;
property <length> current_x: root.item_width * self.current_item; property <length> current_x: root.item_width * self.current_index;
min_height: max(MaterialStyleMetrics.size_49, layout.min_height); min_height: max(MaterialStyleMetrics.size_49, layout.min_height);
@ -124,7 +124,7 @@ export component TabBar inherits BaseNavigation {
icon_selected: item.icon_selected; icon_selected: item.icon_selected;
text: item.text; text: item.text;
index: index; index: index;
selected: index == root.current_item; selected: index == root.current_index;
empty_badge: item.empty_badge; empty_badge: item.empty_badge;
badge: item.badge; badge: item.badge;
@ -161,7 +161,7 @@ export component TabBar inherits BaseNavigation {
} }
function set_indicator_width(index: int, width: length) { function set_indicator_width(index: int, width: length) {
if index != root.current_item { if index != root.current_index {
return; return;
} }
@ -171,7 +171,7 @@ export component TabBar inherits BaseNavigation {
export component SecondaryTabBar inherits BaseNavigation { export component SecondaryTabBar inherits BaseNavigation {
property <length> item_width: root.width / root.items.length; property <length> item_width: root.width / root.items.length;
property <length> current_x: root.item_width * self.current_item; property <length> current_x: root.item_width * self.current_index;
min_height: max(MaterialStyleMetrics.size_49, layout.min_height); min_height: max(MaterialStyleMetrics.size_49, layout.min_height);
@ -184,7 +184,7 @@ export component SecondaryTabBar inherits BaseNavigation {
icon_selected: item.icon_selected; icon_selected: item.icon_selected;
text: item.text; text: item.text;
index: index; index: index;
selected: index == root.current_item; selected: index == root.current_index;
empty_badge: item.empty_badge; empty_badge: item.empty_badge;
badge: item.badge; badge: item.badge;

View file

@ -42,10 +42,10 @@ component Clock {
in property <[int]> model; in property <[int]> model;
in property <bool> two_columns; in property <bool> two_columns;
in property <int> total; in property <int> total;
in_out property <int> current_item; in_out property <int> current_index;
in property <int> current_value; in property <int> current_value;
callback current_item_changed(index: int); callback current_index_changed(index: int);
property <length> radius: max(root.width, root.height) / 2; property <length> radius: max(root.width, root.height) / 2;
property <length> picker_ditameter: MaterialStyleMetrics.size_48; property <length> picker_ditameter: MaterialStyleMetrics.size_48;
@ -68,7 +68,7 @@ component Clock {
border_radius: max(self.width, self.height) / 2; border_radius: max(self.width, self.height) / 2;
background: MaterialPalette.surface_container_highest; background: MaterialPalette.surface_container_highest;
if root.current_item >= 0 || root.current_item < root.model.length: Path { if root.current_index >= 0 || root.current_index < root.model.length: Path {
stroke: MaterialPalette.primary; stroke: MaterialPalette.primary;
stroke_width: 2px; stroke_width: 2px;
viewbox_width: self.width / 1px; viewbox_width: self.width / 1px;
@ -92,7 +92,7 @@ component Clock {
border_radius: self.width / 2; border_radius: self.width / 2;
} }
if root.current_item < root.model.length: Rectangle { if root.current_index < root.model.length: Rectangle {
x: root.current_x; x: root.current_x;
y: root.current_y; y: root.current_y;
width: root.picker_ditameter; width: root.picker_ditameter;
@ -100,7 +100,7 @@ component Clock {
border_radius: root.picker_ditameter / 2; border_radius: root.picker_ditameter / 2;
background: MaterialPalette.primary; background: MaterialPalette.primary;
if root.current_item < 0: Rectangle { if root.current_index < 0: Rectangle {
width: MaterialStyleMetrics.size_4; width: MaterialStyleMetrics.size_4;
height: self.width; height: self.width;
border_radius: self.width / 2; border_radius: self.width / 2;
@ -114,7 +114,7 @@ component Clock {
width: root.picker_ditameter; width: root.picker_ditameter;
height: root.picker_ditameter; height: root.picker_ditameter;
value: val; value: val;
selected: index == root.current_item; selected: index == root.current_index;
accessible_role: button; accessible_role: button;
accessible_label: @tr("{} Hours or minutes of {}", val, root.total); accessible_label: @tr("{} Hours or minutes of {}", val, root.total);
accessible_action_default => { accessible_action_default => {
@ -122,7 +122,7 @@ component Clock {
} }
clicked => { clicked => {
root.set_current_item(index); root.set_current_index(index);
} }
} }
} }
@ -162,8 +162,8 @@ component Clock {
root.center + (root.radius_outer / 1px * sin(root.value_to_angle(value))) * 1px root.center + (root.radius_outer / 1px * sin(root.value_to_angle(value))) * 1px
} }
function set_current_item(index: int) { function set_current_index(index: int) {
root.current_item_changed(index); root.current_index_changed(index);
} }
} }
@ -404,7 +404,7 @@ export component TimePicker inherits PopupWindow {
]; ];
property <[int]> minute_model: [0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55]; property <[int]> minute_model: [0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55];
property <[int]> current_model: root.get_current_model(); property <[int]> current_model: root.get_current_model();
property <int> current_item: root.minutes_selected ? root.index_of_minute(root.current_time.minute) : root.index_of_hour(root.current_time.hour); property <int> current_index: root.minutes_selected ? root.index_of_minute(root.current_time.minute) : root.index_of_hour(root.current_time.hour);
property <Time> current_time: root.time; property <Time> current_time: root.time;
property <int> time_picker_hour: hour_time_picker.text.to_float(); property <int> time_picker_hour: hour_time_picker.text.to_float();
property <int> time_picker_minute: minute_time_picker.text.to_float(); property <int> time_picker_minute: minute_time_picker.text.to_float();
@ -521,11 +521,11 @@ export component TimePicker inherits PopupWindow {
if root.horizontal && !root.keyboard_mode : Clock { if root.horizontal && !root.keyboard_mode : Clock {
model: root.current_model; model: root.current_model;
two_columns: !root.minutes_selected && root.use-24_hour_format; two_columns: !root.minutes_selected && root.use-24_hour_format;
current_item: root.current_item; current_index: root.current_index;
total: root.minutes_selected ? 60 : root.use-24_hour_format ? 24 : 12; total: root.minutes_selected ? 60 : root.use-24_hour_format ? 24 : 12;
current_value: root.minutes_selected ? root.current_time.minute : root.current_time.hour; current_value: root.minutes_selected ? root.current_time.minute : root.current_time.hour;
current_item_changed(index) => { current_index_changed(index) => {
root.update_time_by_item(index); root.update_time_by_item(index);
if !root.minutes_selected { if !root.minutes_selected {
@ -543,12 +543,12 @@ export component TimePicker inherits PopupWindow {
if !root.horizontal && !root.keyboard_mode : Clock { if !root.horizontal && !root.keyboard_mode : Clock {
model: root.current_model; model: root.current_model;
two_columns: !root.minutes_selected && root.use-24_hour_format; two_columns: !root.minutes_selected && root.use-24_hour_format;
current_item: root.current_item; current_index: root.current_index;
total: root.minutes_selected ? 60 : root.use-24_hour_format ? 24 : 12; total: root.minutes_selected ? 60 : root.use-24_hour_format ? 24 : 12;
current_value: root.minutes_selected ? root.current_time.minute : root.current_time.hour; current_value: root.minutes_selected ? root.current_time.minute : root.current_time.hour;
height: self.width; height: self.width;
current_item_changed(index) => { current_index_changed(index) => {
root.update_time_by_item(index); root.update_time_by_item(index);
if !root.minutes_selected { if !root.minutes_selected {