From e7b316be1fe64f083619ce007ac03d40007b51cb Mon Sep 17 00:00:00 2001 From: Jarrod Doyle Date: Sun, 14 Apr 2024 13:02:12 +0100 Subject: [PATCH] Add tool switching --- ui/appwindow.slint | 6 ++--- ui/tool_bar.slint | 57 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+), 3 deletions(-) diff --git a/ui/appwindow.slint b/ui/appwindow.slint index 3f9e05f..f3c987c 100644 --- a/ui/appwindow.slint +++ b/ui/appwindow.slint @@ -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 { diff --git a/ui/tool_bar.slint b/ui/tool_bar.slint index f235f1f..fbad514 100644 --- a/ui/tool_bar.slint +++ b/ui/tool_bar.slint @@ -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 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; + } } }