BsGUIContextMenu.cpp 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #include "BsGUIContextMenu.h"
  2. #include "BsGUIDropDownBoxManager.h"
  3. #include "BsGUIManager.h"
  4. namespace BansheeEngine
  5. {
  6. GUIContextMenu::GUIContextMenu()
  7. :GUIMenu(), mContextMenuOpen(false)
  8. {
  9. }
  10. GUIContextMenu::~GUIContextMenu()
  11. {
  12. close();
  13. }
  14. void GUIContextMenu::open(const Vector2I& position, CGUIWidget& widget)
  15. {
  16. DROP_DOWN_BOX_DESC desc;
  17. desc.camera = widget.getCamera();
  18. desc.skin = widget.getSkinResource();
  19. desc.placement = DropDownAreaPlacement::aroundPosition(position);
  20. desc.dropDownData = getDropDownData();
  21. GameObjectHandle<GUIDropDownMenu> dropDownBox = GUIDropDownBoxManager::instance().openDropDownBox(
  22. desc, GUIDropDownType::ContextMenu, std::bind(&GUIContextMenu::onMenuClosed, this));
  23. mContextMenuOpen = true;
  24. }
  25. void GUIContextMenu::close()
  26. {
  27. if(mContextMenuOpen)
  28. {
  29. GUIDropDownBoxManager::instance().closeDropDownBox();
  30. mContextMenuOpen = false;
  31. }
  32. }
  33. void GUIContextMenu::onMenuClosed()
  34. {
  35. mContextMenuOpen = false;
  36. }
  37. }