MainFrame.ts 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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("./MainToolbar");
  7. import MessageModal = require("./modal/MessageModal");
  8. import UIEvents = require("./UIEvents");
  9. import ScriptWidget = require("./ScriptWidget");
  10. import MainFrameMenu = require("./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.showWelcomeFrame(true);
  31. }
  32. frameVisible(frame: Atomic.UIWidget): boolean {
  33. var container = <Atomic.UILayout> this.getWidget("resourceviewcontainer");
  34. var child = null;
  35. for (child = container.firstChild; child; child = child.next) {
  36. if (child == frame)
  37. return true;
  38. }
  39. return false;
  40. }
  41. showWelcomeFrame(show: boolean) {
  42. if (show) {
  43. this.showInspectorFrame(false);
  44. this.welcomeFrame.visibility = Atomic.UI_WIDGET_VISIBILITY_VISIBLE;
  45. this.resourceframe.visibility = Atomic.UI_WIDGET_VISIBILITY_GONE;
  46. }
  47. else {
  48. this.showInspectorFrame(true);
  49. this.resourceframe.visibility = Atomic.UI_WIDGET_VISIBILITY_VISIBLE;
  50. this.welcomeFrame.visibility = Atomic.UI_WIDGET_VISIBILITY_GONE;
  51. }
  52. }
  53. showInspectorFrame(show: boolean) {
  54. if (show) {
  55. this.inspectorlayout.visibility = Atomic.UI_WIDGET_VISIBILITY_VISIBLE;
  56. this.inspectorframe.visibility = Atomic.UI_WIDGET_VISIBILITY_VISIBLE;
  57. } else {
  58. this.inspectorframe.visibility = Atomic.UI_WIDGET_VISIBILITY_GONE;
  59. this.inspectorlayout.visibility = Atomic.UI_WIDGET_VISIBILITY_GONE;
  60. }
  61. }
  62. onEventClick(target: Atomic.UIWidget, refid: string): boolean {
  63. if (this.menu.handlePopupMenu(target, refid))
  64. return true;
  65. var src = MenuItemSources.getMenuItemSource(target.id);
  66. if (src) {
  67. var menu = new Atomic.UIMenuWindow(target, target.id + " popup");
  68. menu.show(src);
  69. return true;
  70. }
  71. return false;
  72. }
  73. handleResourceEditorChanged(data): void {
  74. var editor = <Editor.ResourceEditor> data.editor;
  75. if (editor) {
  76. //this.showInspectorFrame(editor.requiresInspector());
  77. } else {
  78. //this.showInspectorFrame(false);
  79. }
  80. }
  81. projectframe: ProjectFrame;
  82. resourceframe: ResourceFrame;
  83. inspectorframe: InspectorFrame;
  84. hierarchyFrame: HierarchyFrame;
  85. welcomeFrame: WelcomeFrame;
  86. inspectorlayout: Atomic.UILayout;
  87. mainToolbar: MainToolbar;
  88. menu: MainFrameMenu;
  89. }
  90. export = MainFrame;