Add tool switching

This commit is contained in:
Jarrod Doyle 2024-04-14 13:02:12 +01:00
parent 8eee3c9a1c
commit e7b316be1f
Signed by: Jayrude
GPG Key ID: 38B57B16E7C0ADF7
2 changed files with 60 additions and 3 deletions

View File

@ -3,7 +3,7 @@ import { VerticalBox, HorizontalBox } from "widgets/components.slint";
import { EditorBar } from "editor_bar.slint";
import { StatusBar } from "status_bar.slint";
import { ToolBar } from "tool_bar.slint";
import { ToolBar, ToolType } from "tool_bar.slint";
import { ObjectToolPanel } from "object_tool_panel.slint";
export component AppWindow inherits Window {
@ -22,9 +22,9 @@ export component AppWindow inherits Window {
p-padding: 0px;
p-spacing: Metrics.spacing-sm;
ToolBar { }
c-toolbar := ToolBar { }
ObjectToolPanel { }
if (c-toolbar.p-current-tool == ToolType.Object): ObjectToolPanel { }
Rectangle {
Text {

View File

@ -1,6 +1,22 @@
import { Metrics, DarkPalette } from "theme.slint";
import { Box, Button, HorizontalSeparator, VerticalBox } from "widgets/components.slint";
export enum ToolType {
Select,
Move,
Rotate,
Scale,
Brush,
Light,
Area,
Object,
Flow,
Room,
Texture,
Timeline,
Multibrush,
}
component ToolBarItem inherits Button {
width: Metrics.size-lg;
height: Metrics.size-lg;
@ -11,59 +27,100 @@ export component ToolBar inherits VerticalBox {
width: Metrics.size-xl;
p-alignment: start;
out property <ToolType> p-current-tool: ToolType.Select;
ToolBarItem {
p-text: "s";
a-clicked => {
p-current-tool = ToolType.Select;
}
}
ToolBarItem {
p-text: "m";
a-clicked => {
p-current-tool = ToolType.Move;
}
}
ToolBarItem {
p-text: "r";
a-clicked => {
p-current-tool = ToolType.Rotate;
}
}
ToolBarItem {
p-text: "s";
a-clicked => {
p-current-tool = ToolType.Scale;
}
}
HorizontalSeparator { }
ToolBarItem {
p-text: "b";
a-clicked => {
p-current-tool = ToolType.Brush;
}
}
ToolBarItem {
p-text: "o";
a-clicked => {
p-current-tool = ToolType.Object;
}
}
ToolBarItem {
p-text: "f";
a-clicked => {
p-current-tool = ToolType.Flow;
}
}
ToolBarItem {
p-text: "r";
a-clicked => {
p-current-tool = ToolType.Room;
}
}
ToolBarItem {
p-text: "l";
a-clicked => {
p-current-tool = ToolType.Light;
}
}
ToolBarItem {
p-text: "a";
a-clicked => {
p-current-tool = ToolType.Area;
}
}
HorizontalSeparator { }
ToolBarItem {
p-text: "t";
a-clicked => {
p-current-tool = ToolType.Texture;
}
}
ToolBarItem {
p-text: "t";
a-clicked => {
p-current-tool = ToolType.Timeline;
}
}
ToolBarItem {
p-text: "m";
a-clicked => {
p-current-tool = ToolType.Multibrush;
}
}
}