diff --git a/src/assets/infopanel.svg b/src/assets/infopanel.svg new file mode 100644 index 0000000..6df5109 --- /dev/null +++ b/src/assets/infopanel.svg @@ -0,0 +1,108 @@ + + + + + + + + + image/svg+xml + + + + + Klaus Staedtler + + + + + + + + + + + + i + + + diff --git a/src/assets/timeline.svg b/src/assets/timeline.svg new file mode 100644 index 0000000..776dfce --- /dev/null +++ b/src/assets/timeline.svg @@ -0,0 +1,143 @@ + + + + + + + image/svg+xml + + + + + Barbara Muraus, Jakub Steiner, Klaus Staedtler + + + Images originally created as the "Art Libre" icon set. Extended and adopted for GIMP + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/assets/buttons.svg b/src/assets/toolbar.svg similarity index 100% rename from src/assets/buttons.svg rename to src/assets/toolbar.svg diff --git a/src/main.js b/src/main.js index 22877fe..577c503 100644 --- a/src/main.js +++ b/src/main.js @@ -3,6 +3,7 @@ import * as fitCurve from '/fit-curve.js'; import { Bezier } from "/bezier.js"; import { Quadtree } from './quadtree.js'; import { createNewFileDialog, showNewFileDialog, closeDialog } from './newfile.js'; +import { titleCase } from './utils.js'; const { writeTextFile: writeTextFile, readTextFile: readTextFile }= window.__TAURI__.fs; const { open: openFileDialog, @@ -748,10 +749,9 @@ class Shape { let newCurves = [] let intersectMap = {} for (let i=0; i= j) continue; let intersects = this.curves[i].intersects(this.curves[j]) if (intersects.length) { intersectMap[i] ||= [] @@ -872,7 +872,6 @@ class Shape { } this.vertices.forEach((vertex, i) => { - console.log(i) for (let i=0; i { rootPane = document.querySelector("#root") - rootPane.appendChild(createPane(toolbar())) + rootPane.appendChild(createPane(panes.toolbar)) rootPane.addEventListener("mousemove", (e) => { mouseEvent = e; }) - let [_toolbar, panel] = splitPane(rootPane, 10, true, createPane(timeline())) - let [stageAndTimeline, _infopanel] = splitPane(panel, 70, false, createPane(infopanel())) - let [_timeline, _stage] = splitPane(stageAndTimeline, 30, false, createPane(stage())) + let [_toolbar, panel] = splitPane(rootPane, 10, true, createPane(panes.timeline)) + let [stageAndTimeline, _infopanel] = splitPane(panel, 70, false, createPane(panes.infopanel)) + let [_timeline, _stage] = splitPane(stageAndTimeline, 30, false, createPane(panes.stage)) }); window.addEventListener("resize", () => { updateAll() }) +window.addEventListener("click", function(event) { + const popupMenu = document.getElementById("popupMenu"); + + // If the menu exists and the click is outside the menu and any button with the class 'paneButton', remove the menu + if (popupMenu && !popupMenu.contains(event.target) && !event.target.classList.contains("paneButton")) { + popupMenu.remove(); // Remove the menu from the DOM + } +}) + window.addEventListener("keydown", (e) => { // let shortcuts = {} // for (let shortcut of config.shortcuts) { // shortcut = shortcut.split("+") // TODO // } - console.log(e) + // console.log(e) if (e.key == config.shortcuts.playAnimation) { console.log("Spacebar pressed") } else if (e.key == config.shortcuts.undo && e.ctrlKey == true) { @@ -1289,7 +1297,6 @@ async function saveAs() { } async function open() { - console.log("gonna open") const path = await openFileDialog({ multiple: false, directory: false, @@ -1353,18 +1360,15 @@ async function quit() { } function addFrame() { - console.log(context.activeObject.currentFrameNum) if (context.activeObject.currentFrameNum >= context.activeObject.activeLayer.frames.length) { for (let i=context.activeObject.activeLayer.frames.length; i<=context.activeObject.currentFrameNum; i++) { context.activeObject.activeLayer.frames.push(new Frame()) } - console.log(context.activeObject.activeLayer) updateLayers() } } function addKeyframe() { - console.log(context.activeObject.currentFrameNum) let newKeyframe = new Frame("keyframe") let latestFrame = context.activeObject.getFrame(Math.max(context.activeObject.currentFrameNum-1, 0)) for (let key in latestFrame.keys) { @@ -1381,7 +1385,6 @@ function addKeyframe() { } else if (context.activeObject.activeLayer.frames[context.activeObject.currentFrameNum].frameType != "keyframe") { context.activeObject.activeLayer.frames[context.activeObject.currentFrameNum] = newKeyframe } - console.log(context.activeObject.activeLayer) updateLayers() } @@ -1509,8 +1512,6 @@ function stage() { for (let curve of region.curves) { intersect_count += curve.intersects(line).length } - console.log(region) - console.log(intersect_count) if (intersect_count%2==1) { // region.fillStyle = context.fillStyle actions.colorRegion.create(region, context.fillStyle) @@ -1833,20 +1834,84 @@ function infopanel() { createNewFileDialog(_newFile); showNewFileDialog() -function createPane(content=undefined) { - let div = document.createElement("div") - let header = document.createElement("div") - if (!content) { - content = stage() // TODO: change based on type +function createPaneMenu(div) { + const menuItems = ["Item 1", "Item 2", "Item 3"]; // The items for the menu + + // Get the menu container (create a new div for the menu) + const popupMenu = document.createElement("div"); + popupMenu.id = "popupMenu"; // Set the ID to ensure we can target it later + + // Create a