MainFrame.ts 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. import ProjectFrame = require("./ProjectFrame");
  2. import ResourceFrame = require("./ResourceFrame");
  3. import WelcomeFrame = require("./WelcomeFrame");
  4. import InspectorFrame = require("./inspector/InspectorFrame");
  5. import HierarchyFrame = require("./HierarchyFrame");
  6. import MainToolbar = require("ui//MainToolbar");
  7. import UIEvents = require("ui/UIEvents");
  8. import ScriptWidget = require("ui/ScriptWidget");
  9. import MainFrameMenu = require("./menus/MainFrameMenu");
  10. import MenuItemSources = require("./menus/MenuItemSources");
  11. class MainFrame extends ScriptWidget {
  12. constructor() {
  13. super();
  14. this.load("AtomicEditor/editor/ui/mainframe.tb.txt");
  15. this.inspectorlayout = <Atomic.UILayout> this.getWidget("inspectorlayout");
  16. this.getWidget("consolecontainer").visibility = Atomic.UI_WIDGET_VISIBILITY_GONE;
  17. this.inspectorframe = new InspectorFrame();
  18. this.inspectorlayout.addChild(this.inspectorframe);
  19. this.projectframe = new ProjectFrame(this);
  20. this.hierarchyFrame = new HierarchyFrame(this);
  21. this.welcomeFrame = new WelcomeFrame(this);
  22. this.resourceframe = new ResourceFrame(this);
  23. this.mainToolbar = new MainToolbar(this.getWidget("maintoolbarcontainer"));
  24. this.menu = new MainFrameMenu();
  25. this.subscribeToEvent(UIEvents.ResourceEditorChanged, (data) => this.handleResourceEditorChanged(data));
  26. this.subscribeToEvent("ProjectLoaded", (data) => {
  27. this.showWelcomeFrame(false);
  28. });
  29. this.subscribeToEvent("ProjectUnloaded", (data) => {
  30. this.showWelcomeFrame(true);
  31. });
  32. this.showWelcomeFrame(true);
  33. }
  34. frameVisible(frame: Atomic.UIWidget): boolean {
  35. var container = <Atomic.UILayout> this.getWidget("resourceviewcontainer");
  36. var child = null;
  37. for (child = container.firstChild; child; child = child.next) {
  38. if (child == frame)
  39. return true;
  40. }
  41. return false;
  42. }
  43. showWelcomeFrame(show: boolean) {
  44. if (show) {
  45. this.showInspectorFrame(false);
  46. this.welcomeFrame.visibility = Atomic.UI_WIDGET_VISIBILITY_VISIBLE;
  47. this.resourceframe.visibility = Atomic.UI_WIDGET_VISIBILITY_GONE;
  48. }
  49. else {
  50. this.showInspectorFrame(true);
  51. this.resourceframe.visibility = Atomic.UI_WIDGET_VISIBILITY_VISIBLE;
  52. this.welcomeFrame.visibility = Atomic.UI_WIDGET_VISIBILITY_GONE;
  53. }
  54. }
  55. showInspectorFrame(show: boolean) {
  56. if (show) {
  57. this.inspectorlayout.visibility = Atomic.UI_WIDGET_VISIBILITY_VISIBLE;
  58. this.inspectorframe.visibility = Atomic.UI_WIDGET_VISIBILITY_VISIBLE;
  59. } else {
  60. this.inspectorframe.visibility = Atomic.UI_WIDGET_VISIBILITY_GONE;
  61. this.inspectorlayout.visibility = Atomic.UI_WIDGET_VISIBILITY_GONE;
  62. }
  63. }
  64. onEventClick(target: Atomic.UIWidget, refid: string): boolean {
  65. if (this.menu.handlePopupMenu(target, refid))
  66. return true;
  67. var src = MenuItemSources.getMenuItemSource(target.id);
  68. if (src) {
  69. var menu = new Atomic.UIMenuWindow(target, target.id + " popup");
  70. menu.show(src);
  71. return true;
  72. }
  73. return false;
  74. }
  75. shutdown() {
  76. this.resourceframe.shutdown();
  77. this.deleteAllChildren();
  78. }
  79. handleResourceEditorChanged(data): void {
  80. var editor = <Editor.ResourceEditor> data.editor;
  81. if (editor) {
  82. //this.showInspectorFrame(editor.requiresInspector());
  83. } else {
  84. //this.showInspectorFrame(false);
  85. }
  86. }
  87. projectframe: ProjectFrame;
  88. resourceframe: ResourceFrame;
  89. inspectorframe: InspectorFrame;
  90. hierarchyFrame: HierarchyFrame;
  91. welcomeFrame: WelcomeFrame;
  92. inspectorlayout: Atomic.UILayout;
  93. mainToolbar: MainToolbar;
  94. menu: MainFrameMenu;
  95. }
  96. export = MainFrame;