PropertyLine.d.ts 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. declare module INSPECTOR {
  2. class PropertyFormatter {
  3. /**
  4. * Format the value of the given property of the given object.
  5. */
  6. static format(obj: any, prop: string): string;
  7. }
  8. /**
  9. * A property line represents a line in the detail panel. This line is composed of :
  10. * - a name (the property name)
  11. * - a value if this property is of a type 'simple' : string, number, boolean, color, texture
  12. * - the type of the value if this property is of a complex type (Vector2, Size, ...)
  13. * - a ID if defined (otherwise an empty string is displayed)
  14. * The original object is sent to the value object who will update it at will.
  15. *
  16. * A property line can contain OTHER property line objects in the case of a complex type.
  17. * If this instance has no link to other instances, its type is ALWAYS a simple one (see above).
  18. *
  19. */
  20. class PropertyLine {
  21. private _property;
  22. private _div;
  23. private _valueDiv;
  24. private _children;
  25. private static _SIMPLE_TYPE;
  26. private static _MARGIN_LEFT;
  27. private _level;
  28. /** The list of viewer element displayed at the end of the line (color, texture...) */
  29. private _elements;
  30. /** The property parent of this one. Used to update the value of this property and to retrieve the correct object */
  31. private _parent;
  32. /** The input element to display if this property is 'simple' in order to update it */
  33. private _input;
  34. /** Display input handler (stored to be removed afterwards) */
  35. private _displayInputHandler;
  36. /** Handler used to validate the input by pressing 'enter' */
  37. private _validateInputHandler;
  38. constructor(prop: Property, parent?: PropertyLine, level?: number);
  39. /**
  40. * Init the input element and al its handler :
  41. * - a click in the window remove the input and restore the old property value
  42. * - enters updates the property
  43. */
  44. private _initInput();
  45. /**
  46. * On enter : validates the new value and removes the input
  47. * On escape : removes the input
  48. */
  49. private _validateInput(e);
  50. /** Removes the input without validating the new value */
  51. private _removeInputWithoutValidating();
  52. /** Replaces the default display with an input */
  53. private _displayInput(e);
  54. /** Retrieve the correct object from its parent.
  55. * If no parent exists, returns the property value.
  56. * This method is used at each update in case the property object is removed from the original object
  57. * (example : mesh.position = new BABYLON.Vector3 ; the original vector3 object is deleted from the mesh).
  58. */
  59. updateObject(): any;
  60. name: string;
  61. value: any;
  62. type: string;
  63. /**
  64. * Creates elements that wil be displayed on a property line, depending on the
  65. * type of the property.
  66. */
  67. private _createElements();
  68. private _displayValueContent();
  69. /** Delete properly this property line.
  70. * Removes itself from the scheduler.
  71. * Dispose all viewer element (color, texture...)
  72. */
  73. dispose(): void;
  74. /** Updates the content of _valueDiv with the value of the property,
  75. * and all HTML element correpsonding to this type.
  76. * Elements are updated as well
  77. */
  78. private _updateValue();
  79. /**
  80. * Update the property division with the new property value.
  81. * If this property is complex, update its child, otherwise update its text content
  82. */
  83. update(): void;
  84. /**
  85. * Returns true if the given instance is a simple type
  86. */
  87. private static _IS_TYPE_SIMPLE(inst);
  88. /**
  89. * Returns true if the type of this property is simple, false otherwise.
  90. * Returns true if the value is null
  91. */
  92. private _isSimple();
  93. toHtml(): HTMLElement;
  94. /**
  95. * Add sub properties in case of a complex type
  96. */
  97. private _addDetails();
  98. }
  99. }