controls.tsx 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /**
  2. * Copyright (c) 2019-2020 mol* contributors, licensed under MIT, See LICENSE file for more info.
  3. *
  4. * @author Alexander Rose <alexander.rose@weirdbyte.de>
  5. */
  6. import * as React from 'react';
  7. import { PluginUIComponent } from 'molstar/lib/mol-plugin-ui/base';
  8. import { ViewerState } from '../types';
  9. import { CustomStructureControls } from 'molstar/lib/mol-plugin-ui/controls';
  10. import { ImportControls } from './import';
  11. import { StructureSourceControls } from 'molstar/lib/mol-plugin-ui/structure/source';
  12. import { StructureMeasurementsControls } from 'molstar/lib/mol-plugin-ui/structure/measurements';
  13. import { StructureSuperpositionControls } from 'molstar/lib/mol-plugin-ui/structure/superposition';
  14. import { StructureComponentControls } from 'molstar/lib/mol-plugin-ui/structure/components';
  15. import { VolumeStreamingControls } from 'molstar/lib/mol-plugin-ui/structure/volume';
  16. import { SessionControls } from './session';
  17. export class StructureTools extends PluginUIComponent {
  18. get customState() {
  19. return ViewerState(this.plugin);
  20. }
  21. componentDidMount() {
  22. this.subscribe(this.customState.collapsed, () => this.forceUpdate());
  23. }
  24. render() {
  25. const collapsed = this.customState.collapsed.value;
  26. return <>
  27. <StructureSourceControls />
  28. <StructureMeasurementsControls initiallyCollapsed={collapsed.measurements} />
  29. <StructureSuperpositionControls initiallyCollapsed={collapsed.superposition} />
  30. <StructureComponentControls initiallyCollapsed={collapsed.component} />
  31. <VolumeStreamingControls header='Density' initiallyCollapsed={collapsed.volume} />
  32. <CustomStructureControls initiallyCollapsed={collapsed.custom} />
  33. </>;
  34. }
  35. }
  36. export class ControlsWrapper extends PluginUIComponent {
  37. render() {
  38. return <div className='msp-scrollable-container'>
  39. {ViewerState(this.plugin).showImportControls && <ImportControls />}
  40. {ViewerState(this.plugin).showSessionControls && <SessionControls />}
  41. <StructureTools />
  42. </div>;
  43. }
  44. }