-
-
Notifications
You must be signed in to change notification settings - Fork 21.1k
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 support for multiline cells to Tree
#61714
Conversation
Should be the opposite. |
2f21498
to
8c8f099
Compare
@KoBeWi this is up to you to decide what to do |
8c8f099
to
53f1d02
Compare
Fixed.
@KoBeWi If you are going to rewrite Tree in the near future, then this PR can probably be closed. Just don't forget about multiline cells, please. |
53f1d02
to
174727e
Compare
174727e
to
9de10d0
Compare
Needs rebase. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes seems fine. It's probably should additionally expose TextServer::AutowrapMode
for the cell to have more control.
9de10d0
to
c177db8
Compare
@@ -1722,7 +1739,7 @@ void Tree::draw_item_rect(TreeItem::Cell &p_cell, const Rect2i &p_rect, const Co | |||
|
|||
if (rtl) { | |||
Point2 draw_pos = rect.position; | |||
draw_pos.y += Math::floor((rect.size.y - p_cell.text_buf->get_size().y) / 2.0); | |||
draw_pos.y += Math::floor(p_draw_ofs.y) - _get_title_button_height(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this really use title height? It's a method for drawing cells (I think) and titles can be disabled, making their height 0.
EDIT:
Seems to work correctly though, so idk.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The title height is used for the initial drawing offset. If the title is hidden, then there is no offset. Perhaps this value is already taken into account in some variable, but I could not fix the offset error until I used this function. The Tree
class is very large and needs to be refactored.
c177db8
to
9b69fae
Compare
The height of the editor is equal to the height of the line. If all cells are empty,
In this case, the editor can overflow through the line without stretching it in height. I don't think this is what we need. |
Well, if the cell is editable, it's not very useful when it's tiny. Maaybe having cell edit without other cells isn't very common, but for multiline edits the height should definitely match the edited text.
You could try using |
The problem is that until the change is applied, the text is only in the TextEdit, not in the |
Then not sure what to do about the cell. IMO it's not fine if you have scrollable TextEdit, but then the text properly expands when you accept it. You could maybe change the cell text, but revert if it the user cancels editing text. |
9b69fae
to
a0ec886
Compare
I made the minimum height the same size as the height of one empty line:
I don't think this is a good solution since editing is a lengthy process and user code can get errors if it reads the text of the cells (the value can be new before the signal, and roll back if the user undoes the changes). Ideally, |
In some applications this is Shift+Enter, in others Ctrl+Enter (for example, LibreOffice Calc). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't say if the code is 100% correct, but looks ok and it works.
a0ec886
to
3be112d
Compare
3be112d
to
d4d3b7b
Compare
Needs a rebase, then I think it should be mergeable? |
d4d3b7b
to
005937b
Compare
Rebased. |
Thanks! |
I believe this breaks set_column_clip_content, at least when using text. I'm using this method in order to display ellipsis when text overflows the column width. Is there a way to get around this that I'm not seeing? |
See #76532 (comment). I added this to my TODO list and will try to fix it. |
Confirming a change to a multiline cell is done with Ctrl+Enter instead of Enter.
My tree CSV editor
Test project: gd4-tree-multiline-items.zip
Closes godotengine/godot-proposals#3632.