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

Modify the behavior of the Label component when the node size changes. #5908

Merged
merged 2 commits into from Dec 24, 2019

Conversation

caryliu1999
Copy link
Contributor

@holycanvas
Copy link
Contributor

这样改会导致 widget 变化的时候 Label 一直不变么?

@caryliu1999
Copy link
Contributor Author

这样改会导致 widget 变化的时候 Label 一直不变么?

对于NONE模式的文本来说,这里只是优先以widget设置的node size为准,widget变化本身是不影响文本内容的,只是修改了节点的size。

@jareguo
Copy link
Contributor

jareguo commented Dec 17, 2019

这样设置了 none 之后,如果改了节点尺寸,label 不就不会把尺寸自动重置回文本大小了?

@caryliu1999
Copy link
Contributor Author

caryliu1999 commented Dec 18, 2019

None 模式是按照文本内容设置节点size,对于没有widget限制大小的节点来说,还是会正常设置节点size。只不过当widget有限制大小,Label更新完文本设置了新的size之后还是会被widget组件重置为之前的固定size,但是size变化就不再触发Label重新更新文本了。否则就是目前的问题,Label设置为新的size,widget再更新会旧的,反复执行这两个行为。

@jareguo
Copy link
Contributor

jareguo commented Dec 19, 2019

但是这样可能还有一个问题,就是设置成 NONE 之后,如果尺寸能被更改(比如编辑器中),那么开发者对文字的排版可能会容易出错。不知道有没有更好的解决办法。

@caryliu1999
Copy link
Contributor Author

但是这样可能还有一个问题,就是设置成 NONE 之后,如果尺寸能被更改(比如编辑器中),那么开发者对文字的排版可能会容易出错。不知道有没有更好的解决办法。

应该还好,对于 NONE 模式来说,修改节点尺寸是没用的,还是会根据文本内容自动修改为文本内容的尺寸。其他方式,就是更新完文本的时候,判断有widget存在立即做一次align,或者就是两个组件之间的耦合判断,有widget并且左右对齐的情况才不响应size改变。

@caryliu1999
Copy link
Contributor Author

但是这样可能还有一个问题,就是设置成 NONE 之后,如果尺寸能被更改(比如编辑器中),那么开发者对文字的排版可能会容易出错。不知道有没有更好的解决办法。

应该还好,对于 NONE 模式来说,修改节点尺寸是没用的,还是会根据文本内容自动修改为文本内容的尺寸。其他方式,就是更新完文本的时候,判断有widget存在立即做一次align,或者就是两个组件之间的耦合判断,有widget并且左右对齐的情况才不响应size改变。

增加了编辑器的判断,在编辑器下就不需要做这个处理了。

@holycanvas holycanvas merged commit 0ed9d7e into cocos:v2.3.0 Dec 24, 2019
@caryliu1999 caryliu1999 deleted the v2.3.0-aligment branch June 22, 2021 02:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants