-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Generic UI Framework - basic implementation #56126
Conversation
With the new If I understand your goal correctly, you could implement |
@andrei8l Currently, @mqrause My concern though is that even if someone creates generic UI subcomponents, other contributors are often disinclined to use them simply because they are unaware of the new subcomponent; and unless the whole codebase is migrated to the new subcomponents, they tend to copy and use the legacy code simply because more UIs use the legacy code than the new code. |
You can just have one But if we're breaking down the UI to subcomponents that are just individual lines of text, I'm not sure the effort is worthwhile.
I see that it defines an |
No, the way you would use it currently is to have one top level element, most likely an Ultimately that should move inside the framework, too, but that's a thing for future improvements, not for a first pass.
Yes, that is generally an issue I don't have a good solution for. I just copied what
That is not the point of this. You can create any kind of subcomponent you want. Individual lines of text was just the first thing I needed. |
It's used in |
This is definitely a problem we have and have had in this code base with things like item_location and generic_factory. The solution, as it were so far, is to just update as much legacy code as you can stomach and to make documentation easily understandable and available; and to keep an eye, at least for a little while, on new prs that implement up stuff so that they use the new system. I certainly would not use this concern as a reason not to implement something new, but as a word of caution that unfortunately the work isn't done just by writing this new framework. |
I don't think I'm getting my points across very well so let me try some code instead: andrei8l@afe221a this is how I think this andrei8l@5d34b54 this is a wrapper over andrei8l@648124c and this is a (very!) barebones and dirty re-implementation of Let me know what you think. |
Yes, that is pretty much what I meant with "Ultimately that should move inside the framework". But keep in mind what Qrox said: "The ui_adaptor system can of course be extended to UI subcomponents but that's a lot of further work, and the ui_adaptor system itself may need to be upgraded (for example, currently you can't adjust the z-order of the ui_adaptors, which are redrawn in the order they are created)"
I'll check it out over the weekend. I already gave up on doing only as much as I need for the other PR btw. This needs to get all of the basic structure implemented at least. So a window with a layout with elements and all the drawing logic being internal to it. The point is that developers can just stitch together the basic elements without having to worry about any of the low level stuff. And there's no point in merging it before that's achieved. |
@andrei8l What you did with the wrapper over |
Expanded it to roughly how I think it should be structured. Still heavily WIP, so any details can and will change. But the baseline is there, and as usual #55503 has a (currently very basic) demonstration of how to use it. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. Please do not 'bump' or comment on this issue unless you are actively working on it. Stale issues, and stale issues that are closed are still considered. |
I came from a ERP framework that uses a declarative UI. You describe what form contain and how it's elements should behave - and renderer does the rest based on this information. It hides lots of low level calculation and drawing from programmer. Every UI window is
Generally Im thinking about this kind of UI: set of abstract elements and ability to create forms using them. Every window extends base class and defines it's default content in the constructor.
Since it's declarative - it can be JSONized and changed on the fly. And since it is abstract - it can use any "driver" rendered: catacurses, IMGui, SDL, etc |
Yes, that is more or less what I'm trying to do here. |
Ive found some interesting libraries for ncurses we can draw inspiration from or use: in CDDA |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. Please do not 'bump' or comment on this issue unless you are actively working on it. Stale issues, and stale issues that are closed are still considered. |
Summary
Infrastructure "Generic UI Framework - basic implementation"
Purpose of change
Allow easier UI development by providing some default classes.
Mostly done to further #55503, so it only contains things I need for that.
Also see #56026 for a previous version and discussion.
Describe the solution
ui_element
absolute_layout
ui_elements
at the given locationstext_block
list_view
ui_element
todos:
list_view
gets the category of its elements (probably by turning the template function into a class and handling it there)Describe alternatives you've considered
I'm not fully convinced by the
rectangle
s for locations. I might instead go back to a point and two ints for the start and width/height, but that means more parameter juggling. Usingrectangle
is kind of unintuitive, though, because it's going by terminal cells and not by pixels. So a rectangle with a height of zero has one line.Testing
It's used in #55503
See these 200 lines: https://github.com/CleverRaven/Cataclysm-DDA/pull/55503/files#diff-323b6d7ca56f6c7fb3d8f3fd71b66870cd60b31f6f9aa39e06e6583304ae69b5R290-R490
Additional context
This is slighly beyond my actual C++ abilities, so it might contain stupid design choices. And the constant scope creep is driving me insane.