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

feat(annotations): Toggle region annotation mode #1192

Merged
merged 7 commits into from
Apr 2, 2020

Conversation

mxiao6
Copy link
Contributor

@mxiao6 mxiao6 commented Apr 1, 2020

No description provided.

@mxiao6 mxiao6 requested a review from a team as a code owner April 1, 2020 21:07
src/lib/AnnotationControls.ts Outdated Show resolved Hide resolved
src/lib/AnnotationControls.ts Outdated Show resolved Hide resolved
src/lib/AnnotationControls.ts Outdated Show resolved Hide resolved
return;
}

switch (this.currentActiveControl) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if the switch is needed at all. Should it just blindly run through all the update*Button methods each time? For instance if the click region and then click highlight, we would need region and highlight to update respectively

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wonder if the switch is needed at all. Should it just blindly run through all the update*Button methods each time? For instance if the click region and then click highlight, we would need region and highlight to update respectively

This is deactivateCurrentControl(), which only deactivate the current control. Update next control will happen in handle*Click.

src/lib/AnnotationControls.ts Outdated Show resolved Hide resolved
* Region comment button click handler
*/
private handleRegionClick = (onRegionClick: RegionHandler) => (event: MouseEvent): void => {
const activeControl = this.currentActiveControl;
Copy link
Contributor

Choose a reason for hiding this comment

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

The call to this.deactivateCurrentControl() seems unnecessary. It seems like this method's responsibility should be (and all handle([Region|Highlight|Draw])Click for that matter):

  • update currentActiveControl
  • update all buttons states accordingly
  • callback to Viewer with the type toggled

so maybe something like this

this.currentActiveControl = this.currentActiveControl === 'region' ? 'none' : 'region';
this.controlsMap.keys().forEach(updateButton => updateButton());
onModeClick('region');

Thoughts?

src/lib/AnnotationControls.ts Outdated Show resolved Hide resolved
src/lib/AnnotationControls.ts Outdated Show resolved Hide resolved
@@ -93,16 +95,16 @@ export default class AnnotationControls {
private handleFullscreenExit = (): void => this.handleFullscreenChange(false);

/**
* Deactive current control button
* Deactivate current control button
Copy link
Contributor

Choose a reason for hiding this comment

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

Update method description?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Update method description?

I think it's the same meaning 😂

@mxiao6 mxiao6 merged commit a0c0827 into box:master Apr 2, 2020
@mxiao6 mxiao6 deleted the toggle-mode branch April 2, 2020 21:23
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.

3 participants