CmTestTextSprite.cpp 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  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. #include "BsGUIIntField.h"
  31. #include "BsGUIFloatField.h"
  32. using namespace CamelotFramework;
  33. using namespace BansheeEngine;
  34. namespace BansheeEditor
  35. {
  36. TestTextSprite::TestTextSprite(const HSceneObject& parent, CM::Viewport* target)
  37. :GUIWidget(parent, target), mListBox(nullptr)
  38. {
  39. }
  40. TestTextSprite::~TestTextSprite()
  41. {
  42. }
  43. void TestTextSprite::init(const HCamera& camera, const String& text, CM::RenderTexturePtr sceneView)
  44. {
  45. setSkin(BansheeEditor::EditorGUI::instance().getSkin());
  46. setDepth(128);
  47. GUIArea* area = GUIArea::createStretchedXY(*this, 0, 0, 0, 0);
  48. mSceneTreeView = GUISceneTreeView::create(*this, GUIOptions(GUIOption::flexibleWidth(), GUIOption::flexibleHeight()));
  49. mResourceTreeView = GUIResourceTreeView::create(*this, GUIOptions(GUIOption::flexibleWidth(), GUIOption::flexibleHeight()));
  50. GUILayout& sceneTreeViewLayout = area->getLayout().addLayoutY();
  51. //sceneTreeViewLayout.addElement(mSceneTreeView);
  52. SceneObject::create("FILLER_A");
  53. SceneObject::create("FILLER_B");
  54. SceneObject::create("FILLER_C");
  55. SceneObject::create("FILLER_D");
  56. SceneObject::create("FILLER_E");
  57. SceneObject::create("FILLER_F");
  58. SceneObject::create("FILLER_G");
  59. SceneObject::create("FILLER_H");
  60. SceneObject::create("FILLER_I");
  61. SceneObject::create("FILLER_J");
  62. SceneObject::create("FILLER_K");
  63. SceneObject::create("FILLER_L");
  64. area->getLayout().addElement(GUIRenderTexture::create(*this, sceneView, GUIOptions(GUIOption::fixedWidth(800), GUIOption::fixedHeight(600))));
  65. //mLabel = GUILabel::create(*this, HString(L""));
  66. //area->getLayout().addElement(mLabel);
  67. //Vector<HString>::type dropDownElements;
  68. //dropDownElements.push_back(HString(L"Ejlement #1"));
  69. //dropDownElements.push_back(HString(L"Element #2"));
  70. //dropDownElements.push_back(HString(L"Element #3"));
  71. //mListBox = GUIListBox::create(*this, dropDownElements, GUIOptions(GUIOption::fixedWidth(50), GUIOption::fixedHeight(13)));
  72. //area->getLayout().addElement(mListBox);
  73. GUIScrollArea* scrollArea = GUIScrollArea::create(*this, GUIOptions(GUIOption::fixedWidth(100), GUIOption::fixedHeight(100)));
  74. sceneTreeViewLayout.addFlexibleSpace();
  75. area->getLayout().addElement(scrollArea);
  76. sceneTreeViewLayout.addFlexibleSpace();
  77. scrollArea->getLayout().addElement(mSceneTreeView);
  78. area->getLayout().addElement(mResourceTreeView);
  79. GUIIntField* intField = GUIIntField::create(*this, HString(L"Int Field"), GUIOptions(GUIOption::fixedWidth(200)));
  80. GUIFloatField* floatField = GUIFloatField::create(*this, HString(L"Float Field"), GUIOptions(GUIOption::fixedWidth(200)));
  81. area->getLayout().addElement(intField);
  82. area->getLayout().addElement(floatField);
  83. //GUIButton* button = GUIButton::create(*this, HString(L"dbgBtn"));
  84. //button->onClick.connect(boost::bind(&TestTextSprite::dbgBtn, this));
  85. //area->getLayout().addElement(button);
  86. //button = GUIButton::create(*this, HString(L"Add GameObjects"));
  87. //button->onClick.connect(boost::bind(&TestTextSprite::dbgAdd, this));
  88. //area->getLayout().addElement(button);
  89. //button = GUIButton::create(*this, HString(L"Rename GameObject"));
  90. //button->onClick.connect(boost::bind(&TestTextSprite::dbgRename, this));
  91. //area->getLayout().addElement(button);
  92. //button = GUIButton::create(*this, HString(L"Remove child GameObjects"));
  93. //button->onClick.connect(boost::bind(&TestTextSprite::dbgRemoveChildren, this));
  94. //area->getLayout().addElement(button);
  95. //button = GUIButton::create(*this, HString(L"Remove parent GameObjects"));
  96. //button->onClick.connect(boost::bind(&TestTextSprite::dbgRemoveParents, this));
  97. //area->getLayout().addElement(button);
  98. area->getLayout().addFlexibleSpace();
  99. labelString = HString(L"\\{0}, {1}");
  100. //mLabel->setContent(GUIContent(labelString));
  101. }
  102. void TestTextSprite::update()
  103. {
  104. labelString.setParameter(0, toWString(Input::instance().getCursorPosition().x));
  105. mSceneTreeView->update();
  106. mResourceTreeView->update();
  107. //labelString.setParameter(1, toWString(Input::instance().getCursorPosition().y));
  108. }
  109. void TestTextSprite::dbgBtn()
  110. {
  111. static int dbg = 0;
  112. if(dbg == 0)
  113. {
  114. //Vector<HString>::type dropDownElements;
  115. //dropDownElements.push_back(HString(L"Element #4"));
  116. //dropDownElements.push_back(HString(L"Element #5"));
  117. //dropDownElements.push_back(HString(L"Element #6"));
  118. //mListBox->setElements(dropDownElements);
  119. //StringTable::instance().setString(L"dbgBtn", Language::Abkhazian, L"ALOALO");
  120. //StringTable::instance().setActiveLanguage(Language::Abkhazian);
  121. }
  122. else if(dbg == 1)
  123. {
  124. //StringTable::instance().removeString(L"dbgBtn");
  125. }
  126. dbg++;
  127. }
  128. void TestTextSprite::dbgAdd()
  129. {
  130. mDbgMainA = SceneObject::create("DEBUG_A");
  131. mDbgChildA = SceneObject::create("DEBUG_CHILD_0");
  132. mDbgChildA->setParent(mDbgMainA);
  133. mDbgChildB = SceneObject::create("DEBUG_CHILD_1");
  134. mDbgChildB->setParent(mDbgMainA);
  135. mDbgChildC = SceneObject::create("DEBUG_CHILD_2");
  136. mDbgChildC->setParent(mDbgMainA);
  137. mDbgMainB = SceneObject::create("DEBUG_B");
  138. }
  139. void TestTextSprite::dbgRename()
  140. {
  141. mDbgMainA->setName("Z_DEBUG_RENAMED_A");
  142. }
  143. void TestTextSprite::dbgRemoveChildren()
  144. {
  145. mDbgChildA->destroy();
  146. mDbgChildB->destroy();
  147. }
  148. void TestTextSprite::dbgRemoveParents()
  149. {
  150. mDbgMainA->destroy();
  151. mDbgMainB->destroy();
  152. }
  153. }