kodi
GUIControlGroup.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2018 Team Kodi
3  * This file is part of Kodi - https://kodi.tv
4  *
5  * SPDX-License-Identifier: GPL-2.0-or-later
6  * See LICENSES/README.md for more information.
7  */
8 
9 #pragma once
10 
16 #include "GUIControlLookup.h"
17 
18 #include <vector>
19 
25 {
26 public:
28  CGUIControlGroup(int parentID, int controlID, float posX, float posY, float width, float height);
29  explicit CGUIControlGroup(const CGUIControlGroup& from);
30  ~CGUIControlGroup(void) override;
31  CGUIControlGroup* Clone() const override { return new CGUIControlGroup(*this); }
32 
33  void Process(unsigned int currentTime, CDirtyRegionList &dirtyregions) override;
34  void Render() override;
35  void RenderEx() override;
36  bool OnAction(const CAction &action) override;
37  bool OnMessage(CGUIMessage& message) override;
38  virtual bool SendControlMessage(CGUIMessage& message);
39  bool HasFocus() const override;
40  void AllocResources() override;
41  void FreeResources(bool immediately = false) override;
42  void DynamicResourceAlloc(bool bOnOff) override;
43  bool CanFocus() const override;
44 
45  EVENT_RESULT SendMouseEvent(const CPoint& point, const KODI::MOUSE::CMouseEvent& event) override;
46  void UnfocusFromPoint(const CPoint &point) override;
47 
48  void SetInitialVisibility() override;
49 
50  bool IsAnimating(ANIMATION_TYPE anim) override;
51  bool HasAnimation(ANIMATION_TYPE anim) override;
52  void QueueAnimation(ANIMATION_TYPE anim) override;
53  void ResetAnimation(ANIMATION_TYPE anim) override;
54  void ResetAnimations() override;
55 
56  int GetFocusedControlID() const;
57  CGUIControl *GetFocusedControl() const;
58  virtual CGUIControl *GetFirstFocusableControl(int id);
59 
60  virtual void AddControl(CGUIControl *control, int position = -1);
61  bool InsertControl(CGUIControl *control, const CGUIControl *insertPoint);
62  virtual bool RemoveControl(const CGUIControl *control);
63  virtual void ClearAll();
64  void SetDefaultControl(int id, bool always)
65  {
66  m_defaultControl = id;
67  m_defaultAlways = always;
68  }
69  void SetRenderFocusedLast(bool renderLast) { m_renderFocusedLast = renderLast; }
70 
71  void SaveStates(std::vector<CControlState> &states) override;
72 
73  bool IsGroup() const override { return true; }
74 
75 #ifdef _DEBUG
76  void DumpTextureUse() override;
77 #endif
78 protected:
79  // sub controls
80  std::vector<CGUIControl *> m_children;
81 
82  typedef std::vector<CGUIControl *>::iterator iControls;
83  typedef std::vector<CGUIControl *>::const_iterator ciControls;
84  typedef std::vector<CGUIControl *>::reverse_iterator rControls;
85  typedef std::vector<CGUIControl *>::const_reverse_iterator crControls;
86 
87  int m_defaultControl;
88  bool m_defaultAlways;
89  int m_focusedControl;
90  bool m_renderFocusedLast;
91 private:
92  typedef std::vector< std::vector<CGUIControl *> * > COLLECTORTYPE;
93 
94  struct IDCollectorList
95  {
96  ~IDCollectorList()
97  {
98  for (auto item : m_items)
99  delete item;
100  }
101 
102  std::vector<CGUIControl *> *Get() {
103  if (++m_stackDepth > m_items.size())
104  m_items.push_back(new std::vector<CGUIControl *>());
105  return m_items[m_stackDepth - 1];
106  }
107 
108  void Release() { --m_stackDepth; }
109 
110  COLLECTORTYPE m_items;
111  size_t m_stackDepth = 0;
112  }m_idCollector;
113 
114  struct IDCollector
115  {
116  explicit IDCollector(IDCollectorList& list) : m_list(list), m_collector(list.Get()) {}
117 
118  ~IDCollector() { m_list.Release(); }
119 
120  IDCollectorList &m_list;
121  std::vector<CGUIControl *> *m_collector;
122  };
123 };
124 
Definition: GUIControlLookup.h:13
Base class for controls.
Definition: GUIControl.h:83
EVENT_RESULT
Results of OnMouseEvent() Any value not equal to EVENT_RESULT_UNHANDLED indicates that the event was ...
Definition: GUIControl.h:68
EVENT_RESULT SendMouseEvent(const CPoint &point, const KODI::MOUSE::CMouseEvent &event) override
React to a mouse event.
Definition: GUIControlGroup.cpp:357
Class encapsulating information regarding a particular user action to be sent to windows and controls...
Definition: Action.h:21
Definition: GUIMessage.h:365
group of controls, useful for remembering last control + animating/hiding together ...
Definition: GUIControlGroup.h:24
Simple class for mouse events.
Definition: MouseEvent.h:20
void UnfocusFromPoint(const CPoint &point) override
Unfocus the control if the given point on screen is not within it&#39;s boundary.
Definition: GUIControlGroup.cpp:385