GUIAdapter.ts 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import { PropertyLine } from "../details/PropertyLine";
  2. import { Helpers } from "../helpers/Helpers";
  3. import { AbstractTreeTool } from "../treetools/AbstractTreeTool";
  4. import { Checkbox, IToolVisible } from "../treetools/Checkbox";
  5. import { Adapter } from "./Adapter";
  6. import { Control } from "babylonjs-gui";
  7. export class GUIAdapter
  8. extends Adapter
  9. implements IToolVisible {
  10. constructor(obj: Control) {
  11. super(obj);
  12. }
  13. /** Returns the name displayed in the tree */
  14. public id(): string {
  15. let str = '';
  16. if (this._obj.name) {
  17. str = this._obj.name;
  18. } // otherwise nothing displayed
  19. return str;
  20. }
  21. /** Returns the type of this object - displayed in the tree */
  22. public type(): string {
  23. return Helpers.GET_TYPE(this._obj);
  24. }
  25. /** Returns the list of properties to be displayed for this adapter */
  26. public getProperties(): Array<PropertyLine> {
  27. return Helpers.GetAllLinesProperties(this._obj);
  28. }
  29. public getTools(): Array<AbstractTreeTool> {
  30. let tools = [];
  31. tools.push(new Checkbox(this));
  32. return tools;
  33. }
  34. public setVisible(b: boolean) {
  35. (this._obj as Control).isVisible = b;
  36. }
  37. public isVisible(): boolean {
  38. return (this._obj as Control).isVisible;
  39. }
  40. }