From b0309c970724e17a2ec2abe07f1a8a4f3d332c56 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Tue, 2 Jun 2020 16:15:41 +0200 Subject: [PATCH] added ScaleOrigin to RootElement --- MLEM.Ui/Elements/CustomDrawGroup.cs | 2 +- MLEM.Ui/UiSystem.cs | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/MLEM.Ui/Elements/CustomDrawGroup.cs b/MLEM.Ui/Elements/CustomDrawGroup.cs index bf53125..0e56c35 100644 --- a/MLEM.Ui/Elements/CustomDrawGroup.cs +++ b/MLEM.Ui/Elements/CustomDrawGroup.cs @@ -71,7 +71,7 @@ namespace MLEM.Ui.Elements { /// The scale to use /// The origin to use for scaling, or null to use this element's center point public void ScaleOrigin(float scale, Vector2? origin = null) { - this.Transform = Matrix.CreateScale(scale, scale, 0) * Matrix.CreateTranslation(new Vector3((1 - scale) * (origin ?? this.DisplayArea.Center), 0)); + this.Transform = Matrix.CreateScale(scale, scale, 1) * Matrix.CreateTranslation(new Vector3((1 - scale) * (origin ?? this.DisplayArea.Center), 0)); } /// diff --git a/MLEM.Ui/UiSystem.cs b/MLEM.Ui/UiSystem.cs index 0de7170..0a4bbc7 100644 --- a/MLEM.Ui/UiSystem.cs +++ b/MLEM.Ui/UiSystem.cs @@ -442,5 +442,14 @@ namespace MLEM.Ui { this.System.Controls.SelectElement(this, element, autoNav); } + /// + /// Scales this root element's matrix based on the given scale and origin. + /// + /// The scale to use + /// The origin to use for scaling, or null to use this root's element's center point + public void ScaleOrigin(float scale, Vector2? origin = null) { + this.Transform = Matrix.CreateScale(scale, scale, 1) * Matrix.CreateTranslation(new Vector3((1 - scale) * (origin ?? this.Element.DisplayArea.Center), 0)); + } + } } \ No newline at end of file