Skip to content
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

fix: toolGroup default cursor #120

Merged
merged 2 commits into from
Jun 1, 2022
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
10 changes: 7 additions & 3 deletions packages/core/src/cache/cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,6 @@ class Cache implements ICache {
* @fires Events.IMAGE_CACHE_IMAGE_REMOVED
* @fires Events.VOLUME_CACHE_VOLUME_REMOVED
*
* @param numBytes - number of bytes
*
* @returns available number of bytes
*/
public purgeCache = (): void => {
const imageIterator = this._imageCache.keys();
Expand All @@ -167,6 +164,13 @@ class Cache implements ICache {
triggerEvent(eventTarget, Events.IMAGE_CACHE_IMAGE_REMOVED, { imageId });
}

this.purgeVolumeCache();
};

/**
* Deletes all the volumes in the cache
*/
public purgeVolumeCache = (): void => {
const volumeIterator = this._volumeCache.keys();

/* eslint-disable no-constant-condition */
Expand Down
17 changes: 13 additions & 4 deletions packages/tools/src/store/ToolGroupManager/ToolGroup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,11 +218,14 @@ export default class ToolGroup implements IToolGroup {

// reset the mouse cursor if tool has left click binding
const runtimeSettings = Settings.getRuntimeSettings();
if (
this._hasMousePrimaryButtonBinding(toolBindingsOptions) &&
runtimeSettings.get('useCursors')
) {
const useCursor = runtimeSettings.get('useCursors');

if (this._hasMousePrimaryButtonBinding(toolBindingsOptions) && useCursor) {
this.setViewportsCursorByToolName(toolName);
} else {
// reset to default cursor
const cursor = MouseCursor.getDefinedCursor('default');
this._setCursorForViewports(cursor);
}

if (typeof this._toolInstances[toolName].onSetToolActive === 'function') {
Expand Down Expand Up @@ -379,9 +382,15 @@ export default class ToolGroup implements IToolGroup {
setViewportsCursorByToolName(toolName: string, strategyName?: string): void {
const cursorName = strategyName ? `${toolName}.${strategyName}` : toolName;
let cursor = SVGMouseCursor.getDefinedCursor(cursorName, true);

if (!cursor) {
cursor = MouseCursor.getDefinedCursor('default');
}

this._setCursorForViewports(cursor);
}

_setCursorForViewports(cursor: MouseCursor): void {
this.viewportsInfo.forEach(({ renderingEngineId, viewportId }) => {
const viewport =
getRenderingEngine(renderingEngineId).getViewport(viewportId);
Expand Down