Some start for layering

Signed-off-by: Victor Seiji Hariki <victorseijih@gmail.com>
This commit is contained in:
Victor Seiji Hariki 2022-11-27 09:54:34 -03:00
parent 0a33d3e491
commit c1b17c1b0e
4 changed files with 59 additions and 0 deletions

View file

@ -2,8 +2,16 @@
font-size: 100%; font-size: 100%;
font-family: Arial, Helvetica, sans-serif; font-family: Arial, Helvetica, sans-serif;
} }
/* Body is stuck with no scroll */
body { body {
width: 100%;
height: 100%;
margin: 0px; margin: 0px;
padding: 0px;
overflow: clip;
} }
.container { .container {

6
css/layers.css Normal file
View file

@ -0,0 +1,6 @@
/* Debug floating window */
#layer-preview .preview-canvas {
background-color: white;
width: 100%;
height: 150px;
}

View file

@ -7,6 +7,8 @@
<link href="css/colors.css" rel="stylesheet" /> <link href="css/colors.css" rel="stylesheet" />
<link href="css/index.css" rel="stylesheet" /> <link href="css/index.css" rel="stylesheet" />
<link href="css/layers.css" rel="stylesheet" />
<link href="css/ui/generic.css" rel="stylesheet" /> <link href="css/ui/generic.css" rel="stylesheet" />
<link href="css/ui/history.css" rel="stylesheet" /> <link href="css/ui/history.css" rel="stylesheet" />
@ -189,6 +191,17 @@
<div class="toolbar-section"></div> <div class="toolbar-section"></div>
</div> </div>
<!-- Layer Allocation View -->
<div
id="layer-preview"
class="floating-window toolbar"
style="left: 10px; bottom: 10px">
<div class="draggable floating-window-title">Layer Debug View</div>
<div class="menu-container" style="min-width: 200px">
<canvas class="preview-canvas"></canvas>
</div>
</div>
<!-- Canvases --> <!-- Canvases -->
<div <div
id="mainHSplit" id="mainHSplit"

32
js/layers.js Normal file
View file

@ -0,0 +1,32 @@
/**
* This is a manager for the many canvas and content layers that compose the application
*
* It manages canvases and their locations and sizes according to current viewport views
*/
const layers = {
_layers: [],
layers: {},
// Registers a new layer
registerLayer: (name) => {
const layer = {
id: guid(),
name: layer,
// This is where black magic starts
// A proxy for the canvas object
canvas: new Proxy(document.createElement("canvas"), {}),
};
},
// Deletes a layer
deleteLayer: (layer) => {
if (typeof layer === "object") {
layers._layers = layers._layers.filter((l) => l.id === layer.id);
delete layers[layer.id];
} else if (typeof layer === "string") {
layers._layers = layers._layers.filter((l) => l.id === layer);
delete layers[layer];
}
},
};