mirror of
https://github.com/Ellpeck/MLEM.git
synced 2024-11-27 15:08:33 +01:00
Compare commits
No commits in common. "294af052ae313e1dabd3c9ac098b2ee32b155e66" and "6c4d241d9127f1251c91e86e42d4f1c22bf54856" have entirely different histories.
294af052ae
...
6c4d241d91
5 changed files with 9 additions and 52 deletions
|
@ -31,7 +31,6 @@ Fixes
|
|||
### MLEM.Ui
|
||||
Additions
|
||||
- Added UiControls.NavType, which stores the most recently used type of ui navigation
|
||||
- Added SetWidthBasedOnAspect and SetHeightBasedOnAspect to images
|
||||
|
||||
Improvements
|
||||
- Allow scrolling panels to contain other scrolling panels
|
||||
|
|
|
@ -48,10 +48,10 @@ public class Activity1 : AndroidGameActivity {
|
|||
base.OnWindowFocusChanged(hasFocus);
|
||||
// hide the status bar
|
||||
if (hasFocus) {
|
||||
#pragma warning disable CS0618
|
||||
#pragma warning disable CA1422
|
||||
// TODO this is deprecated, find out how to replace it
|
||||
this.Window.DecorView.SystemUiVisibility = (StatusBarVisibility) (SystemUiFlags.ImmersiveSticky | SystemUiFlags.LayoutStable | SystemUiFlags.LayoutHideNavigation | SystemUiFlags.LayoutFullscreen | SystemUiFlags.HideNavigation | SystemUiFlags.Fullscreen);
|
||||
#pragma warning restore CS0618
|
||||
#pragma warning restore CA1422
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -12,16 +12,12 @@ Strikethrough with ~~two tildes~~.
|
|||
[I'm an inline-style link](https://www.google.com)
|
||||
<http://www.example.com>
|
||||
|
||||
Logo:
|
||||
![](https://raw.githubusercontent.com/Ellpeck/MLEM/main/Media/Logo.png)
|
||||
|
||||
Wide logo:
|
||||
![](https://raw.githubusercontent.com/Ellpeck/MLEM/main/Media/Banner.png)
|
||||
|
||||
Some `inline code` right here
|
||||
|
||||
```js
|
||||
function codeBlock() {
|
||||
|
||||
}
|
||||
```
|
||||
```
|
|
@ -69,40 +69,11 @@ namespace MLEM.Ui.Elements {
|
|||
/// Note that increased rotation does not increase this component's size, even if the rotated texture would go out of bounds of this component.
|
||||
/// </summary>
|
||||
public float ImageRotation;
|
||||
/// <summary>
|
||||
/// Whether this image's width should automatically be calculated based on this image's calculated height in relation to its <see cref="Texture"/>'s aspect ratio.
|
||||
/// Note that, if this is <see langword="true"/>, the <see cref="Element.AutoSizeAddedAbsolute"/> value will still be applied to this image's width.
|
||||
/// </summary>
|
||||
public bool SetWidthBasedOnAspect {
|
||||
get => this.setWidthBasedOnAspect;
|
||||
set {
|
||||
if (this.setWidthBasedOnAspect != value) {
|
||||
this.setWidthBasedOnAspect = value;
|
||||
this.SetAreaDirty();
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Whether this image's height should automatically be calculated based on this image's calculated width in relation to its <see cref="Texture"/>'s aspect ratio.
|
||||
/// This behavior is useful if an image should take up a certain width, but the aspect ratio of its texture can vary and the image should not take up more height than is necessary.
|
||||
/// Note that, if this is <see langword="true"/>, the <see cref="Element.AutoSizeAddedAbsolute"/> value will still be applied to this image's height.
|
||||
/// </summary>
|
||||
public bool SetHeightBasedOnAspect {
|
||||
get => this.setHeightBasedOnAspect;
|
||||
set {
|
||||
if (this.setHeightBasedOnAspect != value) {
|
||||
this.setHeightBasedOnAspect = value;
|
||||
this.SetAreaDirty();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool IsHidden => base.IsHidden || this.Texture == null;
|
||||
|
||||
private bool scaleToImage;
|
||||
private bool setWidthBasedOnAspect;
|
||||
private bool setHeightBasedOnAspect;
|
||||
private TextureRegion explicitlySetTexture;
|
||||
private TextureRegion displayedTexture;
|
||||
|
||||
|
@ -115,7 +86,7 @@ namespace MLEM.Ui.Elements {
|
|||
/// <param name="scaleToImage">Whether this image's size should be based on the texture's size</param>
|
||||
public Image(Anchor anchor, Vector2 size, TextureRegion texture, bool scaleToImage = false) : base(anchor, size) {
|
||||
this.Texture = texture;
|
||||
this.ScaleToImage = scaleToImage;
|
||||
this.scaleToImage = scaleToImage;
|
||||
this.CanBeSelected = false;
|
||||
this.CanBeMoused = false;
|
||||
}
|
||||
|
@ -124,23 +95,14 @@ namespace MLEM.Ui.Elements {
|
|||
public Image(Anchor anchor, Vector2 size, TextureCallback getTextureCallback, bool scaleToImage = false) : base(anchor, size) {
|
||||
this.GetTextureCallback = getTextureCallback;
|
||||
this.Texture = getTextureCallback(this);
|
||||
this.ScaleToImage = scaleToImage;
|
||||
this.scaleToImage = scaleToImage;
|
||||
this.CanBeSelected = false;
|
||||
this.CanBeMoused = false;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override Vector2 CalcActualSize(RectangleF parentArea) {
|
||||
var ret = base.CalcActualSize(parentArea);
|
||||
if (this.Texture != null) {
|
||||
if (this.ScaleToImage)
|
||||
ret = this.Texture.Size.ToVector2() * this.Scale;
|
||||
if (this.SetWidthBasedOnAspect)
|
||||
ret.X = ret.Y * this.Texture.Width / this.Texture.Height + this.ScaledAutoSizeAddedAbsolute.X;
|
||||
if (this.SetHeightBasedOnAspect)
|
||||
ret.Y = ret.X * this.Texture.Height / this.Texture.Width + this.ScaledAutoSizeAddedAbsolute.Y;
|
||||
}
|
||||
return ret;
|
||||
return this.Texture != null && this.scaleToImage ? this.Texture.Size.ToVector2() * this.Scale : base.CalcActualSize(parentArea);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
@ -172,7 +134,7 @@ namespace MLEM.Ui.Elements {
|
|||
return;
|
||||
var nullChanged = this.displayedTexture == null != (newTexture == null);
|
||||
this.displayedTexture = newTexture;
|
||||
if (nullChanged || this.ScaleToImage || this.SetWidthBasedOnAspect || this.SetHeightBasedOnAspect)
|
||||
if (nullChanged || this.scaleToImage)
|
||||
this.SetAreaDirty();
|
||||
}
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ using MLEM.Ui.Style;
|
|||
|
||||
#if NETSTANDARD2_0_OR_GREATER || NET6_0_OR_GREATER
|
||||
using System.Net.Http;
|
||||
|
||||
#else
|
||||
using System.Net;
|
||||
#endif
|
||||
|
@ -145,8 +146,7 @@ namespace MLEM.Ui.Parsers {
|
|||
throw new NullReferenceException("A UI parser requires a GraphicsDevice for parsing images");
|
||||
|
||||
TextureRegion image = null;
|
||||
return new Image(Anchor.AutoLeft, Vector2.One, _ => image) {
|
||||
SetHeightBasedOnAspect = true,
|
||||
return new Image(Anchor.AutoLeft, new Vector2(1, -1), _ => image) {
|
||||
OnAddedToUi = e => {
|
||||
if (image == null)
|
||||
LoadImageAsync();
|
||||
|
|
Loading…
Reference in a new issue