Working on drag..

This commit is contained in:
Paulo Veiga 2012-01-12 13:44:35 -03:00
parent aee1dfbff9
commit eca97f6a72
6 changed files with 15 additions and 20 deletions

View File

@ -153,7 +153,7 @@ mindplot.Designer = new Class({
// Hide topic during draw ...
draggedTopic.setBranchVisibility(false);
var parentNode = draggedTopic.getParent();
dragTopic.updateDraggedTopic(workspace);
dragTopic.applyChanges(workspace);
// Make all node visible ...

View File

@ -121,7 +121,7 @@ mindplot.DragTopic = new Class({
return true;
},
updateDraggedTopic : function(workspace) {
applyChanges : function(workspace) {
$assert(workspace, 'workspace can not be null');
var dragPivot = this._getDragPivot();
@ -190,7 +190,7 @@ mindplot.DragTopic.init = function(workspace) {
$assert(workspace, "workspace can not be null");
var pivot = mindplot.DragTopic.__getDragPivot();
workspace.appendChild(pivot);
}
};
mindplot.DragTopic.__getDragPivot = function() {
var result = mindplot.DragTopic._dragPivot;

View File

@ -37,13 +37,14 @@ mindplot.DragTopicPositioner = new Class({
// Position topic in the board
if (dragTopic.isConnected()) {
var targetTopic = dragTopic.getConnectedToTopic();
var topicBoard = this._layoutManager.getTopicBoardForTopic(targetTopic);
topicBoard.positionateDragTopic(dragTopic);
// @todo: Hack ...
var position = designer._eventBussDispatcher._layoutManager.predict(targetTopic.getId(),dragTopicPosition);
console.log(position);
}
},
_checkDragTopicConnection : function(dragTopic) {
var topics = this._topics;
var topics = this._designerModel.getTopics();
// Must be disconnected from their current connection ?.
var mainTopicToMainTopicConnection = this._lookUpForMainTopicToMainTopicConnection(dragTopic);
@ -82,7 +83,7 @@ mindplot.DragTopicPositioner = new Class({
},
_lookUpForMainTopicToMainTopicConnection : function(dragTopic) {
var topics = this._topics;
var topics = this._designerModel.getTopics();
var result = null;
var draggedNode = dragTopic.getDraggedTopic();
var distance = null;

View File

@ -70,13 +70,14 @@ mindplot.nlayout.BalancedSorter = new Class({
if (position.y > cpos.y) {
result = [child.getOrder(),{x:cpos.x,y:cpos.y + child.getSize().height}];
}
// Ok, no overlap. Suggest a new order.
if (result) {
var last = children.getLast();
result = [last.getOrder() + 1,{x:cpos.x,y:cpos.y - (mindplot.nlayout.BalancedSorter.INTERNODE_VERTICAL_PADDING * 4)}];
}
});
// Ok, no overlap. Suggest a new order.
if (result) {
var last = children.getLast();
result = [last.getOrder() + 1,{x:cpos.x,y:cpos.y - (mindplot.nlayout.BalancedSorter.INTERNODE_VERTICAL_PADDING * 4)}];
}
return result;
},

View File

@ -34,8 +34,6 @@ mindplot.nlayout.LayoutManager = new Class({
var node = this._treeSet.find(id);
node.setSize(size);
// Todo: This must be completed ...
},
updateShrinkState: function(id, value) {
@ -86,9 +84,8 @@ mindplot.nlayout.LayoutManager = new Class({
},
predict: function(parentId, childId, position) {
predict: function(parentId, position) {
$assert($defined(parentId), "parentId can not be null");
$assert($defined(childId), "childId can not be null");
$assert(position, "childId can not be null");
var parent = this._treeSet.find(parentId);

View File

@ -100,11 +100,7 @@ mindplot.nlayout.OriginalLayout = new Class({
var parentX = parentPosition.x;
var parentY = parentPosition.y;
var verticalOffset = (node.getSize().height / 2);
//TODO(gb): Not sure why verticalOffset is added again, since it is considered in the sorter.
var newPos = {x:parentX + offset.x,y:parentY + offset.y};
// var newPos = {x:parentX + offset.x,y:parentY + offset.y + verticalOffset};
this._treeSet.updateBranchPosition(child, newPos);
}.bind(this));