diff --git a/samples/XrvSamples/Scenes/WindowScene.cs b/samples/XrvSamples/Scenes/WindowScene.cs index b485359e..4be4541b 100644 --- a/samples/XrvSamples/Scenes/WindowScene.cs +++ b/samples/XrvSamples/Scenes/WindowScene.cs @@ -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; diff --git a/src/core/Evergine.Xrv.Core/UI/Dialogs/Dialog.cs b/src/core/Evergine.Xrv.Core/UI/Dialogs/Dialog.cs index 7f68c639..61b2e179 100644 --- a/src/core/Evergine.Xrv.Core/UI/Dialogs/Dialog.cs +++ b/src/core/Evergine.Xrv.Core/UI/Dialogs/Dialog.cs @@ -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(); diff --git a/src/core/Evergine.Xrv.Core/UI/Windows/BaseWindowConfigurator.cs b/src/core/Evergine.Xrv.Core/UI/Windows/BaseWindowConfigurator.cs index 0fd2fdda..c21ffab4 100644 --- a/src/core/Evergine.Xrv.Core/UI/Windows/BaseWindowConfigurator.cs +++ b/src/core/Evergine.Xrv.Core/UI/Windows/BaseWindowConfigurator.cs @@ -85,13 +85,11 @@ public abstract class BaseWindowConfigurator : Component private Vector2 frontPlateSize; private string title; private Func localizedTitle; - private Entity logoEntity; private Entity contentEntity; private Entity content; private bool displayBackPlate = true; private bool displayFrontPlate = true; - private bool displayLogo = true; /// /// Gets or sets window contents. @@ -231,23 +229,6 @@ public bool DisplayBackPlate } } - /// - /// Gets or sets a value indicating whether bottom left icon should be displayed or not. - /// - public bool DisplayLogo - { - get => this.displayLogo; - - set - { - if (this.displayLogo != value) - { - this.displayLogo = value; - this.UpdateDisplayLogo(); - } - } - } - internal void UpdateContent() { if (this.contentEntity == null) @@ -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) { @@ -304,7 +284,6 @@ protected override void OnActivated() this.UpdateFrontPlateOffsets(); this.UpdateContent(); this.UpdateTitle(); - this.UpdateDisplayLogo(); this.UpdateDisplayBackPlate(); this.UpdateDisplayFrontPlate(); } @@ -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) diff --git a/src/core/Evergine.Xrv.Core/UI/Windows/Window.cs b/src/core/Evergine.Xrv.Core/UI/Windows/Window.cs index f54e3c69..d63dd5aa 100644 --- a/src/core/Evergine.Xrv.Core/UI/Windows/Window.cs +++ b/src/core/Evergine.Xrv.Core/UI/Windows/Window.cs @@ -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; @@ -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); } @@ -190,6 +192,12 @@ protected virtual float GetOpenDistance() return distances.GetDistanceOrAlternative(this.DistanceKey, Distances.MediumKey); } + /// + /// Changes window logo visibility. + /// + /// True to make it visible; false otherwise. + protected void UpdateLogoVisibility(bool visible) => this.logoEntity.IsEnabled = visible; + private void SubscribeEvents() { var followButtonPressable = this.followButton.FindComponentInChildren(); diff --git a/src/core/Evergine.Xrv.Core/UI/Windows/WindowConfigurator.cs b/src/core/Evergine.Xrv.Core/UI/Windows/WindowConfigurator.cs index ac2fb519..8ea3a52b 100644 --- a/src/core/Evergine.Xrv.Core/UI/Windows/WindowConfigurator.cs +++ b/src/core/Evergine.Xrv.Core/UI/Windows/WindowConfigurator.cs @@ -4,6 +4,7 @@ using Evergine.Framework; using Evergine.Framework.Graphics; using Evergine.Mathematics; +using System.Linq; namespace Evergine.Xrv.Core.UI.Windows { @@ -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; @@ -37,6 +40,35 @@ public Material LogoMaterial } } + /// + /// Gets or sets a value indicating whether bottom left icon should be displayed or not. + /// + public bool DisplayLogo + { + get => this.displayLogo; + + set + { + if (this.displayLogo != value) + { + this.displayLogo = value; + this.UpdateDisplayLogo(); + } + } + } + + /// + protected override bool OnAttached() + { + bool attached = base.OnAttached(); + if (attached) + { + this.logoEntity = this.Owner.FindChildrenByTag("PART_window_logo", isRecursive: true).First(); + } + + return attached; + } + /// protected override void OnActivated() { @@ -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; + } } } } diff --git a/src/core/Evergine.Xrv.Core/UI/Windows/WindowsSystem.cs b/src/core/Evergine.Xrv.Core/UI/Windows/WindowsSystem.cs index fb5b25c5..72d1c713 100644 --- a/src/core/Evergine.Xrv.Core/UI/Windows/WindowsSystem.cs +++ b/src/core/Evergine.Xrv.Core/UI/Windows/WindowsSystem.cs @@ -292,7 +292,6 @@ private Entity CreateDialogAux(TDialog dialog, string title, string tex offset.X = 0; offset.Y = 0; dialogConfigurator.FrontPlateOffsets = offset; - dialogConfigurator.DisplayLogo = false; return owner; }