textBlockPropertyGridComponent.tsx 4.2 KB

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