BsGUIContextMenu.cpp 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. #include "BsGUIContextMenu.h"
  4. #include "BsGUIDropDownBoxManager.h"
  5. #include "BsGUIManager.h"
  6. namespace BansheeEngine
  7. {
  8. GUIContextMenu::GUIContextMenu()
  9. :GUIMenu(), mContextMenuOpen(false)
  10. {
  11. }
  12. GUIContextMenu::~GUIContextMenu()
  13. {
  14. close();
  15. }
  16. void GUIContextMenu::open(const Vector2I& position, GUIWidget& widget)
  17. {
  18. DROP_DOWN_BOX_DESC desc;
  19. desc.camera = widget.getCamera();
  20. desc.skin = widget.getSkinResource();
  21. desc.placement = DropDownAreaPlacement::aroundPosition(position);
  22. desc.dropDownData = getDropDownData();
  23. GameObjectHandle<GUIDropDownMenu> dropDownBox = GUIDropDownBoxManager::instance().openDropDownBox(
  24. desc, GUIDropDownType::ContextMenu, std::bind(&GUIContextMenu::onMenuClosed, this));
  25. mContextMenuOpen = true;
  26. }
  27. void GUIContextMenu::close()
  28. {
  29. if(mContextMenuOpen)
  30. {
  31. GUIDropDownBoxManager::instance().closeDropDownBox();
  32. mContextMenuOpen = false;
  33. }
  34. }
  35. void GUIContextMenu::onMenuClosed()
  36. {
  37. mContextMenuOpen = false;
  38. }
  39. }