Add DropDownButtonWidget.PanelAlign.
This commit is contained in:
committed by
Matthias Mailänder
parent
f730b55255
commit
83732f299b
@@ -21,6 +21,7 @@ namespace OpenRA.Mods.Common.Widgets
|
|||||||
{
|
{
|
||||||
public readonly string SeparatorCollection = "dropdown";
|
public readonly string SeparatorCollection = "dropdown";
|
||||||
public readonly string SeparatorImage = "separator";
|
public readonly string SeparatorImage = "separator";
|
||||||
|
public readonly TextAlign PanelAlign = TextAlign.Left;
|
||||||
|
|
||||||
Widget panel;
|
Widget panel;
|
||||||
MaskWidget fullscreenMask;
|
MaskWidget fullscreenMask;
|
||||||
@@ -101,12 +102,18 @@ namespace OpenRA.Mods.Common.Widgets
|
|||||||
panelRoot.AddChild(fullscreenMask);
|
panelRoot.AddChild(fullscreenMask);
|
||||||
|
|
||||||
var oldBounds = panel.Bounds;
|
var oldBounds = panel.Bounds;
|
||||||
|
var panelX = RenderOrigin.X - panelRoot.RenderOrigin.X;
|
||||||
|
if (PanelAlign == TextAlign.Right)
|
||||||
|
panelX += Bounds.Width - oldBounds.Width;
|
||||||
|
else if (PanelAlign == TextAlign.Center)
|
||||||
|
panelX += (Bounds.Width - oldBounds.Width) / 2;
|
||||||
|
|
||||||
var panelY = RenderOrigin.Y + Bounds.Height - panelRoot.RenderOrigin.Y;
|
var panelY = RenderOrigin.Y + Bounds.Height - panelRoot.RenderOrigin.Y;
|
||||||
if (panelY + oldBounds.Height > Game.Renderer.Resolution.Height)
|
if (panelY + oldBounds.Height > Game.Renderer.Resolution.Height)
|
||||||
panelY -= (Bounds.Height + oldBounds.Height);
|
panelY -= (Bounds.Height + oldBounds.Height);
|
||||||
|
|
||||||
panel.Bounds = new Rectangle(
|
panel.Bounds = new Rectangle(
|
||||||
RenderOrigin.X - panelRoot.RenderOrigin.X,
|
panelX,
|
||||||
panelY,
|
panelY,
|
||||||
oldBounds.Width,
|
oldBounds.Width,
|
||||||
oldBounds.Height);
|
oldBounds.Height);
|
||||||
|
|||||||
Reference in New Issue
Block a user