GithubHelp home page GithubHelp logo

videogamers0 / mgui Goto Github PK

View Code? Open in Web Editor NEW
54.0 5.0 7.0 2.72 MB

UI framework for MonoGame game engine.

License: MIT License

C# 100.00%
monogame monogame-framework monogame-gui user-interface c-sharp csharp dotnet6 gamedev open-source xna

mgui's People

Contributors

videogamers0 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

mgui's Issues

Cannot use special characters like "é" or "è"

I have a exception KeyNotFoundException when i using a special character like "é" or "è". I have set the spritefont end character region to 383. Monogame displays them however by modifying the spritefont.

Help would be appreciated thank you very much.

Question: Designer?

I wasnt sure how to contact you directly, I am trying to design the layout of my UI using the xaml designer in visual studio 2022, but visual studio is having some issues and puts a message "SomePage.xaml cannot be edited in the Design View." I was wondering if there were any tips to get this working? Or if you have any suggestions on a good designer, I am all ears! Thanks! I see on your profile you are in Florida, nice I am in Palm Bay / Melbourne area myself.

Cannot build with new monogame project

I tried your library with the latest monogame in visual studio 2022, but the projects refuse to build. Here is the output for the test project I tried making:

Severity	Code	Description	Project	File	Line	Suppression State
Error	MSB3073	The command "dotnet C:\Users\DankM\.nuget\packages\monogame.content.builder.task\3.8.0.1641\build\\..\tools\netcoreapp3.1\any\mgcb.dll /quiet /@:"C:\Users\DankM\source\repos\Erm\MGUI\MGUI.Shared\Content\MGUI.Shared.Content.mgcb" /platform:DesktopGL /outputDir:"C:/Users/DankM/source/repos/Erm/MGUI/MGUI.Shared/Content/bin/DesktopGL/MGUI.Shared.Content" /intermediateDir:"C:/Users/DankM/source/repos/Erm/MGUI/MGUI.Shared/Content/obj/DesktopGL/MGUI.Shared.Content" /workingDir:"C:/Users/DankM/source/repos/Erm/MGUI/MGUI.Shared/Content/"" exited with code -2147450730.	MGUI.Shared	C:\Users\DankM\.nuget\packages\monogame.content.builder.task\3.8.0.1641\build\MonoGame.Content.Builder.Task.targets	138	
Error	MSB3073	The command "dotnet C:\Users\DankM\.nuget\packages\monogame.content.builder.task\3.8.0.1641\build\\..\tools\netcoreapp3.1\any\mgcb.dll /quiet /@:"C:\Users\DankM\source\repos\Erm\Erm\Content\Content.mgcb" /platform:DesktopGL /outputDir:"C:/Users/DankM/source/repos/Erm/Erm/Content/bin/DesktopGL/Content" /intermediateDir:"C:/Users/DankM/source/repos/Erm/Erm/Content/obj/DesktopGL/Content" /workingDir:"C:/Users/DankM/source/repos/Erm/Erm/Content/"" exited with code -2147450730.	Erm	C:\Users\DankM\.nuget\packages\monogame.content.builder.task\3.8.0.1641\build\MonoGame.Content.Builder.Task.targets	138	
Error	MSB3073	The command "dotnet C:\Users\DankM\.nuget\packages\monogame.content.builder.task\3.8.0.1641\build\\..\tools\netcoreapp3.1\any\mgcb.dll /quiet /@:"C:\Users\DankM\source\repos\Erm\MGUI\MGUI.Core\Content\MGUI.Core.Content.mgcb" /platform:DesktopGL /outputDir:"C:/Users/DankM/source/repos/Erm/MGUI/MGUI.Core/Content/bin/DesktopGL/MGUI.Core.Content" /intermediateDir:"C:/Users/DankM/source/repos/Erm/MGUI/MGUI.Core/Content/obj/DesktopGL/MGUI.Core.Content" /workingDir:"C:/Users/DankM/source/repos/Erm/MGUI/MGUI.Core/Content/"" exited with code -2147450730.	MGUI.Core	C:\Users\DankM\.nuget\packages\monogame.content.builder.task\3.8.0.1641\build\MonoGame.Content.Builder.Task.targets	138

I even tried downgrading the monogame version in the main project to match the mgui version, but still no luck. I also tried fiddling with the .NET core versions, again no luck.

Any help would be great!

Layout bugs due to incorrect component measurements

There are currently 2 bugs related to how MGComponent<TElementType> instances are measured:


1. The component measuring logic is not robust enough to account for cases where multiple components of the same control must share their measurement with the control's Content

Suppose you created a control called MGHeaderFooterPresenter which was structured something like this (but using MGComponent<TElementType> to apply the layout instead of actually using an MGDockPanel):

<DockPanel>
    <ContentPresenter Name="HeaderPresenter" Dock="Top" />
    <ContentPresenter Name="FooterPresenter" Dock="Bottom" />
    <ContentPresenter Name="ContentPresenter" />
</DockPanel>

If the HeaderPresenter and FooterPresenter are both components of the control, the total width of the control would need to be:

int Width = Max(HeaderWidth, FooterWidth, ContentWidth);

MGComponent<TElementType> allows a component to share its width with the control's Content, but does NOT allow it to share width with other components inside that same control. So you end up with an incorrect measurement that's something like this:
int Width = Max(Sum(components that share width with content), ContentWidth);

Currently, the only control that this seems to affect is MGListBox which has 2 components, 1 for the title header, and 1 for the rows of content. MGListBox intentionally does not measure the title's width when measuring itself in order to avoid this bug (which in turn means the MGListBox might not be wide enough in cases where the title would normally be wider than the rows)


2. The component measuring logic incorrectly handles Padding

If the component does not use the owner's Padding for its measurements (MGComponentBase.UsesOwnersPadding = false, such as for the tab headers of an MGTabControl where the Padding of the MGTabControl only affects the content region), then the measurement logic may incorrectly add the Padding to the end result in cases where it shouldn't.

Suppose we're measuring an MGTabControl where the tab headers are docked to the top. If the tab headers are 100px wide, the tab content is 50px wide, and the Padding is 20px, the total width should be:

int Width = Max(100, 50+20);

But the Padding is being automatically applied to the result before any components are measured, so we currently end up with:

int Padding = 20;
int UnpaddedWidth = Max(100, 50);
int TotalWidth = Padding + UnpaddedWidth;

Meaning we get an incorrect result in cases where the component shares width with the content, AND the component is wider than the content, AND the component does not respect the control's Padding.

To demonstrate this issue, create a window with the following layout:

<Window xmlns="clr-namespace:MGUI.Core.UI.XAML;assembly=MGUI.Core"
        SizeToContent="WidthAndHeight" WindowStyle="None">
    <TabControl TabHeaderPosition="Left" Padding="20">
        <TabItem Header="Tab Header">
            <Rectangle Fill="Red" Height="10" Width="10" />
        </TabItem>
    </TabControl>
</Window>

Result:

component bug

The TabControl ends up being 42px too tall. (40px of the Padding's Top+Bottom, and 2px of the BorderThickness Top+Bottom)


To fix these bugs, the following methods should be refactored:

MGElement.MeasureSelf(Size, Thickness)
MGElement.UpdateLayout(Rectangle)
MGComponentBase.Arrange(Thickness)

After fixing these bugs, we should also modify MGListBox<TITemType>'s constructor to set the title component's ConsumesLeftSpace to true since listboxes currently don't account for the title bar's width when measuring their entire width:

Before bugfix:

this.TitleComponent = new(TitleBorder, true, false, false, true, false, false, false,
    (AvailableBounds, ComponentSize) => ApplyAlignment(AvailableBounds, HorizontalAlignment.Stretch, VerticalAlignment.Top, ComponentSize.Size));

After bugfix:

this.TitleComponent = new(TitleBorder, true, false, true, true, false, false, false,
    (AvailableBounds, ComponentSize) => ApplyAlignment(AvailableBounds, HorizontalAlignment.Stretch, VerticalAlignment.Top, ComponentSize.Size));

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.