fmeditor-slint/ui/tool_bar.slint

77 lines
2.0 KiB
Plaintext
Raw Normal View History

2024-04-10 12:28:43 +00:00
import { Metrics, DarkPalette } from "theme.slint";
import { Box, Button, HorizontalSeparator, VerticalBox } from "widgets/components.slint";
2024-04-09 19:47:10 +00:00
2024-04-14 12:02:12 +00:00
export enum ToolType {
Select,
Move,
Rotate,
Scale,
Brush,
Light,
Area,
Object,
Flow,
Room,
Texture,
Timeline,
Multibrush,
}
2024-04-10 15:44:23 +00:00
component ToolBarItem inherits Button {
width: Metrics.size-lg;
height: Metrics.size-lg;
2024-04-10 15:44:23 +00:00
p-elevation: 0;
2024-04-09 19:47:10 +00:00
}
2024-04-10 12:28:43 +00:00
export component ToolBar inherits VerticalBox {
width: Metrics.size-xl;
p-alignment: start;
2024-04-09 19:47:10 +00:00
2024-04-14 12:02:12 +00:00
out property <ToolType> p-current-tool: ToolType.Select;
2024-04-14 12:14:32 +00:00
private property <[{text: string, type: ToolType}]> p-transform-tools: [
{ text: "s", type: ToolType.Select },
{ text: "m", type: ToolType.Move },
{ text: "r", type: ToolType.Rotate },
{ text: "s", type: ToolType.Scale },
];
private property <[{text: string, type: ToolType}]> p-brush-tools: [
{ text: "b", type: ToolType.Brush },
{ text: "o", type: ToolType.Object },
{ text: "f", type: ToolType.Flow },
{ text: "r", type: ToolType.Room },
{ text: "l", type: ToolType.Light },
{ text: "a", type: ToolType.Area },
];
private property <[{text: string, type: ToolType}]> p-other-tools: [
{ text: "t", type: ToolType.Texture },
{ text: "t", type: ToolType.Timeline },
{ text: "m", type: ToolType.Multibrush },
];
for item[index] in root.p-transform-tools: ToolBarItem {
p-text: item.text;
2024-04-14 12:02:12 +00:00
a-clicked => {
2024-04-14 12:14:32 +00:00
root.p-current-tool = item.type;
2024-04-14 12:02:12 +00:00
}
2024-04-10 15:44:23 +00:00
}
2024-04-09 19:47:10 +00:00
2024-04-10 12:28:43 +00:00
HorizontalSeparator { }
2024-04-09 19:47:10 +00:00
2024-04-14 12:14:32 +00:00
for item[index] in root.p-brush-tools: ToolBarItem {
p-text: item.text;
2024-04-14 12:02:12 +00:00
a-clicked => {
2024-04-14 12:14:32 +00:00
root.p-current-tool = item.type;
2024-04-14 12:02:12 +00:00
}
2024-04-10 15:44:23 +00:00
}
2024-04-09 19:47:10 +00:00
2024-04-10 12:28:43 +00:00
HorizontalSeparator { }
2024-04-09 19:47:10 +00:00
2024-04-14 12:14:32 +00:00
for item[index] in root.p-other-tools: ToolBarItem {
p-text: item.text;
2024-04-14 12:02:12 +00:00
a-clicked => {
2024-04-14 12:14:32 +00:00
root.p-current-tool = item.type;
2024-04-14 12:02:12 +00:00
}
2024-04-10 15:44:23 +00:00
}
2024-04-09 19:47:10 +00:00
}