DbgEditorWidget2.cpp 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. #include "DbgEditorWidget2.h"
  2. #include "BsEditorWindow.h"
  3. #include "BsGUIToggle.h"
  4. #include "BsGUIScrollArea.h"
  5. #include "BsGUIArea.h"
  6. #include "BsGUILayout.h"
  7. #include "BsEditorWindow.h"
  8. #include "BsEditorWidgetContainer.h"
  9. #include "BsEngineGUI.h"
  10. using namespace CamelotFramework;
  11. using namespace BansheeEngine;
  12. namespace BansheeEditor
  13. {
  14. DbgEditorWidget2* DbgEditorWidget2::Instance = nullptr;
  15. DbgEditorWidget2::DbgEditorWidget2()
  16. :EditorWidget(HString(L"DbgEditorWidget2"))
  17. {
  18. }
  19. DbgEditorWidget2::~DbgEditorWidget2()
  20. {
  21. }
  22. void DbgEditorWidget2::initialize()
  23. {
  24. GUILayout& layout = mContent->getLayout();
  25. GUIScrollArea* scrollArea = GUIScrollArea::create(getParentWidget());
  26. layout.addElement(scrollArea);
  27. GUILayout& scrollLayout = scrollArea->getLayout().addLayoutY();
  28. std::shared_ptr<GUIToggleGroup> toggleGroup = GUIToggle::createToggleGroup();
  29. scrollLayout.addElement(GUIToggle::create(getParentWidget(), HString(L"Test A"), toggleGroup, EngineGUI::instance().getSkin().getStyle("Button")));
  30. scrollLayout.addElement(GUIToggle::create(getParentWidget(), HString(L"Test B"), toggleGroup, EngineGUI::instance().getSkin().getStyle("Button")));
  31. scrollLayout.addElement(GUIToggle::create(getParentWidget(), HString(L"Test C"), toggleGroup, EngineGUI::instance().getSkin().getStyle("Button")));
  32. scrollLayout.addElement(GUIToggle::create(getParentWidget(), HString(L"Test D"), toggleGroup, EngineGUI::instance().getSkin().getStyle("Button")));
  33. scrollLayout.addElement(GUIToggle::create(getParentWidget(), HString(L"Test E"), toggleGroup, EngineGUI::instance().getSkin().getStyle("Button")));
  34. }
  35. DbgEditorWidget2* DbgEditorWidget2::instance()
  36. {
  37. return Instance;
  38. }
  39. DbgEditorWidget2* DbgEditorWidget2::open()
  40. {
  41. if(Instance != nullptr)
  42. return Instance;
  43. EditorWindow* newWindow = EditorWindow::create();
  44. DbgEditorWidget2* newWidget = new (cm_alloc<DbgEditorWidget2>()) DbgEditorWidget2();
  45. newWindow->widgets().add(*newWidget);
  46. newWidget->initialize();
  47. Instance = newWidget;
  48. return newWidget;
  49. }
  50. void DbgEditorWidget2::close()
  51. {
  52. if(Instance != nullptr)
  53. {
  54. Instance->mParent->_notifyWidgetDestroyed(Instance);
  55. EditorWidget::destroy(Instance);
  56. }
  57. Instance = nullptr;
  58. }
  59. }