From b6506588105604a4004ed2eea32244bf5034f5ce Mon Sep 17 00:00:00 2001 From: Keavon Chambers Date: Sat, 17 Jul 2021 16:11:52 -0700 Subject: [PATCH] Add (nonfunctional) rulers and scrollbars to the viewport (#279) * Add nonfunctional rulers and scrollbars to viewport * Switch from DOM divs to SVG lines * Switch from SVG lines to a single SVG path * Change variable names --- client/web/src/components/panels/Document.vue | 67 +++++++- .../components/widgets/rulers/CanvasRuler.vue | 113 +++++++++++++ .../scrollbars/PersistentScrollbar.vue | 148 ++++++++++++++++++ 3 files changed, 320 insertions(+), 8 deletions(-) create mode 100644 client/web/src/components/widgets/rulers/CanvasRuler.vue create mode 100644 client/web/src/components/widgets/scrollbars/PersistentScrollbar.vue diff --git a/client/web/src/components/panels/Document.vue b/client/web/src/components/panels/Document.vue index f502eebc..576ec33a 100644 --- a/client/web/src/components/panels/Document.vue +++ b/client/web/src/components/panels/Document.vue @@ -139,15 +139,31 @@
- - + +
-
- -
+ + + + + + + + +
+ +
+
+ + + +
+ + +
@@ -184,6 +200,27 @@ .viewport { flex: 1 1 100%; + .canvas-area { + flex: 1 1 100%; + } + + .bar-area { + flex: 0 0 auto; + } + + .top-ruler { + padding-left: 16px; + margin-right: 16px; + } + + .right-scrollbar { + margin-top: -16px; + } + + .bottom-scrollbar { + margin-right: 16px; + } + .canvas { background: var(--color-1-nearblack); width: 100%; @@ -210,6 +247,8 @@ import SwatchPairInput from "@/components/widgets/inputs/SwatchPairInput.vue"; import { MenuDirection } from "@/components/widgets/floating-menus/FloatingMenu.vue"; import ShelfItemInput from "@/components/widgets/inputs/ShelfItemInput.vue"; import Separator, { SeparatorDirection, SeparatorType } from "@/components/widgets/separators/Separator.vue"; +import PersistentScrollbar, { ScrollbarDirection } from "@/components/widgets/scrollbars/PersistentScrollbar.vue"; +import CanvasRuler, { RulerDirection } from "@/components/widgets/rulers/CanvasRuler.vue"; import IconButton from "@/components/widgets/buttons/IconButton.vue"; import PopoverButton from "@/components/widgets/buttons/PopoverButton.vue"; import RadioInput from "@/components/widgets/inputs/RadioInput.vue"; @@ -274,6 +313,14 @@ export default defineComponent({ } todo(toolIndex); }, + async swapWorkingColors() { + const { swap_colors } = await wasm; + swap_colors(); + }, + async resetWorkingColors() { + const { reset_colors } = await wasm; + reset_colors(); + }, download(filename: string, svgData: string) { const svgBlob = new Blob([svgData], { type: "image/svg+xml;charset=utf-8" }); const svgUrl = URL.createObjectURL(svgBlob); @@ -328,14 +375,16 @@ export default defineComponent({ return { viewportSvg: "", activeTool: "Select", - MenuDirection, - SeparatorDirection, - SeparatorType, modeMenuEntries, viewModeIndex: 0, snappingEnabled: true, gridEnabled: true, overlaysEnabled: true, + MenuDirection, + SeparatorDirection, + ScrollbarDirection, + RulerDirection, + SeparatorType, }; }, components: { @@ -344,6 +393,8 @@ export default defineComponent({ SwatchPairInput, ShelfItemInput, Separator, + PersistentScrollbar, + CanvasRuler, IconButton, PopoverButton, RadioInput, diff --git a/client/web/src/components/widgets/rulers/CanvasRuler.vue b/client/web/src/components/widgets/rulers/CanvasRuler.vue new file mode 100644 index 00000000..da05dd1d --- /dev/null +++ b/client/web/src/components/widgets/rulers/CanvasRuler.vue @@ -0,0 +1,113 @@ + + + + + diff --git a/client/web/src/components/widgets/scrollbars/PersistentScrollbar.vue b/client/web/src/components/widgets/scrollbars/PersistentScrollbar.vue new file mode 100644 index 00000000..0988e932 --- /dev/null +++ b/client/web/src/components/widgets/scrollbars/PersistentScrollbar.vue @@ -0,0 +1,148 @@ + + + + +