textBlockPropertyGridComponent.tsx 4.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. import * as React from "react";
  2. import { Observable } from "babylonjs/Misc/observable";
  3. import { PropertyChangedEvent } from "../../../propertyChangedEvent";
  4. import { CommonControlPropertyGridComponent } from "../../../tabs/propertyGrids/gui/commonControlPropertyGridComponent";
  5. import { TextBlock, TextWrapping } from "babylonjs-gui/2D/controls/textBlock";
  6. import { Control } from "babylonjs-gui/2D/controls/control";
  7. import { LineContainerComponent } from "../../../lines/lineContainerComponent";
  8. import { TextInputLineComponent } from "../../../lines/textInputLineComponent";
  9. import { LockObject } from "../../../tabs/propertyGrids/lockObject";
  10. import { OptionsLineComponent } from "../../../lines/optionsLineComponent";
  11. import { CheckBoxLineComponent } from "../../../lines/checkBoxLineComponent";
  12. import { FloatLineComponent } from "../../../lines/floatLineComponent";
  13. interface ITextBlockPropertyGridComponentProps {
  14. textBlock: TextBlock;
  15. lockObject: LockObject;
  16. onPropertyChangedObservable?: Observable<PropertyChangedEvent>;
  17. }
  18. export class TextBlockPropertyGridComponent extends React.Component<ITextBlockPropertyGridComponentProps> {
  19. constructor(props: ITextBlockPropertyGridComponentProps) {
  20. super(props);
  21. }
  22. render() {
  23. const textBlock = this.props.textBlock;
  24. var horizontalOptions = [
  25. { label: "Left", value: Control.HORIZONTAL_ALIGNMENT_LEFT },
  26. { label: "Right", value: Control.HORIZONTAL_ALIGNMENT_RIGHT },
  27. { label: "Center", value: Control.HORIZONTAL_ALIGNMENT_CENTER },
  28. ];
  29. var verticalOptions = [
  30. { label: "Top", value: Control.VERTICAL_ALIGNMENT_TOP },
  31. { label: "Bottom", value: Control.VERTICAL_ALIGNMENT_BOTTOM },
  32. { label: "Center", value: Control.VERTICAL_ALIGNMENT_CENTER },
  33. ];
  34. var wrappingOptions = [
  35. { label: "Clip", value: TextWrapping.Clip },
  36. { label: "Ellipsis", value: TextWrapping.Ellipsis },
  37. { label: "Word wrap", value: TextWrapping.WordWrap },
  38. ];
  39. return (
  40. <div className="pane">
  41. <CommonControlPropertyGridComponent lockObject={this.props.lockObject} control={textBlock} onPropertyChangedObservable={this.props.onPropertyChangedObservable} />
  42. <LineContainerComponent title="TEXTBLOCK">
  43. <TextInputLineComponent lockObject={this.props.lockObject} label="Text" target={textBlock} propertyName="text" onPropertyChangedObservable={this.props.onPropertyChangedObservable} />
  44. <OptionsLineComponent label="Horizontal text alignment" options={horizontalOptions} target={textBlock} propertyName="textHorizontalAlignment" onPropertyChangedObservable={this.props.onPropertyChangedObservable} />
  45. <OptionsLineComponent label="Vertical text alignment" options={verticalOptions} target={textBlock} propertyName="textVerticalAlignment" onPropertyChangedObservable={this.props.onPropertyChangedObservable} />
  46. <CheckBoxLineComponent label="Resize to fit" target={textBlock} propertyName="resizeToFit" onPropertyChangedObservable={this.props.onPropertyChangedObservable} />
  47. <OptionsLineComponent label="Wrapping" options={wrappingOptions} target={textBlock} propertyName="textWrapping" onPropertyChangedObservable={this.props.onPropertyChangedObservable} />
  48. <TextInputLineComponent lockObject={this.props.lockObject} label="Line spacing" target={textBlock} propertyName="lineSpacing" onPropertyChangedObservable={this.props.onPropertyChangedObservable} />
  49. </LineContainerComponent>
  50. <LineContainerComponent title="OUTLINE">
  51. <FloatLineComponent lockObject={this.props.lockObject} label="Outline width" target={textBlock} propertyName="outlineWidth" onPropertyChangedObservable={this.props.onPropertyChangedObservable} />
  52. <TextInputLineComponent lockObject={this.props.lockObject} label="Outline color" target={textBlock} propertyName="outlineColor" onPropertyChangedObservable={this.props.onPropertyChangedObservable} />
  53. </LineContainerComponent>
  54. </div>
  55. );
  56. }
  57. }