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

Allow to switch to fill or pick segment tool when eraser is active #8314

Merged
merged 6 commits into from
Jan 9, 2025

Conversation

philippotto
Copy link
Member

@philippotto philippotto commented Jan 9, 2025

This contributes to the #8078 as it allows to fill a segment quickly from within the eraser tool (by holding ctrl+shift). Concretely, one can erase cell membranes and then fill one half of the segment with the fill tool while having minimum overhead for tool switching. Alternatively, one would need to move the mouse to the toolbar twice (for switching back and forth) or one would need to use the context menu (which also means two clicks).
To keep things consistent with the other tools, I also added that the shift modifier switches to the pick-segment tool.

URL of deployed dev instance (used for testing):

  • https://___.webknossos.xyz

Steps to test:

  • use the eraser normally
  • hold shift --> should switch to the pick segment tool
  • hold ctrl + shift --> should switch to the fill segment tool

Issues:


(Please delete unneeded items, merge only when none are left open)

@philippotto philippotto self-assigned this Jan 9, 2025
Copy link
Contributor

coderabbitai bot commented Jan 9, 2025

📝 Walkthrough

Walkthrough

The pull request introduces modifications to the tool control and interaction mechanisms in the frontend. Changes primarily focus on enhancing the behavior of the erase tool and flood fill functionality by adding more nuanced handling of mouse events and keyboard modifier keys. The modifications span multiple files, updating method signatures, adding new methods, and refining the logic for tool adaptations based on user input states like Shift, Control, and Meta keys.

Changes

File Change Summary
frontend/javascripts/oxalis/controller/combinations/tool_controls.ts - Updated leftMouseDown method signature to include MouseEvent
- Added new leftClick method with modifier key handling
frontend/javascripts/oxalis/model/accessors/tool_accessor.ts - Renamed isControlPressed parameter to isControlOrMetaPressed
- Refined tool adaptation logic for keyboard shortcuts
frontend/javascripts/oxalis/model/sagas/volume/floodfill_saga.tsx - Added import for getDisabledInfoForTools
- Enhanced flood fill validation with tool disability check
frontend/javascripts/oxalis/view/input_catcher.tsx - Renamed isControlPressed to isControlOrMetaPressed
- Improved readability of function call
frontend/javascripts/theme.tsx - Added new constant lightGlobalToken for light themes
- Updated nodeSelectedBg property for light theme
CHANGELOG.unreleased.md - Added feature for switching tools with modifier keys

Possibly related PRs

Suggested labels

bug, frontend, documentation

Suggested reviewers

  • daniel-wer
  • MichaelBuessemeyer

Poem

🐰 In the land of code where rabbits play,
Tools now dance in a new ballet,
Shift and Control, a magical blend,
With every click, the rules amend,
A whimsical world where inputs sway! 🖱️


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d093b8f and 5ad3297.

📒 Files selected for processing (4)
  • CHANGELOG.unreleased.md (1 hunks)
  • frontend/javascripts/oxalis/controller/combinations/tool_controls.ts (1 hunks)
  • frontend/javascripts/oxalis/model/accessors/tool_accessor.ts (1 hunks)
  • frontend/javascripts/oxalis/model/sagas/volume/floodfill_saga.tsx (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (4)
  • CHANGELOG.unreleased.md
  • frontend/javascripts/oxalis/model/sagas/volume/floodfill_saga.tsx
  • frontend/javascripts/oxalis/controller/combinations/tool_controls.ts
  • frontend/javascripts/oxalis/model/accessors/tool_accessor.ts
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: circleci_build

Finishing Touches

  • 📝 Generate Docstrings

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
frontend/javascripts/oxalis/model/accessors/tool_accessor.ts (1)

353-354: LGTM! Consider adding JSDoc comments.

The parameter rename from isControlPressed to isControlOrMetaPressed improves cross-platform compatibility. Consider adding JSDoc comments to document the parameters and their usage.

/**
 * Adapts the active tool based on keyboard shortcuts.
 * @param activeTool - The currently active annotation tool
 * @param isShiftPressed - Whether the Shift key is pressed
 * @param isControlOrMetaPressed - Whether the Control key (Windows/Linux) or Command key (Mac) is pressed
 * @param isAltPressed - Whether the Alt/Option key is pressed
 * @returns The adapted annotation tool based on the pressed modifier keys
 */

Also applies to: 356-356

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 97ce494 and 733f202.

📒 Files selected for processing (4)
  • frontend/javascripts/oxalis/controller/combinations/tool_controls.ts (1 hunks)
  • frontend/javascripts/oxalis/model/accessors/tool_accessor.ts (1 hunks)
  • frontend/javascripts/oxalis/model/sagas/volume/floodfill_saga.tsx (3 hunks)
  • frontend/javascripts/oxalis/view/input_catcher.tsx (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: circleci_build
🔇 Additional comments (7)
frontend/javascripts/oxalis/model/accessors/tool_accessor.ts (2)

370-380: LGTM! Clear and concise logic for erase tool adaptations.

The conditional block for ERASE_BRUSH and ERASE_TRACE tools is well-structured and handles the tool adaptations based on modifier keys appropriately.


392-402: LGTM! Consistent handling of modifier keys.

The logic for handling Shift and Control/Meta keys is consistent with the tool adaptation patterns used throughout the codebase.

frontend/javascripts/oxalis/controller/combinations/tool_controls.ts (2)

500-504: LGTM! Improved modifier key handling.

The leftMouseDown method now correctly prevents erasing when modifier keys are pressed, allowing for other actions to be triggered instead.


510-519: LGTM! Well-structured tool switching logic.

The leftClick method implements a clear hierarchy of tool actions:

  • Shift + Control/Meta → Flood fill
  • Shift only → Pick cell
frontend/javascripts/oxalis/model/sagas/volume/floodfill_saga.tsx (2)

13-13: LGTM! Added necessary imports.

The imports are correctly organized and include the new getDisabledInfoForTools function.

Also applies to: 35-35


121-123: LGTM! Added safety check for disabled tools.

The code now correctly checks if the fill cell tool is disabled before proceeding with the flood fill operation.

frontend/javascripts/oxalis/view/input_catcher.tsx (1)

143-143: LGTM! Consistent handling of Control/Meta keys.

The changes maintain consistency with the tool accessor updates:

  1. Variable renamed to reflect both Control and Meta key support
  2. Function call updated with proper parameter ordering

Also applies to: 151-156

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
CHANGELOG.unreleased.md (1)

20-20: Enhance the changelog entry for clarity.

The entry correctly describes the new feature, but could be more explicit about the temporary nature and workflow benefits.

Consider this improved wording:

-When the eraser tool is active, one can switch temporarily to the fill-segment tool by pressing shift and ctrl. Only pressing shift, switches to the pick-segment tool. [#8314](https://github.com/scalableminds/webknossos/pull/8314)
+When the eraser tool is active, holding shift+ctrl temporarily switches to the fill-segment tool, while holding shift alone switches to the pick-segment tool. This improves workflow efficiency by reducing tool switching overhead. [#8314](https://github.com/scalableminds/webknossos/pull/8314)
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a463047 and d093b8f.

📒 Files selected for processing (1)
  • CHANGELOG.unreleased.md (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: circleci_build

Copy link
Contributor

@MichaelBuessemeyer MichaelBuessemeyer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this improvement 🎉

Code looks good and works as described 🦕

@philippotto philippotto merged commit 466ce63 into master Jan 9, 2025
3 checks passed
@philippotto philippotto deleted the eraser-to-floodfill-modifier branch January 9, 2025 14:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants