Skip to content

Commit

Permalink
Fixes #436
Browse files Browse the repository at this point in the history
  • Loading branch information
rds1983 committed Nov 9, 2023
1 parent b0d86cb commit e50f650
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 19 deletions.
4 changes: 2 additions & 2 deletions samples/Myra.Samples.AllWidgets/AllWidgets.cs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ public AllWidgets()
public void OpenFile()
{
var fileDialog = new FileDialog(FileDialogMode.OpenFile);
fileDialog.ShowModal(Desktop);
fileDialog.ShowModal(Desktop, darkening: true);

fileDialog.Closed += (s, a) =>
{
Expand All @@ -175,7 +175,7 @@ public void OpenFile()
public void SaveFile()
{
var fileDialog = new FileDialog(FileDialogMode.SaveFile);
fileDialog.ShowModal(Desktop);
fileDialog.ShowModal(Desktop, darkening: true);

fileDialog.Closed += (s, a) =>
{
Expand Down
5 changes: 5 additions & 0 deletions src/Myra/Graphics2D/UI/Desktop.cs
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,11 @@ public void RenderVisual()
{
if (widget.Visible)
{
if (widget.IsDarkening)
{
_renderContext.FillRectangle(bounds, MyraEnvironment.DarkeningColor);

Check failure on line 502 in src/Myra/Graphics2D/UI/Desktop.cs

View workflow job for this annotation

GitHub Actions / BuildAndPublish

Argument 2: cannot convert from 'System.Drawing.Color' to 'FontStashSharp.FSColor'

Check failure on line 502 in src/Myra/Graphics2D/UI/Desktop.cs

View workflow job for this annotation

GitHub Actions / BuildAndPublish

Argument 2: cannot convert from 'System.Drawing.Color' to 'FontStashSharp.FSColor'
}

widget.Render(_renderContext);
}
}
Expand Down
6 changes: 4 additions & 2 deletions src/Myra/Graphics2D/UI/Misc/Window.cs
Original file line number Diff line number Diff line change
Expand Up @@ -260,15 +260,17 @@ private void InternalShow(Desktop desktop, Point? position = null)
}
}

public void Show(Desktop desktop, Point? position = null)
public void Show(Desktop desktop, Point? position = null, bool darkening = false)
{
IsModal = false;
IsDarkening = darkening;
InternalShow(desktop, position);
}

public void ShowModal(Desktop desktop, Point? position = null)
public void ShowModal(Desktop desktop, Point? position = null, bool darkening = false)
{
IsModal = true;
IsDarkening = darkening;
InternalShow(desktop, position);

_previousKeyboardFocus = desktop.FocusedKeyboardWidget;
Expand Down
19 changes: 4 additions & 15 deletions src/Myra/Graphics2D/UI/Widget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ public partial class Widget : BaseObject, ITransformable
private int _zIndex;
private HorizontalAlignment _horizontalAlignment = HorizontalAlignment.Left;
private VerticalAlignment _verticalAlignment = VerticalAlignment.Top;
private bool _isModal = false;
private bool _measureDirty = true;
private bool _arrangeDirty = true;
private Desktop _desktop;
Expand Down Expand Up @@ -591,21 +590,11 @@ internal set

[XmlIgnore]
[Browsable(false)]
public bool IsModal
{
get { return _isModal; }

set
{
if (_isModal == value)
{
return;
}
public bool IsModal { get; set; }

_isModal = value;
InvalidateMeasure();
}
}
[XmlIgnore]
[Browsable(false)]
public bool IsDarkening { get; set; }

[Category("Appearance")]
[DefaultValue(1.0f)]
Expand Down
1 change: 1 addition & 0 deletions src/Myra/MyraEnvironment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ public static AssetManager DefaultAssetManager
/// Makes the text rendering more smooth(especially when scaling) for the cost of sacrificing some performance
/// </summary>
public static bool SmoothText { get; set; }
public static Color DarkeningColor { get; set; } = new Color(0, 0, 0, 192);

Check failure on line 255 in src/Myra/MyraEnvironment.cs

View workflow job for this annotation

GitHub Actions / BuildAndPublish

'Color' does not contain a constructor that takes 4 arguments

Check failure on line 255 in src/Myra/MyraEnvironment.cs

View workflow job for this annotation

GitHub Actions / BuildAndPublish

'Color' does not contain a constructor that takes 4 arguments

private static void GameOnDisposed(object sender, EventArgs eventArgs)
{
Expand Down

0 comments on commit e50f650

Please sign in to comment.