Skip to content

Commit

Permalink
MP1-5241: Core: Add 'centerRelative' attribute to skin animation effects
Browse files Browse the repository at this point in the history
  • Loading branch information
epbk committed Mar 10, 2025
1 parent 02e15c4 commit 8a33702
Showing 1 changed file with 41 additions and 9 deletions.
50 changes: 41 additions & 9 deletions mediaportal/Core/guilib/VisualEffect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ public class VisualEffect : ICloneable
private int _savedHour;
private ClockHandleType _clockHandle;

private bool _isCenterReleative = false;
private bool _isReversible; // whether the animation is reversible or not
private bool _lastCondition;
private TransformMatrix _matrix = new TransformMatrix();
Expand Down Expand Up @@ -197,7 +198,22 @@ private void GetPosition(string text, ref float x, ref float y)

public bool Create(XmlNode node)
{
string animType = node.InnerText.ToLowerInvariant();
XmlNode nodeAttributeCenter = node.Attributes.GetNamedItem("center");
if (nodeAttributeCenter == null)
{
//Try 'relative' version
//This mode allows to move the control around the screen without affecting its rotate animation
//Relative center uses _centerX as relative to control's position:
// {0,0} points to center of the control
//RotateX: adds control's "Y" to _centerX
//RotateY: adds control's "X" to _centerX
//RotateY,Zoom: adds control's "X" to _centerX and control's "Y" to _centerY
nodeAttributeCenter = node.Attributes.GetNamedItem("centerRelative");
if (nodeAttributeCenter != null)
_isCenterReleative = true;
}

string animType = node.InnerText.ToLowerInvariant();
if (String.Compare(animType, "visible", true) == 0)
{
_type = AnimationType.Visible;
Expand Down Expand Up @@ -507,11 +523,9 @@ public bool Create(XmlNode node)
_startX *= -1;
_endX *= -1;


nodeAttribute = node.Attributes.GetNamedItem("center");
if (nodeAttribute != null)
if (nodeAttributeCenter != null)
{
string centerPos = nodeAttribute.Value;
string centerPos = nodeAttributeCenter.Value;
GetPosition(centerPos, ref _centerX, ref _centerY);
GUIGraphicsContext.ScaleHorizontal(ref _centerX);
GUIGraphicsContext.ScaleVertical(ref _centerY);
Expand Down Expand Up @@ -551,10 +565,10 @@ public bool Create(XmlNode node)
_endY = 100;
}
}
nodeAttribute = node.Attributes.GetNamedItem("center");
if (nodeAttribute != null)

if (nodeAttributeCenter != null)
{
string center = nodeAttribute.Value;
string center = nodeAttributeCenter.Value;
GetPosition(center, ref _centerX, ref _centerY);
GUIGraphicsContext.ScaleHorizontal(ref _centerX);
GUIGraphicsContext.ScaleVertical(ref _centerY);
Expand Down Expand Up @@ -842,7 +856,19 @@ public void SetInitialCondition()

public void SetCenter(float x, float y)
{
if (_effect == EffectType.Zoom || _effect == EffectType.RotateZ)
if (_isCenterReleative)
{
if (_effect == EffectType.RotateX)
_centerX += y;
else if (_effect == EffectType.RotateY)
_centerX += x;
else if (_effect == EffectType.Zoom || _effect == EffectType.RotateZ)
{
_centerX += x;
_centerY += y;
}
}
else if (_effect == EffectType.Zoom || _effect == EffectType.RotateZ)
{
if (_centerX == 0.0f)
{
Expand All @@ -860,6 +886,11 @@ public bool IsReversible
get { return _isReversible; }
}

public bool IsCenterRelative
{
get { return _isCenterReleative; }
}

public AnimationProcess QueuedProcess
{
get { return _queuedProcess; }
Expand Down Expand Up @@ -999,6 +1030,7 @@ public object Clone()
effect._clockHandle = _clockHandle;
effect._savedMinute = _savedMinute;
effect._savedHour = _savedHour;
effect._isCenterReleative = _isCenterReleative;
return effect;
}

Expand Down

0 comments on commit 8a33702

Please sign in to comment.