-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(react-components): Add segmented buttons to the architecture (#4781
- Loading branch information
1 parent
1dc99ca
commit 3a5a270
Showing
14 changed files
with
233 additions
and
32 deletions.
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
43 changes: 43 additions & 0 deletions
43
react-components/src/architecture/base/concreteCommands/SetOrbitOrFirstPersonModeCommand.ts
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,43 @@ | ||
/*! | ||
* Copyright 2024 Cognite AS | ||
*/ | ||
|
||
import { type RevealRenderTarget } from '../renderTarget/RevealRenderTarget'; | ||
import { FlexibleControlsType } from '@cognite/reveal'; | ||
import { type TranslateKey } from '../utilities/TranslateKey'; | ||
import { BaseOptionCommand, OptionType } from '../commands/BaseOptionCommand'; | ||
import { SetFlexibleControlsTypeCommand } from './SetFlexibleControlsTypeCommand'; | ||
|
||
export class SetOrbitOrFirstPersonModeCommand extends BaseOptionCommand { | ||
// ================================================== | ||
// CONSTRUCTOR | ||
// ================================================== | ||
|
||
public constructor() { | ||
super(OptionType.Segmented); | ||
this.add(new SetFlexibleControlsTypeCommand(FlexibleControlsType.Orbit, false)); | ||
this.add(new SetFlexibleControlsTypeCommand(FlexibleControlsType.FirstPerson, false)); | ||
} | ||
|
||
// ================================================== | ||
// OVERRIDES | ||
// ================================================== | ||
|
||
public override get tooltip(): TranslateKey { | ||
return { key: 'CONTROLS_TYPE_TOOLTIP', fallback: 'Set Camera to Orbit or Fly mode' }; | ||
} | ||
|
||
public override attach(renderTarget: RevealRenderTarget): void { | ||
super.attach(renderTarget); | ||
const { flexibleCameraManager } = renderTarget; | ||
flexibleCameraManager.addControlsTypeChangeListener(this._controlsTypeChangeHandler); | ||
} | ||
|
||
// ================================================== | ||
// INSTANCE METHODS | ||
// ================================================== | ||
|
||
private readonly _controlsTypeChangeHandler = (_newControlsType: FlexibleControlsType): void => { | ||
this.update(); | ||
}; | ||
} |
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
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.