CmTestTextSprite.cpp 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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. using namespace CamelotFramework;
  29. using namespace BansheeEngine;
  30. namespace BansheeEditor
  31. {
  32. TestTextSprite::TestTextSprite(const HSceneObject& parent, CM::Viewport* target)
  33. :GUIWidget(parent, target), mListBox(nullptr)
  34. {
  35. }
  36. TestTextSprite::~TestTextSprite()
  37. {
  38. }
  39. void TestTextSprite::init(const HCamera& camera, const String& text, CM::RenderTexturePtr sceneView)
  40. {
  41. setSkin(BansheeEditor::EditorGUI::instance().getSkin());
  42. setDepth(128);
  43. GUIArea* area = GUIArea::createStretchedXY(*this, 0, 0, 0, 0);
  44. mSceneTreeView = GUISceneTreeView::create(*this, GUIOptions(GUIOption::flexibleWidth(), GUIOption::flexibleHeight()));
  45. GUILayout& sceneTreeViewLayout = area->getLayout().addLayoutY();
  46. sceneTreeViewLayout.addFlexibleSpace();
  47. sceneTreeViewLayout.addElement(mSceneTreeView);
  48. sceneTreeViewLayout.addFlexibleSpace();
  49. //area->getLayout().addElement(GUIRenderTexture::create(*this, sceneView, GUIOptions(GUIOption::fixedWidth(800), GUIOption::fixedHeight(600))));
  50. //mLabel = GUILabel::create(*this, HString(L""));
  51. //area->getLayout().addElement(mLabel);
  52. //Vector<HString>::type dropDownElements;
  53. //dropDownElements.push_back(HString(L"Ejlement #1"));
  54. //dropDownElements.push_back(HString(L"Element #2"));
  55. //dropDownElements.push_back(HString(L"Element #3"));
  56. //mListBox = GUIListBox::create(*this, dropDownElements, GUIOptions(GUIOption::fixedWidth(50), GUIOption::fixedHeight(13)));
  57. //area->getLayout().addElement(mListBox);
  58. GUIButton* button = GUIButton::create(*this, HString(L"dbgBtn"));
  59. button->onClick.connect(boost::bind(&TestTextSprite::dbgBtn, this));
  60. area->getLayout().addElement(button);
  61. area->getLayout().addFlexibleSpace();
  62. labelString = HString(L"\\{0}, {1}");
  63. //mLabel->setContent(GUIContent(labelString));
  64. }
  65. void TestTextSprite::update()
  66. {
  67. labelString.setParameter(0, toWString(Input::instance().getCursorPosition().x));
  68. mSceneTreeView->update();
  69. //labelString.setParameter(1, toWString(Input::instance().getCursorPosition().y));
  70. }
  71. void TestTextSprite::dbgBtn()
  72. {
  73. static int dbg = 0;
  74. if(dbg == 0)
  75. {
  76. //Vector<HString>::type dropDownElements;
  77. //dropDownElements.push_back(HString(L"Element #4"));
  78. //dropDownElements.push_back(HString(L"Element #5"));
  79. //dropDownElements.push_back(HString(L"Element #6"));
  80. //mListBox->setElements(dropDownElements);
  81. //StringTable::instance().setString(L"dbgBtn", Language::Abkhazian, L"ALOALO");
  82. //StringTable::instance().setActiveLanguage(Language::Abkhazian);
  83. }
  84. else if(dbg == 1)
  85. {
  86. //StringTable::instance().removeString(L"dbgBtn");
  87. }
  88. dbg++;
  89. }
  90. }