MainFrame.ts 4.0 KB

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