Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Borders are calculated wrong #376

Closed
IceReaper opened this issue Oct 14, 2022 · 3 comments · Fixed by #378
Closed

Borders are calculated wrong #376

IceReaper opened this issue Oct 14, 2022 · 3 comments · Fixed by #378

Comments

@IceReaper
Copy link
Contributor

IceReaper commented Oct 14, 2022

When using border, the border is correctly drawn inside the box. However the next element is pushed away by the border distance, resulting in a gap between widgets when using borders.

The following inner boxes do not use margin or padding:
image
which is a borderwidth of 1. when setting it to two, the result is:
image

Also there is a visible magical padding on the right bottom of the lower box. Might be related to that.

@rds1983
Copy link
Owner

rds1983 commented Oct 14, 2022

can you share MML code?

@IceReaper
Copy link
Contributor Author

namespace Prototype.Screens.MainMenu;

using Microsoft.Xna.Framework;
using Myra.Graphics2D.Brushes;
using Myra.Graphics2D.UI;

public sealed class PlayMenuWidget : VerticalStackPanel
{
	public PlayMenuWidget(Game game)
	{
		this.HorizontalAlignment = HorizontalAlignment.Stretch;
		this.VerticalAlignment = VerticalAlignment.Stretch;
		this.Padding = new(9);
		this.Background = new SolidBrush(new Color(0x10, 0x10, 0x10));
		this.Border = new SolidBrush(new Color(0x80, 0x80, 0x80));
		this.BorderThickness = new(1);

		var playersScroll = new ScrollViewer
		{
			Border = new SolidBrush(new Color(0x80, 0x80, 0x80)), BorderThickness = new(1), Margin = new(0, 0, 0, 0), Height = 130
		};

		this.AddChild(playersScroll);

		var players = new VerticalStackPanel();
		playersScroll.Content = players;

		var pressToJoin = new Label();
		players.AddChild(pressToJoin);

		var buttons = new Grid { Border = new SolidBrush(new Color(0x80, 0x80, 0x80)), BorderThickness = new(1) };
		this.AddChild(buttons);

		var back = new TextButton { Text = "Back", Width = 100, Height = 15, HorizontalAlignment = HorizontalAlignment.Left };
		back.Click += (_, _) => this.Desktop.Root = new MainMenuWidget(game);
		buttons.AddChild(back);

		var play = new TextButton { Text = "Play", Width = 100, Height = 15, HorizontalAlignment = HorizontalAlignment.Right };
		play.Click += (_, _) => this.Desktop.Root = new MainMenuWidget(game);
		buttons.AddChild(play);
	}
}

@Sydonian
Copy link

Sydonian commented Oct 15, 2022

I found the same problem:
image

<Project>
  <Project.ExportOptions />
  <Window Title="" Left="372" Top="209">
    <HorizontalStackPanel>
      <Panel Width="20" Height="20" BorderThickness="1" Border="#ff00ff" />
      <Panel Width="20" Height="20" BorderThickness="1" Border="#ff00ff" />
      <Panel Width="20" Height="20" BorderThickness="2" Border="#ff00ff" />
      <Panel Width="20" Height="20" BorderThickness="4" Border="#ff00ff" />
      <Panel Width="20" Height="20" BorderThickness="8" Border="#ff00ff" />
      <Label Text="test" BorderThickness="8" Border="#ff00ff" />
      <Panel Width="20" Height="20" BorderThickness="8" Border="#ff00ff" />
    </HorizontalStackPanel>
  </Window>
</Project>

rds1983 pushed a commit that referenced this issue Oct 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants