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.
9 #include "GUIListLabel.h"
11 #include "addons/Skin.h"
15 using namespace KODI::GUILIB
;
17 CGUIListLabel::CGUIListLabel(int parentID
, int controlID
, float posX
, float posY
, float width
, float height
,
18 const CLabelInfo
& labelInfo
, const GUIINFO::CGUIInfoLabel
&info
, CGUIControl::GUISCROLLVALUE scroll
)
19 : CGUIControl(parentID
, controlID
, posX
, posY
, width
, height
)
20 , m_label(posX
, posY
, width
, height
, labelInfo
, (scroll
== CGUIControl::ALWAYS
) ? CGUILabel::OVER_FLOW_SCROLL
: CGUILabel::OVER_FLOW_TRUNCATE
)
24 if (m_info
.IsConstant())
25 SetLabel(m_info
.GetLabel(m_parentID
, true));
26 m_label
.SetScrollLoopCount(2);
27 ControlType
= GUICONTROL_LISTLABEL
;
30 CGUIListLabel::~CGUIListLabel(void) = default;
32 void CGUIListLabel::SetSelected(bool selected
)
34 if(m_label
.SetColor(selected
? CGUILabel::COLOR_SELECTED
: CGUILabel::COLOR_TEXT
))
38 void CGUIListLabel::SetFocus(bool focus
)
40 CGUIControl::SetFocus(focus
);
41 if (m_scroll
== CGUIControl::FOCUS
)
43 m_label
.SetScrolling(focus
);
47 CRect
CGUIListLabel::CalcRenderRegion() const
49 return m_label
.GetRenderRect();
52 bool CGUIListLabel::UpdateColors(const CGUIListItem
* item
)
54 bool changed
= CGUIControl::UpdateColors(nullptr);
55 changed
|= m_label
.UpdateColors();
60 void CGUIListLabel::Process(unsigned int currentTime
, CDirtyRegionList
&dirtyregions
)
62 if (m_label
.Process(currentTime
))
65 CGUIControl::Process(currentTime
, dirtyregions
);
68 void CGUIListLabel::Render()
70 if (CServiceBroker::GetWinSystem()->GetGfxContext().GetRenderOrder() ==
71 RENDER_ORDER_FRONT_TO_BACK
)
74 CGUIControl::Render();
77 void CGUIListLabel::UpdateInfo(const CGUIListItem
*item
)
79 if (m_info
.IsConstant() && !m_bInvalidated
)
80 return; // nothing to do
83 SetLabel(m_info
.GetItemLabel(item
));
85 SetLabel(m_info
.GetLabel(m_parentID
, true));
88 void CGUIListLabel::SetInvalid()
91 CGUIControl::SetInvalid();
94 void CGUIListLabel::SetWidth(float width
)
97 if (m_label
.GetLabelInfo().align
& XBFONT_RIGHT
)
98 m_label
.SetMaxRect(m_posX
- m_width
, m_posY
, m_width
, m_height
);
99 else if (m_label
.GetLabelInfo().align
& XBFONT_CENTER_X
)
100 m_label
.SetMaxRect(m_posX
- m_width
*0.5f
, m_posY
, m_width
, m_height
);
102 m_label
.SetMaxRect(m_posX
, m_posY
, m_width
, m_height
);
103 CGUIControl::SetWidth(m_width
);
106 void CGUIListLabel::SetLabel(const std::string
&label
)
108 m_label
.SetText(label
);