Drag pivot is not displayed when a node is clicked. Only when the first drag start.

This commit is contained in:
Paulo Veiga 2012-01-19 02:36:46 -03:00
parent c6fa09ec7d
commit db74c63943
6 changed files with 56 additions and 42 deletions

View File

@ -133,29 +133,19 @@ mindplot.Designer = new Class({
if (!dragTopic.isFreeLayoutOn(event)) {
// The node is being drag. Is the connection still valid ?
dragConnector.checkConnection(dragTopic);
if (!dragTopic.isVisible() && dragTopic.isConnected()) {
dragTopic.setVisibility(true);
}
}
});
dragger.addEvent('enddragging', function(event, dragTopic) {
// Enable all mouse events.
for (var i = 0; i < topics.length; i++) {
topics[i].setMouseEventsEnabled(true);
}
// Topic must be positioned in the real board postion.
if (dragTopic._isInTheWorkspace) {
var draggedTopic = dragTopic.getDraggedTopic();
// Hide topic during draw ...
draggedTopic.setBranchVisibility(false);
var parentNode = draggedTopic.getParent();
dragTopic.applyChanges(workspace);
// Make all node visible ...
draggedTopic.setVisibility(true);
if (parentNode != null) {
parentNode.setBranchVisibility(true);
}
}
});
return dragger;

View File

@ -37,7 +37,7 @@ mindplot.DragManager = new Class({
// Set initial position.
var dragNode = node.createDragNode();
var mousePos = screen.getWorkspaceMousePosition(event);
dragNode.setPosition(mousePos.x, mousePos.y);
// dragNode.setPosition(mousePos.x, mousePos.y);
// Register mouse move listener ...
var mouseMoveListener = dragManager._buildMouseMoveListener(workspace, dragNode, dragManager);

View File

@ -20,13 +20,17 @@ mindplot.DragPivot = new Class({
initialize:function() {
this._position = new core.Point();
this._size = mindplot.DragTopic.PIVOT_SIZE;
this._line = null;
this._straightLine = this._buildStraightLine();
this._curvedLine = this._buildCurvedLine();
this._dragPivot = this._buildRect();
this._connectRect = this._buildRect();
this._targetTopic = null;
this._isVisible = false;
},
isVisible:function() {
return this._isVisible;
},
getTargetTopic : function() {
@ -65,7 +69,7 @@ mindplot.DragPivot = new Class({
// Calculate pivot connection point ...
var size = this._size;
var targetPosition = targetTopic.getPosition();
var line = this._line;
var line = this._getConnectionLine();
// Update Line position.
var isAtRight = mindplot.util.Shape.isAtRight(targetPosition, position);
@ -77,14 +81,10 @@ mindplot.DragPivot = new Class({
var cy = position.y - (parseInt(size.height) / 2);
pivotRect.setPosition(cx, cy);
// Display elements if it's required...
if (!pivotRect.isVisible()) {
// Make line visible only when the position has been already changed.
// This solve several strange effects ;)
var targetPoint = targetTopic.workoutIncomingConnectionPoint(pivotPoint);
line.setTo(targetPoint.x, targetPoint.y);
this.setVisibility(true);
}
},
setPosition : function(point) {
@ -114,14 +114,34 @@ mindplot.DragPivot = new Class({
},
setVisibility : function(value) {
if (this.isVisible() != value) {
var pivotRect = this._getPivotRect();
pivotRect.setVisibility(value);
var connectRect = this._connectRect;
connectRect.setVisibility(value);
if (this._line) {
this._line.setVisibility(value);
var line = this._getConnectionLine();
if (line) {
line.setVisibility(value);
}
this._isVisible = value;
}
},
// If the node is connected, validate that there is a line connecting both...
_getConnectionLine : function() {
var result = null;
var parentTopic = this._targetTopic;
if (parentTopic) {
if (parentTopic.getType() == mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE) {
result = this._straightLine;
} else {
result = this._curvedLine;
}
}
return result;
},
addToWorkspace : function(workspace) {
@ -173,14 +193,7 @@ mindplot.DragPivot = new Class({
$assert(targetTopic, 'parent can not be null');
this._position = position;
this._targetTopic = targetTopic;
if (targetTopic.getType() == mindplot.model.INodeModel.CENTRAL_TOPIC_TYPE) {
this._line = this._straightLine;
} else {
this._line = this._curvedLine;
}
this._line.setVisibility(true);
// Connected to Rect ...
var connectRect = this._connectRect;
@ -211,6 +224,5 @@ mindplot.DragPivot = new Class({
this.setVisibility(false);
this._targetTopic = null;
this._line = null;
}
});

View File

@ -67,6 +67,16 @@ mindplot.DragTopic = new Class({
}
},
setVisibility:function(value) {
var dragPivot = this._getDragPivot();
dragPivot.setVisibility(value);
},
isVisible:function() {
var dragPivot = this._getDragPivot();
return dragPivot.isVisible();
},
getInnerShape : function() {
return this._elem2d;
},
@ -110,6 +120,7 @@ mindplot.DragTopic = new Class({
var dragPivot = this._getDragPivot();
var position = predict.position;
dragPivot.connectTo(parent, position);
dragPivot.setVisibility(true);
this.setOrder(predict.order);
},

View File

@ -1163,6 +1163,7 @@ mindplot.Topic = new Class({
var targetTopic = this.getOutgoingConnectedTopic();
if ($defined(targetTopic)) {
result.connectTo(targetTopic);
result.setVisibility(false);
}
// If a drag node is create for it, let's hide the editor.

View File

@ -174,7 +174,7 @@ mindplot.layout.Node = new Class({
},
toString: function() {
return "[id:" + this.getId() + ", order:" + this.getOrder() + ", position: {" + this.getPosition().x + "," + this.getPosition().y + "}, size: {" + this.getSize().width + "}," + this.getSize().height + ", shrink:" + this.areChildrenShrunken() + "]";
return "[id:" + this.getId() + ", order:" + this.getOrder() + ", position: {" + this.getPosition().x + "," + this.getPosition().y + "}, size: {" + this.getSize().width + "," + this.getSize().height + "}, shrink:" + this.areChildrenShrunken() + "]";
}
});