@lvl99dotcom/paintcanvas 0.4.0 → 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/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 +29 -2
- package/dist/lib/classes/BrushSettings/index.js +51 -14
- package/dist/lib/classes/KeyboardShortcuts/index.d.ts +31 -2
- package/dist/lib/classes/KeyboardShortcuts/index.js +66 -4
- package/dist/lib/classes/PaintCanvas/index.d.ts +46 -0
- package/dist/lib/classes/PaintCanvas/index.js +67 -0
- package/dist/lib/classes/SettingsAutosave/index.d.ts +3 -2
- package/dist/lib/classes/SettingsAutosave/index.js +5 -3
- package/dist/lib/classes/UiSettings/index.d.ts +68 -0
- package/dist/lib/classes/UiSettings/index.js +82 -0
- package/dist/lib/settings/index.d.ts +1 -1
- package/dist/lib/settings/index.js +4 -2
- package/dist/lib/settings/schema.d.ts +18 -0
- package/dist/lib/settings/schema.js +14 -0
- package/dist/lib/validation/validators.generated.js +169 -1
- package/dist/locales/en-GB.js +9 -2
- package/dist/locales/en-US.js +9 -2
- package/dist/locales/fr.js +9 -2
- package/dist/locales/ja.js +9 -2
- package/dist/locales/ko.js +9 -2
- package/dist/locales/zh-Hans.js +9 -2
- package/dist/locales/zh-Hant.js +9 -2
- 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 +17 -12
- package/dist/ui/elements/PaintCanvas/index.js +34 -17
- package/dist/ui/elements/PaintCanvas/style.js +1 -1
- package/dist/ui/elements/PcAppSettings/index.d.ts +1 -1
- package/dist/ui/elements/PcAppSettings/index.js +1 -1
- 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 +21 -1
- package/dist/ui/elements/PcCanvas/index.js +53 -10
- 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/PcContextMenu/index.d.ts +2 -2
- package/dist/ui/elements/PcInputSettings/index.d.ts +13 -0
- package/dist/ui/elements/PcInputSettings/index.js +16 -1
- package/dist/ui/elements/PcMenu/index.d.ts +48 -3
- package/dist/ui/elements/PcMenu/index.js +111 -19
- 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 +3 -1
- package/dist/ui/elements/PcPane/index.js +44 -7
- package/dist/ui/elements/PcPanel/index.d.ts +2 -2
- package/dist/ui/elements/PcPanel/index.js +8 -8
- package/dist/ui/elements/PcPanelBrushes/index.d.ts +2 -15
- package/dist/ui/elements/PcPanelBrushes/index.js +6 -43
- package/dist/ui/elements/PcPanelBrushes/style.js +1 -1
- package/dist/ui/elements/PcPopover/index.d.ts +39 -1
- package/dist/ui/elements/PcPopover/index.js +72 -4
- 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 +382 -318
- package/dist/ui/elements/PcToolSettings/style.js +1 -1
- package/dist/ui/elements/PcToolbar/index.d.ts +15 -0
- package/dist/ui/elements/PcToolbar/index.js +55 -14
- 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 +7 -2
- package/dist/ui/index.js +10 -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 +12 -7
- package/locales/en-GB.json +9 -2
- package/locales/en-US.json +9 -2
- package/locales/fr.json +9 -2
- package/locales/ja.json +9 -2
- package/locales/ko.json +9 -2
- package/locales/zh-Hans.json +9 -2
- package/locales/zh-Hant.json +9 -2
- package/package.json +11 -4
- 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
|
@@ -1,9 +1,34 @@
|
|
|
1
1
|
import { PcElement, defineElement, emit } from "../../base/index.js";
|
|
2
|
+
import { markDismissingPress } from "../../dismiss/index.js";
|
|
2
3
|
import { css, html } from "lit";
|
|
3
4
|
// src/ui/elements/PcPopover/index.ts
|
|
5
|
+
/** Height of a popover's arrow (pixels) */
|
|
6
|
+
var POPOVER_ARROW_SIZE = 8;
|
|
7
|
+
/** Side of the square turned 45° that makes the arrow (its diagonal is about twice the arrow's height) */
|
|
8
|
+
var ARROW_SQUARE = Math.round(8 * Math.SQRT2);
|
|
9
|
+
/** Space kept between a placed popover and the window's edges (pixels) */
|
|
10
|
+
var POPOVER_MARGIN = 8;
|
|
11
|
+
/**
|
|
12
|
+
* Where a popover goes under its anchor: centred below it (leaving room for the arrow), moved sideways as far as needed
|
|
13
|
+
* to stay in the window, with its arrow still pointing at the anchor's centre (`arrowX`, from the popover's left).
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* popoverBelow({ left: 100, bottom: 40, width: 40 }, 200, 1000); // { left: 20, top: 48, arrowX: 100 }
|
|
17
|
+
* popoverBelow({ left: 0, bottom: 40, width: 40 }, 200, 1000); // { left: 8, top: 48, arrowX: 12 }
|
|
18
|
+
*/
|
|
19
|
+
var popoverBelow = (anchor, popoverWidth, viewportWidth, margin = 8) => {
|
|
20
|
+
const centre = anchor.left + anchor.width / 2;
|
|
21
|
+
const left = Math.max(margin, Math.min(centre - popoverWidth / 2, viewportWidth - margin - popoverWidth));
|
|
22
|
+
return {
|
|
23
|
+
left,
|
|
24
|
+
top: anchor.bottom + 8,
|
|
25
|
+
arrowX: centre - left
|
|
26
|
+
};
|
|
27
|
+
};
|
|
4
28
|
/**
|
|
5
29
|
* A floating box for a menu or settings (e.g. the brush presets), shown while `open`. The implementer places it (e.g.
|
|
6
|
-
* next to the button that opens it)
|
|
30
|
+
* next to the button that opens it), or `placeBelow` puts it under its `anchor`. With `arrow`, an arrow on its top edge
|
|
31
|
+
* points up at the anchor (at `--pc-popover-arrow-x` from its left, the middle by default). It isn't modal: Escape, or a press outside it and outside its `anchor`, fires
|
|
7
32
|
* `pc-close`, and the implementer sets `open` to false in response. Focus moves into it when it opens.
|
|
8
33
|
*
|
|
9
34
|
* @example
|
|
@@ -17,7 +42,11 @@ var PcPopover = class extends PcElement {
|
|
|
17
42
|
reflect: true
|
|
18
43
|
},
|
|
19
44
|
label: { type: String },
|
|
20
|
-
anchor: { attribute: false }
|
|
45
|
+
anchor: { attribute: false },
|
|
46
|
+
arrow: {
|
|
47
|
+
type: Boolean,
|
|
48
|
+
reflect: true
|
|
49
|
+
}
|
|
21
50
|
};
|
|
22
51
|
static styles = [PcElement.styles, css`
|
|
23
52
|
:host {
|
|
@@ -32,6 +61,7 @@ var PcPopover = class extends PcElement {
|
|
|
32
61
|
max-height: inherit;
|
|
33
62
|
overflow: auto;
|
|
34
63
|
padding: var(--pc-space-2);
|
|
64
|
+
border: 1px solid var(--pc-border);
|
|
35
65
|
border-radius: var(--pc-radius);
|
|
36
66
|
background: var(--pc-surface-raised);
|
|
37
67
|
color: var(--pc-text);
|
|
@@ -39,6 +69,22 @@ var PcPopover = class extends PcElement {
|
|
|
39
69
|
font-family: var(--pc-font);
|
|
40
70
|
font-size: var(--pc-font-size);
|
|
41
71
|
}
|
|
72
|
+
/* A square turned 45° with its top corner showing, outlined like the popover */
|
|
73
|
+
:host([arrow])::before {
|
|
74
|
+
content: "";
|
|
75
|
+
position: absolute;
|
|
76
|
+
z-index: 1;
|
|
77
|
+
top: -${ARROW_SQUARE / 2}px;
|
|
78
|
+
left: var(--pc-popover-arrow-x, 50%);
|
|
79
|
+
width: ${ARROW_SQUARE}px;
|
|
80
|
+
height: ${ARROW_SQUARE}px;
|
|
81
|
+
box-sizing: border-box;
|
|
82
|
+
border: 1px solid var(--pc-border);
|
|
83
|
+
border-right-color: transparent;
|
|
84
|
+
border-bottom-color: transparent;
|
|
85
|
+
background: var(--pc-surface-raised);
|
|
86
|
+
transform: translateX(-50%) rotate(45deg);
|
|
87
|
+
}
|
|
42
88
|
[role="dialog"]:focus-visible {
|
|
43
89
|
outline: var(--pc-focus-width) solid var(--pc-focus);
|
|
44
90
|
}
|
|
@@ -46,12 +92,34 @@ var PcPopover = class extends PcElement {
|
|
|
46
92
|
onPointerDown = (event) => {
|
|
47
93
|
if (!this.open) return;
|
|
48
94
|
const path = event.composedPath();
|
|
49
|
-
if (
|
|
95
|
+
if (path.includes(this) || this.anchor && path.includes(this.anchor)) return;
|
|
96
|
+
markDismissingPress(event);
|
|
97
|
+
emit(this, "pc-close");
|
|
50
98
|
};
|
|
51
99
|
constructor() {
|
|
52
100
|
super();
|
|
53
101
|
this.open = false;
|
|
54
102
|
this.label = "";
|
|
103
|
+
this.arrow = false;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Put the popover under its anchor, in the window (see `popoverBelow`), with its arrow pointing at the anchor. Call it
|
|
107
|
+
* once open, so it can be measured.
|
|
108
|
+
*
|
|
109
|
+
* @example
|
|
110
|
+
* popover.open = true;
|
|
111
|
+
* await popover.updateComplete;
|
|
112
|
+
* popover.placeBelow();
|
|
113
|
+
*/
|
|
114
|
+
placeBelow() {
|
|
115
|
+
if (!this.anchor) return;
|
|
116
|
+
const { left, top, arrowX } = popoverBelow(this.anchor.getBoundingClientRect(), this.offsetWidth, window.innerWidth);
|
|
117
|
+
Object.assign(this.style, {
|
|
118
|
+
position: "fixed",
|
|
119
|
+
left: `${left}px`,
|
|
120
|
+
top: `${top}px`
|
|
121
|
+
});
|
|
122
|
+
this.style.setProperty("--pc-popover-arrow-x", `${arrowX}px`);
|
|
55
123
|
}
|
|
56
124
|
connectedCallback() {
|
|
57
125
|
super.connectedCallback();
|
|
@@ -83,4 +151,4 @@ var PcPopover = class extends PcElement {
|
|
|
83
151
|
}
|
|
84
152
|
};
|
|
85
153
|
defineElement("pc-popover", PcPopover);
|
|
86
|
-
export { PcPopover };
|
|
154
|
+
export { POPOVER_ARROW_SIZE, POPOVER_MARGIN, PcPopover, popoverBelow };
|
|
@@ -1,25 +1,19 @@
|
|
|
1
1
|
import { PcElement } from "../../base";
|
|
2
2
|
import type { IconName } from "../../icons";
|
|
3
|
+
import { THEMES, isTheme, type Theme, type UiSettingsLike } from "../../../lib/classes/UiSettings";
|
|
3
4
|
import "../PcButtonGroup";
|
|
4
|
-
|
|
5
|
-
export declare const THEMES: readonly ["light", "dark", "auto"];
|
|
6
|
-
export type Theme = (typeof THEMES)[number];
|
|
5
|
+
export { THEMES, isTheme, type Theme };
|
|
7
6
|
/** Each theme's icon */
|
|
8
7
|
export declare const THEME_ICONS: Readonly<Record<Theme, IconName>>;
|
|
9
8
|
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* isTheme("dark"); // true
|
|
14
|
-
* isTheme(undefined); // false
|
|
15
|
-
*/
|
|
16
|
-
export declare const isTheme: (value: unknown) => value is Theme;
|
|
17
|
-
/**
|
|
18
|
-
* Picks the light, dark or automatic theme (which follows the device), as a labelled group of three radios joined into
|
|
9
|
+
* Picks the light, dark or system theme (which follows the device's), as a labelled group of three radios joined into
|
|
19
10
|
* one pill (a joined `<pc-button-group>`), each with its icon (sun, moon and star) and name; the picked one is purple.
|
|
20
|
-
* Shows the theme of its `target` (the page's root element by default;
|
|
11
|
+
* Shows the theme of its `target` (the page's root element by default; system unless it has another), and sets the
|
|
21
12
|
* target's `data-pc-theme` when the user picks one, firing `change` (detail: the theme).
|
|
22
13
|
*
|
|
14
|
+
* With `settings` (e.g. the canvas's `ui`), it shows and keeps the theme there instead, and sets the target's theme
|
|
15
|
+
* whenever theirs changes (e.g. when restored), so it's kept with the other app settings.
|
|
16
|
+
*
|
|
23
17
|
* @example
|
|
24
18
|
* html`<pc-theme-picker @change=${(e) => save(e.detail)}></pc-theme-picker>`
|
|
25
19
|
*/
|
|
@@ -29,6 +23,9 @@ export declare class PcThemePicker extends PcElement {
|
|
|
29
23
|
type: StringConstructor;
|
|
30
24
|
reflect: boolean;
|
|
31
25
|
};
|
|
26
|
+
settings: {
|
|
27
|
+
attribute: boolean;
|
|
28
|
+
};
|
|
32
29
|
translations: {
|
|
33
30
|
attribute: boolean;
|
|
34
31
|
};
|
|
@@ -41,15 +38,20 @@ export declare class PcThemePicker extends PcElement {
|
|
|
41
38
|
theme: Theme;
|
|
42
39
|
/** The element whose `data-pc-theme` is shown and set (the page's root element by default) */
|
|
43
40
|
target?: HTMLElement;
|
|
41
|
+
/** Where the theme is kept, if anywhere (e.g. the canvas's `ui`) */
|
|
42
|
+
settings?: UiSettingsLike;
|
|
43
|
+
private changes;
|
|
44
44
|
constructor();
|
|
45
45
|
connectedCallback(): void;
|
|
46
|
+
/** Show the kept theme, and set it on the target */
|
|
47
|
+
protected willUpdate(): void;
|
|
46
48
|
/** The element whose theme is shown and set */
|
|
47
49
|
private get themeTarget();
|
|
48
50
|
/**
|
|
49
|
-
* Pick a theme: show it, set it on the target and tell listeners.
|
|
51
|
+
* Pick a theme: show it, keep it in the settings (if any), set it on the target and tell listeners.
|
|
50
52
|
*
|
|
51
53
|
* @example
|
|
52
|
-
* picker.pick("
|
|
54
|
+
* picker.pick("system");
|
|
53
55
|
*/
|
|
54
56
|
pick(theme: Theme): void;
|
|
55
57
|
render(): import("lit").TemplateResult<1>;
|
|
@@ -1,34 +1,25 @@
|
|
|
1
1
|
import { ICON_CONTROLS_CSS } from "../../styles/index.js";
|
|
2
2
|
import { PcElement, defineElement, emit } from "../../base/index.js";
|
|
3
|
+
import ChangeController from "../../ChangeController/index.js";
|
|
4
|
+
import { THEMES, isTheme } from "../../../lib/classes/UiSettings/index.js";
|
|
3
5
|
import "../PcButtonGroup/index.js";
|
|
4
6
|
import { css, html, unsafeCSS } from "lit";
|
|
5
7
|
// src/ui/elements/PcThemePicker/index.ts
|
|
6
|
-
/** The themes to pick from: light, dark, or following the device (auto) */
|
|
7
|
-
var THEMES = [
|
|
8
|
-
"light",
|
|
9
|
-
"dark",
|
|
10
|
-
"auto"
|
|
11
|
-
];
|
|
12
8
|
/** Each theme's icon */
|
|
13
9
|
var THEME_ICONS = {
|
|
14
10
|
light: "sun",
|
|
15
11
|
dark: "moon",
|
|
16
|
-
|
|
12
|
+
system: "star"
|
|
17
13
|
};
|
|
18
14
|
/**
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
* @example
|
|
22
|
-
* isTheme("dark"); // true
|
|
23
|
-
* isTheme(undefined); // false
|
|
24
|
-
*/
|
|
25
|
-
var isTheme = (value) => THEMES.includes(value);
|
|
26
|
-
/**
|
|
27
|
-
* Picks the light, dark or automatic theme (which follows the device), as a labelled group of three radios joined into
|
|
15
|
+
* Picks the light, dark or system theme (which follows the device's), as a labelled group of three radios joined into
|
|
28
16
|
* one pill (a joined `<pc-button-group>`), each with its icon (sun, moon and star) and name; the picked one is purple.
|
|
29
|
-
* Shows the theme of its `target` (the page's root element by default;
|
|
17
|
+
* Shows the theme of its `target` (the page's root element by default; system unless it has another), and sets the
|
|
30
18
|
* target's `data-pc-theme` when the user picks one, firing `change` (detail: the theme).
|
|
31
19
|
*
|
|
20
|
+
* With `settings` (e.g. the canvas's `ui`), it shows and keeps the theme there instead, and sets the target's theme
|
|
21
|
+
* whenever theirs changes (e.g. when restored), so it's kept with the other app settings.
|
|
22
|
+
*
|
|
32
23
|
* @example
|
|
33
24
|
* html`<pc-theme-picker @change=${(e) => save(e.detail)}></pc-theme-picker>`
|
|
34
25
|
*/
|
|
@@ -38,7 +29,8 @@ var PcThemePicker = class extends PcElement {
|
|
|
38
29
|
theme: {
|
|
39
30
|
type: String,
|
|
40
31
|
reflect: true
|
|
41
|
-
}
|
|
32
|
+
},
|
|
33
|
+
settings: { attribute: false }
|
|
42
34
|
};
|
|
43
35
|
static styles = [
|
|
44
36
|
PcElement.styles,
|
|
@@ -88,27 +80,36 @@ var PcThemePicker = class extends PcElement {
|
|
|
88
80
|
];
|
|
89
81
|
/** The element whose `data-pc-theme` is shown and set (the page's root element by default) */
|
|
90
82
|
target;
|
|
83
|
+
changes = new ChangeController(this, () => [this.settings]);
|
|
91
84
|
constructor() {
|
|
92
85
|
super();
|
|
93
|
-
this.theme = "
|
|
86
|
+
this.theme = "system";
|
|
94
87
|
}
|
|
95
88
|
connectedCallback() {
|
|
96
89
|
super.connectedCallback();
|
|
97
90
|
const current = this.themeTarget.dataset.pcTheme;
|
|
98
91
|
if (isTheme(current)) this.theme = current;
|
|
99
92
|
}
|
|
93
|
+
/** Show the kept theme, and set it on the target */
|
|
94
|
+
willUpdate() {
|
|
95
|
+
const theme = this.settings?.data.theme;
|
|
96
|
+
if (theme === void 0) return;
|
|
97
|
+
this.theme = theme;
|
|
98
|
+
this.themeTarget.dataset.pcTheme = theme;
|
|
99
|
+
}
|
|
100
100
|
/** The element whose theme is shown and set */
|
|
101
101
|
get themeTarget() {
|
|
102
102
|
return this.target ?? document.documentElement;
|
|
103
103
|
}
|
|
104
104
|
/**
|
|
105
|
-
* Pick a theme: show it, set it on the target and tell listeners.
|
|
105
|
+
* Pick a theme: show it, keep it in the settings (if any), set it on the target and tell listeners.
|
|
106
106
|
*
|
|
107
107
|
* @example
|
|
108
|
-
* picker.pick("
|
|
108
|
+
* picker.pick("system");
|
|
109
109
|
*/
|
|
110
110
|
pick(theme) {
|
|
111
111
|
this.theme = theme;
|
|
112
|
+
this.settings?.update({ theme });
|
|
112
113
|
this.themeTarget.dataset.pcTheme = theme;
|
|
113
114
|
emit(this, "change", theme);
|
|
114
115
|
}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import { nothing } from "lit";
|
|
1
|
+
import { nothing, type PropertyValues } from "lit";
|
|
2
2
|
import { PcElement } from "../../base";
|
|
3
3
|
import PaintCanvas, { Tool } from "../../../lib/classes/PaintCanvas";
|
|
4
4
|
import type { BrushConfig } from "../../../lib/brushes/types";
|
|
5
|
+
import "../PcBrushSize";
|
|
6
|
+
import "../PcNumberSlider";
|
|
7
|
+
import "../PcPopover";
|
|
5
8
|
/** Settings varied with pen tilt by the tilt toggle */
|
|
6
9
|
declare const TILT_PARAMS: readonly ["widthConfig", "heightConfig", "rotationConfig"];
|
|
7
10
|
/** A setting's variation config key */
|
|
@@ -28,6 +31,8 @@ export declare const withSource: (preset: BrushConfig, params: readonly ParamKey
|
|
|
28
31
|
* roundAngle(12.3456); // 12.35
|
|
29
32
|
*/
|
|
30
33
|
export declare const roundAngle: (degrees: number) => number;
|
|
34
|
+
/** Largest width or height the move tool's fields go to (pixels or percent) */
|
|
35
|
+
export declare const MAX_MOVE_SIZE = 10000;
|
|
31
36
|
/** Steps of the zoom slider, across the whole zoom range */
|
|
32
37
|
export declare const ZOOM_SLIDER_STEPS = 1000;
|
|
33
38
|
/**
|
|
@@ -54,13 +59,20 @@ export declare const sliderToZoom: (value: number) => number;
|
|
|
54
59
|
*/
|
|
55
60
|
export declare const zoomPercent: (zoom: number) => string;
|
|
56
61
|
/**
|
|
57
|
-
* The bar of settings for the current tool, shown at the top of the canvas when the tool has any
|
|
62
|
+
* The bar of settings for the current tool, shown at the top of the canvas when the tool has any. The tool's settings
|
|
63
|
+
* are at the start (part `start`); the end, on the right (part `end`), is for your own items. The `start` and `end`
|
|
64
|
+
* slots add your own items to each. (Cut, copy and paste are `<pc-clipboard-tools>`.)
|
|
58
65
|
*
|
|
59
|
-
* - Brush and eraser: the preset (its name and shape; shows or hides the preset menu),
|
|
60
|
-
*
|
|
66
|
+
* - Brush and eraser: the preset (its name and shape; shows or hides the preset menu), the size (`pc-brush-size`), the
|
|
67
|
+
* size settings (a cog button that shows or hides a popover under it with pressure, tilt and focus pen mode above the
|
|
68
|
+
* width, constrain proportions and height), opacity and "Configure" (fires `pc-configure-brush` with the tool,
|
|
69
|
+
* "brush" or "eraser"). The size, width, height and opacity are `pc-number-slider`s: pressed and dragged right or up
|
|
70
|
+
* to raise them, left or down to lower them, or tapped to type a value. Focus pen mode: only pens draw, and touches
|
|
71
|
+
* are ignored while a pen is down or just lifted.
|
|
61
72
|
* - Lassos: select all, and invert selection and deselect (only while there is a mask).
|
|
62
73
|
* - Move, scale and rotate: width and height (in pixels or percent), constrain proportions, flip horizontal and vertical,
|
|
63
|
-
* angle (to 2 decimal places), rotate 90° left and right, and reset (undoes the whole transform).
|
|
74
|
+
* angle (to 2 decimal places), rotate 90° left and right, and reset (undoes the whole transform). The width, height
|
|
75
|
+
* and angle are `pc-number-slider`s.
|
|
64
76
|
* - Colour sample: point sample (the pixel under the pointer) or area sample (the average of a dragged rectangle).
|
|
65
77
|
* - Zoom: zoom in and out, a slider across the zoom range (logarithmic) with the zoom as a percentage, and reset (100%),
|
|
66
78
|
* all around the centre of the view.
|
|
@@ -68,7 +80,9 @@ export declare const zoomPercent: (zoom: number) => string;
|
|
|
68
80
|
* Changes to the brush or eraser apply to the current settings only, not the preset. Styling is structural only.
|
|
69
81
|
*
|
|
70
82
|
* @example
|
|
71
|
-
* html`<pc-tool-settings .app=${app}
|
|
83
|
+
* html`<pc-tool-settings .app=${app}>
|
|
84
|
+
* <button slot="end" @click=${share}>Share</button>
|
|
85
|
+
* </pc-tool-settings>`
|
|
72
86
|
*/
|
|
73
87
|
export declare class PcToolSettings extends PcElement {
|
|
74
88
|
static properties: {
|
|
@@ -78,6 +92,9 @@ export declare class PcToolSettings extends PcElement {
|
|
|
78
92
|
percent: {
|
|
79
93
|
state: boolean;
|
|
80
94
|
};
|
|
95
|
+
sizeOpen: {
|
|
96
|
+
state: boolean;
|
|
97
|
+
};
|
|
81
98
|
translations: {
|
|
82
99
|
attribute: boolean;
|
|
83
100
|
};
|
|
@@ -93,8 +110,24 @@ export declare class PcToolSettings extends PcElement {
|
|
|
93
110
|
app?: PaintCanvas;
|
|
94
111
|
/** Whether the move tool's width and height are in percent (of the original size) instead of pixels */
|
|
95
112
|
percent: boolean;
|
|
113
|
+
/** Whether the brush or eraser's size settings (width, height, constrain proportions) are shown */
|
|
114
|
+
sizeOpen: boolean;
|
|
115
|
+
private readonly placeSizeSettings;
|
|
96
116
|
private changes;
|
|
97
117
|
constructor();
|
|
118
|
+
disconnectedCallback(): void;
|
|
119
|
+
/** The size settings' popover, while a brush or eraser's settings are shown */
|
|
120
|
+
private get sizePopover();
|
|
121
|
+
/** Follow the window's scrolling and resizing (or stop) */
|
|
122
|
+
private listenWhileSizeOpen;
|
|
123
|
+
/**
|
|
124
|
+
* Hide the size settings (e.g. on Escape or a press outside them), returning focus to their button if it was in them.
|
|
125
|
+
*/
|
|
126
|
+
private closeSizeSettings;
|
|
127
|
+
protected willUpdate(changed: PropertyValues<this>): void;
|
|
128
|
+
protected updated(changed: PropertyValues<this>): void;
|
|
129
|
+
/** Put the opened size settings under their button, once they can be measured */
|
|
130
|
+
private showSizeSettings;
|
|
98
131
|
/** Fire an event that crosses shadow DOM boundaries */
|
|
99
132
|
private emit;
|
|
100
133
|
/**
|
|
@@ -102,10 +135,14 @@ export declare class PcToolSettings extends PcElement {
|
|
|
102
135
|
*/
|
|
103
136
|
private changeBox;
|
|
104
137
|
/**
|
|
105
|
-
* Render the focus pen mode toggle,
|
|
106
|
-
*
|
|
138
|
+
* Render the focus pen mode toggle, for the brush and eraser: while on, only pens draw, and touches are ignored while a
|
|
139
|
+
* pen is down or just lifted.
|
|
107
140
|
*/
|
|
108
141
|
private renderFocusPen;
|
|
142
|
+
/**
|
|
143
|
+
* Render a setting as a named `pc-number-slider` (dragged or typed), from 1 to 256 pixels unless given another range.
|
|
144
|
+
*/
|
|
145
|
+
private renderNumberField;
|
|
109
146
|
/** Render the brush or eraser settings */
|
|
110
147
|
private renderBrush;
|
|
111
148
|
/** Render the mask settings */
|
|
@@ -115,7 +152,7 @@ export declare class PcToolSettings extends PcElement {
|
|
|
115
152
|
* proportion when constrained.
|
|
116
153
|
*/
|
|
117
154
|
private resizeBox;
|
|
118
|
-
/** A box side in the current unit
|
|
155
|
+
/** A box side in the current unit (pixels or percent) */
|
|
119
156
|
private sideValue;
|
|
120
157
|
/** Render the move, scale and rotate settings */
|
|
121
158
|
private renderMove;
|
|
@@ -123,6 +160,8 @@ export declare class PcToolSettings extends PcElement {
|
|
|
123
160
|
private renderZoom;
|
|
124
161
|
/** Render the colour sample tool's settings: point or area sampling */
|
|
125
162
|
private renderColourSample;
|
|
163
|
+
/** The current tool's settings, if it has any */
|
|
164
|
+
private toolView;
|
|
126
165
|
render(): import("lit").TemplateResult<1> | typeof nothing;
|
|
127
166
|
}
|
|
128
167
|
export {};
|