Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions examples/gallery/gallery.slint
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
// SPDX-License-Identifier: MIT

import { CheckBox, StandardListView } from "std-widgets.slint";
import { AboutPage, ControlsPage, EasingsPage, ListViewPage, StyledTextPage, TableViewPage, TableViewPageAdapter, TextEditPage } from "ui/pages/pages.slint";
import { AboutPage, ControlsPage, ControlsPageLogic, EasingsPage, ListViewPage, StyledTextPage, TableViewPage, TableViewPageAdapter, TextEditPage } from "ui/pages/pages.slint";
import { GallerySettings } from "ui/gallery_settings.slint";
import { SideBar } from "ui/side_bar.slint";

export { TableViewPageAdapter }
export { TableViewPageAdapter, ControlsPageLogic }

export component App inherits Window {
preferred-width: 700px;
Expand Down
10 changes: 10 additions & 0 deletions examples/gallery/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,20 @@ pub fn main() {

app.global::<TableViewPageAdapter>().set_row_data(row_data.clone().into());
app.global::<TableViewPageAdapter>().on_filter_sort_model(filter_sort_model);
app.global::<ControlsPageLogic>().on_split_string(split_string);

app.run().unwrap();
}

fn split_string(input: slint::SharedString) -> slint::ModelRc<slint::SharedString> {
let items: Vec<slint::SharedString> = input
.split(',')
.map(|s| slint::SharedString::from(s.trim()))
.filter(|s| !s.is_empty())
.collect();
slint::ModelRc::new(slint::VecModel::from(items))
}

fn filter_sort_model(
source_model: ModelRc<ModelRc<StandardListViewItem>>,
filter: SharedString,
Expand Down
123 changes: 93 additions & 30 deletions examples/gallery/ui/pages/controls_page.slint
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ import { Button, GroupBox, SpinBox, ComboBox, CheckBox, LineEdit, TabWidget, Ver
import { GallerySettings } from "../gallery_settings.slint";
import { Page } from "page.slint";

export global ControlsPageLogic {
callback split-string(string) -> [string];
}

export component ControlsPage inherits Page {
title: @tr("Controls");
show-enable-read-only: true;
Expand Down Expand Up @@ -188,58 +192,117 @@ export component ControlsPage inherits Page {
}
}

GroupBox {
tabGroup := GroupBox {
title: @tr("TabWidget");

TabWidget {
Tab {
title: @tr("Tab 1");
in-out property <bool> show-tab-1: true;
in-out property <bool> show-tab-2: true;
in-out property <bool> show-tab-3: true;

VerticalBox {
HorizontalBox {
padding-top: 10px;
padding-bottom: 10px;

CheckBox {
text: "Show Tab 1";
checked <=> tabGroup.show-tab-1;
}
CheckBox {
text: "Show Tab 2";
checked <=> tabGroup.show-tab-2;
}
CheckBox {
text: "Show Tab 3";
checked <=> tabGroup.show-tab-3;
}
}

VerticalBox {
alignment: start;
TabWidget {
if tabGroup.show-tab-1: Tab {
title: @tr("Tab 1");

GroupBox {
title: @tr("Content of tab 1");
VerticalBox {
alignment: start;

HorizontalBox {
alignment: start;
GroupBox {
title: @tr("Content of tab 1");

Button {
text: @tr("Click me");
enabled: GallerySettings.widgets-enabled;
HorizontalBox {
alignment: start;

Button {
text: @tr("Click me");
enabled: GallerySettings.widgets-enabled;
}
}
}
}
}
}

Tab {
title: @tr("Tab 2");
if tabGroup.show-tab-2: Tab {
title: @tr("Tab 2");

VerticalBox {
alignment: start;
VerticalBox {
alignment: start;

GroupBox {
title: @tr("Content of tab 2");
GroupBox {
title: @tr("Content of tab 2");

VerticalBox {
alignment: start;
VerticalBox {
alignment: start;

CheckBox {
text: @tr("Check me");
enabled: GallerySettings.widgets-enabled;
CheckBox {
text: @tr("Check me");
enabled: GallerySettings.widgets-enabled;
}
}
}
}
}

if tabGroup.show-tab-3: Tab {
title: @tr("Tab 3");

VerticalBox {
Text {
text: @tr("Content of tab 3");
}
}
}
}
}

editableTabs := VerticalBox {
in-out property <string> tab-text: "Alpha,Beta,Gamma";
in-out property <[string]> tab-names: ["Alpha", "Beta", "Gamma"];

HorizontalBox {
padding-top: 10px;
padding-bottom: 10px;

Tab {
title: @tr("Tab 3");
Text {
text: "Tabs (comma separated):";
vertical-alignment: center;
}
LineEdit {
text <=> editableTabs.tab-text;
edited(value) => {
editableTabs.tab-names = ControlsPageLogic.split-string(value);
}
}
}

VerticalBox {
Text {
text: @tr("Content of tab 3");
TabWidget {
for tab-name[idx] in editableTabs.tab-names: Tab {
title: tab-name;
VerticalBox {
alignment: center;
Text {
text: tab-name;
font-size: 32px;
horizontal-alignment: center;
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion examples/gallery/ui/pages/pages.slint
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-License-Identifier: MIT

export { AboutPage } from "about_page.slint";
export { ControlsPage } from "controls_page.slint";
export { ControlsPage, ControlsPageLogic } from "controls_page.slint";
export { EasingsPage } from "easings_page.slint";
export { ListViewPage } from "list_view_page.slint";
export { StyledTextPage } from "styled_text_page.slint";
Expand Down
1 change: 1 addition & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
in
mkShell {
nativeBuildInputs = [
cargo
pkg-config
perf
];
Expand Down
Loading
Loading