Skip to content

Commit

Permalink
CGUIControl: Add stats parameter to Process calls
Browse files Browse the repository at this point in the history
No change other than plumbing
  • Loading branch information
popcornmix committed Jun 4, 2017
1 parent b4889a5 commit 38fc658
Show file tree
Hide file tree
Showing 105 changed files with 1,628 additions and 306 deletions.
1,208 changes: 1,208 additions & 0 deletions xbmc/addons/GUIDialogAddonSettings.cpp

Large diffs are not rendered by default.

95 changes: 95 additions & 0 deletions xbmc/addons/GUIDialogAddonSettings.h
@@ -0,0 +1,95 @@
#pragma once
/*
* Copyright (C) 2005-2013 Team XBMC
* http://xbmc.org
*
* This Program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This Program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with XBMC; see the file COPYING. If not, see
* <http://www.gnu.org/licenses/>.
*
*/

#include <map>
#include <string>
#include <vector>

#include "dialogs/GUIDialogBoxBase.h"
#include "IAddon.h"

class CGUIDialogAddonSettings : public CGUIDialogBoxBase
{
public:
CGUIDialogAddonSettings(void);
virtual ~CGUIDialogAddonSettings(void);
virtual bool OnMessage(CGUIMessage& message);
virtual bool OnAction(const CAction& action);
/*! \brief Show the addon settings dialog, allowing the user to configure an addon
\param addon the addon to configure
\param saveToDisk whether the changes should be saved to disk or just made local to the addon. Defaults to true
\return true if settings were changed and the dialog confirmed, false otherwise.
*/
static bool ShowAndGetInput(const ADDON::AddonPtr &addon, bool saveToDisk = true);
virtual void DoProcess(CGUIRenderInfo &renderInfo);

std::string GetCurrentID() const;
protected:
virtual void OnInitWindow();
virtual int GetDefaultLabelID(int controlId) const;

private:
/*! \brief return a (localized) addon string.
\param value either a character string (which is used directly) or a number to lookup in the addons strings.xml
\param subsetting whether the character string should be prefixed by "- ", defaults to false
\return the localized addon string
*/
std::string GetString(const char *value, bool subSetting = false) const;

/*! \brief return a the values for a fileenum setting
\param path the path to use for files
\param mask the mask to use
\param options any options, such as "hideext" to hide extensions
\return the filenames in the path that match the mask
*/
std::vector<std::string> GetFileEnumValues(const std::string &path, const std::string &mask, const std::string &options) const;

/*! \brief Translate list of addon IDs to list of addon names
\param addonIDslist comma separated list of addon IDs
\return comma separated list of addon names
*/
std::string GetAddonNames(const std::string& addonIDslist) const;

void CreateSections();
void FreeSections();
void CreateControls();
void FreeControls();
void UpdateFromControls();
void EnableControls();
void SetDefaultSettings();
bool GetCondition(const std::string &condition, const int controlId);

void SaveSettings(void);
bool ShowVirtualKeyboard(int iControl);
bool TranslateSingleString(const std::string &strCondition, std::vector<std::string> &enableVec);

const TiXmlElement *GetFirstSetting() const;

ADDON::AddonPtr m_addon;
std::map<std::string,std::string> m_buttonValues;
bool m_saveToDisk; // whether the addon settings should be saved to disk or just stored locally in the addon

unsigned int m_currentSection;
unsigned int m_totalSections;

std::map<std::string,std::string> m_settings; // local storage of values
};

4 changes: 2 additions & 2 deletions xbmc/dialogs/GUIDialogBoxBase.cpp
Expand Up @@ -110,7 +110,7 @@ void CGUIDialogBoxBase::SetChoice(int iButton, const CVariant &choice) // iButto
}
}

void CGUIDialogBoxBase::Process(unsigned int currentTime, CDirtyRegionList &dirtyregions)
void CGUIDialogBoxBase::Process(CGUIRenderInfo &renderInfo)
{
if (m_bInvalidated)
{ // take a copy of our labels to save holding the lock for too long
Expand Down Expand Up @@ -139,7 +139,7 @@ void CGUIDialogBoxBase::Process(unsigned int currentTime, CDirtyRegionList &dirt
for (size_t i = 0 ; i < choices.size() ; ++i)
SET_CONTROL_LABEL(CONTROL_CHOICES_START + i, choices[i]);
}
CGUIDialog::Process(currentTime, dirtyregions);
CGUIDialog::Process(renderInfo);
}

void CGUIDialogBoxBase::OnInitWindow()
Expand Down
2 changes: 1 addition & 1 deletion xbmc/dialogs/GUIDialogBoxBase.h
Expand Up @@ -58,7 +58,7 @@ class CGUIDialogBoxBase :
*/
std::string GetLocalized(const CVariant &var) const;

virtual void Process(unsigned int currentTime, CDirtyRegionList &dirtyregions);
virtual void Process(CGUIRenderInfo &renderInfo);
virtual void OnInitWindow();
virtual void OnDeinitWindow(int nextWindowID);

Expand Down
6 changes: 3 additions & 3 deletions xbmc/dialogs/GUIDialogBusy.cpp
Expand Up @@ -112,11 +112,11 @@ void CGUIDialogBusy::Open_Internal(const std::string &param /* = "" */)
}


void CGUIDialogBusy::DoProcess(unsigned int currentTime, CDirtyRegionList &dirtyregions)
void CGUIDialogBusy::DoProcess(CGUIRenderInfo &renderInfo)
{
bool visible = g_windowManager.GetTopMostModalDialogID() == WINDOW_DIALOG_BUSY;
if(!visible && m_bLastVisible)
dirtyregions.push_back(m_renderRegion);
renderInfo.AddRegion(m_renderRegion);
m_bLastVisible = visible;

// update the progress control if available
Expand All @@ -128,7 +128,7 @@ void CGUIDialogBusy::DoProcess(unsigned int currentTime, CDirtyRegionList &dirty
progress->SetVisible(m_progress > -1);
}

CGUIDialog::DoProcess(currentTime, dirtyregions);
CGUIDialog::DoProcess(renderInfo);
}

void CGUIDialogBusy::Render()
Expand Down
2 changes: 1 addition & 1 deletion xbmc/dialogs/GUIDialogBusy.h
Expand Up @@ -31,7 +31,7 @@ class CGUIDialogBusy: public CGUIDialog
CGUIDialogBusy(void);
virtual ~CGUIDialogBusy(void);
virtual bool OnBack(int actionID);
virtual void DoProcess(unsigned int currentTime, CDirtyRegionList &dirtyregions);
virtual void DoProcess(CGUIRenderInfo &renderInfo);
virtual void Render();
/*! \brief set the current progress of the busy operation
\param progress a percentage of progress
Expand Down
6 changes: 3 additions & 3 deletions xbmc/dialogs/GUIDialogExtendedProgressBar.cpp
Expand Up @@ -96,12 +96,12 @@ bool CGUIDialogExtendedProgressBar::OnMessage(CGUIMessage& message)
return CGUIDialog::OnMessage(message);
}

void CGUIDialogExtendedProgressBar::Process(unsigned int currentTime, CDirtyRegionList &dirtyregions)
void CGUIDialogExtendedProgressBar::Process(CGUIRenderInfo &renderInfo)
{
if (m_active)
UpdateState(currentTime);
UpdateState(renderInfo.GetTime());

CGUIDialog::Process(currentTime, dirtyregions);
CGUIDialog::Process(renderInfo);
}

void CGUIDialogExtendedProgressBar::UpdateState(unsigned int currentTime)
Expand Down
2 changes: 1 addition & 1 deletion xbmc/dialogs/GUIDialogExtendedProgressBar.h
Expand Up @@ -60,7 +60,7 @@ class CGUIDialogExtendedProgressBar : public CGUIDialog
CGUIDialogExtendedProgressBar(void);
virtual ~CGUIDialogExtendedProgressBar(void) {};
virtual bool OnMessage(CGUIMessage& message);
virtual void Process(unsigned int currentTime, CDirtyRegionList &dirtyregions);
virtual void Process(CGUIRenderInfo &renderInfo);

CGUIDialogProgressBarHandle *GetHandle(const std::string &strTitle);

Expand Down
4 changes: 2 additions & 2 deletions xbmc/dialogs/GUIDialogProgress.cpp
Expand Up @@ -176,7 +176,7 @@ void CGUIDialogProgress::ShowProgressBar(bool bOnOff)
SetInvalid();
}

void CGUIDialogProgress::Process(unsigned int currentTime, CDirtyRegionList &dirtyregions)
void CGUIDialogProgress::Process(CGUIRenderInfo &renderInfo)
{
if (m_bInvalidated)
{ // take a copy to save holding the lock for too long
Expand All @@ -195,7 +195,7 @@ void CGUIDialogProgress::Process(unsigned int currentTime, CDirtyRegionList &dir
else
SET_CONTROL_HIDDEN(CONTROL_NO_BUTTON);
}
CGUIDialogBoxBase::Process(currentTime, dirtyregions);
CGUIDialogBoxBase::Process(renderInfo);
}

void CGUIDialogProgress::OnInitWindow()
Expand Down
2 changes: 1 addition & 1 deletion xbmc/dialogs/GUIDialogProgress.h
Expand Up @@ -50,7 +50,7 @@ class CGUIDialogProgress :
protected:
virtual void OnInitWindow();
virtual int GetDefaultLabelID(int controlId) const;
virtual void Process(unsigned int currentTime, CDirtyRegionList &dirtyregions);
virtual void Process(CGUIRenderInfo &renderInfo);

bool m_bCanCancel;
bool m_bCanceled;
Expand Down
4 changes: 2 additions & 2 deletions xbmc/games/controllers/windows/GUIControllerWindow.cpp
Expand Up @@ -59,7 +59,7 @@ CGUIControllerWindow::~CGUIControllerWindow(void)
delete m_featureList;
}

void CGUIControllerWindow::DoProcess(unsigned int currentTime, CDirtyRegionList &dirtyregions)
void CGUIControllerWindow::DoProcess(CGUIRenderInfo &renderInfo)
{
/*
* Apply the faded focus texture to the current controller when unfocused
Expand All @@ -82,7 +82,7 @@ void CGUIControllerWindow::DoProcess(unsigned int currentTime, CDirtyRegionList
}
}

CGUIDialog::DoProcess(currentTime, dirtyregions);
CGUIDialog::DoProcess(renderInfo);

if (control && bAlphaFaded)
{
Expand Down
2 changes: 1 addition & 1 deletion xbmc/games/controllers/windows/GUIControllerWindow.h
Expand Up @@ -35,7 +35,7 @@ namespace GAME
virtual ~CGUIControllerWindow(void);

// implementation of CGUIControl via CGUIDialog
virtual void DoProcess(unsigned int currentTime, CDirtyRegionList &dirtyregions) override;
virtual void DoProcess(CGUIRenderInfo &renderInfo) override;
virtual bool OnMessage(CGUIMessage& message) override;

protected:
Expand Down
20 changes: 20 additions & 0 deletions xbmc/guilib/DirtyRegion.h
Expand Up @@ -35,3 +35,23 @@ class CDirtyRegion : public CRect
};

typedef std::vector<CDirtyRegion> CDirtyRegionList;

class CGUIRenderInfo
{
public:
CGUIRenderInfo() { Reset(0); }
void Reset(unsigned int t) { m_currentTime = t; m_dirtyregions.clear(); m_visible = 0; m_total = 0; }
void IncVisible() { m_visible++; }
void IncTotal() { m_total++; }
int GetVisible() { return m_visible; }
int GetTotal() { return m_total; }
unsigned int GetTime() { return m_currentTime; }
void AddRegion(const CDirtyRegion &region) { m_dirtyregions.push_back(region); }
CDirtyRegionList &GetRegions() { return m_dirtyregions; }
size_t GetRegionSize() { return m_dirtyregions.size(); }
private:
unsigned int m_currentTime;
CDirtyRegionList m_dirtyregions;
int m_visible;
int m_total;
};
26 changes: 13 additions & 13 deletions xbmc/guilib/GUIBaseContainer.cpp
Expand Up @@ -68,9 +68,9 @@ CGUIBaseContainer::~CGUIBaseContainer(void)
delete m_listProvider;
}

void CGUIBaseContainer::DoProcess(unsigned int currentTime, CDirtyRegionList &dirtyregions)
void CGUIBaseContainer::DoProcess(CGUIRenderInfo &renderInfo)
{
CGUIControl::DoProcess(currentTime, dirtyregions);
CGUIControl::DoProcess(renderInfo);

if (m_pageChangeTimer.IsRunning() && m_pageChangeTimer.GetElapsedMilliseconds() > 200)
m_pageChangeTimer.Stop();
Expand All @@ -83,10 +83,10 @@ void CGUIBaseContainer::DoProcess(unsigned int currentTime, CDirtyRegionList &di
}
}

void CGUIBaseContainer::Process(unsigned int currentTime, CDirtyRegionList &dirtyregions)
void CGUIBaseContainer::Process(CGUIRenderInfo &renderInfo)
{
// update our auto-scrolling as necessary
UpdateAutoScrolling(currentTime);
UpdateAutoScrolling(renderInfo.GetTime());

ValidateOffset();

Expand All @@ -95,7 +95,7 @@ void CGUIBaseContainer::Process(unsigned int currentTime, CDirtyRegionList &dirt

if (!m_layout || !m_focusedLayout) return;

UpdateScrollOffset(currentTime);
UpdateScrollOffset(renderInfo.GetTime());

int offset = (int)floorf(m_scroller.GetValue() / m_layout->Size(m_orientation));

Expand Down Expand Up @@ -130,9 +130,9 @@ void CGUIBaseContainer::Process(unsigned int currentTime, CDirtyRegionList &dirt
CGUIListItemPtr item = m_items[itemNo];
// render our item
if (m_orientation == VERTICAL)
ProcessItem(origin.x, pos, item, focused, currentTime, dirtyregions);
ProcessItem(origin.x, pos, item, focused, renderInfo);
else
ProcessItem(pos, origin.y, item, focused, currentTime, dirtyregions);
ProcessItem(pos, origin.y, item, focused, renderInfo);
}
// increment our position
pos += focused ? m_focusedLayout->Size(m_orientation) : m_layout->Size(m_orientation);
Expand All @@ -143,12 +143,12 @@ void CGUIBaseContainer::Process(unsigned int currentTime, CDirtyRegionList &dirt
// to have same behaviour when scrolling down, we need to set page control to offset+1
UpdatePageControl(offset + (m_scroller.IsScrollingDown() ? 1 : 0));

m_lastRenderTime = currentTime;
m_lastRenderTime = renderInfo.GetTime();

CGUIControl::Process(currentTime, dirtyregions);
CGUIControl::Process(renderInfo);
}

void CGUIBaseContainer::ProcessItem(float posX, float posY, CGUIListItemPtr& item, bool focused, unsigned int currentTime, CDirtyRegionList &dirtyregions)
void CGUIBaseContainer::ProcessItem(float posX, float posY, CGUIListItemPtr& item, bool focused, CGUIRenderInfo &renderInfo)
{
if (!m_focusedLayout || !m_layout) return;

Expand Down Expand Up @@ -178,7 +178,7 @@ void CGUIBaseContainer::ProcessItem(float posX, float posY, CGUIListItemPtr& ite
subItem = m_lastItem->GetFocusedLayout()->GetFocusedItem();
item->GetFocusedLayout()->SetFocusedItem(subItem ? subItem : 1);
}
item->GetFocusedLayout()->Process(item.get(), m_parentID, currentTime, dirtyregions);
item->GetFocusedLayout()->Process(item.get(), m_parentID, renderInfo);
}
m_lastItem = item;
}
Expand All @@ -192,9 +192,9 @@ void CGUIBaseContainer::ProcessItem(float posX, float posY, CGUIListItemPtr& ite
item->SetLayout(layout);
}
if (item->GetFocusedLayout())
item->GetFocusedLayout()->Process(item.get(), m_parentID, currentTime, dirtyregions);
item->GetFocusedLayout()->Process(item.get(), m_parentID, renderInfo);
if (item->GetLayout())
item->GetLayout()->Process(item.get(), m_parentID, currentTime, dirtyregions);
item->GetLayout()->Process(item.get(), m_parentID, renderInfo);
}

g_graphicsContext.RestoreOrigin();
Expand Down
6 changes: 3 additions & 3 deletions xbmc/guilib/GUIBaseContainer.h
Expand Up @@ -69,8 +69,8 @@ class CGUIBaseContainer : public IGUIContainer
virtual void SaveStates(std::vector<CControlState> &states);
virtual int GetSelectedItem() const;

virtual void DoProcess(unsigned int currentTime, CDirtyRegionList &dirtyregions);
virtual void Process(unsigned int currentTime, CDirtyRegionList &dirtyregions);
virtual void DoProcess(CGUIRenderInfo &renderInfo);
virtual void Process(CGUIRenderInfo &renderInfo);

void LoadLayout(TiXmlElement *layout);
void LoadListProvider(TiXmlElement *content, int defaultItem, bool defaultAlways);
Expand Down Expand Up @@ -107,7 +107,7 @@ class CGUIBaseContainer : public IGUIContainer
virtual EVENT_RESULT OnMouseEvent(const CPoint &point, const CMouseEvent &event);
bool OnClick(int actionID);

virtual void ProcessItem(float posX, float posY, CGUIListItemPtr& item, bool focused, unsigned int currentTime, CDirtyRegionList &dirtyregions);
virtual void ProcessItem(float posX, float posY, CGUIListItemPtr& item, bool focused, CGUIRenderInfo &renderInfo);

virtual void Render();
virtual void RenderItem(float posX, float posY, CGUIListItem *item, bool focused);
Expand Down
6 changes: 3 additions & 3 deletions xbmc/guilib/GUIBorderedImage.cpp
Expand Up @@ -38,9 +38,9 @@ CGUIBorderedImage::~CGUIBorderedImage(void)
{
}

void CGUIBorderedImage::Process(unsigned int currentTime, CDirtyRegionList &dirtyregions)
void CGUIBorderedImage::Process(CGUIRenderInfo &renderInfo)
{
CGUIImage::Process(currentTime, dirtyregions);
CGUIImage::Process(renderInfo);
if (!m_borderImage.GetFileName().empty() && m_texture.ReadyToRender())
{
CRect rect = CRect(m_texture.GetXPosition(), m_texture.GetYPosition(), m_texture.GetXPosition() + m_texture.GetWidth(), m_texture.GetYPosition() + m_texture.GetHeight());
Expand All @@ -49,7 +49,7 @@ void CGUIBorderedImage::Process(unsigned int currentTime, CDirtyRegionList &dirt
m_borderImage.SetWidth(rect.Width() + m_borderSize.x1 + m_borderSize.x2);
m_borderImage.SetHeight(rect.Height() + m_borderSize.y1 + m_borderSize.y2);
m_borderImage.SetDiffuseColor(m_diffuseColor);
if (m_borderImage.Process(currentTime))
if (m_borderImage.Process(renderInfo.GetTime()))
MarkDirtyRegion();
}
}
Expand Down
2 changes: 1 addition & 1 deletion xbmc/guilib/GUIBorderedImage.h
Expand Up @@ -33,7 +33,7 @@ class CGUIBorderedImage : public CGUIImage
virtual ~CGUIBorderedImage(void);
virtual CGUIBorderedImage *Clone() const { return new CGUIBorderedImage(*this); };

virtual void Process(unsigned int currentTime, CDirtyRegionList &dirtyregions);
virtual void Process(CGUIRenderInfo &renderInfo);
virtual void Render();
virtual void AllocResources();
virtual void FreeResources(bool immediately = false);
Expand Down

0 comments on commit 38fc658

Please sign in to comment.