|
From: <ma...@us...> - 2011-01-15 22:34:33
|
Revision: 249
http://openautomation.svn.sourceforge.net/openautomation/?rev=249&view=rev
Author: mayerch
Date: 2011-01-15 22:34:27 +0000 (Sat, 15 Jan 2011)
Log Message:
-----------
New function that gives the current coordinate based on the event object that is passed as an parameter.
This will be extended later when the zooming functionality gets implemented
Modified Paths:
--------------
PyWireGate/trunk/logic_editor/logicEditor.js
Modified: PyWireGate/trunk/logic_editor/logicEditor.js
===================================================================
--- PyWireGate/trunk/logic_editor/logicEditor.js 2011-01-14 23:50:58 UTC (rev 248)
+++ PyWireGate/trunk/logic_editor/logicEditor.js 2011-01-15 22:34:27 UTC (rev 249)
@@ -158,3 +158,14 @@
});
element.setAttribute( 'class', element.getAttribute( 'class' ) + ' selected' );
}
+
+jQuery(document).ready(function(){
+ var getCoordinate = (function()
+ {
+ var svg = $('#editor svg'); // quasi static variable
+ return function( event ) {
+ var o = svg.offset();
+ return {x: event.pageX - o.left, y: event.pageY - o.top};
+ };
+ })();
+});
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ma...@us...> - 2011-01-15 22:38:38
|
Revision: 250
http://openautomation.svn.sourceforge.net/openautomation/?rev=250&view=rev
Author: mayerch
Date: 2011-01-15 22:38:32 +0000 (Sat, 15 Jan 2011)
Log Message:
-----------
bug fix: scope was too narrow
Modified Paths:
--------------
PyWireGate/trunk/logic_editor/logicEditor.js
Modified: PyWireGate/trunk/logic_editor/logicEditor.js
===================================================================
--- PyWireGate/trunk/logic_editor/logicEditor.js 2011-01-15 22:34:27 UTC (rev 249)
+++ PyWireGate/trunk/logic_editor/logicEditor.js 2011-01-15 22:38:32 UTC (rev 250)
@@ -160,7 +160,7 @@
}
jQuery(document).ready(function(){
- var getCoordinate = (function()
+ getCoordinate = (function()
{
var svg = $('#editor svg'); // quasi static variable
return function( event ) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ma...@us...> - 2011-01-16 12:45:00
|
Revision: 254
http://openautomation.svn.sourceforge.net/openautomation/?rev=254&view=rev
Author: mayerch
Date: 2011-01-16 12:44:54 +0000 (Sun, 16 Jan 2011)
Log Message:
-----------
Automatically resize the canvas when a new block is dropped on the border
Modified Paths:
--------------
PyWireGate/trunk/logic_editor/logicEditor.js
Modified: PyWireGate/trunk/logic_editor/logicEditor.js
===================================================================
--- PyWireGate/trunk/logic_editor/logicEditor.js 2011-01-16 12:23:36 UTC (rev 253)
+++ PyWireGate/trunk/logic_editor/logicEditor.js 2011-01-16 12:44:54 UTC (rev 254)
@@ -20,7 +20,7 @@
// global variables
var overPort = false;
var connectionLookingForInPort = true; // only relevant in connection drawing mode
-var maxX = 500; // the biggest x value of the current view
+var maxX = 0; // the biggest x value of the current view
var maxY = 0; // the biggest y value of the current view
$(function() {
@@ -28,8 +28,8 @@
applyDefaultStyles: false,
center__onresize: function( name, element, state ){
var editor = element.find('svg')[0];
- editor.width.baseVal.value = Math.max( maxX, state.innerWidth-2 );
- editor.height.baseVal.value = Math.max( maxY, state.innerHeight-2 );
+ editor.width.baseVal.value = Math.max( maxX, state.innerWidth );
+ editor.height.baseVal.value = Math.max( maxY, state.innerHeight );
},
north__closable: false,
north__resizable: false
@@ -146,6 +146,7 @@
var c = getCoordinate( {pageX: ui.position.left, pageY: ui.position.top} );
var data = $.extend( true, c, ui.draggable.data('element') );
drawElement( $('#editor').svg('get'), data );
+ editorResize( c );
}
}
@@ -157,6 +158,34 @@
element.setAttribute( 'class', element.getAttribute( 'class' ) + ' selected' );
}
+/**
+ * Iterate over all blocks to make sure the editor is big enough
+ * The optional parameter "test" allows to bypass the resize if it's not
+ * necessary, i.e. the test.{xy} fits into the current canvas
+ */
+function editorResize( test )
+{
+ var extraSpace = 20; // a bit more space, e.g. for scroll bars
+
+ if( test !== undefined &&
+ test.x + extraSpace <= maxX && test.y + extraSpace <= maxY )
+ return;
+
+ maxX = 0;
+ maxY = 0;
+ $.each( blockRegistry, function(){
+ var x = this.getX() + this.getWidth();
+ var y = this.getY() + this.getHeight();
+ if( x > maxX ) maxX = x;
+ if( y > maxY ) maxY = y;
+ });
+ maxX += extraSpace; maxY += extraSpace;
+ var editor = $('#editor');
+ var svg = $('#editor svg')[0];
+ svg.width.baseVal.value = Math.max( maxX, editor.innerWidth() );
+ svg.height.baseVal.value = Math.max( maxY, editor.innerHeight() );
+}
+
jQuery(document).ready(function(){
getCoordinate = (function()
{
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ma...@us...> - 2011-01-16 12:53:20
|
Revision: 255
http://openautomation.svn.sourceforge.net/openautomation/?rev=255&view=rev
Author: mayerch
Date: 2011-01-16 12:53:14 +0000 (Sun, 16 Jan 2011)
Log Message:
-----------
Fix: compare bottom right corner for canvas resize (and not top left...)
Modified Paths:
--------------
PyWireGate/trunk/logic_editor/logicEditor.js
Modified: PyWireGate/trunk/logic_editor/logicEditor.js
===================================================================
--- PyWireGate/trunk/logic_editor/logicEditor.js 2011-01-16 12:44:54 UTC (rev 254)
+++ PyWireGate/trunk/logic_editor/logicEditor.js 2011-01-16 12:53:14 UTC (rev 255)
@@ -146,7 +146,7 @@
var c = getCoordinate( {pageX: ui.position.left, pageY: ui.position.top} );
var data = $.extend( true, c, ui.draggable.data('element') );
drawElement( $('#editor').svg('get'), data );
- editorResize( c );
+ editorResize( { x: c.x + data.width, y: c.y + data.height } );
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ma...@us...> - 2011-01-22 15:20:25
|
Revision: 265
http://openautomation.svn.sourceforge.net/openautomation/?rev=265&view=rev
Author: mayerch
Date: 2011-01-22 15:20:19 +0000 (Sat, 22 Jan 2011)
Log Message:
-----------
Added debug tool to show all bound events
Modified Paths:
--------------
PyWireGate/trunk/logic_editor/logicEditor.js
Modified: PyWireGate/trunk/logic_editor/logicEditor.js
===================================================================
--- PyWireGate/trunk/logic_editor/logicEditor.js 2011-01-22 14:45:58 UTC (rev 264)
+++ PyWireGate/trunk/logic_editor/logicEditor.js 2011-01-22 15:20:19 UTC (rev 265)
@@ -260,4 +260,25 @@
svg.viewBox.baseVal.width = x / factor;
svg.viewBox.baseVal.height = y / factor;
}
+}
+
+////////////////////////
+// FIXME - delete it later, this are just helpers for debugging
+function _showEvents( target )
+{
+ var count = 0;
+ jQuery.each($(target || '*'), function(j){
+ //console.log( j, this );
+ var that = this;
+ var d = $(this).data();
+ if( d.events )
+ {
+ console.log( count, this );
+ jQuery.each( d.events, function( i, handler ){
+ //console.log( j, i, handler[0].handler.toString() );
+ console.log( count, i, handler[0].handler );
+ });
+ count++;
+ }
+ });
}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|