mirror of
https://github.com/google/blockly.git
synced 2026-01-07 09:00:11 +01:00
Dragging changes, rebased on develop (#1078)
* Add block drag surface translateSurfaceBy * Add dragged connection manager * Add gesture.js * Add GestureHandler * Implemented gesture skeleton * Most basic workspace dragging * Add dragged connection manager * cleanup * doc * more cleanup * Add gesture handler * Add translateSurfaceInternal * core/block_dragger.js * cleanup * Pull in changes to dragged connection manager * Pull in changes to dragged connection manager * comments * more annotations * Add workspace dragger * Add coordinate annotations * Start on block dragging * Limit number of concurrent gestures * Add some TODOs * start using dragged connection manager * Set origin correctly for dragging blocks * Connect or delete at the end of a block drag. * cleanup * handle field clicks and block + workspace right-clicks * move code into BlockDragger class, but still reach into Gesture internals a lot * Clean up block dragger * Call blockDragger constructor with correct arguments * Enable block dragging in a mutator workspace * Add workspace dragger * click todos * Drag flyout with background * more dragging from flyout * nit * fix dragging from flyouts * Remove unused code and rename gestureHandler to gestureDB * Rename gesture handler * Added some jsdoc in gesture.js * Update some docs * Move some code to block_svg and clean up code * Lots of coordinate annotations * Fix block dragging when zoomed. * Remove built files from branch * More dragging work (#1026) -- Drag bubbles while dragging blocks -- Use bindEventWithChecks to work in touch on Android. Not tested anywhere else yet. -- Handle dragging blocks while zoomed -- Handle dragging blocks in mutators -- Handle right-clicks (I hope) -- Removed lots of unused code * More dragging work (#1048) - Removed gestureDB - Removing uses of terminateDrag - Cleaned up disposal code * Dragging bugfixes (#1058) - Get rid of flyout.dragMode_ and blockly.dragMode_ - Make drags from the flyout start from the top block in the group - Block tooltips from being scheduled or shown during gestures - Don't resize mutator bubbles mid-drag * Fix events in new dragging (#1060) * rebuild for testing * unbuild * Fix events * rebuild * Fix up cursors * Use language files from develop * Remove handled TODOS * attempt to fix IE rerendering bug, and recalculate workspace positions on scroll * Rebuild all the things * Comment cleanup; annotations; delete unused variables.
This commit is contained in:
@@ -73,20 +73,6 @@ Blockly.mainWorkspace = null;
|
||||
*/
|
||||
Blockly.selected = null;
|
||||
|
||||
/**
|
||||
* Currently highlighted connection (during a drag).
|
||||
* @type {Blockly.Connection}
|
||||
* @private
|
||||
*/
|
||||
Blockly.highlightedConnection_ = null;
|
||||
|
||||
/**
|
||||
* Connection on dragged block that matches the highlighted connection.
|
||||
* @type {Blockly.Connection}
|
||||
* @private
|
||||
*/
|
||||
Blockly.localConnection_ = null;
|
||||
|
||||
/**
|
||||
* All of the connections on blocks that are currently being dragged.
|
||||
* @type {!Array.<!Blockly.Connection>}
|
||||
@@ -108,15 +94,6 @@ Blockly.clipboardXml_ = null;
|
||||
*/
|
||||
Blockly.clipboardSource_ = null;
|
||||
|
||||
/**
|
||||
* Is the mouse dragging a block?
|
||||
* DRAG_NONE - No drag operation.
|
||||
* DRAG_STICKY - Still inside the sticky DRAG_RADIUS.
|
||||
* DRAG_FREE - Freely draggable.
|
||||
* @private
|
||||
*/
|
||||
Blockly.dragMode_ = Blockly.DRAG_NONE;
|
||||
|
||||
/**
|
||||
* Cached value for whether 3D is supported.
|
||||
* @type {!boolean}
|
||||
@@ -206,10 +183,18 @@ Blockly.onKeyDown_ = function(e) {
|
||||
// Do this first to prevent an error in the delete code from resulting in
|
||||
// data loss.
|
||||
e.preventDefault();
|
||||
// Don't delete while dragging. Jeez.
|
||||
if (Blockly.mainWorkspace.isDragging()) {
|
||||
return;
|
||||
}
|
||||
if (Blockly.selected && Blockly.selected.isDeletable()) {
|
||||
deleteBlock = true;
|
||||
}
|
||||
} else if (e.altKey || e.ctrlKey || e.metaKey) {
|
||||
// Don't use meta keys during drags.
|
||||
if (Blockly.mainWorkspace.isDragging()) {
|
||||
return;
|
||||
}
|
||||
if (Blockly.selected &&
|
||||
Blockly.selected.isDeletable() && Blockly.selected.isMovable()) {
|
||||
if (e.keyCode == 67) {
|
||||
@@ -239,25 +224,11 @@ Blockly.onKeyDown_ = function(e) {
|
||||
// Common code for delete and cut.
|
||||
Blockly.Events.setGroup(true);
|
||||
Blockly.hideChaff();
|
||||
var heal = Blockly.dragMode_ != Blockly.DRAG_FREE;
|
||||
Blockly.selected.dispose(heal, true);
|
||||
if (Blockly.highlightedConnection_) {
|
||||
Blockly.highlightedConnection_.unhighlight();
|
||||
Blockly.highlightedConnection_ = null;
|
||||
}
|
||||
Blockly.selected.dispose(/* heal */ true, true);
|
||||
Blockly.Events.setGroup(false);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Stop binding to the global mouseup and mousemove events.
|
||||
* @private
|
||||
*/
|
||||
Blockly.terminateDrag_ = function() {
|
||||
Blockly.BlockSvg.terminateDrag();
|
||||
Blockly.Flyout.terminateDrag_();
|
||||
};
|
||||
|
||||
/**
|
||||
* Copy a block onto the local clipboard.
|
||||
* @param {!Blockly.Block} block Block to be copied.
|
||||
@@ -265,9 +236,8 @@ Blockly.terminateDrag_ = function() {
|
||||
*/
|
||||
Blockly.copy_ = function(block) {
|
||||
var xmlBlock = Blockly.Xml.blockToDom(block);
|
||||
if (Blockly.dragMode_ != Blockly.DRAG_FREE) {
|
||||
Blockly.Xml.deleteNext(xmlBlock);
|
||||
}
|
||||
// Copy only the selected block and internal blocks.
|
||||
Blockly.Xml.deleteNext(xmlBlock);
|
||||
// Encode start position in XML.
|
||||
var xy = block.getRelativeToSurfaceXY();
|
||||
xmlBlock.setAttribute('x', block.RTL ? -xy.x : xy.x);
|
||||
|
||||
Reference in New Issue
Block a user