RUPopupMgr.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. //
  2. // RUPopupMgr.h
  3. // red_utils
  4. //
  5. // Created by ZhengSong on 2023/6/9.
  6. //
  7. #ifndef RUPopupMgr_h
  8. #define RUPopupMgr_h
  9. #include "RUDefine.h"
  10. NS_RU_BEGIN
  11. class BasePopup;
  12. class PopupDelegate;
  13. class PopupMgr {
  14. public:
  15. static PopupMgr* getInstance();
  16. /// 立即打开弹窗
  17. void openPopup(BasePopup* popup);
  18. /// 打开弹窗(向队列插入待打开窗口),如果当前没有弹窗,根据窗口优先级排序,优先级越小优先弹窗
  19. void openPopupByQueue(BasePopup* popup);
  20. /// 关闭指定弹窗
  21. void closePopup(std::string popupName);
  22. /// 弹窗页面关闭成功
  23. void popupLayerClosed(std::string popupName);
  24. ///强制关闭当前,清空队列,重新开启新弹窗
  25. void forcePopup(BasePopup* popup);
  26. ///设置代理
  27. void setPopupDelegate(PopupDelegate* delegate);
  28. ///弹窗析构检查
  29. void checkPopupByDestruct(BasePopup* popup);
  30. private:
  31. void _popupLayer(BasePopup* popup);
  32. ///是否已经存在同名窗口
  33. bool _existWindowName(std::string popupName);
  34. private:
  35. std::vector<BasePopup*> _waiting; //弹窗等待数组
  36. std::vector<BasePopup*> _running; //正在运行弹窗数组
  37. PopupDelegate* _delegate = nullptr;
  38. bool _isClosing = false;
  39. };
  40. NS_RU_END
  41. #endif /* RUPopupMgr_h */