Skip to content

Commit 56ff184

Browse files
committed
Some fixes
1 parent 21c8838 commit 56ff184

File tree

8 files changed

+113
-106
lines changed

8 files changed

+113
-106
lines changed

samples/Myra.Samples.AllWidgets/AllWidgets.Generated.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Generated by MyraPad at 10/26/2023 8:43:05 AM */
1+
/* Generated by MyraPad at 10/26/2023 10:19:14 AM */
22
using Myra;
33
using Myra.Graphics2D;
44
using Myra.Graphics2D.TextureAtlases;
@@ -341,6 +341,7 @@ private void BuildUI()
341341
_gridRight.Widgets.Add(label12);
342342

343343
var scrollViewer1 = new ScrollViewer();
344+
scrollViewer1.ShowHorizontalScrollBar = false;
344345
scrollViewer1.Content = _gridRight;
345346

346347
var label13 = new Label();

samples/Myra.Samples.AllWidgets/allControls.xmmp

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
</MenuItem>
2323
</HorizontalMenu>
2424
<HorizontalSplitPane StackPanel.ProportionType="Fill">
25-
<ScrollViewer>
25+
<ScrollViewer ShowHorizontalScrollBar="False">
2626
<Grid ColumnSpacing="8" RowSpacing="8" Id="_gridRight">
2727
<Grid.DefaultRowProportion Type="Auto" />
2828
<Grid.ColumnsProportions>

samples/Myra.Samples.CustomUIStylesheet/AllWidgets.Generated.cs

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Generated by MyraPad at 10/26/2023 8:58:09 AM */
1+
/* Generated by MyraPad at 10/26/2023 10:42:08 AM */
22
using Myra;
33
using Myra.Graphics2D;
44
using Myra.Graphics2D.TextureAtlases;
@@ -52,10 +52,13 @@ private void BuildUI()
5252
label3.Text = "Image Button:";
5353
Grid.SetRow(label3, 2);
5454

55-
_imageButton = new ImageButton();
55+
var image1 = new Image();
56+
57+
_imageButton = new Button();
5658
_imageButton.Id = "_imageButton";
5759
Grid.SetColumn(_imageButton, 1);
5860
Grid.SetRow(_imageButton, 2);
61+
_imageButton.Content = image1;
5962

6063
var checkBox1 = new CheckBox();
6164
checkBox1.Text = "This is checkbox";
@@ -166,6 +169,7 @@ private void BuildUI()
166169
_gridRight.Widgets.Add(label8);
167170

168171
var scrollViewer1 = new ScrollViewer();
172+
scrollViewer1.ShowHorizontalScrollBar = false;
169173
scrollViewer1.Content = _gridRight;
170174

171175
var label9 = new Label();
@@ -239,7 +243,7 @@ private void BuildUI()
239243
public ImageTextButton _button;
240244
public Label _textButtonLabel;
241245
public Button _textButton;
242-
public ImageButton _imageButton;
246+
public Button _imageButton;
243247
public Grid _gridRight;
244248
public HorizontalProgressBar _horizontalProgressBar;
245249
public VerticalProgressBar _verticalProgressBar;

samples/Myra.Samples.CustomUIStylesheet/CustomUIStylesheetGame.cs

+3-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ protected override void LoadContent()
4141
_allWidgets = new AllWidgets();
4242
var textureAtlas = assetManager.LoadTextureRegionAtlas("ui_stylesheet.xmat");
4343
_allWidgets._button.Image = textureAtlas["music-off"];
44-
_allWidgets._imageButton.Image = textureAtlas["sound-off"];
44+
45+
var image = (Image)_allWidgets._imageButton.Content;
46+
image.Renderable = textureAtlas["sound-off"];
4547

4648
_desktop = new Desktop
4749
{

samples/Myra.Samples.CustomUIStylesheet/allControls.xmmp

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project StylesheetPath="Resources/ui_stylesheet.xmms">
22
<Project.ExportOptions Namespace="Myra.Samples.CustomUIStylesheet" Class="AllWidgets" OutputPath="D:\Projects\Myra\samples\Myra.Samples.CustomUIStylesheet" />
33
<HorizontalSplitPane>
4-
<ScrollViewer>
4+
<ScrollViewer ShowHorizontalScrollBar="False">
55
<Grid ColumnSpacing="8" RowSpacing="8" Id="_gridRight">
66
<Grid.DefaultRowProportion Type="Auto" />
77
<Grid.ColumnsProportions>
@@ -15,7 +15,9 @@
1515
<Label Text="Button 2" />
1616
</Button>
1717
<Label Text="Image Button:" Grid.Row="2" />
18-
<ImageButton Id="_imageButton" Grid.Column="1" Grid.Row="2" />
18+
<Button Id="_imageButton" Grid.Column="1" Grid.Row="2">
19+
<Image />
20+
</Button>
1921
<CheckBox Text="This is checkbox" ImageWidth="10" ImageHeight="10" Grid.Row="3" Grid.ColumnSpan="2" />
2022
<Label Text="Horizontal Slider:" Grid.Row="4" />
2123
<HorizontalSlider Grid.Column="1" Grid.Row="4" />

src/Myra/Graphics2D/UI/Containers/ScrollViewer.cs

+7-23
Original file line numberDiff line numberDiff line change
@@ -483,14 +483,14 @@ protected override void InternalArrange()
483483
var availableSize = bounds.Size();
484484
var oldMeasureSize = InternalChild.Measure(availableSize);
485485

486-
_horizontalScrollingOn = oldMeasureSize.X > bounds.Width;
487-
_verticalScrollingOn = oldMeasureSize.Y > bounds.Height;
486+
_horizontalScrollingOn = (oldMeasureSize.X > bounds.Width) && ShowHorizontalScrollBar;
487+
_verticalScrollingOn = (oldMeasureSize.Y > bounds.Height) && ShowVerticalScrollBar;
488488
if (_horizontalScrollingOn || _verticalScrollingOn)
489489
{
490490
var vsWidth = VerticalScrollbarWidth;
491491
var hsHeight = HorizontalScrollbarHeight;
492492

493-
if (_horizontalScrollingOn && ShowHorizontalScrollBar)
493+
if (_horizontalScrollingOn)
494494
{
495495
availableSize.Y -= hsHeight;
496496

@@ -500,7 +500,7 @@ protected override void InternalArrange()
500500
}
501501
}
502502

503-
if (_verticalScrollingOn && ShowVerticalScrollBar)
503+
if (_verticalScrollingOn)
504504
{
505505
availableSize.X -= vsWidth;
506506

@@ -512,7 +512,7 @@ protected override void InternalArrange()
512512

513513
// Remeasure with scrollbars
514514
var measureSize = InternalChild.Measure(availableSize);
515-
var bw = bounds.Width - (_verticalScrollingOn && ShowVerticalScrollBar ? vsWidth : 0);
515+
var bw = bounds.Width - (_verticalScrollingOn ? vsWidth : 0);
516516

517517
_horizontalScrollbarFrame = new Rectangle(bounds.Left,
518518
bounds.Bottom - hsHeight,
@@ -563,31 +563,15 @@ protected override void InternalArrange()
563563
_thumbMaximumY = 1;
564564
}
565565

566-
if (_horizontalScrollingOn && ShowHorizontalScrollBar)
566+
if (_horizontalScrollingOn)
567567
{
568568
bounds.Width = measureSize.X;
569569
}
570-
else if (_horizontalScrollingOn)
571-
{
572-
bounds.Width = oldMeasureSize.X;
573-
}
574-
else
575-
{
576-
bounds.Width = availableSize.X;
577-
}
578570

579-
if (_verticalScrollingOn && ShowVerticalScrollBar)
571+
if (_verticalScrollingOn)
580572
{
581573
bounds.Height = measureSize.Y;
582574
}
583-
else if (_verticalScrollingOn)
584-
{
585-
bounds.Height = oldMeasureSize.Y;
586-
}
587-
else
588-
{
589-
bounds.Height = availableSize.Y;
590-
}
591575
}
592576

593577
InternalChild.Arrange(bounds);

src/MyraPad/AsyncTasksQueue.cs

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
using Myra.Graphics2D.UI;
2+
using System;
3+
using System.Threading;
4+
5+
namespace MyraPad
6+
{
7+
internal class AsyncTasksQueue
8+
{
9+
private string _projectXml;
10+
private string _objectXml;
11+
12+
private readonly AutoResetEvent _refreshProjectEvent = new AutoResetEvent(false);
13+
14+
public AsyncTasksQueue()
15+
{
16+
ThreadPool.QueueUserWorkItem(RefreshProc);
17+
}
18+
19+
public void QueueLoadProject(string xml)
20+
{
21+
_projectXml = xml;
22+
_refreshProjectEvent.Set();
23+
}
24+
25+
public void QueueLoadObject(string xml)
26+
{
27+
_objectXml = xml;
28+
_refreshProjectEvent.Set();
29+
}
30+
31+
private void RefreshProc(object state)
32+
{
33+
while (true)
34+
{
35+
_refreshProjectEvent.WaitOne();
36+
37+
if (!string.IsNullOrEmpty(_projectXml))
38+
{
39+
try
40+
{
41+
Studio.Instance.QueueSetStatusText("Reloading Project...");
42+
Studio.Instance.NewProject = Project.LoadFromXml(_projectXml, Studio.Instance.AssetManager);
43+
Studio.Instance.QueueSetStatusText(string.Empty);
44+
}
45+
catch (Exception ex)
46+
{
47+
Studio.Instance.QueueSetStatusText(ex.Message);
48+
}
49+
50+
_projectXml = null;
51+
}
52+
53+
if (!string.IsNullOrEmpty(_objectXml))
54+
{
55+
if (Studio.Instance.Project != null)
56+
{
57+
try
58+
{
59+
Studio.Instance.QueueSetStatusText("Reloading Object...");
60+
Studio.Instance.NewObject = Studio.Instance.Project.LoadObjectFromXml(_objectXml, Studio.Instance.AssetManager);
61+
Studio.Instance.QueueSetStatusText(string.Empty);
62+
}
63+
catch (Exception ex)
64+
{
65+
Studio.Instance.QueueSetStatusText(ex.Message);
66+
}
67+
}
68+
69+
_objectXml = null;
70+
}
71+
}
72+
}
73+
}
74+
}

0 commit comments

Comments
 (0)