Skip to content

Commit

Permalink
Flex-box based layout (for docking).
Browse files Browse the repository at this point in the history
  • Loading branch information
mcwehner committed Mar 19, 2013
1 parent e7469dc commit 3749154
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 31 deletions.
1 change: 1 addition & 0 deletions css/main.less
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
}

body {
display: -webkit-box;
position: relative;
height: 100%;

Expand Down
14 changes: 12 additions & 2 deletions css/panels/editor.less
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
.panel[data-name=Source] {
textarea {
box-sizing: border-box;

width: 100%;
height: 100%;

border: 0;
margin: 0;

resize: none;

font-size: 1.3em;
font-family: "Bitstream Vera Sans Mono", monospace;

min-width: 55em;
min-height: 37em;
white-space: pre;

&:focus { outline: none; }
}
Expand Down
23 changes: 12 additions & 11 deletions css/panels/panel.less
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.panel-group {
display: inline-block;
display: -webkit-box;
-webkit-box-orient: vertical;

font-size: 0.625em;
text-shadow: 0 -1px 0 #262626;
Expand All @@ -17,21 +18,19 @@
0 0 0 1px #262626,
0 0 8px 5px #262626
;

header {
// border-top-left-radius: 0.5em;
// border-top-right-radius: 0.5em;
}
}

&.docked {
position: absolute;
&.left {
&:not(:last-child) { margin-right: 0.5em; }
&:last-child { -webkit-box-flex: 1; }
}

&.left, &.right { height: 100%; }
&.top, &.bottom { width: 100%; }
&.right {
&:not(:first-child) { margin-left: 0.5em; }
}

&.right { right: 0; }
&.bottom { bottom: 0; }
// &.left, &.right { height: 100%; }
}

header {
Expand Down Expand Up @@ -63,6 +62,8 @@
1px 0 0 #262626,
0 1px 0 #4a4a4a
;

cursor: pointer;
}
}

Expand Down
12 changes: 8 additions & 4 deletions js/panels/editor.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
define([
"./panel", // Panel
"./panel", // Panel

"text!templates/panels/editor.ejs" // template
"text!templates/panels/editor.ejs", // template

"text!assets/shaders/three-test/test.vert" // vertexSource
],
function (Panel, template) {
function (Panel, template, vertexSource) {

function EditorPanel () {
Panel.call(this, "Source");
Expand All @@ -14,7 +16,9 @@ function (Panel, template) {


EditorPanel.prototype.render = function (parentElement) {
parentElement.append( new EJS({ text: template }).render({}) );
parentElement.append( new EJS({ text: template }).render({
source : vertexSource
}) );
};

return EditorPanel;
Expand Down
12 changes: 7 additions & 5 deletions js/panels/panel-group.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,14 @@ function (template) {
}

this.domElement = element;
this.domElement.css("z-index", ++PanelGroup.counter);
// this.domElement.css("z-index", ++PanelGroup.counter);

$.each(this.panels, function (i, panel) {
panel.render( $(".panel-group .panel[data-name='" + panel.name + "']") );
});

// Moving panel groups
/*
$("header", this.domElement).on("mousedown", function (mousedownEvent) {
var offset = $(this).offset();
var snapWidth = 30;
Expand Down Expand Up @@ -65,11 +66,12 @@ function (template) {
return false;
});

*/

// Panel group focus
$(this.domElement).on("mouseup", function () {
self.domElement.css("z-index", ++PanelGroup.counter);
});
// $(this.domElement).on("mouseup", function () {
// self.domElement.css("z-index", ++PanelGroup.counter);
// });
};

PanelGroup.prototype.float = function (x, y) {
Expand Down
10 changes: 5 additions & 5 deletions js/panels/preview.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
define([
"./panel", // Panel
"./panel", // Panel

"text!templates/panels/preview-panel.ejs", // template
"text!templates/panels/preview.ejs", // template

"text!shaders/three-test/test.vert", // testVertexShader
"text!shaders/three-test/test.frag" // testFragmentShaders
"text!shaders/three-test/test.vert", // testVertexShader
"text!shaders/three-test/test.frag" // testFragmentShaders
],
function (Panel, template, testVertexShader, testFragmentShader) {
function PreviewPanel (options) {
Expand Down Expand Up @@ -32,7 +32,7 @@ function (Panel, template, testVertexShader, testFragmentShader) {
this.renderer.setSize(this.options.width, this.options.height);

this.animationEnabled = true;
this.tumbleEnabled = true;
this.tumbleEnabled = false;

this.tumbleX = 0.01;
this.tumbleY = 0.01;
Expand Down
3 changes: 1 addition & 2 deletions templates/panels/editor.ejs
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
<textarea>
</textarea>
<textarea><%= source %></textarea>
2 changes: 1 addition & 1 deletion templates/panels/panel-group.ejs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class="panel-group docked left">
<header>
<h1>x</h1>
<h1></h1>
</header>

<nav>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<section class="control-group">
<label>
<input name="tumble" type="checkbox" checked="checked"/>
<input name="tumble" type="checkbox"/>
<span>Tumble</span>
</label>
</section>

0 comments on commit 3749154

Please sign in to comment.