Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

[gui] added colordiffuse attribute on texture definition #1772

Merged
merged 1 commit into from

8 participants

@xhaggi
Collaborator

This PR adds color diffuse attribute for texture definitions.

It's based on the PR #268 and gets rid of the borderdiffuse attribute. also it don't override m_diffuseColor as @jmarshallnz has suggested.

Example:

<texture colordiffuse="FFFFAAFF">texture.png</texture>
<texture colordiffuse="$VAR[colordiffuse]">texture.png</texture>
<texture colordiffuse="$INFO[colordiffuse]">texture.png</texture>

Works for all texture controls, for example textureradioon, textureradiooff, texturefocus, texturenofocus etc.

@xhaggi
Collaborator

it would be nice if this gets into frodo, because without this you need two button controls to use a colordiffuse while button gets focused.

@ronie
Collaborator

there are 100's of things that would be nice to have in frodo :)

but reality is, we're way past feature freeze and have beta1 knocking around the corner.

@xhaggi
Collaborator

@ronie i only want a statement if this could get in or not .. sorry if I seem a little impatient ;)

@jmarshallnz
Owner

No, this won't be going in for Frodo.

@xhaggi
Collaborator

@jmarshallnz is there a reason why this is rejected?

@MartijnKaijser

@xhaggi
Because we are in feature freeze for a month so nothing will be added until after Frodo release

@xhaggi
Collaborator

thanks

@lemonboy999

Now you have some time, you should look at a couple of extra things. Since I put the original PR in, the code base has moved on. The change as submitted does not allow for skin variables to be used in the texture colordiffuse attribute, whereas the control diffusecolor allows this. Also I don't think the original point with one diffuse overriding the other was the real issue, I thought it was about merging the two. The reason the borderdiffuse was rejected was because you could use a bordertexture, however this cannot be applied as an attribute - maybe you could look at this as well.

@xhaggi
Collaborator

@lemonboy999 as you can see in the main description of this PR, it is possible to use $VAR and $INFO .. so i don't know what you mean with skin variables?

@lemonboy999

Sorry, I meant that although you can put a $VAR as the colordiffuse attribute, it will only use the value when the control is created and wont update as the $VAR changes. You need to put an extra check in the TextureBase::SetDiffuseColor routine.

@ghost

@jmarshallnz post-frodo ping.

xbmc/guilib/GUITexture.cpp
@@ -23,6 +23,7 @@
#include "TextureManager.h"
#include "GUILargeTextureManager.h"
#include "utils/MathUtils.h"
+#include "GUIInfoTypes.h"
@jmarshallnz Owner

Unneeded include - you include it in the header.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
xbmc/guilib/GUITexture.cpp
@@ -174,8 +176,19 @@ void CGUITextureBase::Render()
// set our draw color
#define MIX_ALPHA(a,c) (((a * (c >> 24)) / 255) << 24) | (c & 0x00ffffff)
- color_t color = m_diffuseColor;
- if (m_alpha != 0xFF) color = MIX_ALPHA(m_alpha, m_diffuseColor);
+ color_t color;
+ if (m_info.colorDiffuse)
+ {
+ color = m_info.colorDiffuse;
+ if (m_alpha != 0xFF)
+ color = MIX_ALPHA(m_alpha, m_info.colorDiffuse);
@jmarshallnz Owner

cosmetic: indent

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
xbmc/guilib/GUITexture.cpp
@@ -174,8 +176,19 @@ void CGUITextureBase::Render()
// set our draw color
#define MIX_ALPHA(a,c) (((a * (c >> 24)) / 255) << 24) | (c & 0x00ffffff)
- color_t color = m_diffuseColor;
- if (m_alpha != 0xFF) color = MIX_ALPHA(m_alpha, m_diffuseColor);
+ color_t color;
+ if (m_info.colorDiffuse)
+ {
+ color = m_info.colorDiffuse;
+ if (m_alpha != 0xFF)
+ color = MIX_ALPHA(m_alpha, m_info.colorDiffuse);
+ }
+ else
+ {
+ color = m_diffuseColor;
+ if (m_alpha != 0xFF)
+ color = MIX_ALPHA(m_alpha, m_diffuseColor);
+ }
@jmarshallnz Owner

This could be simplified as:

color_t color = (m_info.colorDiffuse) ? m_info.colorDiffuse : m_diffuseColor;
if (m_alpha != 0xFF)
  color = MIX_ALPHA(m_alpha, color);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
xbmc/guilib/GUITexture.h
@@ -77,6 +78,7 @@ class CTextureInfo
CRect border; // scaled - unneeded if we get rid of scale on load
int orientation; // orientation of the texture (0 - 7 == EXIForientation - 1)
CStdString diffuse; // diffuse overlay texture
+ CGUIInfoColor colorDiffuse; // diffuse color
@jmarshallnz Owner

so why not name it diffuseColor :p

@xhaggi Collaborator
xhaggi added a note

should be the same name as the control ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@jmarshallnz
Owner

You currently don't call Update() on the CGUIInfoColor, so it won't work with $INFO or $VAR as things stand. I suggest calling it in SetDiffusedColor() would be the best place. Obviously you need to check the Update() routine's return value to return the appropriate changed status.

Exactly how the control's diffuse color and the textures diffuse color interact will need defining. ATM you have the texture's diffuse color overriding the controls. This may not be what is wanted. For example, it might make sense for them to be diffused (multiplied).

@xhaggi
Collaborator

@jmarshallnz thank you for the hints .. i will change it in a few days.

The main reason for this PR is to use it on button controls with <texturefocus colordiffuse="">, so you don't need a second texture or control for highlighting. Well, i don't know if multiply the diffuse color is the best way.

@xhaggi
Collaborator

@jmarshallnz changed up on your hints

@jmarshallnz jmarshallnz was assigned
@jmarshallnz
Owner

Looks good. Queued for next merge window (May 1->May 10). Before then, it'll need squashing down.

@phil65
Collaborator

would it be lot of work to also allow this for radiobutton textures? that would be great, too.

@xhaggi
Collaborator

@phil65 it work's for every texture control .. the comment was an unfortunate choise , I will update it

@MassIV

Will this also work for the label / altlabel of the togglebutton?

Edit:
Ok, thnx. Either way, awesome work.

@xhaggi
Collaborator

@MassIV only for texture controls .. no labels.

@xhaggi
Collaborator

@MartijnKaijser something wrong with this, because it was not included in the last merge window

@jmarshallnz
Owner

Nope - my fault for not hitting the button. Apologies.

@jmarshallnz jmarshallnz merged commit 20b850e into xbmc:master
@FernetMenta FernetMenta commented on the diff
xbmc/guilib/GUITexture.cpp
@@ -174,8 +175,12 @@ void CGUITextureBase::Render()
// set our draw color
#define MIX_ALPHA(a,c) (((a * (c >> 24)) / 255) << 24) | (c & 0x00ffffff)
- color_t color = m_diffuseColor;
- if (m_alpha != 0xFF) color = MIX_ALPHA(m_alpha, m_diffuseColor);
+
+ // diffuse color
+ color_t color = (m_info.diffuseColor) ? m_info.diffuseColor : m_diffuseColor;
@FernetMenta Collaborator

this does not compile on Linux. m_info.diffuseColor is a class (CGUIInfoColor) and not of type color_t

@jmarshallnz Owner
@xhaggi Collaborator
xhaggi added a note

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@xhaggi xhaggi deleted the xhaggi:texture-colordiffuse branch
@jmarshallnz
Owner

Thanks - we'll keep you on :)

@mo123 mo123 referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 12, 2013
  1. @xhaggi
This page is out of date. Refresh to see the latest.
View
1  xbmc/guilib/GUIControlFactory.cpp
@@ -254,6 +254,7 @@ bool CGUIControlFactory::GetTexture(const TiXmlNode* pRootNode, const char* strT
const char *flipY = pNode->Attribute("flipy");
if (flipY && strcmpi(flipY, "true") == 0) image.orientation = 3 - image.orientation; // either 3 or 2
image.diffuse = pNode->Attribute("diffuse");
+ image.diffuseColor.Parse(pNode->Attribute("colordiffuse"), 0);
const char *background = pNode->Attribute("background");
if (background && strnicmp(background, "true", 4) == 0)
image.useLarge = true;
View
10 xbmc/guilib/GUITexture.cpp
@@ -46,6 +46,7 @@ CTextureInfo& CTextureInfo::operator=(const CTextureInfo &right)
diffuse = right.diffuse;
filename = right.filename;
useLarge = right.useLarge;
+ diffuseColor = right.diffuseColor;
return *this;
}
@@ -174,8 +175,12 @@ void CGUITextureBase::Render()
// set our draw color
#define MIX_ALPHA(a,c) (((a * (c >> 24)) / 255) << 24) | (c & 0x00ffffff)
- color_t color = m_diffuseColor;
- if (m_alpha != 0xFF) color = MIX_ALPHA(m_alpha, m_diffuseColor);
+
+ // diffuse color
+ color_t color = (m_info.diffuseColor) ? m_info.diffuseColor : m_diffuseColor;
@FernetMenta Collaborator

this does not compile on Linux. m_info.diffuseColor is a class (CGUIInfoColor) and not of type color_t

@jmarshallnz Owner
@xhaggi Collaborator
xhaggi added a note

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ if (m_alpha != 0xFF)
+ color = MIX_ALPHA(m_alpha, color);
+
color = g_graphicsContext.MergeAlpha(color);
// setup our renderer
@@ -543,6 +548,7 @@ bool CGUITextureBase::SetDiffuseColor(color_t color)
{
bool changed = m_diffuseColor != color;
m_diffuseColor = color;
+ changed |= m_info.diffuseColor.Update();
return changed;
}
View
10 xbmc/guilib/GUITexture.h
@@ -31,6 +31,7 @@
#include "TextureManager.h"
#include "Geometry.h"
#include "system.h" // HAS_GL, HAS_DX, etc
+#include "GUIInfoTypes.h"
typedef uint32_t color_t;
@@ -74,10 +75,11 @@ class CTextureInfo
CTextureInfo(const CStdString &file);
CTextureInfo& operator=(const CTextureInfo &right);
bool useLarge;
- CRect border; // scaled - unneeded if we get rid of scale on load
- int orientation; // orientation of the texture (0 - 7 == EXIForientation - 1)
- CStdString diffuse; // diffuse overlay texture
- CStdString filename; // main texture file
+ CRect border; // scaled - unneeded if we get rid of scale on load
+ int orientation; // orientation of the texture (0 - 7 == EXIForientation - 1)
+ CStdString diffuse; // diffuse overlay texture
+ CGUIInfoColor diffuseColor; // diffuse color
+ CStdString filename; // main texture file
};
class CGUITextureBase
Something went wrong with that request. Please try again.