Commit 923eed0f authored by Jérome Perrin's avatar Jérome Perrin

Graph Editor: use CSS defined in the json and define box-sizing to have proper ratio

parent 65cbd50f
...@@ -74,8 +74,9 @@ path, ._jsPlumb_endpoint { ...@@ -74,8 +74,9 @@ path, ._jsPlumb_endpoint {
.window, .dummy_window { .window, .dummy_window {
border:1px solid lightgray; border:1px solid lightgray;
width:100px; width: 80px;
height:64px; height: 80px;
box-sizing: border-box;
position:absolute; position:absolute;
color:black; color:black;
font-family:serif; font-family:serif;
......
...@@ -149,7 +149,7 @@ ...@@ -149,7 +149,7 @@
} }
function convertToAbsolutePosition(gadget, x, y) { function convertToAbsolutePosition(gadget, x, y) {
var zoom_level = gadget.props.zoom_level * 1.1111, var zoom_level = gadget.props.zoom_level,
canvas_size_x = $(gadget.props.main).width(), canvas_size_x = $(gadget.props.main).width(),
canvas_size_y = $(gadget.props.main).height(), canvas_size_y = $(gadget.props.main).height(),
size_x = $(gadget.props.element).find('.dummy_window').width() * size_x = $(gadget.props.element).find('.dummy_window').width() *
...@@ -162,7 +162,7 @@ ...@@ -162,7 +162,7 @@
} }
function convertToRelativePosition(gadget, x, y) { function convertToRelativePosition(gadget, x, y) {
var zoom_level = gadget.props.zoom_level * 1.1111, var zoom_level = gadget.props.zoom_level,
canvas_size_x = $(gadget.props.main).width(), canvas_size_x = $(gadget.props.main).width(),
canvas_size_y = $(gadget.props.main).height(), canvas_size_y = $(gadget.props.main).height(),
size_x = $(gadget.props.element).find('.dummy_window').width() * size_x = $(gadget.props.element).find('.dummy_window').width() *
...@@ -240,11 +240,11 @@ ...@@ -240,11 +240,11 @@
function updateNodeStyle(gadget, element_id) { function updateNodeStyle(gadget, element_id) {
// Update node size according to the zoom level // Update node size according to the zoom level
// XXX does nothing for now // XXX does nothing for now
var zoom_level = gadget.props.zoom_level * 1.1111, var zoom_level = gadget.props.zoom_level,
element = $(gadget.props.element).find("#" + element_id), element = $(gadget.props.element).find("#" + element_id),
new_value; new_value;
$.each(gadget.props.style_attr_list, function (i, j) { $.each(gadget.props.style_attr_list, function (i, j) {
new_value = $(gadget.props.element).find('.dummy_window').css(j) new_value = element.css(j)
.replace('px', '') * zoom_level + 'px'; .replace('px', '') * zoom_level + 'px';
element.css(j, new_value); element.css(j, new_value);
}); });
...@@ -734,7 +734,6 @@ ...@@ -734,7 +734,6 @@
coordinate coordinate
); );
// XXX make node template an option, or use CSS from class_definition
/*jslint nomen: true*/ /*jslint nomen: true*/
domElement = domParser.parseFromString( domElement = domParser.parseFromString(
node_template({ node_template({
...@@ -755,6 +754,9 @@ ...@@ -755,6 +754,9 @@
coordinate.left, coordinate.left,
coordinate.top coordinate.top
); );
if (class_definition.css) {
box.css(class_definition.css);
}
box.css("top", absolute_position[1]); box.css("top", absolute_position[1]);
box.css("left", absolute_position[0]); box.css("left", absolute_position[0]);
updateNodeStyle(gadget, dom_element_id); updateNodeStyle(gadget, dom_element_id);
......
...@@ -17,7 +17,8 @@ ...@@ -17,7 +17,8 @@
border: 1px solid lightgray; border: 1px solid lightgray;
box-shadow: 1px 1px 2px #aaa; box-shadow: 1px 1px 2px #aaa;
min-width:7em; min-width:7em;
height:3em; min-height:6em;
box-sizing: border-box;
z-index: 10001; z-index: 10001;
color: gray; color: gray;
font-family:serif; font-family:serif;
...@@ -30,45 +31,3 @@ ...@@ -30,45 +31,3 @@
padding-top: 1.3em; padding-top: 1.3em;
cursor: move; cursor: move;
} }
.Dream-Source, .Dream-BatchSource {
border: 1px solid #bbc;
background-color:#ffe;
background-image: linear-gradient(to bottom, #ffe 0%, #dde 100%);
}
.Dream-Machine, .Dream-MachineJobShop, .Dream-BatchScrapMachine, .Dream-MachineManagedJob, .Dream-MouldAssembly {
border: 1px solid #cbc;
background-color: #fef;
background-image: linear-gradient(to bottom, #fef 0%, #ede 100%);
}
.Dream-Queue, .Dream-QueueJobShop, .Dream-LineClearance, .Dream-QueueManagedJob, .Dream-ConditionalBuffer, .Dream-OrderDecomposition, .Dream-MouldAssemblyBuffer {
border: 1px solid #bcc;
background-color:#eff;
background-image: linear-gradient(to bottom, #eff 0%, #dee 100%);
}
.Dream-Exit, .Dream-ExitJobShop {
border: 1px solid #ccb;
background-color:#eef;
background-image: linear-gradient(to bottom, #eef 0%, #dde 100%);
}
.Dream-EventGenerator {
border: 1px solid #cba;
background-color:#fdc;
background-image: linear-gradient(to bottom, #fdc 0%, #ecb 100%);
}
.Dream-BatchDecomposition, .Dream-BatchDecompositionStartTime, .Dream-BatchReassembly {
border: 1px solid #bcb;
background-color:#dfd;
background-image: linear-gradient(to bottom, #dfd 0%, #cec 100%);
}
.Dream-Repairman {
border: 1px solid #cbb;
background-color:#fdd;
background-image: linear-gradient(to bottom, #fdd 0%, #dcc 100%);
}
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment