Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[guilib] add ability to visualize control hitrects #8230

Merged
merged 1 commit into from Oct 16, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion xbmc/guilib/GUIButtonControl.cpp
Expand Up @@ -155,7 +155,7 @@ void CGUIButtonControl::ProcessText(unsigned int currentTime)
if (m_minWidth && m_width != renderWidth)
{
CRect rect(m_posX, m_posY, renderWidth, m_height);
SetHitRect(rect);
SetHitRect(rect, m_hitColor);
}

// render the second label if it exists
Expand Down
12 changes: 11 additions & 1 deletion xbmc/guilib/GUIControl.cpp
Expand Up @@ -24,6 +24,7 @@
#include "utils/log.h"
#include "GUIWindowManager.h"
#include "GUIControlProfiler.h"
#include "GUITexture.h"
#include "input/MouseStat.h"
#include "input/InputManager.h"
#include "input/Key.h"
Expand Down Expand Up @@ -185,7 +186,15 @@ void CGUIControl::DoRender()
g_graphicsContext.SetStereoFactor(m_stereo);

GUIPROFILER_RENDER_BEGIN(this);

if (m_hitColor != 0xFFFFFFFF)

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

{
color_t color = g_graphicsContext.MergeAlpha(m_hitColor);
CGUITexture::DrawQuad(g_graphicsContext.generateAABB(m_hitRect), color);
}

Render();

GUIPROFILER_RENDER_END(this);

if (hasStereo)
Expand Down Expand Up @@ -908,9 +917,10 @@ void CGUIControl::SaveStates(std::vector<CControlState> &states)
// empty for now - do nothing with the majority of controls
}

void CGUIControl::SetHitRect(const CRect &rect)
void CGUIControl::SetHitRect(const CRect &rect, const CGUIInfoColor &color)
{
m_hitRect = rect;
m_hitColor = color;
}

void CGUIControl::SetCamera(const CPoint &camera)
Expand Down
3 changes: 2 additions & 1 deletion xbmc/guilib/GUIControl.h
Expand Up @@ -163,7 +163,7 @@ class CGUIControl
bool IsVisibleFromSkin() const { return m_visibleFromSkinCondition; };
virtual bool IsDisabled() const;
virtual void SetPosition(float posX, float posY);
virtual void SetHitRect(const CRect &rect);
virtual void SetHitRect(const CRect &rect, const CGUIInfoColor &color);
virtual void SetCamera(const CPoint &camera);
virtual void SetStereoFactor(const float &factor);
bool SetColorDiffuse(const CGUIInfoColor &color);
Expand Down Expand Up @@ -326,6 +326,7 @@ class CGUIControl
float m_height;
float m_width;
CRect m_hitRect;
CGUIInfoColor m_hitColor;
CGUIInfoColor m_diffuseColor;
int m_controlID;
int m_parentID;
Expand Down
5 changes: 4 additions & 1 deletion xbmc/guilib/GUIControlFactory.cpp
Expand Up @@ -760,6 +760,7 @@ CGUIControl* CGUIControlFactory::Create(int parentID, const CRect &rect, TiXmlEl
CLabelInfo labelInfo;
CLabelInfo spinInfo;

CGUIInfoColor hitColor(0xFFFFFFFF);
CGUIInfoColor textColor3;
CGUIInfoColor headlineColor;

Expand Down Expand Up @@ -822,6 +823,8 @@ CGUIControl* CGUIControlFactory::Create(int parentID, const CRect &rect, TiXmlEl
hitRect.SetRect(posX, posY, posX + width, posY + height);
GetHitRect(pControlNode, hitRect);

GetInfoColor(pControlNode, "hitrectcolor", hitColor, parentID);

GetActions(pControlNode, "onup", actions[ACTION_MOVE_UP]);
GetActions(pControlNode, "ondown", actions[ACTION_MOVE_DOWN]);
GetActions(pControlNode, "onleft", actions[ACTION_MOVE_LEFT]);
Expand Down Expand Up @@ -1485,7 +1488,7 @@ CGUIControl* CGUIControlFactory::Create(int parentID, const CRect &rect, TiXmlEl
// things that apply to all controls
if (control)
{
control->SetHitRect(hitRect);
control->SetHitRect(hitRect, hitColor);
control->SetVisibleCondition(visibleCondition, allowHiddenFocus);
control->SetEnableCondition(enableCondition);
control->SetAnimations(animations);
Expand Down