mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-11-26 15:54:55 +01:00
Working on drag..
This commit is contained in:
parent
aee1dfbff9
commit
eca97f6a72
@ -153,7 +153,7 @@ mindplot.Designer = new Class({
|
|||||||
// Hide topic during draw ...
|
// Hide topic during draw ...
|
||||||
draggedTopic.setBranchVisibility(false);
|
draggedTopic.setBranchVisibility(false);
|
||||||
var parentNode = draggedTopic.getParent();
|
var parentNode = draggedTopic.getParent();
|
||||||
dragTopic.updateDraggedTopic(workspace);
|
dragTopic.applyChanges(workspace);
|
||||||
|
|
||||||
|
|
||||||
// Make all node visible ...
|
// Make all node visible ...
|
||||||
|
@ -121,7 +121,7 @@ mindplot.DragTopic = new Class({
|
|||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
|
|
||||||
updateDraggedTopic : function(workspace) {
|
applyChanges : function(workspace) {
|
||||||
$assert(workspace, 'workspace can not be null');
|
$assert(workspace, 'workspace can not be null');
|
||||||
|
|
||||||
var dragPivot = this._getDragPivot();
|
var dragPivot = this._getDragPivot();
|
||||||
@ -190,7 +190,7 @@ mindplot.DragTopic.init = function(workspace) {
|
|||||||
$assert(workspace, "workspace can not be null");
|
$assert(workspace, "workspace can not be null");
|
||||||
var pivot = mindplot.DragTopic.__getDragPivot();
|
var pivot = mindplot.DragTopic.__getDragPivot();
|
||||||
workspace.appendChild(pivot);
|
workspace.appendChild(pivot);
|
||||||
}
|
};
|
||||||
|
|
||||||
mindplot.DragTopic.__getDragPivot = function() {
|
mindplot.DragTopic.__getDragPivot = function() {
|
||||||
var result = mindplot.DragTopic._dragPivot;
|
var result = mindplot.DragTopic._dragPivot;
|
||||||
|
@ -37,13 +37,14 @@ mindplot.DragTopicPositioner = new Class({
|
|||||||
// Position topic in the board
|
// Position topic in the board
|
||||||
if (dragTopic.isConnected()) {
|
if (dragTopic.isConnected()) {
|
||||||
var targetTopic = dragTopic.getConnectedToTopic();
|
var targetTopic = dragTopic.getConnectedToTopic();
|
||||||
var topicBoard = this._layoutManager.getTopicBoardForTopic(targetTopic);
|
// @todo: Hack ...
|
||||||
topicBoard.positionateDragTopic(dragTopic);
|
var position = designer._eventBussDispatcher._layoutManager.predict(targetTopic.getId(),dragTopicPosition);
|
||||||
|
console.log(position);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
_checkDragTopicConnection : function(dragTopic) {
|
_checkDragTopicConnection : function(dragTopic) {
|
||||||
var topics = this._topics;
|
var topics = this._designerModel.getTopics();
|
||||||
|
|
||||||
// Must be disconnected from their current connection ?.
|
// Must be disconnected from their current connection ?.
|
||||||
var mainTopicToMainTopicConnection = this._lookUpForMainTopicToMainTopicConnection(dragTopic);
|
var mainTopicToMainTopicConnection = this._lookUpForMainTopicToMainTopicConnection(dragTopic);
|
||||||
@ -82,7 +83,7 @@ mindplot.DragTopicPositioner = new Class({
|
|||||||
},
|
},
|
||||||
|
|
||||||
_lookUpForMainTopicToMainTopicConnection : function(dragTopic) {
|
_lookUpForMainTopicToMainTopicConnection : function(dragTopic) {
|
||||||
var topics = this._topics;
|
var topics = this._designerModel.getTopics();
|
||||||
var result = null;
|
var result = null;
|
||||||
var draggedNode = dragTopic.getDraggedTopic();
|
var draggedNode = dragTopic.getDraggedTopic();
|
||||||
var distance = null;
|
var distance = null;
|
||||||
|
@ -70,13 +70,14 @@ mindplot.nlayout.BalancedSorter = new Class({
|
|||||||
if (position.y > cpos.y) {
|
if (position.y > cpos.y) {
|
||||||
result = [child.getOrder(),{x:cpos.x,y:cpos.y + child.getSize().height}];
|
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;
|
return result;
|
||||||
},
|
},
|
||||||
|
@ -34,8 +34,6 @@ mindplot.nlayout.LayoutManager = new Class({
|
|||||||
|
|
||||||
var node = this._treeSet.find(id);
|
var node = this._treeSet.find(id);
|
||||||
node.setSize(size);
|
node.setSize(size);
|
||||||
|
|
||||||
// Todo: This must be completed ...
|
|
||||||
},
|
},
|
||||||
|
|
||||||
updateShrinkState: function(id, value) {
|
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(parentId), "parentId can not be null");
|
||||||
$assert($defined(childId), "childId can not be null");
|
|
||||||
$assert(position, "childId can not be null");
|
$assert(position, "childId can not be null");
|
||||||
|
|
||||||
var parent = this._treeSet.find(parentId);
|
var parent = this._treeSet.find(parentId);
|
||||||
|
@ -100,11 +100,7 @@ mindplot.nlayout.OriginalLayout = new Class({
|
|||||||
var parentX = parentPosition.x;
|
var parentX = parentPosition.x;
|
||||||
var parentY = parentPosition.y;
|
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};
|
||||||
// var newPos = {x:parentX + offset.x,y:parentY + offset.y + verticalOffset};
|
|
||||||
|
|
||||||
this._treeSet.updateBranchPosition(child, newPos);
|
this._treeSet.updateBranchPosition(child, newPos);
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
|
Loading…
Reference in New Issue
Block a user