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

Add a TableControl node for complex column-row data sets in UIs #97

Open
Tracked by #7 ...
erodozer opened this issue Sep 22, 2019 · 7 comments
Open
Tracked by #7 ...

Add a TableControl node for complex column-row data sets in UIs #97

erodozer opened this issue Sep 22, 2019 · 7 comments

Comments

@erodozer
Copy link

Describe the project you are working on:
I'm working on a very UI heavy RPG with plenty of menus that present data in a tabular structure.

Describe how this feature / enhancement will help your project:
I find myself in tons of situations where I'm building up tables but have no way of selecting them cleanly without doing something hacky like having a backing ItemList control. Something more powerful than ItemList is necessary, to allow for the ability to select not just a single item, but a whole row or whole column of items and returning the associated group of values as one dictionary. A tabular UI is valuable for creating things like inventory lists as seen in RPGs where item names and counts are displayed on the same row but aligned to different sides of the row. Keeping an association of all data within the row and represented as a single selectable element is key for this.

Describe implementation detail for your proposal (in code), if possible:
Using a single controller, being able to define the following values

  • Column Names, used for field lookup in the item records, as well as translated for column header labels
  • Visible Header toggle, since sometimes you don't need to have column names visible in the UI
  • Column Content Alignment, allowing each column's contents to be aligned differently. Might want to have the ability to have row alignment different from header alignment
  • Minimum Column widths and expansion
  • Row height
  • Toggle allow Field Selection
  • Toggle allow Row Selection
  • Toggle allow Column Selection
  • Themeable selection, hover, normal, and disabled states for fields
  • Themeable normal, hover, focus states for the table itself
  • Standard font theming

If this enhancement will not be used often, can it be worked around with a few lines of script?:
This enhancement has the potential to be used often. It's a complex control element as well, making it difficult to work out with existing control nodes and hacking it without making compromises in feature capability.

Is there a reason why this should be core and not an add-on in the asset library?:
It's a common use-case control for more UI heavy games, and would be a powerful addition to the editor itself in certain UIs, especially for something like #13

@KoBeWi
Copy link
Member

KoBeWi commented Sep 22, 2019

This could be probably achieved with a GridContainer, although it would require some work. Potential material for a plugin (unless many people want this in core ofc).

@erodozer
Copy link
Author

The biggest change for this over a GridContainer is the fact that it's an input focused controller instead of just layout. Something derived from GridContainer would be useful, though, especially if what's desired is also for content in each cell to be anything instead of just labels or editable text fields.

@Xrayez
Copy link
Contributor

Xrayez commented Feb 22, 2021

Note that there's also #1107 which talks about the same thing by now, but this proposal is older.

@Calinou Calinou changed the title TableControl for complex column-row data sets in UIs Add a TableControl node for complex column-row data sets in UIs Feb 22, 2021
@Xrayez
Copy link
Contributor

Xrayez commented May 24, 2021

#1107 (comment):

Tree is responsible for all Table views within Godot. For more complex custom systems an implementation based on GridContainer should suffice.

I think if we do implement this, it may be easier to just extend Tree class as a Table node and implement necessary logic to represent table view (and modify Tree implementation if some table-specific features cannot be done), so in theory you could reuse Tree theme elements.

A new class can have a method such as create_from_data() which could accept Variant and interpret it according to type. It may accept two-dimensional arrays, or dictionaries representing column names as keys and row data (as far as I know, dictionaries in Godot remain insertion order). This should facilitate the model/view architecture.

As a user, it's not completely obvious why and how the Tree class could be used to create tables, it's not even documented (which could be at least mentioned in the documentation).

Of course, it's always possible to come up with a completely new implementation without bloating Tree class with features mandated from use cases needed to create a general-purpose Table node.

It's indeed possible to create new GUI nodes via plugin/modules (goostengine/goost#80), but I haven't found a way to create new custom theme items for new classes. At most, I've previously managed to add overrides for constants/colors etc. But when it comes to defining new styles (like suggested in the proposal), it sounds difficult or impossible to do, because looks like you'd have to modify the default Theme:

image

Do we have a proposal for this? Looks like there's no way to add new node types to themes (even on the level of C++ modules development).

@KoBeWi
Copy link
Member

KoBeWi commented May 24, 2021

When you set a property of a theme, you can specify any type, even if it doesn't exist. Then you can use the newly added theme_custom_type property: godotengine/godot#47544

@YuriSizov
Copy link
Contributor

YuriSizov commented May 24, 2021

That linked PR also fixed the docs mentioned, because that underlined statement is false.

Note that theme_custom_type is more useful when you want to override properties used internally by the engine. If you want to have a completely custom property for a custom node type, you'd still need to assign it via code, which is already doable even without this PR. Though on a plus side with theme_custom_type you can just fetch get_icon("name") and the custom type should be checked automatically before anything else.

@Anutrix
Copy link

Anutrix commented May 6, 2024

I came across this ticket while trying to achieve much simpler use-case where I need GridContainer(3x3) with children stretch ratio for height(and/or width) in 1:2:1.
Very sad that Grid doesn't support stretch ratios.

Since it is not supported, we should make stretch-ratio set to 1 and read-only in inspector for the Control Nodes added under GridContainer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants