slint/examples/todo-mvc/ui/widgets/state_layer.slint
Florian Blasius 0870585c32
Added TodoMVC example (Rust mock version) (#5396)
* Added TodoMVC example (Rust mock version)

* TodoMVC: use visible-width instead of width for selection items

and format

* TodoMVC: layout fix for qt checkbox

* TdodoMVC: fix license issues in the example

* Update examples/todo_mvc/ui/views/task_list_view.slint

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* TdodoMVC: fix license issues in the example

* TodoMVC: code review changes

* TodoMVC: code review changes

* Update .reuse/dep5

Co-authored-by: Simon Hausmann <simon.hausmann@slint.dev>

* Update examples/todo_mvc/rust/src/adapters/navigation_adapter.rs

Co-authored-by: Simon Hausmann <simon.hausmann@slint.dev>

* Update examples/todo_mvc/rust/src/adapters/navigation_adapter.rs

Co-authored-by: Simon Hausmann <simon.hausmann@slint.dev>

* TodoMVC: refactor task list model (code review feedback)

* TodoMVC: code review feedback

* Update examples/todo-mvc/rust/src/mvc/controllers/task_list_controller.rs

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* TodoMVC: add missing link in dep5

* dep5 fix

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Simon Hausmann <simon.hausmann@slint.dev>
2024-06-13 13:05:44 +02:00

54 lines
1.4 KiB
Text

// Copyright © SixtyFPS GmbH <info@slint.dev>
// SPDX-License-Identifier: MIT
import { TodoPalette, AnimationSettings } from "styling.slint";
export component StateLayer {
// styling
in property <length> border-radius <=> state-layer.border-radius;
// states
in property <bool> pressed;
in property <bool> has-hover;
in property <bool> has-focus;
in property <length> focus-padding: 2px;
focus-border := Rectangle {
x: (root.width - self.width) / 2;
y: (root.height - self.height) / 2;
width: root.width + 2 * root.focus-padding;
height: root.height + 2 * root.focus-padding;
border-radius: state-layer.border-radius + root.focus-padding;
border-width: 1px;
border-color: TodoPalette.focus-border;
opacity: 0;
states [
focused when root.has-focus : {
opacity: 1;
}
]
animate opacity {
duration: AnimationSettings.color-duration;
}
}
state-layer := Rectangle {
width: 100%;
height: 100%;
animate background {
duration: AnimationSettings.color-duration;
}
}
states [
pressed when root.pressed : {
state-layer.background: TodoPalette.state-pressed;
}
hoverd when root.has-hover: {
state-layer.background: TodoPalette.state-hovered;
}
]
}