1 | // Copyright © SixtyFPS GmbH <info@slint.dev> |
2 | // SPDX-License-Identifier: MIT |
3 | |
4 | import { Theme } from "../theme.slint" ; |
5 | |
6 | export component IconButton { |
7 | in property <image> icon <=> i-icon.source; |
8 | in property <bool> enabled <=> i-touch-area.enabled; |
9 | |
10 | callback clicked <=> i-touch-area.clicked; |
11 | |
12 | vertical-stretch: 0; |
13 | horizontal-stretch: 0; |
14 | min-width: 24px; |
15 | min-height: 24px; |
16 | |
17 | states [ |
18 | disabled when !root.enabled : { |
19 | opacity: 0.25; |
20 | } |
21 | pressed when i-touch-area.pressed : { |
22 | i-icon.colorize: Theme.palette.lemon-green; |
23 | } |
24 | ] |
25 | |
26 | GridLayout { |
27 | padding: 4px; |
28 | |
29 | i-icon := Image { |
30 | colorize: Theme.palette.slint-blue-300; |
31 | |
32 | animate colorize { duration: Theme.durations.medium; } |
33 | } |
34 | } |
35 | |
36 | i-touch-area := TouchArea {} |
37 | } |
38 | |