AdamsLair / duality

a 2D Game Development Framework
https://adamslair.github.io/duality
MIT License
1.41k stars 287 forks source link

Evaluate Editor UI Frameworks #274

Open ilexp opened 8 years ago

ilexp commented 8 years ago

While the current editor is in a very good state and WinForms is fine, it does have the major drawback of being Windows only - and Mono can't really fix this in a good way.

This is a long term investigation. Neither do I plan to start implementing something anytime soon, nor do I currently have the resources to do so for a change on this scale - but it can't hurt to do some research.

Required Traits


There is nothing wrong with WinForms or the current editor, and while there sure is room for improvement, a UI framework change would be a considerable effort that should not be decided easily. This issue is not about starting something, but about looking around what options there are for the long term future.

ilexp commented 8 years ago

The Perspex framework looks promising, but it is unclear whether some of the requirements are met. I have created an issue to talk about their future plans.

mlaskus commented 8 years ago

Maybe Qt?

It's cross platform, can use OpenGL, can do High-DPI and has a docking widget.

I'm don't think you can deploy the same binaries to multiple platforms but other desirable traits should be possible.

A big drawback would be having to rely on some 3rd party project for C# bindings.

Xinayder commented 8 years ago

There's Eto.Forms https://github.com/picoe/Eto However, I'm not sure if you can use the docking controls with it. Perhaps you could fork the project and adapt it to Eto?

ilexp commented 8 years ago

Maybe Qt?

I really like Qt, but this feels like a bit of an overkill - it's essentially a whole framework, complete with everything down to file system access, strings, collections and all sorts of things. I don't really want to introduce a "second .Net framework" here.

Also, I'd like to avoid unmanaged code. (Added a new trait above, forgot that one :) )

There's Eto.Forms https://github.com/picoe/Eto

This one looks neat. Might be something to keep an eye on.

ilexp commented 8 years ago

Took a look at Eto and it seems like the overall concept is to wrap native UI in an abstract way. Favoring Perspex right now for its custom drawing / custom control logic approach, as this has a higher potential to mesh well with the whole "same UI for ingame and editor" idea.

One drawback of Perspex at this point seems to be a focus on very high-level graphics, requiring each backend to implement a full vector rendering stack, which would be a bit too much for Duality purposes. It also seems a lot more heavy-weight than what Duality would really need. Then again, it seems to provide a lot of great functionality.

Research continues. This isn't decided anytime soon anyway.

ilexp commented 8 years ago

Apparently, this has come up before. Linking to the old issue for historic reasons: #159

ChristianGreiner commented 8 years ago

Maybe Xwt? https://github.com/mono/xwt

sappho192 commented 8 years ago

Mono launched SkiaSharp, cross platform 2D Graphics API based on Google's Skia library. You gotta see this. https://github.com/mono/SkiaSharp

Xinayder commented 8 years ago

The framework that @sappho192 suggested looks great (I had a quick, quick look). Maybe it could be the first step towards natively supporting android?

sappho192 commented 8 years ago

@RockyTV Maybe yes, but maybe not. SkiaSharp just provides graphics API so we need to construct UI framework.

ilexp commented 8 years ago

SkiaSharp just provides graphics API so we need to construct UI framework.

I'm not really looking for a graphics-only framework though - if we were to create a custom UI, we might as well do it on top of Duality itself. Which I personally don't plan to do for practical reasons. Even re-implementing the editor only is a huge piece of work, adding implementing a custom UI framework before certainly doesn't make it easier!

Maybe it could be the first step towards natively supporting android?

Maybe - but providing additional core backends is a different issue than this one here, and should be discussed elsewhere :) Android is not on my radar right now to be honest. Desktop first!

xgalaxy commented 8 years ago

Hey. Just a thought to maybe mull over. You could go a similar route that Unreal Engine decided to go and just render your UI using the engine itself and develop your own widgets, controls, etc. This would be a lot more work but you would be able to hit all of your required and desirable traits.

The way Unreal Engine did it is by have several layers of UI functionality. There is the Slate api which is your low level UI system and its at this level they implement all of the Unreal Editor UI. Then there is the UMG api which is built on top of the Slate api that includes the UI designer for game ui layout and the game widgets and skinning.

ilexp commented 8 years ago

Hey. Just a thought to maybe mull over. You could go a similar route that Unreal Engine decided to go and just render your UI using the engine itself and develop your own widgets, controls, etc. This would be a lot more work but you would be able to hit all of your required and desirable traits.

Yep, this is what I would consider the ideal solution. I don't see this happening in the foreseeable future though, simply because it would be so much work.

ilexp commented 8 years ago

Spinning the thought a bit more, what would be required for Duality to build a UI system that is sophisticated enough to serve as a basis for the editor UI?

...and then there's also the whole "porting the editor" set of tasks.

Summarizing this, a custom UI would be a really huge workload. Virtually the only way I would be able to pull this off would be if it was my actual job five days a week and even then things would take a noticeable amount of time as long as I don't have a small team helping me along the way as well.

And yes, it's already Open Source and contributors can help, but that only does so much. For a system of this size to succeed, there needs to be a significant amount of technical leadership, which also consumes a lot of time itself, and it's complicated by the fact that Open Source contributors tend to "come and go" - so a lot of the transferred and taught knowledge doesn't even stay in the project, but needs to be taught again when the next contributors arrive.

So.. yeah. This is probably the long version of my above "I don't see this happening in the foreseeable future".

@xgalaxy Please don't read this post as me trying to prove your idea impractical, but as an acknowledgement of its appeal to me and the project, yet I want to put out there what I'm up against if I was to approach something like this.

RabbitB commented 8 years ago

I don't want to recommend any particular library or offering, but has there been any thought into using an HTML5 renderer? Most of the offerings I can think of are true open source licensed (MIT or BSD), as most are also built upon the Chromium renderer.

It sounds bizarre, but when you really think about it, everything you need comes together. Most of the basic controls are natively supported by the rendering engine; everything is customizable; completely platform agnostic; easy to write in with lots of 3rd party WYSIWYG editors. HTML5 and CSS3 are completely dynamic too, so having a JUICY (do people still use that term?) interface that animates and reacts is fully supported without additional work.

I've personally never used an HTML5 renderer for this purpose, but from what I understand, implementing it for a real-time program breaks down to a handful of fundamental steps all of them share:

For handling a traditional orthographic overlay UI (such as the editor), you create a full-screen quad and just render the texture directly to it, with the source page being 1:1 with the rendered texture. Nothing stopping you however from treating the source page as a sprite-sheet, and displaying it on dynamic elements for in-game interactive UI. At least Chromium based renderers are entirely capable of rendering with transparency, so there's no additional work involved.

ilexp commented 8 years ago

I don't want to recommend any particular library or offering, but has there been any thought into using an HTML5 renderer?

I actually have! Nice writeup of this approach by the way, thanks for adding it. :+1:

While I like the idea of separating structure (HTML), style (CSS) and logic (JS) completely, JavaScript is a terrible language that I don't want to drag into the Duality ecosystem. A also don't want any kind of secondary runtime / VM for this, so there would be the need for engineering a solution where the code part is still handled in C#, or differently put: I'd really emphasize the HTML Renderer part of this, as opposed to considering hosting an actual website in there.

This would of course rule out fetching anything from the web, as well as all the JS frameworks out there or even anything that contains a single line of JavaScript, which would probably rule out most pre-made UI components that are available on the web. It would mean to only use a very limited subset of web technology, basically only reducing it to the HTML structure / CSS style part and maybe even removing some more functionality that doesn't make sense outside the web context.

If you're following along until here, then you might notice some conceptual similarity of this very reduced HTML / CSS / C# logic combo with XAML. Which would put Perspex (now renamed to Avalonia) back into the spotlight.

xgalaxy commented 6 years ago

Hate to resurrect this old ticket from the dead but I thought you'd find this library interesting:

Qml.Net - Qt/Qml integration/support for .NET https://github.com/pauldotknopf/Qml.Net

michael-hawker commented 5 years ago

What about Uno?

ilexp commented 4 years ago

It was just announced that there will be a cross-platform UI solution from Microsoft starting with .NET 6, could be worth a look as well:

Barsonax commented 4 years ago

Iam watching the The Journey to One .NET. session in microsoft build which should mention the new cross platform UI tonight. Hoping to hear more details.