Godot-proposals: New GUI Component - Table

Created on 23 Jun 2020  路  6Comments  路  Source: godotengine/godot-proposals

I want to create table, like database gui, like JTable in Java Swing.
model

Describe the feature / enhancement and how it helps to overcome the problem or limitation:
I want to pull my request: https://github.com/godotengine/godot/pull/36053
(Pull request # #36053)
image

And the current file dialog uses Tree. Which is a bad choice. ItemList is preferred. Even so, a Table with dedicated Title (like in the picture) and user can click on title and sort the table.
Moreover, current solutions don't allow user to select a row and that row will be selected and highlighted. I modified the code, turns out Tree is designed that way. It only has 2 modes: Single (single cell select) and Multi (multi cell select). If I want to select a row, I need to set multi mode and select all the cells in that row. This is bad.
In the pull request I switched multi mode with Row mode. This however throws error (not crashing, just log. Other than that the code works perfectly with correct selection of files)

Describe how your proposal will work, with code, pseudocode, mockups, and/or diagrams:
I am working on it on 3.2 on commit a662b853dd5de7d47a8c5ebee3ae35cf66490d3f (latest as of writing this post)
Though I'm not working on it full time, as I got work and university, but as side project, torwards big goal

If this enhancement will not be used often, can it be worked around with a few lines of script?:
No, need dedicated GUI component

Is there a reason why this should be core and not an add-on in the asset library?:
Yes, GUI is core feature

Another feature I want to add, after Table is ready:

  • Sort the table (with function call according to one column)
  • Sort the table (with user clicking on title) (Defenition of title: in the picture above the title is the first row, describing the column's names)
gui

Most helpful comment

A generic table node would be a good addition imo. A simple can be created fairly easily using a combination of a few different nodes, but packaging everything and adding advanced functionality like sorting and filtering eould be useful. Might i suggest beginning with a gdscript addon for prototyping?

All 6 comments

Moreover, current solutions don't allow user to select a row and that row will be selected and highlighted. I modified the code, turns out Tree is designed that way. It only has 2 modes: Single (single cell select) and Multi (multi cell select). If I want to select a row, I need to set multi mode and select all the cells in that row. This is bad.

Am I missing something? There is the row mode in Tree:
https://docs.godotengine.org/en/stable/classes/class_tree.html#enum-tree-selectmode

A generic table node would be a good addition imo. A simple can be created fairly easily using a combination of a few different nodes, but packaging everything and adding advanced functionality like sorting and filtering eould be useful. Might i suggest beginning with a gdscript addon for prototyping?

See also #97, #13.

Can you describe more design for how this is different from a regular tree. I might look into this.

I don't understand why you can't use GridContainer for this. Here is a screenshot from Unknown Horizons:

Screenshot from 2020-07-02 16-37-58

Is there a reason why this should be core and not an add-on in the asset library?:
Yes, GUI is core feature

This is not a justification. GUI itself is a core feature, but this particular GUI element is not. Godot does not include every possible kind of UI element that anyone could ever want, since you can build GUI elements yourself using existing GUI elements (for example, in the above image, where a table is built using GridContainer).

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

SpyrexDE picture SpyrexDE  路  3Comments

davthedev picture davthedev  路  3Comments

lupoDharkael picture lupoDharkael  路  3Comments

Torguen picture Torguen  路  3Comments

PLyczkowski picture PLyczkowski  路  3Comments