Skip to content

Commit

Permalink
#414: Replaced TextButtons and ImageButtons with the new Button
Browse files Browse the repository at this point in the history
  • Loading branch information
rds1983 committed Oct 26, 2023
1 parent 1c24793 commit 21c8838
Show file tree
Hide file tree
Showing 56 changed files with 618 additions and 406 deletions.
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<RootNamespace>Myra</RootNamespace>
<Description>UI Library for MonoGame, FNA and Stride</Description>
<VersionPrefix>1.5.1</VersionPrefix>
<XNAssetsVersion>0.6.7</XNAssetsVersion>
<XNAssetsVersion>0.6.8</XNAssetsVersion>
<FontStashSharpVersion>1.3.0</FontStashSharpVersion>
<LangVersion>8.0</LangVersion>
<InfoLundinMathVersion>1.2.6</InfoLundinMathVersion>
Expand Down
94 changes: 50 additions & 44 deletions samples/Myra.Samples.AllWidgets/AllWidgets.Generated.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Generated by MyraPad at 10/23/2023 9:50:50 AM */
/* Generated by MyraPad at 10/26/2023 8:43:05 AM */
using Myra;
using Myra.Graphics2D;
using Myra.Graphics2D.TextureAtlases;
Expand Down Expand Up @@ -160,22 +160,28 @@ private void BuildUI()
_textButtonLabel.Id = "_textButtonLabel";
Grid.SetRow(_textButtonLabel, 3);

_buttonChooseColor = new TextButton();
_buttonChooseColor.Text = "Choose Color";
var label4 = new Label();
label4.Text = "Choose Color";

_buttonChooseColor = new Button();
_buttonChooseColor.Padding = new Thickness(8, 0);
_buttonChooseColor.Id = "_buttonChooseColor";
Grid.SetColumn(_buttonChooseColor, 1);
Grid.SetRow(_buttonChooseColor, 3);
_buttonChooseColor.Content = label4;

var label4 = new Label();
label4.Text = "Image Button:";
Grid.SetRow(label4, 4);
var label5 = new Label();
label5.Text = "Image Button:";
Grid.SetRow(label5, 4);

var image1 = new Image();

_imageButton = new ImageButton();
_imageButton = new Button();
_imageButton.Padding = new Thickness(8, 0);
_imageButton.Id = "_imageButton";
Grid.SetColumn(_imageButton, 1);
Grid.SetRow(_imageButton, 4);
_imageButton.Content = image1;

var checkBox1 = new CheckBox();
checkBox1.Text = "This is checkbox";
Expand All @@ -184,18 +190,18 @@ private void BuildUI()
Grid.SetRow(checkBox1, 5);
Grid.SetColumnSpan(checkBox1, 2);

var label5 = new Label();
label5.Text = "Horizontal Slider:";
Grid.SetRow(label5, 6);
var label6 = new Label();
label6.Text = "Horizontal Slider:";
Grid.SetRow(label6, 6);

var horizontalSlider1 = new HorizontalSlider();
Grid.SetColumn(horizontalSlider1, 1);
Grid.SetRow(horizontalSlider1, 6);
Grid.SetColumnSpan(horizontalSlider1, 2);

var label6 = new Label();
label6.Text = "Combo Box:";
Grid.SetRow(label6, 7);
var label7 = new Label();
label7.Text = "Combo Box:";
Grid.SetRow(label7, 7);

var listItem1 = new ListItem();
listItem1.Text = "Red";
Expand All @@ -218,28 +224,28 @@ private void BuildUI()
comboBox1.Items.Add(listItem2);
comboBox1.Items.Add(listItem3);

var label7 = new Label();
label7.Text = "Text Field:";
Grid.SetRow(label7, 8);
var label8 = new Label();
label8.Text = "Text Field:";
Grid.SetRow(label8, 8);

var textBox1 = new TextBox();
Grid.SetColumn(textBox1, 1);
Grid.SetRow(textBox1, 8);
Grid.SetColumnSpan(textBox1, 2);

var label8 = new Label();
label8.Text = "Spin Button:";
Grid.SetRow(label8, 9);
var label9 = new Label();
label9.Text = "Spin Button:";
Grid.SetRow(label9, 9);

var spinButton1 = new SpinButton();
spinButton1.Value = 1;
spinButton1.Width = 100;
Grid.SetColumn(spinButton1, 1);
Grid.SetRow(spinButton1, 9);

var label9 = new Label();
label9.Text = "List Box:";
Grid.SetRow(label9, 10);
var label10 = new Label();
label10.Text = "List Box:";
Grid.SetRow(label10, 10);

var listItem4 = new ListItem();
listItem4.Text = "Red";
Expand All @@ -262,9 +268,9 @@ private void BuildUI()
listBox1.Items.Add(listItem5);
listBox1.Items.Add(listItem6);

var label10 = new Label();
label10.Text = "Vertical Menu:";
Grid.SetRow(label10, 11);
var label11 = new Label();
label11.Text = "Vertical Menu:";
Grid.SetRow(label11, 11);

var menuItem1 = new MenuItem();
menuItem1.Text = "Start New Game";
Expand All @@ -282,9 +288,9 @@ private void BuildUI()
verticalMenu1.Items.Add(menuItem2);
verticalMenu1.Items.Add(menuItem3);

var label11 = new Label();
label11.Text = "Tree";
Grid.SetRow(label11, 12);
var label12 = new Label();
label12.Text = "Tree";
Grid.SetRow(label12, 12);

_gridRight = new Grid();
_gridRight.ColumnSpacing = 8;
Expand Down Expand Up @@ -317,28 +323,28 @@ private void BuildUI()
_gridRight.Widgets.Add(_textChooseFolder);
_gridRight.Widgets.Add(_textButtonLabel);
_gridRight.Widgets.Add(_buttonChooseColor);
_gridRight.Widgets.Add(label4);
_gridRight.Widgets.Add(label5);
_gridRight.Widgets.Add(_imageButton);
_gridRight.Widgets.Add(checkBox1);
_gridRight.Widgets.Add(label5);
_gridRight.Widgets.Add(horizontalSlider1);
_gridRight.Widgets.Add(label6);
_gridRight.Widgets.Add(comboBox1);
_gridRight.Widgets.Add(horizontalSlider1);
_gridRight.Widgets.Add(label7);
_gridRight.Widgets.Add(textBox1);
_gridRight.Widgets.Add(comboBox1);
_gridRight.Widgets.Add(label8);
_gridRight.Widgets.Add(spinButton1);
_gridRight.Widgets.Add(textBox1);
_gridRight.Widgets.Add(label9);
_gridRight.Widgets.Add(listBox1);
_gridRight.Widgets.Add(spinButton1);
_gridRight.Widgets.Add(label10);
_gridRight.Widgets.Add(verticalMenu1);
_gridRight.Widgets.Add(listBox1);
_gridRight.Widgets.Add(label11);
_gridRight.Widgets.Add(verticalMenu1);
_gridRight.Widgets.Add(label12);

var scrollViewer1 = new ScrollViewer();
scrollViewer1.Content = _gridRight;

var label12 = new Label();
label12.Text = "Vertical Slider:";
var label13 = new Label();
label13.Text = "Vertical Slider:";

var verticalSlider1 = new VerticalSlider();
verticalSlider1.HorizontalAlignment = Myra.Graphics2D.UI.HorizontalAlignment.Center;
Expand All @@ -358,11 +364,11 @@ private void BuildUI()
{
Type = Myra.Graphics2D.UI.ProportionType.Fill,
});
grid1.Widgets.Add(label12);
grid1.Widgets.Add(label13);
grid1.Widgets.Add(verticalSlider1);

var label13 = new Label();
label13.Text = "Progress Bars:";
var label14 = new Label();
label14.Text = "Progress Bars:";

_horizontalProgressBar = new HorizontalProgressBar();
_horizontalProgressBar.Id = "_horizontalProgressBar";
Expand Down Expand Up @@ -391,7 +397,7 @@ private void BuildUI()
{
Type = Myra.Graphics2D.UI.ProportionType.Fill,
});
grid2.Widgets.Add(label13);
grid2.Widgets.Add(label14);
grid2.Widgets.Add(_horizontalProgressBar);
grid2.Widgets.Add(_verticalProgressBar);

Expand Down Expand Up @@ -432,8 +438,8 @@ private void BuildUI()
public ImageTextButton _buttonChooseFolder;
public TextBox _textChooseFolder;
public Label _textButtonLabel;
public TextButton _buttonChooseColor;
public ImageButton _imageButton;
public Button _buttonChooseColor;
public Button _imageButton;
public Grid _gridRight;
public HorizontalProgressBar _horizontalProgressBar;
public VerticalProgressBar _verticalProgressBar;
Expand Down
3 changes: 2 additions & 1 deletion samples/Myra.Samples.AllWidgets/AllWidgets.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ public AllWidgets()

_buttonChooseColor.Click += (sender, args) => ChooseColor();

_imageButton.Image = DefaultAssets.UITextureRegionAtlas["icon-star-outline"];
var image = (Image)_imageButton.Content;
image.Renderable = DefaultAssets.UITextureRegionAtlas["icon-star-outline"];
_imageButton.Click += (sender, args) =>
{
var debugWindow = new DebugOptionsWindow();
Expand Down
10 changes: 7 additions & 3 deletions samples/Myra.Samples.AllWidgets/allControls.xmmp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<MenuItem Text="&amp;About" Id="_menuItemAbout" />
</MenuItem>
</HorizontalMenu>
<HorizontalSplitPane StackPanel.ProportionType="Fill" >
<HorizontalSplitPane StackPanel.ProportionType="Fill">
<ScrollViewer>
<Grid ColumnSpacing="8" RowSpacing="8" Id="_gridRight">
<Grid.DefaultRowProportion Type="Auto" />
Expand All @@ -40,9 +40,13 @@
<ImageTextButton Text="Choose Folder" StyleName="blue" Padding="8, 0" Id="_buttonChooseFolder" Grid.Column="1" Grid.Row="2" />
<TextBox Id="_textChooseFolder" Grid.Column="2" Grid.Row="2" />
<Label Text="Text Button:" Id="_textButtonLabel" Grid.Row="3" />
<TextButton Text="Choose Color" Padding="8, 0" Id="_buttonChooseColor" Grid.Column="1" Grid.Row="3" />
<Button Padding="8, 0" Id="_buttonChooseColor" Grid.Column="1" Grid.Row="3">
<Label Text="Choose Color" />
</Button>
<Label Text="Image Button:" Grid.Row="4" />
<ImageButton Padding="8, 0" Id="_imageButton" Grid.Column="1" Grid.Row="4" />
<Button Padding="8, 0" Id="_imageButton" Grid.Column="1" Grid.Row="4">
<Image />
</Button>
<CheckBox Text="This is checkbox" ImageWidth="10" ImageHeight="10" Grid.Row="5" Grid.ColumnSpan="2" />
<Label Text="Horizontal Slider:" Grid.Row="6" />
<HorizontalSlider Grid.Column="1" Grid.Row="6" Grid.ColumnSpan="2" />
Expand Down
Loading

0 comments on commit 21c8838

Please sign in to comment.