Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
130 changes: 129 additions & 1 deletion codepad/bundle_resources/web/static/codepad.css
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,18 @@ svg, .svg-image {
margin-right: 6px;
}

#pane-editor, #pane-console {
#pane-editor, #pane-console, #pane-canvas, #row-top, #row-bottom, #inspector-pane {
position: relative;
}

#inspector-wrap {
position: absolute;
top: 0px;
bottom: 0px;
left: 0px;
right: 0px;
}

#editor-wrap {
width: 100%;
position: absolute;
Expand Down Expand Up @@ -219,6 +227,121 @@ svg, .svg-image {
font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'source-code-pro', monospace;
}

#hierarchy-pane, #properties-pane {
position: relative;
height: 100%;
}

#hierarchy-tree, #properties-list {
position: absolute;
top: 38px;
bottom: 8px;
left: 8px;
right: 8px;
overflow: auto;
font-size: 12px;
}

#hierarchy-pane .tabs-wrap, #properties-pane .tabs-wrap {
background-color: #2a2d32;
border-bottom: 1px solid #1f2125;
}

#hierarchy-pane .tabs-wrap label, #properties-pane .tabs-wrap label {
opacity: 1;
border-bottom: none;
color: #cfd3d7;
font-weight: 600;
}

.tree-item {
display: flex;
align-items: center;
gap: 6px;
padding: 4px 6px;
border-radius: 2px;
cursor: pointer;
}

.tree-item:hover {
background-color: #34373c;
}

.tree-item.is-selected {
background-color: #3d4046;
color: #ffffff;
}

.tree-caret {
width: 10px;
height: 10px;
display: inline-flex;
align-items: center;
justify-content: center;
color: #9aa0a6;
font-size: 10px;
flex: 0 0 10px;
}

.tree-caret::before {
content: "\25B8";
transform: rotate(0deg);
transition: transform 0.15s ease;
}

.tree-node.is-expanded > .tree-item .tree-caret::before {
transform: rotate(90deg);
}

.tree-node.is-collapsed > .tree-children {
display: none;
}

.tree-label {
font-weight: 600;
}

.tree-meta {
margin-left: auto;
opacity: 0.6;
font-size: 11px;
}

.tree-children {
margin-left: 14px;
border-left: 1px solid #32353a;
padding-left: 6px;
}

.properties-header {
font-weight: 600;
margin-bottom: 8px;
color: #eff2f6;
}

.prop-row {
display: grid;
grid-template-columns: 120px 1fr;
gap: 8px;
padding: 6px 0px;
}

.prop-key {
color: #9aa0a6;
text-transform: capitalize;
}

.prop-value {
background-color: #25282d;
border: 1px solid #3a3d43;
border-radius: 3px;
color: #d0d4d9;
font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'source-code-pro', monospace;
white-space: pre-wrap;
word-break: break-word;
padding: 4px 6px;
}

.gutter {
}

Expand All @@ -235,6 +358,11 @@ svg, .svg-image {
float: left;
}

.split.split-vertical, .gutter.gutter-vertical {
width: 100%;
float: none;
}

.canvas-app-container {
background: #000;
position: relative;
Expand Down
85 changes: 71 additions & 14 deletions codepad/bundle_resources/web/static/codepad.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ var scenes = [];

var project_info = {};
var engine_info = {};
var scene_hierarchy = null;
var scene_node_index = {};
var scene_selected_path = null;
var scene_structure_signature = null;
var scene_dump_running = false;
var scene_dump_frame = 0;
var scene_dump_missing_warned = false;
var scene_dump_filter = null;

var default_script = `function init(self)

Expand Down Expand Up @@ -87,14 +95,39 @@ function codepad_load_editor(callback) {
//editor.session.setMode("ace/mode/lua");

// Setup panel splitters
Split(['#pane-editors', '#pane-canvas'], {
direction: 'vertical',
onDrag: function () { fix_canvas_size(); }
});
if (document.getElementById("row-top") && document.getElementById("row-bottom")) {
Split(['#row-top', '#row-bottom'], {
direction: 'vertical',
sizes: [55, 45],
minSize: [160, 160],
onDrag: function () { fix_canvas_size(); }
});
}

Split(['#pane-console', '#pane-editor'], {
sizes: [30, 70]
});
if (document.getElementById("pane-console") && document.getElementById("pane-editor")) {
Split(['#pane-console', '#pane-editor'], {
direction: 'horizontal',
sizes: [30, 70],
minSize: [180, 320]
});
}

if (document.getElementById("inspector-pane") && document.getElementById("pane-canvas")) {
Split(['#inspector-pane', '#pane-canvas'], {
direction: 'horizontal',
sizes: [30, 70],
minSize: [180, 320],
onDrag: function () { fix_canvas_size(); }
});
}

if (document.getElementById("hierarchy-pane") && document.getElementById("properties-pane")) {
Split(['#hierarchy-pane', '#properties-pane'], {
direction: 'vertical',
sizes: [50, 50],
minSize: [80, 80]
});
}

if (callback) {
callback();
Expand Down Expand Up @@ -194,6 +227,9 @@ function codepad_change_scene() {
break;
}
}
scene_structure_signature = null;
scene_selected_path = null;
codepad_set_dump_filter();
}


Expand Down Expand Up @@ -234,6 +270,10 @@ function codepad_ready(scenes_json, project_json, engine_json) {

codepad_trigger_url_check();
codepad_change_scene();
setTimeout(function () {
codepad_dump_hierarchy(true);
codepad_start_dump_loop();
}, 0);
}

/**
Expand Down Expand Up @@ -447,12 +487,23 @@ function codepad_is_embedded() {

function fix_canvas_size(event) {
var canvas = document.getElementById('canvas');
if (!canvas) {
return;
}
var container = document.getElementById("app-container") || canvas.parentElement;
var rect = container ? container.getBoundingClientRect() : canvas.getBoundingClientRect();
var width = rect.width;
var height = rect.height;
if (codepad_is_embedded()) {
canvas.width = document.body.offsetWidth;
canvas.height = document.body.offsetHeight;
} else {
canvas.width = canvas.offsetWidth;
canvas.height = canvas.offsetHeight;
width = document.body.offsetWidth || width;
height = document.body.offsetHeight || height;
}
if (width > 0 && height > 0) {
var dpr = window.devicePixelRatio || 1;
canvas.style.width = Math.round(width) + "px";
canvas.style.height = Math.round(height) + "px";
canvas.width = Math.max(1, Math.round(width * dpr));
canvas.height = Math.max(1, Math.round(height * dpr));
}
}

Expand All @@ -471,8 +522,14 @@ function codepad_show_play_embed(callback) {
};
splash.innerHTML = "<div>Run code</div>";
document.body.classList += "embedded";
var pane_editors = document.getElementById("pane-editors");
pane_editors.remove();
var row_top = document.getElementById("row-top");
if (row_top) {
row_top.remove();
}
var inspector = document.getElementById("inspector-pane");
if (inspector) {
inspector.remove();
}
}

function codepad_start(callback) {
Expand Down
Loading