Skip to content
This repository has been archived by the owner on Jan 22, 2024. It is now read-only.

delete works now! #110

Merged
merged 16 commits into from
Dec 17, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions app/CircularView.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class CircularView extends React.Component {
var angle = Math.atan2(clickY, clickX) + Math.PI/2
if (angle < 0) angle += Math.PI * 2
console.log('angle: ' + JSON.stringify(angle,null,4));
var caretGrabbed = event.target.className === "cursor"
var caretGrabbed = event.target.className && event.target.className.animVal === "cursor"
var nearestBP = Math.floor(angle / Math.PI / 2 * sequenceLength)
callback({
shiftHeld: event.shiftKey,
Expand Down Expand Up @@ -266,7 +266,8 @@ function Caret ({caretPosition, sequenceLength, innerRadius, outerRadius}) {
eAngle={ endAngle }
height={ 0 }>
<line
style={ { className:"cursor", opacity: 9} }//tnr: the classname needs to be cursor here!
className="cursor"
style={ { opacity: 9, cursor: "ew-resize",} }//tnr: the classname needs to be cursor here!
x1={0}
y1={-innerRadius}
x2={0}
Expand Down
97 changes: 0 additions & 97 deletions app/SequenceEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,103 +131,6 @@ class SequenceEditor extends React.Component {
// Remove any Mousetrap bindings before unmounting.detach()
combokeys.detach()
}

// handleEditorClick({nearestBP, shiftHeld}) {
// //if cursor position is different than the original position, reset the position and clear the selection
// if (this.editorBeingDragged) {
// //do nothing because the click was triggered by a drag event
// } else {
// this.props.signals.editorClicked({
// shiftHeld,
// type: 'editorClick',
// updatedCaretPos: nearestBP
// })
// }
// }

// handleEditorDrag({nearestBP}) {
// var {
// setCaretPosition,
// setSelectionLayer
// } = this.props.signals;
// //note this method relies on variables that are set in the handleEditorDragStart method!
// this.editorBeingDragged = true;
// console.log('nearestBP: ' + JSON.stringify(nearestBP,null,4));
// if (nearestBP === this.fixedCaretPositionOnEditorDragStart) {
// setCaretPosition(nearestBP);
// setSelectionLayer(false);
// } else {
// var newSelectionLayer;
// if (this.fixedCaretPositionOnEditorDragStartType === 'start') {
// newSelectionLayer = {
// start: this.fixedCaretPositionOnEditorDragStart,
// end: nearestBP - 1,
// cursorAtEnd: true,
// };
// } else if (this.fixedCaretPositionOnEditorDragStartType === 'end') {
// newSelectionLayer = {
// start: nearestBP,
// end: this.fixedCaretPositionOnEditorDragStart - 1,
// cursorAtEnd: false,
// };
// } else {
// if (nearestBP > this.fixedCaretPositionOnEditorDragStart) {
// newSelectionLayer = {
// start: this.fixedCaretPositionOnEditorDragStart,
// end: nearestBP - 1,
// cursorAtEnd: true,
// };
// } else {
// newSelectionLayer = {
// start: nearestBP,
// end: this.fixedCaretPositionOnEditorDragStart - 1,
// cursorAtEnd: false,
// };
// }
// }
// setSelectionLayer({selectionLayer: newSelectionLayer});
// }
// }

// handleEditorDragStart({nearestBP, caretGrabbed}) {
// var {selectionLayer} = this.props;
// if (caretGrabbed && selectionLayer.selected) {
// // this.circularSelectionOnEditorDragStart = (selectionLayer.start > selectionLayer.end);
// if (selectionLayer.start === nearestBP) {
// this.fixedCaretPositionOnEditorDragStart = selectionLayer.end + 1;
// this.fixedCaretPositionOnEditorDragStartType = 'end';

// //plus one because the cursor position will be 1 more than the selectionLayer.end
// //imagine selection from
// //0 1 2 <--possible cursor positions
// // A T G
// //if A is selected, selection.start = 0, selection.end = 0
// //so the nearestBP for the end of the selection is 1!
// //which is selection.end+1
// } else {
// this.fixedCaretPositionOnEditorDragStart = selectionLayer.start;
// this.fixedCaretPositionOnEditorDragStartType = 'start';
// }
// } else {
// // this.circularSelectionOnEditorDragStart = false;
// this.fixedCaretPositionOnEditorDragStart = nearestBP;
// this.fixedCaretPositionOnEditorDragStartType = 'caret';
// }
// }

// handleEditorDragStop(event, ui) {
// var self = this;
// if (this.editorBeingDragged) { //check to make sure dragging actually occurred
// setTimeout(function() {
// //we use setTimeout to put the call to change editorBeingDragged to false
// //on the bottom of the event stack, thus the click event that is fired because of the drag
// //will be able to check if editorBeingDragged and not trigger if it is
// self.editorBeingDragged = false;
// }, 0);
// } else {
// self.editorBeingDragged = false;
// }
// }
render() {
var {
selectedSequenceString,
Expand Down
8 changes: 2 additions & 6 deletions app/StatusBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,8 @@ export default class StatusBar extends React.Component {
return (
<div ref="statusBar">
<div className={styles.bar}>
<div>
<button onClick={function () {
signals.setEditState();}}>Set Edit</button>
<button onClick={function () {
signals.testSignal();}}>Test Edit</button>
</div>

{readOnly ? <div className={styles.label}>Read Only Mode</div> : <div>Editing Allowed</div>}
<div className={styles.box}>
<div className={styles.label}>Length</div>
<div className={styles.data}>{sequenceLength}</div>
Expand Down
2 changes: 1 addition & 1 deletion app/cerebral/actions/checkBooleanState.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ module.exports = function checkBooleanState(path) {
output.error()
}
}
stateCheck.displayName = 'checkBooleanState' + path.toString();
stateCheck.displayName = 'checkBooleanState: [' + path.toString() + ']';
return stateCheck;
}
12 changes: 6 additions & 6 deletions app/cerebral/actions/createSelectionShiftClick.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
export default function createSelectionShiftClick({
updatedCaretPos, caretPosition
nearestBP, caretPosition
}, tree, output) {
var ac = require('ve-api-check');
ac.throw(ac.posInt, updatedCaretPos)
ac.throw(ac.posInt, nearestBP)
ac.throw(ac.posInt, caretPosition)
if (updatedCaretPos === caretPosition) {
if (nearestBP === caretPosition) {
return output.doNothing()
}
if (updatedCaretPos > caretPosition) {
if (nearestBP > caretPosition) {
output.updateSelection({
selectionLayer: {
start: caretPosition,
end: updatedCaretPos - 1,
end: nearestBP - 1,
cursorAtEnd: true,
selected: true
}
})
} else {
output.updateSelection({
selectionLayer: {
start: updatedCaretPos,
start: nearestBP,
end: caretPosition - 1,
cursorAtEnd: false,
selected: true
Expand Down
11 changes: 9 additions & 2 deletions app/cerebral/actions/deleteSequence.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,18 @@ var ac = require('ve-api-check');
var adjustRangeToDeletionOfAnotherRange = require('ve-range-utils/adjustRangeToDeletionOfAnotherRange');
var tidyUpSequenceData = require('ve-sequence-utils/tidyUpSequenceData');
var assign = require('lodash/object/assign');
// var setSelectionLayer = require('./setSelectionLayer');

export default function deleteSequence({selectionLayer, sequenceData}, tree, output) {
// var {selectionLayer, sequenceData, } = tree.get();
ac.throw(ac.range, selectionLayer)
var newCaretPosition = selectionLayer.start;

if (selectionLayer.start > selectionLayer.end) {
newCaretPosition = selectionLayer.start - selectionLayer.end - 1;
}
var newSequenceData = {};
// lodash assign
var newSequenceData =assign({}, sequenceData);
if (sequenceData.sequence) {
//splice the underlying sequence
if (selectionLayer.start > selectionLayer.end) {
Expand Down Expand Up @@ -44,5 +48,8 @@ export default function deleteSequence({selectionLayer, sequenceData}, tree, out
return [];
}
}
// tree.set('sequenceData', tidyUpSequenceData(newSequenceData, true));
// tree.set('caretPosition', newCaretPosition);
output({sequenceData: tidyUpSequenceData(newSequenceData, true), caretPosition: newCaretPosition});
}
// setSelectionLayer(false, tree);
}
5 changes: 4 additions & 1 deletion app/cerebral/actions/handleEditorDragStopped.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
var ac = require('ve-api-check/apiCheck');
export default function handleEditorDragStopped(input, tree) {
tree.set(['editorDrag', 'inProgress'], false)
// setTimeout(function() {
console.log('something cray: ');
tree.set(['editorDrag', 'inProgress'], false)
// }, 0);
}
41 changes: 22 additions & 19 deletions app/cerebral/actions/handleEditorDragged.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// var trimNumberToFitWithin0ToAnotherNumber = require('ve-range-utils/trimNumberToFitWithin0ToAnotherNumber');
// var normalizePositionByRangeLength = require('ve-range-utils/normalizePositionByRangeLength');
var normalizePositionByRangeLength = require('ve-range-utils/normalizePositionByRangeLength');
var getRangeLength = require('ve-range-utils/getRangeLength');
// var ac = require('ve-api-check');
export default function handleEditorDragged({
nearestBP,
Expand All @@ -10,38 +11,40 @@ export default function handleEditorDragged({
}, editorDrag: {fixedCaretPositionOnDragStart, fixedCaretPositionOnDragStartType}
} = tree.get();
tree.set(['editorDrag', 'inProgress'], true)
if (nearestBP === fixedCaretPositionOnDragStart) {
if (nearestBP === fixedCaretPositionOnDragStart && (!selectionLayer.selected || selectionLayer.start < selectionLayer.end)) {
output.caretMoved({
caretPosition: fixedCaretPositionOnDragStart
});
} else {
var newSelectionLayer;
if (fixedCaretPositionOnDragStartType === 'start') {
if (fixedCaretPositionOnDragStartType === 'start' && circular) {
newSelectionLayer = {
start: fixedCaretPositionOnDragStart,
end: nearestBP - 1,
end: normalizePositionByRangeLength(nearestBP - 1, sequenceLength, true),
cursorAtEnd: true,
};
} else if (fixedCaretPositionOnDragStartType === 'end') {
} else if (fixedCaretPositionOnDragStartType === 'end' && circular) {
newSelectionLayer = {
start: nearestBP,
end: fixedCaretPositionOnDragStart - 1,
end: normalizePositionByRangeLength(fixedCaretPositionOnDragStart - 1, sequenceLength, true),
cursorAtEnd: false,
};
} else {
if (nearestBP > fixedCaretPositionOnDragStart) {
newSelectionLayer = {
start: fixedCaretPositionOnDragStart,
end: nearestBP - 1,
cursorAtEnd: true,
};
} else {
newSelectionLayer = {
start: nearestBP,
end: fixedCaretPositionOnDragStart - 1,
cursorAtEnd: false,
};
}
if (nearestBP > fixedCaretPositionOnDragStart) {
newSelectionLayer = {
start: fixedCaretPositionOnDragStart,
end: nearestBP - 1,
cursorAtEnd: true,
};
tree.set(['editorDrag', 'fixedCaretPositionOnDragStartType'], 'start')
} else {
newSelectionLayer = {
start: nearestBP,
end: fixedCaretPositionOnDragStart - 1,
cursorAtEnd: false,
};
tree.set(['editorDrag', 'fixedCaretPositionOnDragStartType'], 'end')
}
}
output.selectionUpdated({
selectionLayer: newSelectionLayer
Expand Down
23 changes: 8 additions & 15 deletions app/cerebral/actions/prepDeleteOneBack.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
export default function prepSelectionLayer (numberToMove, cursorAtEnd) {
return function prepSelectionLayer({caretPosition, selectionLayer}, tree, output) {
if (caretPosition > 0) {
output({
selectionLayer: {
start: caretPosition - 1,
end: caretPosition - 1,
cursorAtEnd: cursorAtEnd,
}
});
} else {
throw new Error('no caret or selection layer to delete!');
}
}
}
var normalizePositionByRangeLength = require('ve-range-utils/normalizePositionByRangeLength');
var setSelectionLayer = require('./setSelectionLayer');

export default function prepSelectionLayer(input, tree, output) {
var {caretPosition, sequenceLength} = tree.get();
var normedCaretPosition = normalizePositionByRangeLength(caretPosition -1, sequenceLength, true);

setSelectionLayer({selectionLayer: {'start': normedCaretPosition, 'end': normedCaretPosition}}, tree);
}
9 changes: 3 additions & 6 deletions app/cerebral/actions/selectInverse.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
var invertCircularRange = require('ve-range-utils/invertCircularRange');
export default function selectInverse(input, tree, output) {
//compare the sequenceString being pasted in with what's already stored in the clipboard
var selectionLayer = tree.get(['selectionLayer']);

var {selectionLayer, sequenceLength} = tree.get();
output({
selectionLayer: {
start: selectionLayer.end,
end: selectionLayer.start - 1
}
selectionLayer: invertCircularRange(selectionLayer, sequenceLength)
});
}
8 changes: 0 additions & 8 deletions app/cerebral/actions/setEditState.js

This file was deleted.

8 changes: 4 additions & 4 deletions app/cerebral/actions/updateSelectionShiftClick.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
var expandOrContractNonCircularRangeToPosition = require('ve-range-utils/expandOrContractNonCircularRangeToPosition');
var expandOrContractCircularRangeToPosition = require('ve-range-utils/expandOrContractCircularRangeToPosition');
var ac = require('ve-api-check');
export default function updateSelectionShiftClick({updatedCaretPos, sequenceLength, caretPosition, selectionLayer}, tree, output) {
if (selectionLayer.start > selectionLayer.end) {
var {newRange, endMoved} = expandOrContractCircularRangeToPosition(selectionLayer, updatedCaretPos, sequenceLength);
export default function updateSelectionShiftClick({nearestBP, sequenceLength, caretPosition, selectionLayer}, tree, output) {
if (true || selectionLayer.start > selectionLayer.end) {
var {newRange, endMoved} = expandOrContractCircularRangeToPosition(selectionLayer, nearestBP, sequenceLength);
newRange.cursorAtEnd = endMoved;
output({selectionLayer: newRange})
} else {
/*eslint-disable no-redeclare*/
var {newRange, endMoved} = expandOrContractNonCircularRangeToPosition(selectionLayer, updatedCaretPos);
var {newRange, endMoved} = expandOrContractNonCircularRangeToPosition(selectionLayer, nearestBP);
/*eslint-enable no-redeclare*/
newRange.cursorAtEnd = endMoved;
output({selectionLayer: newRange})
Expand Down
Loading