New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New Toolbar #4875
Merged
Merged
New Toolbar #4875
Changes from 39 commits
Commits
Show all changes
40 commits
Select commit
Hold shift + click to select a range
26fed28
implement some small performance improvements
philippotto 397d7ae
implement further small perf improvements
philippotto 827c325
fix linting
philippotto 8768955
avoid Three.Vector3 creation, vector unpacking etc. for position updates
philippotto bc48ce5
avoid some THREE.Vector3 instantiations and redundant set of scale
philippotto 222dd93
fix linting
philippotto 9d456be
only set position in updateCameraForScene
philippotto 4904611
use nanoEvents for buckets instead of backbone events
philippotto 2552407
avoid array allocation in TextureBucketManager
philippotto 89b1e2a
fix test
philippotto bdf71ff
rework toolbar: use icons for tools; show current cell id in navbar
philippotto 9dc4949
reflect modifier change directly in toolbar
philippotto 6b31b81
temporarily disable most CI checks
philippotto 25012b1
work on dynamic overwrite-mode in UI
philippotto 29d4811
refactor overwrite-cell mechanism
philippotto 55f53c8
fix tests
philippotto d21adea
fix test and restore CI
philippotto d6ed58d
Merge branch 'master' of github.com:scalableminds/webknossos into new…
philippotto 694822e
fix broken merge and some padding
philippotto d3fa9bc
fix useEffect toggle bug; also adapt active tool when pressing Alt
philippotto b2bb088
improve tooltips for tools and fix CSS issues with borders on hover
philippotto a28726c
move hooks into own module
philippotto f5fcac7
also show tooltips when pressing modifiers in move-tool; fix missing …
philippotto 3714f54
fix that ctrl+right-click always re-centered the current node
philippotto c6687f1
remove unused idle enum
philippotto 56fe4fe
swap brush and trace-tool; make lasso.svg blue via css-filtering when…
philippotto 190f6d5
support dragging the plane via middle-click
philippotto 1361385
update changelog
philippotto 3b59190
only re-render SaveButton if necessary (by explicitly passing progres…
philippotto 3105bb7
fix cycling order of tools; update changelog
philippotto 66cfb7c
Merge branch 'master' into new-toolbar
philippotto 8bb8a6b
Merge branch 'master' of github.com:scalableminds/webknossos into new…
philippotto da92fc2
Apply suggestions from code review
philippotto 50dccd7
Merge branch 'new-toolbar' of github.com:scalableminds/webknossos int…
philippotto 8e80cf2
remove duplicate from changelog
philippotto 3b6faf7
allow middle-drag-movement in all tracing modes; add more comments
philippotto 64b07dc
fix border on hovering disabled radio button
philippotto 06a5448
respect mapping when rendering the current cell color in the new-cell…
philippotto 1b7ff21
workaround modifier-release-bug and adapt merge-tree-message
philippotto 142e5a4
satisfy linter
philippotto File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
// @flow | ||
import { useState, useEffect, useRef } from "react"; | ||
|
||
// Adapted from: https://usehooks.com/usePrevious/ | ||
export function usePrevious<T>(value: T): ?T { | ||
// The ref object is a generic container whose current property is mutable ... | ||
// ... and can hold any value, similar to an instance property on a class | ||
const ref = useRef<?T>(null); | ||
|
||
// Store current value in ref | ||
useEffect(() => { | ||
ref.current = value; | ||
}, [value]); // Only re-run if value changes | ||
|
||
// Return previous value (happens before update in useEffect above) | ||
return ref.current; | ||
} | ||
|
||
const extractModifierState = event => ({ | ||
Shift: event.shiftKey, | ||
Alt: event.altKey, | ||
Control: event.ctrlKey, | ||
}); | ||
|
||
// Adapted from: https://gist.github.com/gragland/b61b8f46114edbcf2a9e4bd5eb9f47f5 | ||
export function useKeyPress(targetKey: string) { | ||
// State for keeping track of whether key is pressed | ||
const [keyPressed, setKeyPressed] = useState(false); | ||
|
||
// If pressed key is our target key then set to true | ||
function downHandler(event) { | ||
const modifierState = extractModifierState(event); | ||
|
||
if (modifierState[targetKey] === undefined) { | ||
// The targetKey is not a modifier. Compare to the pressed key. | ||
if (event.key === targetKey) { | ||
pressKey(); | ||
} | ||
} else { | ||
// Use the modifierState as this seems to be more robust. See | ||
// the other comment below which describes some edge cases | ||
// regarding modifiers. | ||
if (modifierState[targetKey]) { | ||
pressKey(); | ||
} | ||
} | ||
} | ||
|
||
function pressKey() { | ||
setKeyPressed(true); | ||
window.addEventListener("blur", releaseKey); | ||
} | ||
|
||
function releaseKey() { | ||
setKeyPressed(false); | ||
window.removeEventListener("blur", releaseKey); | ||
} | ||
|
||
// If released key is our target key then set to false | ||
const upHandler = event => { | ||
const modifierState = extractModifierState(event); | ||
|
||
if (modifierState[targetKey] === undefined) { | ||
// The targetKey is not a modifier. Compare to the pressed key. | ||
if (event.key === targetKey) { | ||
releaseKey(); | ||
} | ||
} else { | ||
// The targetKey is a modifier. Use the modifierState as this | ||
// is more robust against pressing multiple modifiers. For example, | ||
// on Linux, pressing Shift and then toggling Alt, will send a release | ||
// of the Meta key even though that key was never touched. | ||
if (!modifierState[targetKey]) { | ||
releaseKey(); | ||
} | ||
} | ||
}; | ||
|
||
// Add event listeners | ||
useEffect(() => { | ||
window.addEventListener("keydown", downHandler); | ||
window.addEventListener("keyup", upHandler); | ||
// Remove event listeners on cleanup | ||
return () => { | ||
window.removeEventListener("keydown", downHandler); | ||
window.removeEventListener("keyup", upHandler); | ||
}; | ||
}, []); // Empty array ensures that effect is only run on mount and unmount | ||
|
||
return keyPressed; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As this is a breaking change (line 28), we should make sure to communicate it properly during release (and highlight volume undo again, maybe :))