GActionGroup.h 879 B

1234567891011121314151617181920212223242526272829303132333435
  1. #pragma once
  2. #include <AK/HashTable.h>
  3. #include <AK/Weakable.h>
  4. class GAction;
  5. class GActionGroup : public Weakable<GActionGroup> {
  6. public:
  7. GActionGroup() {}
  8. ~GActionGroup() {}
  9. void add_action(GAction&);
  10. void remove_action(GAction&);
  11. bool is_exclusive() const { return m_exclusive; }
  12. void set_exclusive(bool exclusive) { m_exclusive = exclusive; }
  13. bool is_unchecking_allowed() const { return m_unchecking_allowed; }
  14. void set_unchecking_allowed(bool unchecking_allowed) { m_unchecking_allowed = unchecking_allowed; }
  15. template<typename C>
  16. void for_each_action(C callback)
  17. {
  18. for (auto& it : m_actions) {
  19. if (callback(*it) == IterationDecision::Break)
  20. break;
  21. }
  22. }
  23. private:
  24. HashTable<GAction*> m_actions;
  25. bool m_exclusive { false };
  26. bool m_unchecking_allowed { false };
  27. };