context.ts 916 B

123456789101112131415161718192021222324252627282930313233
  1. /**
  2. * Copyright (c) 2021 mol* contributors, licensed under MIT, See LICENSE file for more info.
  3. *
  4. * @author David Sehnal <david.sehnal@gmail.com>
  5. */
  6. import { PluginContext } from '../mol-plugin/context';
  7. import { PluginUISpec } from './spec';
  8. import { StateTransformParameters } from './state/common';
  9. export class PluginUIContext extends PluginContext {
  10. readonly customParamEditors = new Map<string, StateTransformParameters.Class>();
  11. private initCustomParamEditors() {
  12. if (!this.spec.customParamEditors) return;
  13. for (const [t, e] of this.spec.customParamEditors) {
  14. this.customParamEditors.set(t.id, e);
  15. }
  16. }
  17. dispose(options?: { doNotForceWebGLContextLoss?: boolean }) {
  18. super.dispose(options);
  19. this.layout.dispose();
  20. }
  21. constructor(public spec: PluginUISpec) {
  22. super(spec);
  23. this.initCustomParamEditors();
  24. }
  25. }