DbgEditorWidget1.cpp 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. #include "DbgEditorWidget1.h"
  2. #include "BsEditorWindow.h"
  3. #include "BsGUILabel.h"
  4. #include "BsGUIButton.h"
  5. #include "BsGUIInputBox.h"
  6. #include "BsGUIScrollArea.h"
  7. #include "BsGUIArea.h"
  8. #include "BsGUILayout.h"
  9. #include "BsEditorWindow.h"
  10. #include "BsEditorWidgetContainer.h"
  11. using namespace CamelotFramework;
  12. using namespace BansheeEngine;
  13. namespace BansheeEditor
  14. {
  15. std::shared_ptr<DbgEditorWidget1> DbgEditorWidget1::Instance;
  16. DbgEditorWidget1::DbgEditorWidget1()
  17. :EditorWidget(L"DbgEditorWidget1")
  18. {
  19. }
  20. DbgEditorWidget1::~DbgEditorWidget1()
  21. {
  22. }
  23. void DbgEditorWidget1::_initialize(BS::GUIWidget& widget, CM::INT32 x, CM::INT32 y, CM::UINT32 width, CM::UINT32 height)
  24. {
  25. EditorWidget::_initialize(widget, x, y, width, height);
  26. GUILayout& layout = mContent->getLayout();
  27. //
  28. //mDbgLabel = GUILabel::create(*mGUI, "Testing test");
  29. //layout.addElement(mDbgLabel);
  30. //layout.addElement(GUIInputBox::create(*mGUI));
  31. //layout.addElement(GUIInputBox::create(*mGUI, GUILayoutOptions::fixed(100, 100), true));
  32. GUIScrollArea* scrollArea = GUIScrollArea::create(*mParentWidget);
  33. layout.addElement(scrollArea);
  34. GUILayout& scrollLayout = scrollArea->getLayout().addLayoutX();
  35. //scrollLayout.addElement(GUIButton::create(*mGUI, L"Test A"));
  36. //scrollLayout.addElement(GUIButton::create(*mGUI, L"Test B"));
  37. //scrollLayout.addElement(GUIButton::create(*mGUI, L"Test C"));
  38. //scrollLayout.addElement(GUIButton::create(*mGUI, L"Test D"));
  39. //scrollLayout.addElement(GUIButton::create(*mGUI, L"Test E"));
  40. //scrollLayout.addElement(GUIButton::create(*mGUI, L"Test F"));
  41. //scrollLayout.addElement(GUIButton::create(*mGUI, L"Test G"));
  42. //scrollLayout.addElement(GUIButton::create(*mGUI, L"Test H"));
  43. //scrollLayout.addElement(GUIButton::create(*mGUI, L"Test I"));
  44. //scrollLayout.addElement(GUIButton::create(*mGUI, L"Test J"));
  45. //scrollLayout.addElement(GUIButton::create(*mGUI, L"Test K"));
  46. //scrollLayout.addElement(GUIButton::create(*mGUI, L"Test L"));
  47. scrollLayout.addElement(GUIInputBox::create(*mParentWidget, GUILayoutOptions::fixed(100, 100), true));
  48. scrollLayout.addElement(GUIInputBox::create(*mParentWidget, GUILayoutOptions::fixed(100, 100), true));
  49. scrollLayout.addElement(GUIInputBox::create(*mParentWidget, GUILayoutOptions::fixed(100, 100), true));
  50. //GUIFlexibleSpace& space4 = otherLayout.addFlexibleSpace();
  51. //otherLayout.addElement(mDbgLabel);
  52. //GUIFixedSpace& space = otherLayout.addSpace(10); // Due to bug in MSVC compiler I need to store return value
  53. //GUIFlexibleSpace& space3 = otherLayout.addFlexibleSpace();
  54. //otherLayout.addElement(GUIWindowFrame::create(*mGUI, GUILayoutOptions::fixed(100, 100)));
  55. //GUIFixedSpace& space2 = otherLayout.addSpace(10);
  56. //otherLayout.addElement(GUIButton::create(*mGUI, "Test"));
  57. //otherLayout.addElement(GUIWindowFrame::create(*mGUI));
  58. //GUIArea* backgroundArea = GUIArea::create(*mGUI, 0, 0, 0, 0, 2000);
  59. //backgroundArea->getLayout().addElement(GUITexture::create(*mGUI, GUILayoutOptions::expandableXY(), GUIImageScaleMode::RepeatToFit, mGUI->getSkin()->getStyle("WindowBackground")));
  60. //GUIArea* windowFrameArea = GUIArea::create(*mGUI, 0, 0, 0, 0, 1999);
  61. //windowFrameArea->getLayout().addElement(GUIWindowFrame::create(*mGUI));
  62. //GUIArea* titleBarBackgroundArea = GUIArea::create(*mGUI, 0, 1, 0, 11, 1999);
  63. //titleBarBackgroundArea->getLayout().addSpace(1);
  64. //titleBarBackgroundArea->getLayout().addElement(GUITexture::create(*mGUI, GUIImageScaleMode::RepeatToFit, GUILayoutOptions::expandableXY(), mGUI->getGUISkin()->getStyle("TitleBarBg")));
  65. //titleBarBackgroundArea->getLayout().addSpace(1);
  66. //mRenderWindow->resize(300, 250);
  67. //mRenderWindow->setVisible(false);
  68. }
  69. std::shared_ptr<DbgEditorWidget1> DbgEditorWidget1::instance()
  70. {
  71. return Instance;
  72. }
  73. std::shared_ptr<DbgEditorWidget1> DbgEditorWidget1::open()
  74. {
  75. if(Instance != nullptr)
  76. return Instance;
  77. EditorWindow* newWindow = cm_new<EditorWindow>();
  78. std::shared_ptr<DbgEditorWidget1> newWidget = std::shared_ptr<DbgEditorWidget1>(new (cm_alloc<DbgEditorWidget1>()) DbgEditorWidget1());
  79. newWindow->getWidgets().add(*newWidget);
  80. return newWidget;
  81. }
  82. void DbgEditorWidget1::close()
  83. {
  84. // TODO - Unregister widget from EditorWidgetContainer
  85. // TODO - Unregister widget from DockManager
  86. // TODO - Release widget resources
  87. Instance = nullptr; // TODO - What happens when something ends up keeping the reference to the widget?
  88. }
  89. }