tint support in GraphicsContext.DrawLine and DrawRectangle

This commit is contained in:
Michael 2017-08-05 15:50:39 -04:00
parent ec363f09ca
commit 2352fcc7a1
2 changed files with 16 additions and 3 deletions

View file

@ -169,7 +169,10 @@ namespace ShiftOS.Frontend.GUI
if(image != null)
{
int imageDrawX = _itemx + ((textwidth - texwidth) / 2);
gfx.DrawRectangle(imageDrawX, _itemy, texwidth, texheight, image);
Color tint = Color.White;
if (_items.IndexOf(item) == _selected)
tint = LoadedSkin.ButtonPressedColor.ToMonoColor();
gfx.DrawRectangle(imageDrawX, _itemy, texwidth, texheight, image, tint);
}
int texty = _itemy + texheight;

View file

@ -93,12 +93,17 @@ namespace ShiftOS.Frontend.GraphicsSubsystem
}
public void DrawLine(int x, int y, int x1, int y1, int thickness, Texture2D tex2)
{
DrawLine(x, y, x1, y1, thickness, tex2, Color.White);
}
public void DrawLine(int x, int y, int x1, int y1, int thickness, Texture2D tex2, Color tint)
{
x += _startx;
y += _starty;
int distance = (int)Vector2.Distance(new Vector2(x, y), new Vector2(x1, y1));
float rotation = getRotation(x, y, x1, y1);
_spritebatch.Draw(tex2, new Rectangle(x, y, distance, thickness), null, Color.White, rotation, Vector2.Zero, SpriteEffects.None, 0);
_spritebatch.Draw(tex2, new Rectangle(x, y, distance, thickness), null, tint, rotation, Vector2.Zero, SpriteEffects.None, 0);
}
public void DrawLine(int x, int y, int x1, int y1, int thickness, Color color)
@ -118,10 +123,15 @@ namespace ShiftOS.Frontend.GraphicsSubsystem
}
public void DrawRectangle(int x, int y, int width, int height, Texture2D tex2)
{
DrawRectangle(x, y, width, height, tex2, Color.White);
}
public void DrawRectangle(int x, int y, int width, int height, Texture2D tex2, Color tint)
{
x += _startx;
y += _starty;
_spritebatch.Draw(tex2, new Rectangle(x, y, width, height), Color.White);
_spritebatch.Draw(tex2, new Rectangle(x, y, width, height), tint);
}
public Vector2 MeasureString(string text, System.Drawing.Font font, int wrapWidth = int.MaxValue)