mirror of
https://github.com/AlexMacocian/MonoGame.Extended.git
synced 2026-07-25 08:22:15 +00:00
fixed some clipping rectangle issues
This commit is contained in:
@@ -80,7 +80,7 @@ namespace MonoGame.Extended.Gui.Controls
|
||||
DrawItemList(context, renderer);
|
||||
}
|
||||
|
||||
var selectedTextInfo = GetItemTextInfo(context, ContentRectangle, SelectedItem, ClippingRectangle);
|
||||
var selectedTextInfo = GetItemTextInfo(context, ContentRectangle, SelectedItem);
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(selectedTextInfo.Text))
|
||||
renderer.DrawText(selectedTextInfo.Font, selectedTextInfo.Text, selectedTextInfo.Position + TextOffset, selectedTextInfo.Color, selectedTextInfo.ClippingRectangle);
|
||||
|
||||
@@ -221,13 +221,13 @@ namespace MonoGame.Extended.Gui.Controls
|
||||
return Parent != null && (Parent == control || Parent.HasParent(control));
|
||||
}
|
||||
|
||||
protected TextInfo GetTextInfo(IGuiContext context, string text, Rectangle targetRectangle, HorizontalAlignment horizontalAlignment, VerticalAlignment verticalAlignment, Rectangle? clippingRectangle = null)
|
||||
protected TextInfo GetTextInfo(IGuiContext context, string text, Rectangle targetRectangle, HorizontalAlignment horizontalAlignment, VerticalAlignment verticalAlignment)
|
||||
{
|
||||
var font = Font ?? context.DefaultFont;
|
||||
var textSize = (Size)font.GetStringRectangle(text ?? string.Empty, Vector2.Zero).Size;
|
||||
var destinationRectangle = LayoutHelper.AlignRectangle(horizontalAlignment, verticalAlignment, textSize, targetRectangle);
|
||||
var textPosition = destinationRectangle.Location.ToVector2();
|
||||
var textInfo = new TextInfo(text, font, textPosition, textSize, TextColor, clippingRectangle);// ?? ClippingRectangle);
|
||||
var textInfo = new TextInfo(text, font, textPosition, textSize, TextColor, targetRectangle);
|
||||
return textInfo;
|
||||
}
|
||||
|
||||
|
||||
@@ -95,11 +95,11 @@ namespace MonoGame.Extended.Gui.Controls
|
||||
|
||||
protected virtual void OnItemClicked(IGuiContext context, PointerEventArgs args) { }
|
||||
|
||||
protected TextInfo GetItemTextInfo(IGuiContext context, Rectangle itemRectangle, object item, Rectangle? clippingRectangle)
|
||||
protected TextInfo GetItemTextInfo(IGuiContext context, Rectangle itemRectangle, object item)
|
||||
{
|
||||
var textRectangle = new Rectangle(itemRectangle.X + ItemPadding.Left, itemRectangle.Y + ItemPadding.Top,
|
||||
itemRectangle.Width - ItemPadding.Right, itemRectangle.Height - ItemPadding.Bottom);
|
||||
var itemTextInfo = GetTextInfo(context, GetItemName(item), textRectangle, HorizontalTextAlignment, VerticalTextAlignment, clippingRectangle);
|
||||
var itemTextInfo = GetTextInfo(context, GetItemName(item), textRectangle, HorizontalTextAlignment, VerticalTextAlignment);
|
||||
return itemTextInfo;
|
||||
}
|
||||
|
||||
@@ -160,7 +160,7 @@ namespace MonoGame.Extended.Gui.Controls
|
||||
{
|
||||
var item = Items[i];
|
||||
var itemRectangle = GetItemRectangle(context, i - FirstIndex, listRectangle);
|
||||
var itemTextInfo = GetItemTextInfo(context, itemRectangle, item, listRectangle);
|
||||
var itemTextInfo = GetItemTextInfo(context, itemRectangle, item);
|
||||
var textColor = i == SelectedIndex ? SelectedTextColor : itemTextInfo.Color;
|
||||
|
||||
if (SelectedIndex == i)
|
||||
|
||||
@@ -47,7 +47,8 @@ namespace MonoGame.Extended.Gui.Controls
|
||||
public override Size GetContentSize(IGuiContext context)
|
||||
{
|
||||
var font = Font ?? context.DefaultFont;
|
||||
return (Size)font.MeasureString(Text ?? string.Empty);
|
||||
var stringSize = (Size)font.MeasureString(Text ?? string.Empty);
|
||||
return new Size(stringSize.Width, stringSize.Height < font.LineHeight ? font.LineHeight : stringSize.Height);
|
||||
}
|
||||
|
||||
//protected override Size2 CalculateDesiredSize(IGuiContext context, Size2 availableSize)
|
||||
|
||||
Reference in New Issue
Block a user