UIMenuWindow.cpp 935 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #include <TurboBadger/tb_widgets.h>
  2. #include <TurboBadger/tb_widgets_common.h>
  3. #include <TurboBadger/tb_menu_window.h>
  4. #include "UI.h"
  5. #include "UIEvents.h"
  6. #include "UIWidget.h"
  7. #include "UISelectItem.h"
  8. #include "UIMenuWindow.h"
  9. using namespace tb;
  10. namespace Atomic
  11. {
  12. UIMenuWindow::UIMenuWindow(Context* context, UIWidget* target, const String& id) : UIWidget(context, false)
  13. , source_(0)
  14. {
  15. widget_ = new TBMenuWindow(target->GetInternalWidget(), TBID(id.CString()));
  16. widget_->SetDelegate(this);
  17. GetSubsystem<UI>()->WrapWidget(this, widget_);
  18. }
  19. UIMenuWindow::~UIMenuWindow()
  20. {
  21. if (source_)
  22. delete source_;
  23. }
  24. void UIMenuWindow::Show(UISelectItemSource* source)
  25. {
  26. if (source_)
  27. delete source_;
  28. source_ = source->GetTBItemSource();
  29. ((TBMenuWindow*)widget_)->Show(source_, TBPopupAlignment());
  30. }
  31. bool UIMenuWindow::OnEvent(const tb::TBWidgetEvent &ev)
  32. {
  33. return false;
  34. }
  35. }