radames commited on
Commit
4346adf
1 Parent(s): f7d189a
frontend/src/app.d.ts CHANGED
@@ -17,6 +17,10 @@ declare global {
17
  transform: ZoomTransform;
18
  x: number;
19
  y: number;
 
 
 
 
20
  sourceEvent: PointerEvent | MouseEvent | TouchEvent
21
  }
22
  }
 
17
  transform: ZoomTransform;
18
  x: number;
19
  y: number;
20
+ subject: {
21
+ x: number;
22
+ y: number;
23
+ }
24
  sourceEvent: PointerEvent | MouseEvent | TouchEvent
25
  }
26
  }
frontend/src/lib/App.svelte CHANGED
@@ -196,7 +196,11 @@
196
  <PaintCanvas bind:canvasEl />
197
 
198
  <main class="z-10 relative">
199
- <PaintFrame transform={$currZoomTransform} interactive={!isPrompting} />
 
 
 
 
200
 
201
  <!-- When others connected, iterate through others and show their cursors -->
202
  {#if $others}
 
196
  <PaintCanvas bind:canvasEl />
197
 
198
  <main class="z-10 relative">
199
+ <PaintFrame
200
+ on:paintMode={onPaintMode}
201
+ transform={$currZoomTransform}
202
+ interactive={!isPrompting}
203
+ />
204
 
205
  <!-- When others connected, iterate through others and show their cursors -->
206
  {#if $others}
frontend/src/lib/Buttons/DragButton.svelte ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ import Move from '$lib/Icons/Move.svelte';
3
+ export let isActive = false;
4
+ </script>
5
+
6
+ <button
7
+ on:click
8
+ class="bg-white rounded-full p-2 {isActive ? 'text-blue-700' : 'text-gray-800'}"
9
+ title="Enable Dragging"
10
+ >
11
+ <Move />
12
+ </button>
13
+
14
+ <style lang="postcss" scoped>
15
+ </style>
frontend/src/lib/Buttons/MaskButton.svelte ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ import Mask from '$lib/Icons/Mask.svelte';
3
+ export let isActive = false;
4
+ </script>
5
+
6
+ <button
7
+ on:click
8
+ class="bg-white rounded-full p-2 {isActive ? 'text-blue-700' : 'text-gray-800'}"
9
+ title="Enable Dragging"
10
+ >
11
+ <Mask />
12
+ </button>
13
+
14
+ <style lang="postcss" scoped>
15
+ </style>
frontend/src/lib/Buttons/PPButton.svelte ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ </script>
3
+
4
+ <button on:click class="button-paint bg-violet-100 text-violet-900" title="New Paint Frame">
5
+ <span
6
+ class="rounded-sm h-6 w-6 flex justify-center items-center border-2 border-dashed border-violet-700 mr-2"
7
+ >
8
+ +
9
+ </span>
10
+ <span>Prompt + Paint</span>
11
+ </button>
12
+
13
+ <style lang="postcss" scoped>
14
+ /* .button {
15
+ @apply disabled:opacity-50 dark:bg-white dark:text-black bg-black text-white rounded-2xl text-xs shadow-sm focus:outline-none focus:border-gray-400;
16
+ } */
17
+ .button-paint {
18
+ @apply font-mono flex justify-center items-center disabled:opacity-50 dark:bg-white dark:text-black rounded-2xl px-3 py-1 shadow-sm focus:outline-none focus:border-gray-400;
19
+ }
20
+ </style>
frontend/src/lib/Frame.svelte CHANGED
@@ -1,5 +1,5 @@
1
  <script lang="ts">
2
- import LoadingIcon from '$lib/LoadingIcon.svelte';
3
 
4
  import type { ZoomTransform } from 'd3-zoom';
5
 
@@ -18,7 +18,7 @@
18
  </script>
19
 
20
  <div
21
- class="frame z-0 relative grid grid-cols-3 grid-rows-3
22
  {!interactive ? 'pointer-events-none touch-none' : ''}
23
  {isDragging ? 'cursor-grabbing' : 'cursor-grab'}"
24
  style={`transform: translateX(${coord.x}px) translateY(${coord.y}px) scale(${transform.k}); border-color: ${color};`}
@@ -36,13 +36,18 @@
36
  {/if}
37
 
38
  <h2 class="text-lg">Click to paint</h2>
39
-
40
  <div class="absolute bottom-0 font-bold text-lg">{prompt}</div>
 
 
 
 
 
 
41
  </div>
42
 
43
  <style lang="postcss" scoped>
44
  .frame {
45
- @apply absolute top-0 left-0 border-2 border-spacing-3 border-sky-500 w-[512px] h-[512px];
46
  transform-origin: 0 0;
47
  }
48
  .small-frame {
 
1
  <script lang="ts">
2
+ import LoadingIcon from '$lib/Icons/LoadingIcon.svelte';
3
 
4
  import type { ZoomTransform } from 'd3-zoom';
5
 
 
18
  </script>
19
 
20
  <div
21
+ class="frame
22
  {!interactive ? 'pointer-events-none touch-none' : ''}
23
  {isDragging ? 'cursor-grabbing' : 'cursor-grab'}"
24
  style={`transform: translateX(${coord.x}px) translateY(${coord.y}px) scale(${transform.k}); border-color: ${color};`}
 
36
  {/if}
37
 
38
  <h2 class="text-lg">Click to paint</h2>
 
39
  <div class="absolute bottom-0 font-bold text-lg">{prompt}</div>
40
+ <div class="absolute top-full">
41
+ <slot name="bottom" />
42
+ </div>
43
+ <div class="absolute left-full bottom-0">
44
+ <slot name="right" />
45
+ </div>
46
  </div>
47
 
48
  <style lang="postcss" scoped>
49
  .frame {
50
+ @apply absolute top-0 left-0 grid grid-cols-3 grid-rows-3 border-2 border-spacing-3 border-sky-500 w-[512px] h-[512px];
51
  transform-origin: 0 0;
52
  }
53
  .small-frame {
frontend/src/lib/{LoadingIcon.svelte → Icons/LoadingIcon.svelte} RENAMED
File without changes
frontend/src/lib/Icons/Mask.svelte ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ export let classList = '';
3
+ </script>
4
+
5
+ <svg
6
+ class={classList}
7
+ width="20"
8
+ height="20"
9
+ viewBox="0 0 11 11"
10
+ fill="none"
11
+ xmlns="http://www.w3.org/2000/svg"
12
+ >
13
+ <path
14
+ d="M5.5 10C7.98528 10 10 7.98528 10 5.5C10 3.01472 7.98528 1 5.5 1C3.01472 1 1 3.01472 1 5.5C1 7.98528 3.01472 10 5.5 10Z"
15
+ stroke="currentColor"
16
+ stroke-width="0.899979"
17
+ />
18
+ <path
19
+ d="M7.07441 1.28369C5.36599 1.92179 4.14941 3.56879 4.14941 5.50019C4.14941 7.43137 5.36599 9.07837 7.07441 9.71669M8.42441 2.12519L4.14941 5.05019M9.32441 3.25019L4.37441 6.62519M9.77441 4.60019L5.04941 7.97519M9.77441 6.40019L5.94941 9.10019"
20
+ stroke="currentColor"
21
+ stroke-width="0.899979"
22
+ stroke-linecap="round"
23
+ stroke-linejoin="round"
24
+ />
25
+ </svg>
frontend/src/lib/Icons/Move.svelte CHANGED
@@ -4,15 +4,15 @@
4
 
5
  <svg
6
  class={classList}
7
- width="11"
8
- height="11"
9
  viewBox="0 0 11 11"
10
  fill="none"
11
  xmlns="http://www.w3.org/2000/svg"
12
  >
13
  <path
14
  d="M2.4 4.26667L1 5.66667L2.4 7.06667M4.26667 2.4L5.66667 1L7.06667 2.4M7.06667 8.93333L5.66667 10.3333L4.26667 8.93333M8.93333 4.26667L10.3333 5.66667L8.93333 7.06667M1 5.66667H10.3333M5.66667 1V10.3333"
15
- stroke="#397DFF"
16
  stroke-width="0.933333"
17
  stroke-linecap="round"
18
  stroke-linejoin="round"
 
4
 
5
  <svg
6
  class={classList}
7
+ width="20"
8
+ height="20"
9
  viewBox="0 0 11 11"
10
  fill="none"
11
  xmlns="http://www.w3.org/2000/svg"
12
  >
13
  <path
14
  d="M2.4 4.26667L1 5.66667L2.4 7.06667M4.26667 2.4L5.66667 1L7.06667 2.4M7.06667 8.93333L5.66667 10.3333L4.26667 8.93333M8.93333 4.26667L10.3333 5.66667L8.93333 7.06667M1 5.66667H10.3333M5.66667 1V10.3333"
15
+ stroke="currentColor"
16
  stroke-width="0.933333"
17
  stroke-linecap="round"
18
  stroke-linejoin="round"
frontend/src/lib/Menu.svelte CHANGED
@@ -1,6 +1,6 @@
1
  <script lang="ts">
2
  import { onMount, createEventDispatcher } from 'svelte';
3
-
4
  const dispatch = createEventDispatcher();
5
 
6
  const onKeyup = (e: KeyboardEvent) => {
@@ -31,24 +31,5 @@
31
  <!-- <button class="button" title="Move" on:click={() => dispatch('paintMode', { mode: 'move' })}>
32
  Move
33
  </button> -->
34
- <button
35
- class="button-paint bg-violet-100 text-violet-900"
36
- title="New Paint Frame"
37
- on:click={() => dispatch('paintMode', { mode: 'paint' })}
38
- >
39
- <span
40
- class="rounded-sm h-6 w-6 flex justify-center items-center border-2 border-dashed border-violet-700 mr-2"
41
- >+</span
42
- >
43
- <span>Paint</span>
44
- </button>
45
  </div>
46
-
47
- <style lang="postcss" scoped>
48
- /* .button {
49
- @apply disabled:opacity-50 dark:bg-white dark:text-black bg-black text-white rounded-2xl text-xs shadow-sm focus:outline-none focus:border-gray-400;
50
- } */
51
- .button-paint {
52
- @apply flex justify-center items-center disabled:opacity-50 dark:bg-white dark:text-black rounded-2xl px-3 py-1 shadow-sm focus:outline-none focus:border-gray-400;
53
- }
54
- </style>
 
1
  <script lang="ts">
2
  import { onMount, createEventDispatcher } from 'svelte';
3
+ import PPButton from '$lib/Buttons/PPButton.svelte';
4
  const dispatch = createEventDispatcher();
5
 
6
  const onKeyup = (e: KeyboardEvent) => {
 
31
  <!-- <button class="button" title="Move" on:click={() => dispatch('paintMode', { mode: 'move' })}>
32
  Move
33
  </button> -->
34
+ <PPButton on:click={() => dispatch('paintMode', { mode: 'paint' })} />
 
 
 
 
 
 
 
 
 
 
35
  </div>
 
 
 
 
 
 
 
 
 
frontend/src/lib/PaintFrame.svelte CHANGED
@@ -1,17 +1,22 @@
1
  <script lang="ts">
2
  import Frame from '$lib/Frame.svelte';
3
- import Move from '$lib/Icons/Move.svelte';
 
 
 
4
  import { drag } from 'd3-drag';
5
  import { select } from 'd3-selection';
6
  import { round } from '$lib/utils';
7
 
8
  import type { ZoomTransform } from 'd3-zoom';
9
- import { onMount } from 'svelte';
10
 
11
  import { useMyPresence } from '$lib/liveblocks';
12
  import { loadingState } from '$lib/store';
13
  const myPresence = useMyPresence();
14
 
 
 
15
  export let transform: ZoomTransform;
16
  export let color = 'black';
17
  export let interactive = false;
@@ -100,5 +105,24 @@
100
  {isLoading}
101
  {isDragging}
102
  {interactive}
103
- />
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
104
  </div>
 
 
 
 
1
  <script lang="ts">
2
  import Frame from '$lib/Frame.svelte';
3
+ import PPButton from '$lib/Buttons/PPButton.svelte';
4
+ import DragButton from '$lib/Buttons/DragButton.svelte';
5
+ import MaskButton from '$lib/Buttons/MaskButton.svelte';
6
+
7
  import { drag } from 'd3-drag';
8
  import { select } from 'd3-selection';
9
  import { round } from '$lib/utils';
10
 
11
  import type { ZoomTransform } from 'd3-zoom';
12
+ import { onMount, createEventDispatcher } from 'svelte';
13
 
14
  import { useMyPresence } from '$lib/liveblocks';
15
  import { loadingState } from '$lib/store';
16
  const myPresence = useMyPresence();
17
 
18
+ const dispatch = createEventDispatcher();
19
+
20
  export let transform: ZoomTransform;
21
  export let color = 'black';
22
  export let interactive = false;
 
105
  {isLoading}
106
  {isDragging}
107
  {interactive}
108
+ >
109
+ <div slot="bottom">
110
+ {#if !isDragging}
111
+ <div class="py-2">
112
+ <PPButton on:click={() => dispatch('paintMode', { mode: 'paint' })} />
113
+ </div>
114
+ {/if}
115
+ </div>
116
+ <div slot="right">
117
+ {#if !isDragging}
118
+ <div class="px-2 flex flex-col gap-2">
119
+ <DragButton />
120
+ <MaskButton />
121
+ </div>
122
+ {/if}
123
+ </div>
124
+ </Frame>
125
  </div>
126
+
127
+ <style lang="postcss" scoped>
128
+ </style>