Browse Source

allow animation button to be hidden

Alexander Rose 5 years ago
parent
commit
27ebbc50d5

+ 3 - 0
src/mol-plugin-state/manager/animation.ts

@@ -44,6 +44,7 @@ class PluginAnimationManager extends StatefulPluginComponent<PluginAnimationMana
     }
 
     updateParams(newParams: Partial<PluginAnimationManager.State['params']>) {
+        if (this.isEmpty) return;
         this.updateState({ params: { ...this.state.params, ...newParams } });
         const anim = this.map.get(this.state.params.current)!;
         const params = anim.params(this.context) as PD.Params;
@@ -59,6 +60,7 @@ class PluginAnimationManager extends StatefulPluginComponent<PluginAnimationMana
     }
 
     updateCurrentParams(values: any) {
+        if (this.isEmpty) return;
         this._current.paramValues = { ...this._current.paramValues, ...values };
         this.triggerUpdate();
     }
@@ -163,6 +165,7 @@ class PluginAnimationManager extends StatefulPluginComponent<PluginAnimationMana
     }
 
     setSnapshot(snapshot: PluginAnimationManager.Snapshot) {
+        if (this.isEmpty) return;
         this.updateState({ animationState: snapshot.state.animationState });
         this.updateParams(snapshot.state.params);
 

+ 2 - 2
src/mol-plugin-ui/controls.tsx

@@ -29,6 +29,7 @@ import { StructureMeasurementsControls } from './structure/measurements';
 import { StructureSelectionActionsControls } from './structure/selection';
 import { StructureSourceControls } from './structure/source';
 import { VolumeStreamingControls, VolumeSourceControls } from './structure/volume';
+import { PluginConfig } from '../mol-plugin/config';
 
 export class TrajectoryViewportControls extends PluginUIComponent<{}, { show: boolean, label: string }> {
     state = { show: false, label: '' }
@@ -219,9 +220,8 @@ export class AnimationViewportControls extends PluginUIComponent<{}, { isEmpty:
     }
 
     render() {
-        // if (!this.state.show) return null;
         const isPlaying = this.plugin.managers.snapshot.state.isPlaying;
-        if (isPlaying || this.state.isEmpty) return null;
+        if (isPlaying || this.state.isEmpty || this.plugin.managers.animation.isEmpty || !this.plugin.config.get(PluginConfig.Viewport.ShowAnimation)) return null;
 
         const isAnimating = this.state.isAnimating;
 

+ 2 - 1
src/mol-plugin/config.ts

@@ -34,7 +34,8 @@ export const PluginConfig = {
     },
     Viewport: {
         ShowExpand: item('viewer.show-expand-button', true),
-        ShowSelectionMode: item('viewer.show-selection-model-button', true)
+        ShowSelectionMode: item('viewer.show-selection-model-button', true),
+        ShowAnimation: item('viewer.show-animation-button', true),
     }
 };