Skip to content

Commit

Permalink
[Fix][Core][Windows] DisplayLogo not being properly applied
Browse files Browse the repository at this point in the history
  • Loading branch information
sescalada committed Dec 12, 2023
1 parent 14cc916 commit ff96f5a
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 31 deletions.
1 change: 1 addition & 0 deletions samples/XrvSamples/Scenes/WindowScene.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ protected override void OnPostCreateXRScene()
Text,
new Vector2(0.3f, 0.2f),
new Vector3(0.01f, -0.01f, 0f));
configurator.DisplayLogo = false;
});

this.window1.Opened += this.Window1_Opened;
Expand Down
1 change: 1 addition & 0 deletions src/core/Evergine.Xrv.Core/UI/Dialogs/Dialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ protected override void OnActivated()
{
base.OnActivated();

this.UpdateLogoVisibility(false);
this.Configurator.UpdateContent();
this.cancelHolder = this.Owner.FindChildrenByTag("PART_base_dialog_cancel_holder", true).First();
this.acceptHolder = this.Owner.FindChildrenByTag("PART_base_dialog_accept_holder", true).First();
Expand Down
29 changes: 0 additions & 29 deletions src/core/Evergine.Xrv.Core/UI/Windows/BaseWindowConfigurator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,11 @@ public abstract class BaseWindowConfigurator : Component
private Vector2 frontPlateSize;
private string title;
private Func<string> localizedTitle;
private Entity logoEntity;
private Entity contentEntity;
private Entity content;

private bool displayBackPlate = true;
private bool displayFrontPlate = true;
private bool displayLogo = true;

/// <summary>
/// Gets or sets window contents.
Expand Down Expand Up @@ -231,23 +229,6 @@ public bool DisplayBackPlate
}
}

/// <summary>
/// Gets or sets a value indicating whether bottom left icon should be displayed or not.
/// </summary>
public bool DisplayLogo
{
get => this.displayLogo;

set
{
if (this.displayLogo != value)
{
this.displayLogo = value;
this.UpdateDisplayLogo();
}
}
}

internal void UpdateContent()
{
if (this.contentEntity == null)
Expand Down Expand Up @@ -282,7 +263,6 @@ protected override bool OnAttached()
if (attached)
{
this.contentEntity = this.Owner.FindChildrenByTag("PART_window_content", isRecursive: true).First();
this.logoEntity = this.Owner.FindChildrenByTag("PART_window_logo", isRecursive: true).First();

if (this.localizedTitle != null && this.titleLocalization != null)
{
Expand All @@ -304,7 +284,6 @@ protected override void OnActivated()
this.UpdateFrontPlateOffsets();
this.UpdateContent();
this.UpdateTitle();
this.UpdateDisplayLogo();
this.UpdateDisplayBackPlate();
this.UpdateDisplayFrontPlate();
}
Expand Down Expand Up @@ -386,14 +365,6 @@ private void UpdateTitle() =>
? this.localizedTitle.Invoke()
: this.title;

private void UpdateDisplayLogo()
{
if (this.IsAttached)
{
this.logoEntity.IsEnabled = this.displayLogo;
}
}

private void UpdateDisplayFrontPlate()
{
if (this.IsAttached)
Expand Down
8 changes: 8 additions & 0 deletions src/core/Evergine.Xrv.Core/UI/Windows/Window.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public class Window : Component

private Entity closeButton = null;
private Entity followButton = null;
private Entity logoEntity = null;
private bool allowPin = true;
private bool enableManipulation = true;

Expand Down Expand Up @@ -158,6 +159,7 @@ protected override bool OnAttached()
{
this.closeButton = this.Owner.FindChildrenByTag("PART_window_close", true).First();
this.followButton = this.Owner.FindChildrenByTag("PART_window_follow", true).First();
this.logoEntity = this.Owner.FindChildrenByTag("PART_window_logo", isRecursive: true).First();
this.SubscribeEvents();
this.UpdateFollowBehavior(false);
}
Expand Down Expand Up @@ -190,6 +192,12 @@ protected virtual float GetOpenDistance()
return distances.GetDistanceOrAlternative(this.DistanceKey, Distances.MediumKey);
}

/// <summary>
/// Changes window logo visibility.
/// </summary>
/// <param name="visible">True to make it visible; false otherwise.</param>
protected void UpdateLogoVisibility(bool visible) => this.logoEntity.IsEnabled = visible;

private void SubscribeEvents()
{
var followButtonPressable = this.followButton.FindComponentInChildren<ToggleButton>();
Expand Down
42 changes: 41 additions & 1 deletion src/core/Evergine.Xrv.Core/UI/Windows/WindowConfigurator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Evergine.Framework;
using Evergine.Framework.Graphics;
using Evergine.Mathematics;
using System.Linq;

namespace Evergine.Xrv.Core.UI.Windows
{
Expand All @@ -14,6 +15,8 @@ public class WindowConfigurator : BaseWindowConfigurator
{
private Vector2 logoOffsets = new Vector2(0.03f, 0.025f);
private Material logoMaterial;
private Entity logoEntity;
private bool displayLogo = true;

[BindComponent(source: BindComponentSource.Children, tag: "PART_window_logo")]
private Transform3D logoTransform = null;
Expand All @@ -37,6 +40,35 @@ public Material LogoMaterial
}
}

/// <summary>
/// Gets or sets a value indicating whether bottom left icon should be displayed or not.
/// </summary>
public bool DisplayLogo
{
get => this.displayLogo;

set
{
if (this.displayLogo != value)
{
this.displayLogo = value;
this.UpdateDisplayLogo();
}
}
}

/// <inheritdoc/>
protected override bool OnAttached()
{
bool attached = base.OnAttached();
if (attached)
{
this.logoEntity = this.Owner.FindChildrenByTag("PART_window_logo", isRecursive: true).First();
}

return attached;
}

/// <inheritdoc/>
protected override void OnActivated()
{
Expand All @@ -58,8 +90,16 @@ protected override void UpdateSize()

private void UpdateLogoMaterial()
{
this.logoMaterialComponent.Owner.IsEnabled = this.logoMaterial != null;
this.logoMaterialComponent.Material = this.logoMaterial;
this.UpdateDisplayLogo();
}

private void UpdateDisplayLogo()
{
if (this.IsAttached)
{
this.logoEntity.IsEnabled = this.displayLogo && this.logoMaterial != null;
}
}
}
}
1 change: 0 additions & 1 deletion src/core/Evergine.Xrv.Core/UI/Windows/WindowsSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,6 @@ private Entity CreateDialogAux<TDialog>(TDialog dialog, string title, string tex
offset.X = 0;
offset.Y = 0;
dialogConfigurator.FrontPlateOffsets = offset;
dialogConfigurator.DisplayLogo = false;

return owner;
}
Expand Down

0 comments on commit ff96f5a

Please sign in to comment.