UILayout.cpp 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. #include <TurboBadger/tb_widgets.h>
  2. #include <TurboBadger/tb_widgets_common.h>
  3. #include <TurboBadger/tb_layout.h>
  4. #include "UI.h"
  5. #include "UIEvents.h"
  6. #include "UIWidget.h"
  7. #include "UILayout.h"
  8. using namespace tb;
  9. namespace Atomic
  10. {
  11. UILayout::UILayout(Context* context, bool createWidget) : UIWidget(context, false)
  12. {
  13. if (createWidget)
  14. {
  15. widget_ = new TBLayout();
  16. widget_->SetDelegate(this);
  17. widget_->SetGravity(WIDGET_GRAVITY_ALL);
  18. GetSubsystem<UI>()->WrapWidget(this, widget_);
  19. }
  20. }
  21. UILayout::~UILayout()
  22. {
  23. }
  24. void UILayout::SetSpacing(int spacing)
  25. {
  26. if (!widget_)
  27. return;
  28. ((tb::TBLayout*)widget_)->SetSpacing(spacing);
  29. }
  30. void UILayout::SetLayoutPosition(/*LAYOUT_POSITION*/ unsigned position)
  31. {
  32. if (!widget_)
  33. return;
  34. ((tb::TBLayout*)widget_)->SetLayoutPosition( (LAYOUT_POSITION) position);
  35. }
  36. void UILayout::SetLayoutDistributionPosition(/*LAYOUT_DISTRIBUTION_POSITION*/ unsigned distribution_pos)
  37. {
  38. if (!widget_)
  39. return;
  40. ((tb::TBLayout*)widget_)->SetLayoutDistributionPosition( (LAYOUT_DISTRIBUTION_POSITION) distribution_pos);
  41. }
  42. void UILayout::SetLayoutSize(unsigned size)
  43. {
  44. if (!widget_)
  45. return;
  46. ((tb::TBLayout*)widget_)->SetLayoutSize((LAYOUT_SIZE) size);
  47. }
  48. void UILayout::SetAxis(unsigned axis)
  49. {
  50. if (!widget_)
  51. return;
  52. ((tb::TBLayout*)widget_)->SetAxis((AXIS) axis);
  53. }
  54. void UILayout::SetLayoutDistribution(/* LAYOUT_DISTRIBUTION */ unsigned distribution)
  55. {
  56. if (!widget_)
  57. return;
  58. ((tb::TBLayout*)widget_)->SetLayoutDistribution((LAYOUT_DISTRIBUTION) distribution);
  59. }
  60. bool UILayout::OnEvent(const tb::TBWidgetEvent &ev)
  61. {
  62. return UIWidget::OnEvent(ev);
  63. }
  64. }