[WASAPI] fix stream types and frequencies enumeration
[xbmc.git] / xbmc / guilib / GUIListLabel.cpp
blob6797ba99dc963e5a22f34c46703daf1a175c6267
1 /*
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.
7 */
9 #include "GUIListLabel.h"
11 #include "addons/Skin.h"
13 #include <limits>
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)
21 , m_info(info)
23 m_scroll = scroll;
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))
35 SetInvalid();
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();
57 return changed;
60 void CGUIListLabel::Process(unsigned int currentTime, CDirtyRegionList &dirtyregions)
62 if (m_label.Process(currentTime))
63 MarkDirtyRegion();
65 CGUIControl::Process(currentTime, dirtyregions);
68 void CGUIListLabel::Render()
70 if (CServiceBroker::GetWinSystem()->GetGfxContext().GetRenderOrder() ==
71 RENDER_ORDER_FRONT_TO_BACK)
72 return;
73 m_label.Render();
74 CGUIControl::Render();
77 void CGUIListLabel::UpdateInfo(const CGUIListItem *item)
79 if (m_info.IsConstant() && !m_bInvalidated)
80 return; // nothing to do
82 if (item)
83 SetLabel(m_info.GetItemLabel(item));
84 else
85 SetLabel(m_info.GetLabel(m_parentID, true));
88 void CGUIListLabel::SetInvalid()
90 m_label.SetInvalid();
91 CGUIControl::SetInvalid();
94 void CGUIListLabel::SetWidth(float width)
96 m_width = 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);
101 else
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);