iTwin / appui

Monorepo for iTwin.js AppUi
MIT License
8 stars 2 forks source link

Allow to enable multiple snaps + Choose what snap are available. #954

Closed mathieu-fournier closed 2 months ago

mathieu-fournier commented 2 months ago

Changes

Multi snaps

We are now able to activate multiple snap modes simultaneousely. We can see in the picture that, when multiple modes are active at the same time, we have multiple possible snaps location depending ont he cursor position. image

Snap modes choices

The consuming app can now choose what snap modes are available in their app. Ex, Bisector option has been filtered out. image

Testing

2 unit tests are added to check the functionnality.

Usage

// Remove Bisector from the modes available.
const snapModes = Object.values(SnapMode).filter(snapMode => snapMode !== SnapMode.Bisector) as SnapMode[];

// Register a status bar item that has the custom snap modes. 
UiItemsManager.register({
    id: "customStatusBarSnapModes",
    getStatusBarItems: () => [
        StatusBarItemUtilities.createCustomItem({
            id: "booster.SnapMode",
            section: StatusBarSection.Center,
            content: <SnapModeField snapModes={snapModes} />
        })
    ]
})
mathieu-fournier commented 2 months ago

In the light of the discussion, this PR will be splitted into 2. 1 - Allow to control what snaps are available. #974 2 - Set multisnap has the default behaviour <- breaking change for the next major version.