chocobar-x11/ui/square-icon-widget.slint
Candifloss 3dca171063 Refactor SquareIconWidget & remove redundant classes
- Eliminate `BatteryWidget`
- Pass all properties to reusable `SquareIconWidget`
- Eliminate need for duplication
2025-11-22 23:00:56 +05:30

45 lines
1.3 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

export component SquareIconWidget {
// Skeleton of suqre-shaped icon widgets
// with similar basic functions and appearance
in property <int> bar_height;
in property <string> icon_text;
in property <string> tooltip_text;
// Colors
in property <color> icon_color: #ffffff;
in property <color> bg_normal: #8e9162;
in property <color> bg_hover: #6d8a4d;
in property <color> bg_clicked: #4a5f70;
callback square_btn_callback();
height: bar_height * 1px; // Same height as the bar
width: bar_height * 1px; // Square shape
Rectangle {
background: touch_area.pressed ? bg_clicked
: touch_area.has-hover ? bg_hover
: bg_normal;
border-radius: 3px;
HorizontalLayout {
padding-left: 3px;
padding-right: 3px;
Text {
text: icon_text; // Every `SquareIconWidget` has an icon
color: icon_color;
vertical-alignment: center;
horizontal-alignment: center;
}
}
touch_area := TouchArea {
// Action when the icon is clicked
clicked => { square_btn_callback(); }
}
}
// Tooltip will be added later — Slints ToolTip element is window-global
}