UIWindow.cpp 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. #include <TurboBadger/tb_widgets.h>
  2. #include <TurboBadger/tb_widgets_common.h>
  3. #include <TurboBadger/tb_window.h>
  4. #include "../IO/Log.h"
  5. #include "UI.h"
  6. #include "UIEvents.h"
  7. #include "UIWindow.h"
  8. using namespace tb;
  9. namespace Atomic
  10. {
  11. UIWindow::UIWindow(Context* context, bool createWidget) : UIWidget(context, false)
  12. {
  13. if (createWidget)
  14. {
  15. widget_ = new TBWindow();
  16. widget_->SetDelegate(this);
  17. GetSubsystem<UI>()->WrapWidget(this, widget_);
  18. }
  19. }
  20. void UIWindow::SetSettings(unsigned settings)
  21. {
  22. if (!widget_)
  23. return;
  24. ((TBWindow*)widget_)->SetSettings((WINDOW_SETTINGS) settings);
  25. }
  26. void UIWindow::ResizeToFitContent()
  27. {
  28. if (!widget_)
  29. return;
  30. ((TBWindow*)widget_)->ResizeToFitContent();
  31. }
  32. void UIWindow::Close()
  33. {
  34. if (!widget_)
  35. return;
  36. ((TBWindow*)widget_)->Close();
  37. }
  38. void UIWindow::AddChild(UIWidget *child)
  39. {
  40. if (!widget_ || !child->GetInternalWidget())
  41. return;
  42. UIWidget::AddChild(child);
  43. // this is to get proper padding, this may cause problems
  44. // as this is called from the widget_reader, and not as part of
  45. // AddChild. This may also need to be called from other widgets
  46. // that have padding, etc
  47. widget_->OnInflateChild(child->GetInternalWidget());
  48. }
  49. UIWindow::~UIWindow()
  50. {
  51. }
  52. bool UIWindow::OnEvent(const tb::TBWidgetEvent &ev)
  53. {
  54. return UIWidget::OnEvent(ev);
  55. }
  56. }