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

ui(components): Adds ToolButton core components and toolbar updates #4728

Open
wants to merge 17 commits into
base: master
Choose a base branch
from

Conversation

dan-rukas
Copy link
Member

Context

  • Introduces Three New Core Components: Adds ToolButton, ToolButtonSmall, and ToolButtonList in ui-next for single‐tool and “split button” functionality within the OHIF toolbar and smaller tools in panels.
  • Toolbar Integration: Updates existing toolbar configuration for new components, fully integrating them with the global ToolbarService logic.
  • Layout Components: Uses new ui-next components for new OHIFToolSettings to replace legacy Inputs, Sliders, and text in Segmentation Tool options
  • Tool Behaviors and Active States: Moved all active‐tool state to the global toolbarService. Design styles are located in new ToolButton components. The panel and main toolbar no longer track separate active states, eliminating the “stuck” tool issue. Separated “which tool is active” (controlled by toolbarService) from “tool configuration” (stored in useToolbox).

Changes & Results

ui-next: new ToolButton core components

  • ToolButton (new component) - Handles single-tool activation with a tooltip and icon.
    • Uses Button and Tooltip from ui-next
    • replaces legacy ToolbarButton (in legacy ui library)
  • ToolButtonList (new component) - ToolButton with secondary tools.
    • Uses ToolButton and Dropdown from ui-next
    • replaces legacy SplitButton (in legacy ui library)
  • ToolButtonSmall (new component) - Grouped and Single Tool Buttons for panel use.
    • Uses ToolButton from ui-next
    • replaces legacy ButtonGroup (in legacy ui library)

ui-next: OHIFToolSettings component group

  • RowInputRange (new component) - Uses Slider, Input, Label from ui-next
    • Replaces legacy InputRange (no legacy code)
  • RowSegmentedControl (new component) - Uses Label and Tabs from ui-next
  • RowDoubleRange (new component) - Uses DoubleSlider from ui-next
    • Replaces legacy InputDoubleRange

ui-next: OHIFToolbox changes

  • Toolbox - Changes:
    • Subscribed to toolbarService events to detect when the globally active tool changes. Ensures that when the user selects a different tool in the main toolbar, the panel sees that change and updates its local “activeTool” if necessary.
    • When a panel tool button is clicked (handleToolSelect), it now calls commandsManager.runCommand('setToolActiveToolbar', { toolName: id }). This sets the active tool globally for the entire application, rather than only locally in the panel. It keeps the panel and main toolbar in sync.
    • Moved the logic for initializing tool options in the panel into a useEffect that runs whenever toolbar buttons or local tool options change. Ensures that each tool’s “advanced settings” (like range sliders) in the panel are properly merged/initialized with the global tool definitions.
  • ToolboxUI - Changes:
    • Removed local checks like const isActive = activeTool === id; and replaced them with toolDef.isActive. Now relies on the global toolbarService to flag whether a tool is active, allowing the panel to match the main toolbar’s state.
    • Bugfix: Some TypeScript/Babel configurations don’t parse <>...</> with inline comments. Using <React.Fragment> fixes those build errors.

App file changes

  • getToolbarModule.ts (and similar “evaluate” modules) - Confirmed that evaluate functions properly return isActive: true for whichever tool is primary in a given viewport.
    • The toolbarService calls these “evaluate” functions to mark tools as disabled or active. The panel’s buttons now display correctly since they read the same isActive that is set here.
    • No significant code modifications were necessary if evaluate was already returning the correct isActive states. We only ensured that these modules align with the global “active tool” logic. Main toolbar and panel buttons see the same final “active” or “disabled” states.
  • segmentationButtons.ts
    • Replaced radioGroup legacy button to work with buttonGroup.

Testing

New Toolbar components are currently working in Basic Viewer and Segmenation modes (tested in Chrome)

Checklist

PR

  • [✅] My Pull Request title is descriptive, accurate and follows the
    semantic-release format and guidelines.

Code

  • [✅] My code has been well-documented (function documentation, inline comments,
    etc.)

Public Documentation Updates

  • [✅] The documentation page has been updated as necessary for any public API
    additions or removals.

Tested Environment

  • [✅] OS: macOS Sequoia 15.2, M4 Pro
  • [✅] Node version: v23.5.0
  • [✅] Browser: Chrome 131.0.6778.205 (Official Build) (arm64)

Copy link

netlify bot commented Jan 23, 2025

Deploy Preview for ohif-dev ready!

Name Link
🔨 Latest commit f116fc6
🔍 Latest deploy log https://app.netlify.com/sites/ohif-dev/deploys/6793ddbe0715440008653237
😎 Deploy Preview https://deploy-preview-4728--ohif-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Jan 23, 2025

Deploy Preview for ohif-platform-docs failed. Why did it fail? →

Name Link
🔨 Latest commit f116fc6
🔍 Latest deploy log https://app.netlify.com/sites/ohif-platform-docs/deploys/6793ddbe12a711000863446d

@dan-rukas
Copy link
Member Author

See previous pull request for additional commit history for all these changes. All working updates are included in this latest PR. This is only for additional history context: #4670

dan-rukas and others added 6 commits January 23, 2025 12:06
…roup, update toolbar button group references, and improve disabled state styling. Cleaned up imports and removed legacy components for better maintainability.
…etter dropdown item separation, refactored interaction handling in ToolButtonListWrapper, and updated imports across the platform. Improved accessibility by ensuring missing icons are handled gracefully.

fixed disabled button and tooltip

Enhance UI components: Added className support to ToolButtonListWrapper, updated icon styles in TrackedCornerstoneViewport and Thumbnail, and adjusted dimensions for ToolWindowRegion icon. Improved toolbar button organization by uncommenting relevant tools in longitudinal mode.

Refactor toolbar components: Introduced size support for ToolButton, updated ToolbarButtonGroupWithServices to utilize new ToolButton, and removed the obsolete ToolButtonGroup component. Enhanced toolbar organization by adjusting component imports and ensuring legacy components are clearly marked. Improved overall maintainability and consistency in button styling.

wip

Implement ToolboxProvider and useToolbox hook: Added a new context for managing toolbox state and actions, enabling better organization of toolbar tools and options. Updated relevant imports across the application to integrate the new toolbox functionality.

Refactor Toolbox imports: Updated Toolbox imports across multiple extensions to use '@ohif/extension-default' instead of '@ohif/ui-next'. Introduced a new Toolbox component in the default extension for better organization and functionality. Cleaned up unused Toolbox references in the UI components.

Refactor toolbar components: Introduced ToolButtonGroupWrapper for enhanced button grouping functionality, updated legacy toolbar component imports to their new counterparts, and adjusted toolbar button section creation in segmentation mode. Improved organization and maintainability of toolbar components.

Refactor toolbar components: Removed legacy className properties and introduced new ToolBox components for better organization. Updated toolbar button evaluation logic to enhance functionality and maintainability. Cleaned up unused imports and improved button state handling across multiple extensions.

Refactor toolbarButtons: Removed unused buttons (Probe, Angle, RectangleROI, CalibrationLine) to streamline the toolbar. This cleanup enhances maintainability and focuses on essential tools for segmentation mode.
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