CmTestTextSprite.cpp 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. #include "CmTestTextSprite.h"
  2. #include "CmSceneObject.h"
  3. #include "BsRenderable.h"
  4. #include "CmMesh.h"
  5. #include "CmVector2.h"
  6. #include "BsTextSprite.h"
  7. #include "CmFont.h"
  8. #include "CmMaterial.h"
  9. #include "BsGUILabel.h"
  10. #include "BsGUIListBox.h"
  11. #include "BsGUISkin.h"
  12. #include "BsOverlayManager.h"
  13. #include "BsSpriteTexture.h"
  14. #include "BsEditorGUI.h"
  15. #include "BsGUITexture.h"
  16. #include "BsGUIRenderTexture.h"
  17. #include "BsGUIArea.h"
  18. #include "BsGUILayout.h"
  19. #include "BsGUISpace.h"
  20. #include "BsGUIViewport.h"
  21. #include "BsGUIButton.h"
  22. #include "BsCamera.h"
  23. #include "CmInput.h"
  24. #include "CmPlatform.h"
  25. #include "BsGUIContent.h"
  26. #include "CmStringTable.h"
  27. #include "BsGUISceneTreeView.h"
  28. #include "BsGUIResourceTreeView.h"
  29. #include "BsGUIScrollArea.h"
  30. using namespace CamelotFramework;
  31. using namespace BansheeEngine;
  32. namespace BansheeEditor
  33. {
  34. TestTextSprite::TestTextSprite(const HSceneObject& parent, CM::Viewport* target)
  35. :GUIWidget(parent, target), mListBox(nullptr)
  36. {
  37. }
  38. TestTextSprite::~TestTextSprite()
  39. {
  40. }
  41. void TestTextSprite::init(const HCamera& camera, const String& text, CM::RenderTexturePtr sceneView)
  42. {
  43. setSkin(BansheeEditor::EditorGUI::instance().getSkin());
  44. setDepth(128);
  45. GUIArea* area = GUIArea::createStretchedXY(*this, 0, 0, 0, 0);
  46. mSceneTreeView = GUISceneTreeView::create(*this, GUIOptions(GUIOption::flexibleWidth(), GUIOption::flexibleHeight()));
  47. mResourceTreeView = GUIResourceTreeView::create(*this, GUIOptions(GUIOption::flexibleWidth(), GUIOption::flexibleHeight()));
  48. GUILayout& sceneTreeViewLayout = area->getLayout().addLayoutY();
  49. //sceneTreeViewLayout.addElement(mSceneTreeView);
  50. SceneObject::create("FILLER_A");
  51. SceneObject::create("FILLER_B");
  52. SceneObject::create("FILLER_C");
  53. SceneObject::create("FILLER_D");
  54. SceneObject::create("FILLER_E");
  55. SceneObject::create("FILLER_F");
  56. SceneObject::create("FILLER_G");
  57. SceneObject::create("FILLER_H");
  58. SceneObject::create("FILLER_I");
  59. SceneObject::create("FILLER_J");
  60. SceneObject::create("FILLER_K");
  61. SceneObject::create("FILLER_L");
  62. area->getLayout().addElement(GUIRenderTexture::create(*this, sceneView, GUIOptions(GUIOption::fixedWidth(800), GUIOption::fixedHeight(600))));
  63. //mLabel = GUILabel::create(*this, HString(L""));
  64. //area->getLayout().addElement(mLabel);
  65. //Vector<HString>::type dropDownElements;
  66. //dropDownElements.push_back(HString(L"Ejlement #1"));
  67. //dropDownElements.push_back(HString(L"Element #2"));
  68. //dropDownElements.push_back(HString(L"Element #3"));
  69. //mListBox = GUIListBox::create(*this, dropDownElements, GUIOptions(GUIOption::fixedWidth(50), GUIOption::fixedHeight(13)));
  70. //area->getLayout().addElement(mListBox);
  71. GUIScrollArea* scrollArea = GUIScrollArea::create(*this, GUIOptions(GUIOption::fixedWidth(100), GUIOption::fixedHeight(100)));
  72. sceneTreeViewLayout.addFlexibleSpace();
  73. area->getLayout().addElement(scrollArea);
  74. sceneTreeViewLayout.addFlexibleSpace();
  75. scrollArea->getLayout().addElement(mSceneTreeView);
  76. area->getLayout().addElement(mResourceTreeView);
  77. //GUIButton* button = GUIButton::create(*this, HString(L"dbgBtn"));
  78. //button->onClick.connect(boost::bind(&TestTextSprite::dbgBtn, this));
  79. //area->getLayout().addElement(button);
  80. //button = GUIButton::create(*this, HString(L"Add GameObjects"));
  81. //button->onClick.connect(boost::bind(&TestTextSprite::dbgAdd, this));
  82. //area->getLayout().addElement(button);
  83. //button = GUIButton::create(*this, HString(L"Rename GameObject"));
  84. //button->onClick.connect(boost::bind(&TestTextSprite::dbgRename, this));
  85. //area->getLayout().addElement(button);
  86. //button = GUIButton::create(*this, HString(L"Remove child GameObjects"));
  87. //button->onClick.connect(boost::bind(&TestTextSprite::dbgRemoveChildren, this));
  88. //area->getLayout().addElement(button);
  89. //button = GUIButton::create(*this, HString(L"Remove parent GameObjects"));
  90. //button->onClick.connect(boost::bind(&TestTextSprite::dbgRemoveParents, this));
  91. //area->getLayout().addElement(button);
  92. area->getLayout().addFlexibleSpace();
  93. labelString = HString(L"\\{0}, {1}");
  94. //mLabel->setContent(GUIContent(labelString));
  95. }
  96. void TestTextSprite::update()
  97. {
  98. labelString.setParameter(0, toWString(Input::instance().getCursorPosition().x));
  99. mSceneTreeView->update();
  100. mResourceTreeView->update();
  101. //labelString.setParameter(1, toWString(Input::instance().getCursorPosition().y));
  102. }
  103. void TestTextSprite::dbgBtn()
  104. {
  105. static int dbg = 0;
  106. if(dbg == 0)
  107. {
  108. //Vector<HString>::type dropDownElements;
  109. //dropDownElements.push_back(HString(L"Element #4"));
  110. //dropDownElements.push_back(HString(L"Element #5"));
  111. //dropDownElements.push_back(HString(L"Element #6"));
  112. //mListBox->setElements(dropDownElements);
  113. //StringTable::instance().setString(L"dbgBtn", Language::Abkhazian, L"ALOALO");
  114. //StringTable::instance().setActiveLanguage(Language::Abkhazian);
  115. }
  116. else if(dbg == 1)
  117. {
  118. //StringTable::instance().removeString(L"dbgBtn");
  119. }
  120. dbg++;
  121. }
  122. void TestTextSprite::dbgAdd()
  123. {
  124. mDbgMainA = SceneObject::create("DEBUG_A");
  125. mDbgChildA = SceneObject::create("DEBUG_CHILD_0");
  126. mDbgChildA->setParent(mDbgMainA);
  127. mDbgChildB = SceneObject::create("DEBUG_CHILD_1");
  128. mDbgChildB->setParent(mDbgMainA);
  129. mDbgChildC = SceneObject::create("DEBUG_CHILD_2");
  130. mDbgChildC->setParent(mDbgMainA);
  131. mDbgMainB = SceneObject::create("DEBUG_B");
  132. }
  133. void TestTextSprite::dbgRename()
  134. {
  135. mDbgMainA->setName("Z_DEBUG_RENAMED_A");
  136. }
  137. void TestTextSprite::dbgRemoveChildren()
  138. {
  139. mDbgChildA->destroy();
  140. mDbgChildB->destroy();
  141. }
  142. void TestTextSprite::dbgRemoveParents()
  143. {
  144. mDbgMainA->destroy();
  145. mDbgMainB->destroy();
  146. }
  147. }