BsGUIFieldBase.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. #pragma once
  2. #include "BsEditorPrerequisites.h"
  3. #include "BsGUIElementContainer.h"
  4. namespace BansheeEditor
  5. {
  6. class BS_ED_EXPORT GUIFieldBase : public BS::GUIElementContainer
  7. {
  8. protected:
  9. struct PrivatelyConstruct {};
  10. public:
  11. GUIFieldBase(const PrivatelyConstruct& dummy, BS::GUIWidget& parent, const BS::GUIContent& labelContent, CM::UINT32 labelWidth,
  12. BS::GUIElementStyle* labelStyle, const BS::GUILayoutOptions& layoutOptions, bool withLabel);
  13. void _updateLayoutInternal(CM::INT32 x, CM::INT32 y, CM::UINT32 width, CM::UINT32 height,
  14. CM::RectI clipRect, CM::UINT8 widgetDepth, CM::UINT16 areaDepth);
  15. CM::Vector2I _getOptimalSize() const;
  16. protected:
  17. virtual ~GUIFieldBase() { }
  18. protected:
  19. static const CM::UINT32 DEFAULT_LABEL_WIDTH;
  20. BS::GUILayout* mLayout;
  21. BS::GUILabel* mLabel;
  22. };
  23. template <class T>
  24. class TGUIField : public GUIFieldBase
  25. {
  26. public:
  27. static T* create(BS::GUIWidget& parent, const BS::GUIContent& labelContent, CM::UINT32 labelWidth, const BS::GUIOptions& layoutOptions,
  28. BS::GUIElementStyle* labelStyle = nullptr, BS::GUIElementStyle* entryElementStyle = nullptr)
  29. {
  30. return cm_new<T>(PrivatelyConstruct(), parent, labelContent, labelWidth, labelStyle, entryElementStyle,
  31. GUILayoutOptions::create(layoutOptions, &GUISkin::DefaultStyle), true);
  32. }
  33. static T* create(BS::GUIWidget& parent, const BS::GUIContent& labelContent, const BS::GUIOptions& layoutOptions,
  34. BS::GUIElementStyle* labelStyle = nullptr, BS::GUIElementStyle* entryElementStyle = nullptr)
  35. {
  36. return cm_new<T>(PrivatelyConstruct(), parent, labelContent, DEFAULT_LABEL_WIDTH, labelStyle, entryElementStyle,
  37. GUILayoutOptions::create(layoutOptions, &GUISkin::DefaultStyle), true);
  38. }
  39. static T* create(BS::GUIWidget& parent, const CM::HString& labelText, CM::UINT32 labelWidth, const BS::GUIOptions& layoutOptions,
  40. BS::GUIElementStyle* labelStyle = nullptr, BS::GUIElementStyle* entryElementStyle = nullptr)
  41. {
  42. return cm_new<T>(PrivatelyConstruct(), parent, BS::GUIContent(labelText), labelWidth, labelStyle, entryElementStyle,
  43. GUILayoutOptions::create(layoutOptions, &GUISkin::DefaultStyle), true);
  44. }
  45. static T* create(BS::GUIWidget& parent, const CM::HString& labelText, const BS::GUIOptions& layoutOptions,
  46. BS::GUIElementStyle* labelStyle = nullptr, BS::GUIElementStyle* entryElementStyle = nullptr)
  47. {
  48. return cm_new<T>(PrivatelyConstruct(), parent, BS::GUIContent(labelText), DEFAULT_LABEL_WIDTH, labelStyle, entryElementStyle,
  49. GUILayoutOptions::create(layoutOptions, &GUISkin::DefaultStyle), true);
  50. }
  51. static T* create(BS::GUIWidget& parent, const BS::GUIOptions& layoutOptions, BS::GUIElementStyle* entryElementStyle = nullptr)
  52. {
  53. return cm_new<T>(PrivatelyConstruct(), parent, BS::GUIContent(), 0, nullptr, entryElementStyle,
  54. GUILayoutOptions::create(layoutOptions, &GUISkin::DefaultStyle), false);
  55. }
  56. static T* create(BS::GUIWidget& parent, const BS::GUIContent& labelContent, CM::UINT32 labelWidth,
  57. BS::GUIElementStyle* labelStyle = nullptr, BS::GUIElementStyle* entryElementStyle = nullptr)
  58. {
  59. return cm_new<T>(PrivatelyConstruct(), parent, labelContent, labelWidth, labelStyle, entryElementStyle,
  60. GUILayoutOptions::create(&GUISkin::DefaultStyle), true);
  61. }
  62. static T* create(BS::GUIWidget& parent, const BS::GUIContent& labelContent,
  63. BS::GUIElementStyle* labelStyle = nullptr, BS::GUIElementStyle* entryElementStyle = nullptr)
  64. {
  65. return cm_new<T>(PrivatelyConstruct(), parent, labelContent, DEFAULT_LABEL_WIDTH, labelStyle, entryElementStyle,
  66. GUILayoutOptions::create(&GUISkin::DefaultStyle), true);
  67. }
  68. static T* create(BS::GUIWidget& parent, const CM::HString& labelText, CM::UINT32 labelWidth,
  69. BS::GUIElementStyle* labelStyle = nullptr, BS::GUIElementStyle* entryElementStyle = nullptr)
  70. {
  71. return cm_new<T>(PrivatelyConstruct(), parent, BS::GUIContent(labelText), labelWidth, labelStyle, entryElementStyle,
  72. GUILayoutOptions::create(&GUISkin::DefaultStyle), true);
  73. }
  74. static T* create(BS::GUIWidget& parent, const CM::HString& labelText,
  75. BS::GUIElementStyle* labelStyle = nullptr, BS::GUIElementStyle* entryElementStyle = nullptr)
  76. {
  77. return cm_new<T>(PrivatelyConstruct(), parent, BS::GUIContent(labelText), DEFAULT_LABEL_WIDTH, labelStyle, entryElementStyle,
  78. GUILayoutOptions::create(&GUISkin::DefaultStyle), true);
  79. }
  80. static T* create(BS::GUIWidget& parent, BS::GUIElementStyle* entryElementStyle = nullptr)
  81. {
  82. return cm_new<T>(PrivatelyConstruct(), parent, BS::GUIContent(), 0, nullptr, entryElementStyle,
  83. GUILayoutOptions::create(&GUISkin::DefaultStyle), false);
  84. }
  85. TGUIField(const PrivatelyConstruct& dummy, BS::GUIWidget& parent, const BS::GUIContent& labelContent, CM::UINT32 labelWidth,
  86. BS::GUIElementStyle* labelStyle, const BS::GUILayoutOptions& layoutOptions, bool withLabel)
  87. :GUIFieldBase(dummy, parent, labelContent, labelWidth, labelStyle, layoutOptions, withLabel)
  88. { }
  89. };
  90. }