Skip to content

Commit

Permalink
Feature: optional window close button (#12)
Browse files Browse the repository at this point in the history
Co-authored-by: Rafael Caro <rafael.caro@plainconcepts.com>
  • Loading branch information
Racafe92 and Rafael Caro authored Dec 19, 2023
1 parent 7dee276 commit 9bdc85c
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/core/Evergine.Xrv.Core/UI/Windows/WindowConfigurator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ public class WindowConfigurator : BaseWindowConfigurator
private Material logoMaterial;
private Entity logoEntity;
private bool displayLogo = true;
private Entity closeButtonEntity;
private bool showCloseButton = true;

[BindComponent(source: BindComponentSource.Children, tag: "PART_window_logo")]
private Transform3D logoTransform = null;
Expand Down Expand Up @@ -57,13 +59,31 @@ public bool DisplayLogo
}
}

/// <summary>
/// Gets or sets a value indicating whether top right close window button should be displayed or not.
/// </summary>
public bool ShowCloseButton
{
get => this.showCloseButton;

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

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

return attached;
Expand Down Expand Up @@ -101,5 +121,13 @@ private void UpdateDisplayLogo()
this.logoEntity.IsEnabled = this.displayLogo && this.logoMaterial != null;
}
}

private void UpdateShowCloseButton()
{
if (this.closeButtonEntity != null)
{
this.closeButtonEntity.IsEnabled = this.ShowCloseButton;
}
}
}
}

0 comments on commit 9bdc85c

Please sign in to comment.