MainFrame.ts 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. import menubar = require("./MainFrameMenu");
  2. import ProjectFrame = require("./ProjectFrame");
  3. import ResourceFrame = require("./ResourceFrame");
  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. var UI = Atomic.UI;
  11. class MainFrame extends ScriptWidget {
  12. projectframe: ProjectFrame;
  13. resourceframe: ResourceFrame;
  14. inspectorframe: InspectorFrame;
  15. hierarchyFrame: HierarchyFrame;
  16. inspectorlayout: Atomic.UILayout;
  17. mainToolbar: MainToolbar;
  18. private messagemodal: MessageModal.MessageModal = new MessageModal.MessageModal();
  19. constructor() {
  20. super();
  21. this.load("AtomicEditor/editor/ui/mainframe.tb.txt");
  22. this.inspectorlayout = <Atomic.UILayout> this.getWidget("inspectorlayout");
  23. this.getWidget("consolecontainer").visibility = Atomic.UI_WIDGET_VISIBILITY_GONE;
  24. this.inspectorframe = new InspectorFrame();
  25. this.inspectorlayout.addChild(this.inspectorframe);
  26. this.projectframe = new ProjectFrame(this);
  27. this.hierarchyFrame = new HierarchyFrame(this);
  28. this.resourceframe = new ResourceFrame(this);
  29. this.mainToolbar = new MainToolbar(this.getWidget("maintoolbarcontainer"));
  30. this.showInspectorFrame(true);
  31. this.subscribeToEvent(UIEvents.ResourceEditorChanged, (data) => this.handleResourceEditorChanged(data));
  32. }
  33. showInspectorFrame(show: boolean) {
  34. return;
  35. if (show) {
  36. this.inspectorlayout.visibility = UI.VISIBILITY_VISIBLE;
  37. this.inspectorframe.visibility = UI.VISIBILITY_VISIBLE;
  38. } else {
  39. this.inspectorframe.visibility = UI.VISIBILITY_GONE;
  40. this.inspectorlayout.visibility = UI.VISIBILITY_GONE;
  41. }
  42. }
  43. onEventClick(target: Atomic.UIWidget, refid: string): boolean {
  44. if (this.handlePopupMenu(target, refid))
  45. return true;
  46. var src = menubar.getMenuItemSource(target.id);
  47. if (src) {
  48. var menu = new Atomic.UIMenuWindow(target, target.id + " popup");
  49. menu.show(src);
  50. return true;
  51. }
  52. return false;
  53. }
  54. handlePopupMenu(target: Atomic.UIWidget, refid: string): boolean {
  55. if (target.id == "menu atomic editor popup") {
  56. if (refid == "quit")
  57. Atomic.getEngine().exit();
  58. } else if (target.id == "menu edit popup") {
  59. if (refid == "edit play") {
  60. new ToolCore.PlayCmd().run();
  61. return true;
  62. }
  63. return false;
  64. } else if (target.id == "menu file popup") {
  65. if (refid == "file save file") {
  66. //TODO: this is horrible
  67. if (this.resourceframe.currentResourceEditor)
  68. this.resourceframe.currentResourceEditor.save();
  69. return true;
  70. }
  71. return false;
  72. }
  73. }
  74. handleResourceEditorChanged(data): void {
  75. var editor = <Editor.ResourceEditor> data.editor;
  76. if (editor) {
  77. this.showInspectorFrame(editor.requiresInspector());
  78. } else {
  79. this.showInspectorFrame(false);
  80. }
  81. }
  82. }
  83. export = MainFrame;