SelectionSection.ts 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. import SerializableEditType = require("./SerializableEditType");
  2. import AttributeInfoEdit = require("./AttributeInfoEdit");
  3. abstract class SelectionSection extends Atomic.UISection {
  4. editType: SerializableEditType;
  5. attrLayout: Atomic.UILayout;
  6. suppressed: boolean = false;
  7. attrEdits: { [name: string]: AttributeInfoEdit } = {};
  8. constructor(editType: SerializableEditType) {
  9. super();
  10. this.editType = editType;
  11. this.text = editType.typeName;
  12. this.value = 1;
  13. this.createUI();
  14. }
  15. refresh() {
  16. for (var name in this.attrEdits) {
  17. this.attrEdits[name].refresh();
  18. }
  19. }
  20. suppress(value: boolean) {
  21. if (this.suppressed == value) {
  22. return;
  23. }
  24. this.suppressed = value;
  25. if (value) {
  26. this.visibility = Atomic.UI_WIDGET_VISIBILITY_GONE;
  27. } else {
  28. this.visibility = Atomic.UI_WIDGET_VISIBILITY_VISIBLE;
  29. }
  30. }
  31. createUI() {
  32. var attrLayout = this.attrLayout = new Atomic.UILayout(Atomic.UI_AXIS_Y);
  33. attrLayout.spacing = 3;
  34. attrLayout.layoutPosition = Atomic.UI_LAYOUT_POSITION_LEFT_TOP;
  35. attrLayout.layoutSize = Atomic.UI_LAYOUT_SIZE_AVAILABLE;
  36. this.contentRoot.addChild(attrLayout);
  37. for (var i in this.editType.attrInfos) {
  38. var attr = this.editType.attrInfos[i];
  39. if (attr.mode & Atomic.AM_NOEDIT)
  40. continue;
  41. var attrEdit = AttributeInfoEdit.createAttrEdit(this.editType, attr);
  42. if (!attrEdit)
  43. continue;
  44. this.attrEdits[attr.name] = attrEdit;
  45. attrLayout.addChild(attrEdit);
  46. }
  47. }
  48. static fontDesc: Atomic.UIFontDescription;
  49. private static Ctor = (() => {
  50. var fd = SelectionSection.fontDesc = new Atomic.UIFontDescription();
  51. fd.id = "Vera";
  52. fd.size = 11;
  53. })();
  54. }
  55. export = SelectionSection;