ProjectModulePanel.cs 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. function ProjectModulePanel::init(%this, %title)
  2. {
  3. %this.leftPanel = new GuiControl()
  4. {
  5. HorizSizing="right";
  6. VertSizing="height";
  7. Position="0 0";
  8. Extent="200 768";
  9. };
  10. ThemeManager.setProfile(%this.leftPanel, "overlayProfile");
  11. %this.add(%this.leftPanel);
  12. %this.title = new GuiControl()
  13. {
  14. Position = "0 4";
  15. Extent = "200 34";
  16. Text = %title;
  17. };
  18. ThemeManager.setProfile(%this.title, "titleProfile");
  19. %this.leftPanel.add(%this.title);
  20. %this.buttonBarContainer = new GuiControl()
  21. {
  22. Position = "0 38";
  23. Extent = "200 34";
  24. };
  25. ThemeManager.setProfile(%this.buttonBarContainer, "panelProfile");
  26. %this.leftPanel.add(%this.buttonBarContainer);
  27. %this.buttonBar = new GuiChainCtrl()
  28. {
  29. Class = "EditorButtonBar";
  30. Position = "0 4";
  31. Extent = "0 30";
  32. ChildSpacing = 4;
  33. IsVertical = false;
  34. Tool = %this;
  35. };
  36. ThemeManager.setProfile(%this.buttonBar, "emptyProfile");
  37. %this.buttonBarContainer.add(%this.buttonBar);
  38. %this.scroller = new GuiScrollCtrl()
  39. {
  40. HorizSizing="width";
  41. VertSizing="height";
  42. Position="0 72";
  43. Extent="200 696";
  44. hScrollBar="alwaysOff";
  45. vScrollBar="dynamic";
  46. constantThumbHeight="0";
  47. showArrowButtons="0";
  48. scrollBarThickness="6";
  49. };
  50. ThemeManager.setProfile(%this.scroller, "emptyProfile");
  51. ThemeManager.setProfile(%this.scroller, "tinyThumbProfile", "ThumbProfile");
  52. ThemeManager.setProfile(%this.scroller, "tinyTrackProfile", "TrackProfile");
  53. ThemeManager.setProfile(%this.scroller, "tinyScrollArrowProfile", "ArrowProfile");
  54. %this.leftPanel.add(%this.scroller);
  55. %this.list = new GuiListBoxCtrl()
  56. {
  57. Class = "ProjectModulePanelList";
  58. HorizSizing="width";
  59. VertSizing="height";
  60. Position="0 0";
  61. Extent="200 10";
  62. AllowMultipleSelections=true;
  63. FitParentWidth=true;
  64. FontSizeAdjust="0.9";
  65. };
  66. ThemeManager.setProfile(%this.list, "listBoxProfile");
  67. %this.scroller.add(%this.list);
  68. %this.startListening(%this.list);
  69. %this.card = new GuiScrollCtrl()
  70. {
  71. Class="ProjectModuleCard";
  72. HorizSizing="width";
  73. VertSizing="height";
  74. Position="200 0";
  75. Extent="312 768";
  76. hScrollBar="alwaysOff";
  77. vScrollBar="dynamic";
  78. constantThumbHeight="0";
  79. showArrowButtons="1";
  80. scrollBarThickness="14";
  81. visible = false;
  82. };
  83. ThemeManager.setProfile(%this.card, "scrollProfile");
  84. ThemeManager.setProfile(%this.card, "thumbProfile", "ThumbProfile");
  85. ThemeManager.setProfile(%this.card, "trackProfile", "TrackProfile");
  86. ThemeManager.setProfile(%this.card, "scrollArrowProfile", "ArrowProfile");
  87. %this.add(%this.card);
  88. %this.startListening(%this.card);
  89. %this.gray = "80 80 80 150";
  90. %this.yellow = "255 255 100 255";
  91. %this.red = "255 80 80 255";
  92. %this.darkRed = "200 0 0 200";
  93. %this.purple = "255 100 255 255";
  94. }
  95. function ProjectModulePanel::setTitle(%this, %title)
  96. {
  97. %this.title.setText(%title);
  98. }
  99. function ProjectModulePanel::clearModules(%this)
  100. {
  101. %this.list.clearItems();
  102. }
  103. function ProjectModulePanel::getModuleName(%this, %module)
  104. {
  105. %name = %module.ModuleId;
  106. if(%module.VersionId !$= "1")
  107. {
  108. %name = %module.ModuleId @ ":" @ %module.VersionId;
  109. }
  110. return %name;
  111. }
  112. function ProjectModulePanelList::onSelect(%this)
  113. {
  114. %index = %this.getSelectedItem();
  115. if(%index != -1)
  116. {
  117. %module = %this.getItemID(%index);
  118. %this.postEvent("ModuleSelected", %module);
  119. }
  120. }
  121. function ProjectModulePanel::onModuleSelected(%this, %module)
  122. {
  123. %this.card.show(%module);
  124. }
  125. function ProjectModulePanel::onClose(%this)
  126. {
  127. %this.list.clearSelection();
  128. %this.card.visible = false;
  129. }
  130. function ProjectModulePanel::sortModules(%this)
  131. {
  132. %this.list.sortByText();
  133. }
  134. function ProjectModulePanel::onModuleShown(%this, %module)
  135. {
  136. %this.buttonBar.refreshEnabled();
  137. }