@lvl99dotcom/paintcanvas 0.3.1 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +30 -15
- package/dist/lib/brushes/StrokeEngine/index.d.ts +2 -2
- package/dist/lib/brushes/StrokeEngine/index.js +26 -28
- package/dist/lib/brushes/presets/round/index.d.ts +1 -1
- package/dist/lib/brushes/presets/round/index.js +12 -7
- package/dist/lib/brushes/presets/square/index.d.ts +1 -1
- package/dist/lib/brushes/presets/square/index.js +7 -3
- package/dist/lib/brushes/shapeImage/index.d.ts +7 -3
- package/dist/lib/brushes/shapeImage/index.js +15 -9
- package/dist/lib/brushes/shapes/index.d.ts +18 -0
- package/dist/lib/brushes/shapes/index.js +86 -0
- package/dist/lib/classes/BrushSettings/index.d.ts +53 -2
- package/dist/lib/classes/BrushSettings/index.js +85 -14
- package/dist/lib/classes/KeyboardShortcuts/index.d.ts +47 -7
- package/dist/lib/classes/KeyboardShortcuts/index.js +145 -20
- package/dist/lib/classes/PaintCanvas/index.d.ts +123 -27
- package/dist/lib/classes/PaintCanvas/index.js +208 -41
- package/dist/lib/classes/PaintCanvas/tool.d.ts +15 -0
- package/dist/lib/classes/PaintCanvas/tool.js +18 -0
- package/dist/lib/classes/Palette/index.d.ts +58 -0
- package/dist/lib/classes/Palette/index.js +92 -0
- package/dist/lib/classes/SettingsAutosave/index.d.ts +53 -0
- package/dist/lib/classes/SettingsAutosave/index.js +98 -0
- package/dist/lib/classes/ShortcutSettings/index.d.ts +63 -0
- package/dist/lib/classes/ShortcutSettings/index.js +110 -0
- package/dist/lib/classes/UiSettings/index.d.ts +68 -0
- package/dist/lib/classes/UiSettings/index.js +82 -0
- package/dist/lib/palette/index.d.ts +49 -0
- package/dist/lib/palette/index.js +82 -0
- package/dist/lib/palette/schema.d.ts +45 -0
- package/dist/lib/palette/schema.js +41 -0
- package/dist/lib/rendering/cursors/index.d.ts +2 -0
- package/dist/lib/rendering/cursors/index.js +3 -1
- package/dist/lib/rendering/sample/index.js +3 -2
- package/dist/lib/settings/index.d.ts +63 -0
- package/dist/lib/settings/index.js +93 -0
- package/dist/lib/settings/schema.d.ts +168 -0
- package/dist/lib/settings/schema.js +116 -0
- package/dist/lib/storage/index.d.ts +36 -5
- package/dist/lib/storage/index.js +87 -29
- package/dist/lib/utils/colour/index.d.ts +72 -0
- package/dist/lib/utils/colour/index.js +154 -0
- package/dist/lib/utils/shortcuts/index.d.ts +174 -11
- package/dist/lib/utils/shortcuts/index.js +391 -145
- package/dist/lib/validation/validators.generated.d.ts +5 -0
- package/dist/lib/validation/validators.generated.js +1040 -1
- package/dist/locales/en-GB.js +96 -3
- package/dist/locales/en-US.js +96 -3
- package/dist/locales/fr.js +96 -3
- package/dist/locales/ja.js +96 -3
- package/dist/locales/ko.js +96 -3
- package/dist/locales/zh-Hans.js +96 -3
- package/dist/locales/zh-Hant.js +96 -3
- package/dist/package.js +1 -1
- package/dist/testing/recordingCanvas.js +2 -1
- package/dist/ui/base/index.d.ts +2 -2
- package/dist/ui/dismiss/index.d.ts +21 -0
- package/dist/ui/dismiss/index.js +27 -0
- package/dist/ui/drag/index.d.ts +51 -0
- package/dist/ui/drag/index.js +81 -0
- package/dist/ui/elements/PaintCanvas/index.d.ts +57 -50
- package/dist/ui/elements/PaintCanvas/index.js +141 -174
- package/dist/ui/elements/PaintCanvas/style.js +1 -1
- package/dist/ui/elements/PcAppSettings/index.d.ts +59 -0
- package/dist/ui/elements/PcAppSettings/index.js +222 -0
- package/dist/ui/elements/PcBrushConfig/index.d.ts +9 -2
- package/dist/ui/elements/PcBrushConfig/index.js +47 -7
- package/dist/ui/elements/PcBrushConfig/style.js +1 -1
- package/dist/ui/elements/PcBrushSize/index.d.ts +53 -0
- package/dist/ui/elements/PcBrushSize/index.js +66 -0
- package/dist/ui/elements/PcBrushTest/index.d.ts +26 -0
- package/dist/ui/elements/PcBrushTest/index.js +73 -5
- package/dist/ui/elements/PcBrushTest/style.js +1 -1
- package/dist/ui/elements/PcCanvas/index.d.ts +22 -2
- package/dist/ui/elements/PcCanvas/index.js +60 -15
- package/dist/ui/elements/PcCanvasMap/style.js +1 -1
- package/dist/ui/elements/PcClipboardTools/index.d.ts +48 -0
- package/dist/ui/elements/PcClipboardTools/index.js +118 -0
- package/dist/ui/elements/PcColourPair/index.d.ts +43 -0
- package/dist/ui/elements/PcColourPair/index.js +125 -0
- package/dist/ui/elements/PcContextMenu/index.d.ts +71 -34
- package/dist/ui/elements/PcContextMenu/index.js +128 -97
- package/dist/ui/elements/PcInputSettings/index.d.ts +13 -0
- package/dist/ui/elements/PcInputSettings/index.js +16 -1
- package/dist/ui/elements/PcLayerItem/index.d.ts +13 -34
- package/dist/ui/elements/PcLayerItem/index.js +39 -91
- package/dist/ui/elements/PcLayerItem/style.js +1 -1
- package/dist/ui/elements/PcMenu/index.d.ts +138 -0
- package/dist/ui/elements/PcMenu/index.js +296 -0
- package/dist/ui/elements/PcNumberSlider/index.d.ts +137 -0
- package/dist/ui/elements/PcNumberSlider/index.js +247 -0
- package/dist/ui/elements/PcPane/index.d.ts +120 -0
- package/dist/ui/elements/PcPane/index.js +394 -0
- package/dist/ui/elements/PcPanel/index.d.ts +26 -8
- package/dist/ui/elements/PcPanel/index.js +76 -8
- package/dist/ui/elements/{PcBrushMenu → PcPanelBrushes}/index.d.ts +22 -21
- package/dist/ui/elements/{PcBrushMenu → PcPanelBrushes}/index.js +24 -57
- package/dist/ui/elements/PcPanelBrushes/style.js +3 -0
- package/dist/ui/elements/PcPanelColours/index.d.ts +171 -0
- package/dist/ui/elements/PcPanelColours/index.js +650 -0
- package/dist/ui/elements/PcPanelColours/style.js +3 -0
- package/dist/ui/elements/{PcLayersMenu → PcPanelLayers}/index.d.ts +17 -4
- package/dist/ui/elements/{PcLayersMenu → PcPanelLayers}/index.js +17 -10
- package/dist/ui/elements/PcPanelLayers/style.js +3 -0
- package/dist/ui/elements/PcPopover/index.d.ts +39 -1
- package/dist/ui/elements/PcPopover/index.js +72 -4
- package/dist/ui/elements/PcShortcutSettings/index.d.ts +69 -0
- package/dist/ui/elements/PcShortcutSettings/index.js +273 -0
- package/dist/ui/elements/PcThemePicker/index.d.ts +17 -15
- package/dist/ui/elements/PcThemePicker/index.js +22 -21
- package/dist/ui/elements/PcToolSettings/index.d.ts +48 -9
- package/dist/ui/elements/PcToolSettings/index.js +384 -319
- package/dist/ui/elements/PcToolSettings/style.js +1 -1
- package/dist/ui/elements/PcToolbar/index.d.ts +62 -12
- package/dist/ui/elements/PcToolbar/index.js +119 -57
- package/dist/ui/elements/PcToolbar/style.js +1 -1
- package/dist/ui/icons/images/icon-brush@2x.js +3 -0
- package/dist/ui/icons/images/icon-circle-mask@2x.js +3 -0
- package/dist/ui/icons/images/icon-clipboard@2x.js +3 -0
- package/dist/ui/icons/images/icon-cog@2x.js +3 -0
- package/dist/ui/icons/images/icon-cursor@2x.js +3 -0
- package/dist/ui/icons/images/icon-diagonal-tlbr-size@2x.js +3 -0
- package/dist/ui/icons/images/icon-diagonal-trbl-size@2x.js +3 -0
- package/dist/ui/icons/images/icon-eraser@2x.js +3 -0
- package/dist/ui/icons/images/icon-eyedropper@2x.js +3 -0
- package/dist/ui/icons/images/icon-flip-horizontal@2x.js +3 -0
- package/dist/ui/icons/images/icon-flip-vertical@2x.js +3 -0
- package/dist/ui/icons/images/icon-focus-pen@2x.js +3 -0
- package/dist/ui/icons/images/icon-freehand-mask@2x.js +3 -0
- package/dist/ui/icons/images/icon-hidden@2x.js +3 -0
- package/dist/ui/icons/images/icon-horizontal-size@2x.js +3 -0
- package/dist/ui/icons/images/icon-layers@2x.js +3 -0
- package/dist/ui/icons/images/icon-linked@2x.js +3 -0
- package/dist/ui/icons/images/icon-locked@2x.js +3 -0
- package/dist/ui/icons/images/icon-moon@2x.js +3 -0
- package/dist/ui/icons/images/icon-pan@2x.js +3 -0
- package/dist/ui/icons/images/icon-polygon-mask@2x.js +3 -0
- package/dist/ui/icons/images/icon-pressure@2x.js +3 -0
- package/dist/ui/icons/images/icon-randomise@2x.js +3 -0
- package/dist/ui/icons/images/icon-rectangle-mask@2x.js +3 -0
- package/dist/ui/icons/images/icon-redo@2x.js +3 -0
- package/dist/ui/icons/images/icon-rotate-90-left@2x.js +3 -0
- package/dist/ui/icons/images/icon-rotate-90-right@2x.js +3 -0
- package/dist/ui/icons/images/icon-rotate@2x.js +3 -0
- package/dist/ui/icons/images/icon-smoothing-bezier-cubic@2x.js +3 -0
- package/dist/ui/icons/images/icon-smoothing-bezier-quad@2x.js +3 -0
- package/dist/ui/icons/images/icon-smoothing-linear@2x.js +3 -0
- package/dist/ui/icons/images/icon-star@2x.js +3 -0
- package/dist/ui/icons/images/icon-sun@2x.js +3 -0
- package/dist/ui/icons/images/icon-tilt@2x.js +3 -0
- package/dist/ui/icons/images/icon-undo@2x.js +3 -0
- package/dist/ui/icons/images/icon-unlinked@2x.js +3 -0
- package/dist/ui/icons/images/icon-unlocked@2x.js +3 -0
- package/dist/ui/icons/images/icon-vertical-size@2x.js +3 -0
- package/dist/ui/icons/images/icon-visible@2x.js +3 -0
- package/dist/ui/icons/images/icon-zoom-in@2x.js +3 -0
- package/dist/ui/icons/images/icon-zoom-out@2x.js +3 -0
- package/dist/ui/icons/images/icon-zoom@2x.js +3 -0
- package/dist/ui/icons/index.d.ts +1 -1
- package/dist/ui/icons/index.js +84 -72
- package/dist/ui/index.d.ts +13 -2
- package/dist/ui/index.js +16 -4
- package/dist/ui/layout/index.d.ts +9 -1
- package/dist/ui/layout/index.js +11 -2
- package/dist/ui/tokens/index.d.ts +5 -4
- package/dist/ui/tokens/index.js +15 -8
- package/locales/en-GB.json +96 -3
- package/locales/en-US.json +96 -3
- package/locales/fr.json +96 -3
- package/locales/ja.json +96 -3
- package/locales/ko.json +96 -3
- package/locales/zh-Hans.json +96 -3
- package/locales/zh-Hant.json +96 -3
- package/package.json +11 -4
- package/dist/ui/elements/PcBrushMenu/style.js +0 -3
- package/dist/ui/elements/PcLayersMenu/style.js +0 -3
- package/dist/ui/icons/images/brush.js +0 -3
- package/dist/ui/icons/images/circle-mask.js +0 -3
- package/dist/ui/icons/images/clipboard.js +0 -3
- package/dist/ui/icons/images/cursor.js +0 -3
- package/dist/ui/icons/images/eraser.js +0 -3
- package/dist/ui/icons/images/eyedropper.js +0 -3
- package/dist/ui/icons/images/flip-horizontal.js +0 -3
- package/dist/ui/icons/images/flip-vertical.js +0 -3
- package/dist/ui/icons/images/focus-pen.js +0 -3
- package/dist/ui/icons/images/freehand-mask.js +0 -3
- package/dist/ui/icons/images/hidden.js +0 -3
- package/dist/ui/icons/images/layers.js +0 -3
- package/dist/ui/icons/images/linked.js +0 -3
- package/dist/ui/icons/images/locked.js +0 -3
- package/dist/ui/icons/images/moon.js +0 -3
- package/dist/ui/icons/images/pan.js +0 -3
- package/dist/ui/icons/images/polygon-mask.js +0 -3
- package/dist/ui/icons/images/pressure.js +0 -3
- package/dist/ui/icons/images/randomise.js +0 -3
- package/dist/ui/icons/images/rectangle-mask.js +0 -3
- package/dist/ui/icons/images/redo.js +0 -3
- package/dist/ui/icons/images/rotate-90-left.js +0 -3
- package/dist/ui/icons/images/rotate-90-right.js +0 -3
- package/dist/ui/icons/images/smoothing-bezier-cubic.js +0 -3
- package/dist/ui/icons/images/smoothing-bezier-quad.js +0 -3
- package/dist/ui/icons/images/smoothing-linear.js +0 -3
- package/dist/ui/icons/images/star.js +0 -3
- package/dist/ui/icons/images/sun.js +0 -3
- package/dist/ui/icons/images/tilt.js +0 -3
- package/dist/ui/icons/images/undo.js +0 -3
- package/dist/ui/icons/images/unlinked.js +0 -3
- package/dist/ui/icons/images/unlocked.js +0 -3
- package/dist/ui/icons/images/visible.js +0 -3
- package/dist/ui/icons/images/zoom-in.js +0 -3
- package/dist/ui/icons/images/zoom-out.js +0 -3
- package/dist/ui/icons/images/zoom.js +0 -3
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
// src/ui/drag/index.ts
|
|
2
|
+
/** How far (in pixels) a press must move before it counts as a drag, where a press can also be a tap */
|
|
3
|
+
var DRAG_THRESHOLD = 4;
|
|
4
|
+
/**
|
|
5
|
+
* How much a pointer moved between two points as one value: right and up are positive, left and down negative.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* dragDelta({ x: 0, y: 0 }, { x: 5, y: -5 }); // 10
|
|
9
|
+
*/
|
|
10
|
+
var dragDelta = (from, to) => to.x - from.x + (from.y - to.y);
|
|
11
|
+
/**
|
|
12
|
+
* Turns pressing and dragging on an element into changes of a value: dragging right or up gives positive deltas, left
|
|
13
|
+
* or down negative ones (see `dragDelta`), in whole pixels (keeping any fraction for the next move). With a `threshold`, the press only becomes a drag once the pointer has moved
|
|
14
|
+
* that far from where it was pressed, so a press that barely moves can still be a tap (e.g. to focus a field).
|
|
15
|
+
*
|
|
16
|
+
* The element is given the pointer while dragging, so the drag carries on outside it.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* const drag = new PointerDrag((delta) => brush.resize(delta));
|
|
20
|
+
* html`<div @pointerdown=${drag.start} @pointermove=${drag.move} @pointerup=${drag.end} @pointercancel=${drag.end}></div>`
|
|
21
|
+
*/
|
|
22
|
+
var PointerDrag = class {
|
|
23
|
+
onDelta;
|
|
24
|
+
threshold;
|
|
25
|
+
/** Where the press started */
|
|
26
|
+
origin = null;
|
|
27
|
+
/** The last position a delta was given from, once dragging */
|
|
28
|
+
last = null;
|
|
29
|
+
/** Movement not yet given, under a whole pixel (pens can move by fractions of a pixel) */
|
|
30
|
+
remainder = 0;
|
|
31
|
+
constructor(onDelta, threshold = 0) {
|
|
32
|
+
this.onDelta = onDelta;
|
|
33
|
+
this.threshold = threshold;
|
|
34
|
+
}
|
|
35
|
+
/** Whether the press has become a drag */
|
|
36
|
+
get dragging() {
|
|
37
|
+
return this.last !== null;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Start a press (on `pointerdown`).
|
|
41
|
+
*/
|
|
42
|
+
start = (event) => {
|
|
43
|
+
this.origin = {
|
|
44
|
+
x: event.clientX,
|
|
45
|
+
y: event.clientY
|
|
46
|
+
};
|
|
47
|
+
this.last = this.threshold > 0 ? null : this.origin;
|
|
48
|
+
this.remainder = 0;
|
|
49
|
+
event.currentTarget.setPointerCapture?.(event.pointerId);
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Give the change since the last move, once the press has become a drag (on `pointermove`).
|
|
53
|
+
*/
|
|
54
|
+
move = (event) => {
|
|
55
|
+
if (!this.origin) return;
|
|
56
|
+
const point = {
|
|
57
|
+
x: event.clientX,
|
|
58
|
+
y: event.clientY
|
|
59
|
+
};
|
|
60
|
+
if (!this.last) {
|
|
61
|
+
if (Math.hypot(point.x - this.origin.x, point.y - this.origin.y) < this.threshold) return;
|
|
62
|
+
this.last = this.origin;
|
|
63
|
+
event.preventDefault();
|
|
64
|
+
}
|
|
65
|
+
const total = this.remainder + dragDelta(this.last, point);
|
|
66
|
+
const delta = Math.trunc(total);
|
|
67
|
+
this.remainder = total - delta;
|
|
68
|
+
this.last = point;
|
|
69
|
+
if (delta !== 0) this.onDelta(delta);
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* End the press (on `pointerup` or `pointercancel`). Returns whether it was a drag.
|
|
73
|
+
*/
|
|
74
|
+
end = () => {
|
|
75
|
+
const dragged = this.dragging;
|
|
76
|
+
this.origin = null;
|
|
77
|
+
this.last = null;
|
|
78
|
+
return dragged;
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
export { DRAG_THRESHOLD, PointerDrag, dragDelta };
|
|
@@ -1,42 +1,45 @@
|
|
|
1
1
|
import { PcElement } from "../../base";
|
|
2
2
|
import PaintCanvas from "../../../lib/classes/PaintCanvas";
|
|
3
|
+
import SettingsAutosave from "../../../lib/classes/SettingsAutosave";
|
|
3
4
|
import type { BrushConfig } from "../../../lib/brushes/types";
|
|
4
5
|
import { type SaveMethod } from "../../../lib/rendering/screenshot";
|
|
5
6
|
import { type InputKind, type LayoutState } from "../../layout";
|
|
6
|
-
import type { PcPanel } from "../PcPanel";
|
|
7
7
|
import "../PcPanel";
|
|
8
|
-
import "../PcToolbar";
|
|
9
8
|
import "../PcToolSettings";
|
|
9
|
+
import "../PcClipboardTools";
|
|
10
10
|
import "../PcCanvas";
|
|
11
11
|
import "../PcCanvasMap";
|
|
12
|
-
import "../
|
|
13
|
-
import "../
|
|
12
|
+
import "../PcPanelBrushes";
|
|
13
|
+
import "../PcPanelLayers";
|
|
14
14
|
import "../PcBrushConfig";
|
|
15
15
|
import "../PcStats";
|
|
16
|
+
import "../PcPanelColours";
|
|
16
17
|
import "../PcDialog";
|
|
17
|
-
/** A side of the layout */
|
|
18
|
-
type Side = "left" | "right";
|
|
19
18
|
/**
|
|
20
19
|
* A ready-made painting app: the drawing elements arranged around the canvas, sized to its container (not the
|
|
21
20
|
* window), with slots to add or replace content:
|
|
22
21
|
*
|
|
23
22
|
* - `header`: across the top (empty by default)
|
|
24
|
-
* - `left`: `<pc-toolbar>` by default
|
|
25
|
-
*
|
|
26
|
-
* - `
|
|
23
|
+
* - `left`: `<pc-toolbar>` (a pane) by default; toolbars in the sides are minimised (their tools one button that opens a
|
|
24
|
+
* menu of them) while the layout is narrow
|
|
25
|
+
* - `top`: a horizontal `<pc-pane>` with `<pc-tool-settings>` (for tools that have settings) and, at its end,
|
|
26
|
+
* `<pc-clipboard-tools>` (cut, copy and paste; a ⋮ menu while the layout is narrow) by default
|
|
27
|
+
* - `right`: a `<pc-pane>` with `<pc-panel-layers>` by default
|
|
27
28
|
* - `center`: `<pc-canvas>` by default
|
|
28
29
|
* - `overlay`: drawn over the canvas; `<pc-canvas-map>` by default
|
|
29
30
|
* - `bottom`: under the canvas (empty by default)
|
|
30
31
|
* - `footer`: across the bottom; `<pc-stats>` by default
|
|
31
|
-
* - `menu`: the app menu the toolbar's menu button opens (the button shows only with a menu)
|
|
32
|
+
* - `menu`: the app menu the toolbar's menu button opens, shown in a `<pc-panel>` (the button shows only with a menu)
|
|
32
33
|
*
|
|
33
34
|
* Content given for a slot replaces its default; an empty element clears it. Empty slots take no space. Hiding the
|
|
34
|
-
* interface (Tab key) leaves only the canvas and overlay.
|
|
35
|
-
*
|
|
35
|
+
* interface (Tab key) leaves only the canvas and overlay. While a side has a `<pc-panel-layers>` (as the right side
|
|
36
|
+
* does by default), the toolbar has no layers menu button.
|
|
36
37
|
*
|
|
37
38
|
* Each side has a mode, chosen by the layout's width from `left-modes` and `right-modes` (default `"docked,
|
|
38
|
-
* rail@600"`): `docked` beside the canvas; `rail`, a
|
|
39
|
-
* the canvas;
|
|
39
|
+
* rail@600"`), which the layout gives the side's `<pc-pane>`s (see `PcPane`): `docked` beside the canvas; `rail`, a
|
|
40
|
+
* column of buttons (one per panel) that open each panel over the canvas; `floating`, the pane over the canvas as a
|
|
41
|
+
* box that collapses to a button; or `overlay`, a rail over the canvas without a background (the canvas fills the
|
|
42
|
+
* width behind it). Give side content in a `<pc-pane>` to have it follow the side's mode.
|
|
40
43
|
*
|
|
41
44
|
* Reports its state for styling as attributes (`narrow`, `input="pen|touch|mouse"`, `ui-hidden`, `left-mode`,
|
|
42
45
|
* `right-mode`) and as `pc-state-change` events (see `LayoutState`). Creates its own canvas unless given one, and
|
|
@@ -46,10 +49,16 @@ type Side = "left" | "right";
|
|
|
46
49
|
* reloading the page (see `LayerAutosave`). While another window is drawing on it, the layout is blocked by a message
|
|
47
50
|
* that offers to draw here instead. Fires `pc-toast` when the drawing can't be loaded or saved.
|
|
48
51
|
*
|
|
52
|
+
* With a `settings-store` name, the user's app settings (input settings, keyboard shortcuts, colour palette, colours,
|
|
53
|
+
* theme and language) are kept in the browser under that name (see `SettingsAutosave`). Fires `pc-toast` when they can't be.
|
|
54
|
+
*
|
|
49
55
|
* @example
|
|
50
56
|
* html`<paint-canvas style="height: 600px"></paint-canvas>`
|
|
51
57
|
* html`<paint-canvas .app=${canvas} right-modes="docked, rail@800">
|
|
52
|
-
* <pc-
|
|
58
|
+
* <pc-pane slot="right">
|
|
59
|
+
* <pc-panel-layers .app=${canvas}></pc-panel-layers>
|
|
60
|
+
* <pc-panel icon="chat" label="Chat"><my-chat></my-chat></pc-panel>
|
|
61
|
+
* </pc-pane>
|
|
53
62
|
* </paint-canvas>`
|
|
54
63
|
*/
|
|
55
64
|
export declare class PaintCanvasElement extends PcElement {
|
|
@@ -83,6 +92,10 @@ export declare class PaintCanvasElement extends PcElement {
|
|
|
83
92
|
store: {
|
|
84
93
|
type: StringConstructor;
|
|
85
94
|
};
|
|
95
|
+
settingsStore: {
|
|
96
|
+
type: StringConstructor;
|
|
97
|
+
attribute: string;
|
|
98
|
+
};
|
|
86
99
|
width: {
|
|
87
100
|
state: boolean;
|
|
88
101
|
};
|
|
@@ -92,12 +105,6 @@ export declare class PaintCanvasElement extends PcElement {
|
|
|
92
105
|
configuring: {
|
|
93
106
|
state: boolean;
|
|
94
107
|
};
|
|
95
|
-
collapsed: {
|
|
96
|
-
state: boolean;
|
|
97
|
-
};
|
|
98
|
-
openPanel: {
|
|
99
|
-
state: boolean;
|
|
100
|
-
};
|
|
101
108
|
translations: {
|
|
102
109
|
attribute: boolean;
|
|
103
110
|
};
|
|
@@ -126,6 +133,8 @@ export declare class PaintCanvasElement extends PcElement {
|
|
|
126
133
|
shortcuts: boolean;
|
|
127
134
|
/** Name to keep the user's layers under in the browser, so the drawing survives reloading the page (none by default) */
|
|
128
135
|
store?: string;
|
|
136
|
+
/** Name to keep the user's app settings under in the browser (none by default) */
|
|
137
|
+
settingsStore?: string;
|
|
129
138
|
/** The layout's width in CSS pixels */
|
|
130
139
|
width: number;
|
|
131
140
|
/** The input being used now */
|
|
@@ -136,10 +145,6 @@ export declare class PaintCanvasElement extends PcElement {
|
|
|
136
145
|
config: BrushConfig;
|
|
137
146
|
editingId?: string;
|
|
138
147
|
};
|
|
139
|
-
/** Which floating sides are collapsed to a button */
|
|
140
|
-
collapsed: Record<Side, boolean>;
|
|
141
|
-
/** The panel open from a rail, if any */
|
|
142
|
-
openPanel?: PcPanel;
|
|
143
148
|
/** Saves files (replaceable for tests) */
|
|
144
149
|
saveFile: (blob: Blob, name: string) => Promise<SaveMethod | undefined>;
|
|
145
150
|
private changes;
|
|
@@ -147,10 +152,10 @@ export declare class PaintCanvasElement extends PcElement {
|
|
|
147
152
|
private ownAutosave?;
|
|
148
153
|
/** The autosave whose errors are shown */
|
|
149
154
|
private watchedAutosave?;
|
|
155
|
+
/** Keeps the app settings under the `settings-store` name, if any */
|
|
156
|
+
private ownSettingsAutosave?;
|
|
150
157
|
/** Whether drawing was blocked when shortcuts were last watched */
|
|
151
158
|
private blockedShortcuts;
|
|
152
|
-
/** The panels in each side's slot */
|
|
153
|
-
private panels;
|
|
154
159
|
/** Whether each side's slot has a layers menu (the toolbar's isn't needed then) */
|
|
155
160
|
private sideLayers;
|
|
156
161
|
/** Whether the implementer gave a menu */
|
|
@@ -161,17 +166,15 @@ export declare class PaintCanvasElement extends PcElement {
|
|
|
161
166
|
private keys?;
|
|
162
167
|
/** The state last reported, to report only changes */
|
|
163
168
|
private reported?;
|
|
164
|
-
/** Space the floating sides cover over the canvas */
|
|
169
|
+
/** Space the floating and overlay sides cover over the canvas */
|
|
165
170
|
private floatingInsets;
|
|
166
|
-
/** The rail button that opened the open panel, to return focus to */
|
|
167
|
-
private opener?;
|
|
168
171
|
private readonly resizeObserver?;
|
|
169
|
-
private readonly panelObserver;
|
|
170
172
|
private readonly onPointerDown;
|
|
171
173
|
private readonly onAutosaveError;
|
|
174
|
+
private readonly onSettingsAutosaveError;
|
|
172
175
|
private readonly onShortcut;
|
|
173
176
|
private readonly onDocumentPointerDown;
|
|
174
|
-
private readonly
|
|
177
|
+
private readonly onPaneCollapse;
|
|
175
178
|
constructor();
|
|
176
179
|
/** Whether another window is drawing on the stored drawing, so this one is blocked */
|
|
177
180
|
get blocked(): boolean;
|
|
@@ -183,13 +186,24 @@ export declare class PaintCanvasElement extends PcElement {
|
|
|
183
186
|
disconnectedCallback(): void;
|
|
184
187
|
protected willUpdate(changed: Map<PropertyKey, unknown>): void;
|
|
185
188
|
protected updated(): void;
|
|
186
|
-
/**
|
|
189
|
+
/** The panes in a side: the default one, or those given for it */
|
|
190
|
+
private panesIn;
|
|
191
|
+
/** Show each side's panes in the side's mode, facing the canvas, with toolbars minimised while the layout is narrow */
|
|
192
|
+
private setPaneModes;
|
|
193
|
+
/** Keep the canvas clear of floating and overlay sides when fitting it */
|
|
187
194
|
private measureFloatingSides;
|
|
188
195
|
/**
|
|
189
196
|
* Keep the canvas's layers under the `store` name, replacing an autosave the layout started earlier (also on the
|
|
190
197
|
* previous canvas). An autosave the implementer started is left alone when there's no name.
|
|
191
198
|
*/
|
|
192
199
|
private useStore;
|
|
200
|
+
/** Keeps the app settings under the `settings-store` name, if any (e.g. to wait until they are restored with `ready`) */
|
|
201
|
+
get settingsAutosave(): SettingsAutosave | undefined;
|
|
202
|
+
/**
|
|
203
|
+
* Keep the canvas's app settings under the `settings-store` name, stopping the previous settings autosave (which
|
|
204
|
+
* saves any change waiting to be saved).
|
|
205
|
+
*/
|
|
206
|
+
private useSettingsStore;
|
|
193
207
|
/** Show errors from the canvas's current autosave */
|
|
194
208
|
private watchAutosaveErrors;
|
|
195
209
|
/** Handle keyboard shortcuts for the current canvas, if asked to (not while blocked) */
|
|
@@ -212,32 +226,26 @@ export declare class PaintCanvasElement extends PcElement {
|
|
|
212
226
|
* Open the configuration window to make a new preset, starting from the current brush or eraser settings.
|
|
213
227
|
*/
|
|
214
228
|
newPreset(kind: "brush" | "eraser"): void;
|
|
215
|
-
/** Which side a panel is in */
|
|
216
|
-
private sideOf;
|
|
217
|
-
/**
|
|
218
|
-
* Open a panel from its rail button (closing any other), or close it if it's open. Focus moves into the panel.
|
|
219
|
-
*/
|
|
220
|
-
togglePanel(panel: PcPanel, opener?: HTMLElement): void;
|
|
221
|
-
/**
|
|
222
|
-
* Close the panel open from a rail, moving focus back to its rail button if asked.
|
|
223
|
-
*/
|
|
224
|
-
closePanel(returnFocus: boolean): void;
|
|
225
229
|
/** Follow which slots have content given (their defaults aren't needed) */
|
|
226
230
|
private onSlotChange;
|
|
227
231
|
/** A slot, with its default content unless content was given for it */
|
|
228
232
|
private slotWithDefault;
|
|
229
|
-
/** Follow
|
|
233
|
+
/** Follow whether a side given content has a layers menu */
|
|
230
234
|
private onSideSlotChange;
|
|
231
235
|
/** Follow whether a menu was given */
|
|
232
236
|
private onMenuSlotChange;
|
|
233
237
|
/** Whether a side has a layers menu, replacing the toolbar's */
|
|
234
238
|
private get layersInSide();
|
|
235
|
-
/**
|
|
236
|
-
private
|
|
237
|
-
/** A side
|
|
238
|
-
private renderRail;
|
|
239
|
-
/** A side, in its mode */
|
|
239
|
+
/** A side's default content: the toolbar on the left, and the layers on the right */
|
|
240
|
+
private renderSideDefault;
|
|
241
|
+
/** A side: its panes, in its mode (set on them after rendering) */
|
|
240
242
|
private renderSide;
|
|
243
|
+
/**
|
|
244
|
+
* Close the open panel (brush, eraser, layers, app menu or colour palette) on a press outside it and the button that
|
|
245
|
+
* opens it, marking the press (see `markDismissingPress`) so the canvas doesn't draw unless it's dragged. Presses in
|
|
246
|
+
* dialogs (e.g. one the panel opened) don't count as outside.
|
|
247
|
+
*/
|
|
248
|
+
private closePanelOutside;
|
|
241
249
|
/** The menus the toolbar opens, floating over the canvas beside it */
|
|
242
250
|
private renderPanels;
|
|
243
251
|
/** The brush configuration window, while open */
|
|
@@ -246,4 +254,3 @@ export declare class PaintCanvasElement extends PcElement {
|
|
|
246
254
|
private renderBlocked;
|
|
247
255
|
render(): import("lit").TemplateResult<1>;
|
|
248
256
|
}
|
|
249
|
-
export {};
|