BsGUIContextMenu.cpp 968 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  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, GUIWidget& widget)
  15. {
  16. GUIDropDownAreaPlacement placement = GUIDropDownAreaPlacement::aroundPosition(position);
  17. GameObjectHandle<GUIDropDownBox> dropDownBox = GUIDropDownBoxManager::instance().openDropDownBox(widget.getTarget(),
  18. placement, getDropDownData(), widget.getSkin(), GUIDropDownType::ContextMenu, std::bind(&GUIContextMenu::onMenuClosed, this));
  19. mContextMenuOpen = true;
  20. }
  21. void GUIContextMenu::close()
  22. {
  23. if(mContextMenuOpen)
  24. {
  25. GUIDropDownBoxManager::instance().closeDropDownBox();
  26. mContextMenuOpen = false;
  27. }
  28. }
  29. void GUIContextMenu::onMenuClosed()
  30. {
  31. mContextMenuOpen = false;
  32. }
  33. }