diff --git a/Vocaluxe/Base/CDraw.cs b/Vocaluxe/Base/CDraw.cs
index 4a9d50e6..0be03c05 100644
--- a/Vocaluxe/Base/CDraw.cs
+++ b/Vocaluxe/Base/CDraw.cs
@@ -391,11 +391,12 @@ namespace Vocaluxe.Base
///
/// (Original) rectangle to draw the reflection for
///
+ ///
/// Spacing between the rect and the reflection
/// Height of the reflection
- public static void DrawTextureReflection(CTextureRef textureRef, SRectF rect, SColorF color, float space, float height)
+ public static void DrawTextureReflection(CTextureRef textureRef, SRectF rect, SColorF color, SRectF bounds, float space, float height)
{
- _Draw.DrawTextureReflection(textureRef, rect, color, space, height);
+ _Draw.DrawTextureReflection(textureRef, rect, color, bounds, space, height);
}
}
}
\ No newline at end of file
diff --git a/Vocaluxe/Base/Fonts/CFont.cs b/Vocaluxe/Base/Fonts/CFont.cs
index 844c8247..a9c31e7a 100644
--- a/Vocaluxe/Base/Fonts/CFont.cs
+++ b/Vocaluxe/Base/Fonts/CFont.cs
@@ -104,7 +104,7 @@ namespace Vocaluxe.Base.Fonts
CTextureRef texture;
SRectF rect;
GetOrAddGlyph(chr).GetTextureAndRect(x, y, z, out texture, out rect);
- CDraw.DrawTextureReflection(texture, rect, color, rspace, rheight);
+ CDraw.DrawTextureReflection(texture, rect, color, rect, rspace, rheight);
}
public float GetWidth(char chr)
diff --git a/Vocaluxe/Lib/Draw/CDirect3D.cs b/Vocaluxe/Lib/Draw/CDirect3D.cs
index 682905bc..446e600f 100644
--- a/Vocaluxe/Lib/Draw/CDirect3D.cs
+++ b/Vocaluxe/Lib/Draw/CDirect3D.cs
@@ -552,7 +552,7 @@ namespace Vocaluxe.Lib.Draw
/// The height of the reflection
public void DrawRectReflection(SColorF color, SRectF rect, float space, float height)
{
- DrawTextureReflection(_BlankTexture, rect, color, space, height);
+ DrawTextureReflection(_BlankTexture, rect, color, rect, space, height);
}
#endregion Basic Draw Methods
@@ -755,30 +755,63 @@ namespace Vocaluxe.Lib.Draw
/// The texture of which a reflection should be drawn
/// A SRectF struct containing the destination coordinates
/// A SColorF struct containing a color which the texture will be colored in
+ /// A SRectF struct containing which part of the texture should be drawn
/// The space between the texture and the reflection
/// The height of the reflection
- public void DrawTextureReflection(CTextureRef textureRef, SRectF rect, SColorF color, float space, float height)
+ public void DrawTextureReflection(CTextureRef textureRef, SRectF rect, SColorF color, SRectF bounds, float space, float height)
{
CD3DTexture texture;
if (!_GetTexture(textureRef, out texture))
return;
- if (Math.Abs(rect.W) < float.Epsilon || Math.Abs(rect.H) < float.Epsilon || Math.Abs(color.A) < float.Epsilon || height <= 0f)
+ if (Math.Abs(rect.W) < float.Epsilon || Math.Abs(rect.H) < float.Epsilon || Math.Abs(bounds.H) < float.Epsilon || Math.Abs(bounds.W) < float.Epsilon ||
+ Math.Abs(color.A) < float.Epsilon || height <= 0f)
return;
- if (height > rect.H)
- height = rect.H;
+ if (bounds.X > rect.X + rect.W || bounds.X + bounds.W < rect.X)
+ return;
+
+ if (bounds.Y > rect.Y + rect.H || bounds.Y + bounds.H < rect.Y)
+ return;
+
+ if (height > bounds.H)
+ height = bounds.H;
+
+ float x1 = (bounds.X - rect.X) / rect.W * texture.WidthRatio;
+ float x2 = (bounds.X + bounds.W - rect.X) / rect.W * texture.WidthRatio;
+ float y1 = (bounds.Y - rect.Y + rect.H - height) / rect.H * texture.HeightRatio;
+ float y2 = (bounds.Y + bounds.H - rect.Y) / rect.H * texture.HeightRatio;
+
+ if (x1 < 0)
+ x1 = 0f;
+
+ if (x2 > texture.WidthRatio)
+ x2 = texture.WidthRatio;
+
+ if (y1 < 0)
+ y1 = 0f;
+
+ if (y2 > texture.HeightRatio)
+ y2 = texture.HeightRatio;
- const float x1 = 0;
- float x2 = texture.WidthRatio;
- float y1 = (rect.H - height) / rect.H * texture.HeightRatio;
- float y2 = texture.HeightRatio;
float rx1 = rect.X;
float rx2 = rect.X + rect.W;
float ry1 = rect.Y + rect.H + space;
float ry2 = rect.Y + rect.H + space + height;
+ if (rx1 < bounds.X)
+ rx1 = bounds.X;
+
+ if (rx2 > bounds.X + bounds.W)
+ rx2 = bounds.X + bounds.W;
+
+ if (ry1 < bounds.Y + space)
+ ry1 = bounds.Y + space;
+
+ if (ry2 > bounds.Y + bounds.H + space + height)
+ ry2 = bounds.Y + bounds.H + space + height;
+
//Align the pixels because Direct3D expects the pixels to be the left top corner
rx1 -= 0.5f;
ry1 -= 0.5f;
diff --git a/Vocaluxe/Lib/Draw/CDrawWinForm.cs b/Vocaluxe/Lib/Draw/CDrawWinForm.cs
index 0c9cb5c4..5fff48f2 100644
--- a/Vocaluxe/Lib/Draw/CDrawWinForm.cs
+++ b/Vocaluxe/Lib/Draw/CDrawWinForm.cs
@@ -435,7 +435,7 @@ namespace Vocaluxe.Lib.Draw
public void DrawTexture(CTextureRef texture, SRectF rect, SColorF color, float begin, float end) {}
- public void DrawTextureReflection(CTextureRef texture, SRectF rect, SColorF color, float space, float height) {}
+ public void DrawTextureReflection(CTextureRef texture, SRectF rect, SColorF color, SRectF bounds, float space, float height) {}
public int GetTextureCount()
{
diff --git a/Vocaluxe/Lib/Draw/COpenGL.cs b/Vocaluxe/Lib/Draw/COpenGL.cs
index 94f0b63d..4096572e 100644
--- a/Vocaluxe/Lib/Draw/COpenGL.cs
+++ b/Vocaluxe/Lib/Draw/COpenGL.cs
@@ -627,24 +627,43 @@ namespace Vocaluxe.Lib.Draw
GL.BindTexture(TextureTarget.Texture2D, 0);
}
- public void DrawTextureReflection(CTextureRef textureRef, SRectF rect, SColorF color, float space, float height)
+ public void DrawTextureReflection(CTextureRef textureRef, SRectF rect, SColorF color, SRectF bounds, float space, float height)
{
COGLTexture texture;
if (!_GetTexture(textureRef, out texture))
return;
- if (Math.Abs(rect.W) < float.Epsilon || Math.Abs(rect.H) < float.Epsilon || Math.Abs(color.A) < float.Epsilon || height <= float.Epsilon)
+ if (Math.Abs(rect.W) < float.Epsilon || Math.Abs(rect.H) < float.Epsilon || Math.Abs(bounds.H) < float.Epsilon || Math.Abs(bounds.W) < float.Epsilon ||
+ Math.Abs(color.A) < float.Epsilon || height <= float.Epsilon)
return;
- if (height > rect.H)
- height = rect.H;
+ if (bounds.X > rect.X + rect.W || bounds.X + bounds.W < rect.X)
+ return;
+
+ if (bounds.Y > rect.Y + rect.H || bounds.Y + bounds.H < rect.Y)
+ return;
+
+ if (height > bounds.H)
+ height = bounds.H;
GL.BindTexture(TextureTarget.Texture2D, texture.Name);
- const float x1 = 0;
- float x2 = texture.WidthRatio;
- float y1 = (rect.H - height) / rect.H * texture.HeightRatio;
- float y2 = texture.HeightRatio;
+ float x1 = (bounds.X - rect.X) / rect.W * texture.WidthRatio;
+ float x2 = (bounds.X + bounds.W - rect.X) / rect.W * texture.WidthRatio;
+ float y1 = (bounds.Y - rect.Y + rect.H - height) / rect.H * texture.HeightRatio;
+ float y2 = (bounds.Y + bounds.H - rect.Y) / rect.H * texture.HeightRatio;
+
+ if (x1 < 0)
+ x1 = 0f;
+
+ if (x2 > texture.WidthRatio)
+ x2 = texture.WidthRatio;
+
+ if (y1 < 0)
+ y1 = 0f;
+
+ if (y2 > texture.HeightRatio)
+ y2 = texture.HeightRatio;
float rx1 = rect.X;
@@ -652,6 +671,18 @@ namespace Vocaluxe.Lib.Draw
float ry1 = rect.Y + rect.H + space;
float ry2 = rect.Y + rect.H + space + height;
+ if (rx1 < bounds.X)
+ rx1 = bounds.X;
+
+ if (rx2 > bounds.X + bounds.W)
+ rx2 = bounds.X + bounds.W;
+
+ if (ry1 < bounds.Y + space)
+ ry1 = bounds.Y + space;
+
+ if (ry2 > bounds.Y + bounds.H + space + height)
+ ry2 = bounds.Y + bounds.H + space + height;
+
GL.Enable(EnableCap.Blend);
GL.MatrixMode(MatrixMode.Texture);
@@ -664,6 +695,7 @@ namespace Vocaluxe.Lib.Draw
GL.Translate(-0.5f, -0.5f, 0);
}
+
GL.Begin(BeginMode.Quads);
GL.Color4(color.R, color.G, color.B, color.A * CGraphics.GlobalAlpha);
@@ -684,6 +716,7 @@ namespace Vocaluxe.Lib.Draw
GL.End();
+
GL.PopMatrix();
GL.Disable(EnableCap.Blend);
diff --git a/Vocaluxe/Lib/Draw/IDraw.cs b/Vocaluxe/Lib/Draw/IDraw.cs
index 0b2421ff..acea643f 100644
--- a/Vocaluxe/Lib/Draw/IDraw.cs
+++ b/Vocaluxe/Lib/Draw/IDraw.cs
@@ -56,6 +56,6 @@ namespace Vocaluxe.Lib.Draw
void DrawTexture(CTextureRef texture, SRectF rect, SColorF color, SRectF bounds, bool mirrored = false);
void DrawTexture(CTextureRef texture, SRectF rect, SColorF color, float begin, float end);
- void DrawTextureReflection(CTextureRef texture, SRectF rect, SColorF color, float space, float height);
+ void DrawTextureReflection(CTextureRef texture, SRectF rect, SColorF color, SRectF bounds, float space, float height);
}
}
\ No newline at end of file
diff --git a/VocaluxeLib/Menu/CButton.cs b/VocaluxeLib/Menu/CButton.cs
index d842a04a..a0fd6039 100644
--- a/VocaluxeLib/Menu/CButton.cs
+++ b/VocaluxeLib/Menu/CButton.cs
@@ -273,7 +273,7 @@ namespace VocaluxeLib.Menu
if (_Reflection)
{
- CBase.Drawing.DrawTextureReflection(texture, Rect, Color, _ReflectionSpace, _ReflectionHeight);
+ CBase.Drawing.DrawTextureReflection(texture, Rect, Color, Rect, _ReflectionSpace, _ReflectionHeight);
Text.DrawRelative(Rect.X, Rect.Y, _ReflectionHeight, _ReflectionSpace, Rect.H);
}
else
@@ -287,7 +287,7 @@ namespace VocaluxeLib.Menu
if (_Reflection)
{
- CBase.Drawing.DrawTextureReflection(texture, Rect, SelColor, _ReflectionSpace, _ReflectionHeight);
+ CBase.Drawing.DrawTextureReflection(texture, Rect, SelColor, Rect, _ReflectionSpace, _ReflectionHeight);
Text.DrawRelative(Rect.X, Rect.Y, _ReflectionHeight, _ReflectionSpace, Rect.H);
}
else
@@ -301,7 +301,7 @@ namespace VocaluxeLib.Menu
if (_Reflection)
{
- CBase.Drawing.DrawTextureReflection(texture, Rect, SelColor, _ReflectionSpace, _ReflectionHeight);
+ CBase.Drawing.DrawTextureReflection(texture, Rect, SelColor, Rect, _ReflectionSpace, _ReflectionHeight);
_SelText.DrawRelative(Rect.X, Rect.Y, _ReflectionHeight, _ReflectionSpace, Rect.H);
}
else
diff --git a/VocaluxeLib/Menu/CStatic.cs b/VocaluxeLib/Menu/CStatic.cs
index 7d1dde1e..e53f3130 100644
--- a/VocaluxeLib/Menu/CStatic.cs
+++ b/VocaluxeLib/Menu/CStatic.cs
@@ -180,19 +180,17 @@ namespace VocaluxeLib.Menu
public void Draw(EAspect aspect, float scale = 1f, float zModify = 0f, bool forceDraw = false)
{
CTextureRef texture = Texture;
- SRectF rect = Rect.Scale(scale);
- rect.Z += zModify;
- if (texture != null)
- rect = CHelper.FitInBounds(rect, texture.OrigAspect, aspect);
-
+ SRectF bounds = Rect.Scale(scale);
+ bounds.Z += zModify;
+ SRectF rect = texture == null ? bounds : CHelper.FitInBounds(bounds, texture.OrigAspect, aspect);
var color = new SColorF(Color.R, Color.G, Color.B, Color.A * Alpha);
if (Visible || forceDraw || (CBase.Settings.GetProgramState() == EProgramState.EditTheme))
{
if (texture != null)
{
- CBase.Drawing.DrawTexture(texture, rect, color);
+ CBase.Drawing.DrawTexture(texture, rect, color, bounds);
if (Reflection)
- CBase.Drawing.DrawTextureReflection(texture, rect, color, ReflectionSpace, ReflectionHeight);
+ CBase.Drawing.DrawTextureReflection(texture, rect, color, bounds, ReflectionSpace, ReflectionHeight);
}
else
CBase.Drawing.DrawRect(color, rect);