2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
12 \file GUIControlGroup.h
16 #include "GUIControlLookup.h"
22 \brief group of controls, useful for remembering last control + animating/hiding together
24 class CGUIControlGroup
: public CGUIControlLookup
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); }
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 void AssignDepth() override
;
46 EVENT_RESULT
SendMouseEvent(const CPoint
& point
, const KODI::MOUSE::CMouseEvent
& event
) override
;
47 void UnfocusFromPoint(const CPoint
&point
) override
;
49 void SetInitialVisibility() override
;
51 bool IsAnimating(ANIMATION_TYPE anim
) override
;
52 bool HasAnimation(ANIMATION_TYPE anim
) override
;
53 void QueueAnimation(ANIMATION_TYPE anim
) override
;
54 void ResetAnimation(ANIMATION_TYPE anim
) override
;
55 void ResetAnimations() override
;
57 int GetFocusedControlID() const;
58 CGUIControl
*GetFocusedControl() const;
59 virtual CGUIControl
*GetFirstFocusableControl(int id
);
61 virtual void AddControl(CGUIControl
*control
, int position
= -1);
62 bool InsertControl(CGUIControl
*control
, const CGUIControl
*insertPoint
);
63 virtual bool RemoveControl(const CGUIControl
*control
);
64 virtual void ClearAll();
65 void SetDefaultControl(int id
, bool always
)
67 m_defaultControl
= id
;
68 m_defaultAlways
= always
;
70 void SetRenderFocusedLast(bool renderLast
) { m_renderFocusedLast
= renderLast
; }
72 void SaveStates(std::vector
<CControlState
> &states
) override
;
74 bool IsGroup() const override
{ return true; }
77 void DumpTextureUse() override
;
81 std::vector
<CGUIControl
*> m_children
;
83 typedef std::vector
<CGUIControl
*>::iterator iControls
;
84 typedef std::vector
<CGUIControl
*>::const_iterator ciControls
;
85 typedef std::vector
<CGUIControl
*>::reverse_iterator rControls
;
86 typedef std::vector
<CGUIControl
*>::const_reverse_iterator crControls
;
91 bool m_renderFocusedLast
;
93 typedef std::vector
< std::vector
<CGUIControl
*> * > COLLECTORTYPE
;
95 struct IDCollectorList
99 for (auto item
: m_items
)
103 std::vector
<CGUIControl
*> *Get() {
104 if (++m_stackDepth
> m_items
.size())
105 m_items
.push_back(new std::vector
<CGUIControl
*>());
106 return m_items
[m_stackDepth
- 1];
109 void Release() { --m_stackDepth
; }
111 COLLECTORTYPE m_items
;
112 size_t m_stackDepth
= 0;
117 explicit IDCollector(IDCollectorList
& list
) : m_list(list
), m_collector(list
.Get()) {}
119 ~IDCollector() { m_list
.Release(); }
121 IDCollectorList
&m_list
;
122 std::vector
<CGUIControl
*> *m_collector
;