NIM_Duilib_Framework icon indicating copy to clipboard operation
NIM_Duilib_Framework copied to clipboard

建议把Box、Control 的width="auto" height="auto" 变成默认属性

Open 01haike opened this issue 5 years ago • 5 comments

建议把Box、Control的width="auto" height="auto" 变成默认属性。

感觉设置成默认的能更合理一些,当需要设置具体值的时候,覆盖这个属性就好了。 这样外层的控件大小是由内部控件计算而来。如果以后改内部控件大小,外边的控件大小自动计算出来了。很方便。

还有当需要在运行程序时动态改变窗体内部控件显示或隐藏的时候,不需要每次都设置一下窗口的大小。

01haike avatar Jun 27 '19 01:06 01haike

很好的建议,因为要考虑旧程序的兼容问题,这个可能要多方面测试以后才能决定是否做这样的修改。

nmgwddj avatar Jun 27 '19 01:06 nmgwddj

这个建议不是太好 感觉stretch用的最多 并不是auto @01haike @nmgwddj

smallevilbeast avatar Jul 25 '19 09:07 smallevilbeast

这个建议不是太好 感觉stretch用的最多 并不是auto @01haike @nmgwddj

感觉 auto 应该用的很多啊,像这种:

<VBox height="auto">
 <Button height="30"/>
 <Button height="30"/>
 <Button height="30"/>
 <Button height="30"/>
</VBox>

roc1 avatar Jul 25 '19 09:07 roc1

这个建议不是太好 感觉stretch用的最多 并不是auto @01haike @nmgwddj

感觉 auto 应该用的很多啊,像这种:

<VBox height="auto">
 <Button height="30"/>
 <Button height="30"/>
 <Button height="30"/>
 <Button height="30"/>
</VBox>

像这种 width还是需要是stretch, 你评估下是打stretch方便还是auto方便 :)

smallevilbeast avatar Jul 25 '19 11:07 smallevilbeast

上面代码如果不用 auto 的话,需要这样写:

<VBox height="120">
 <Button height="30"/>
 <Button height="30"/>
 <Button height="30"/>
 <Button height="30"/>
</VBox>

以后要加一个控件并且修改 button 的大小,还需要用计算器算一下 VBox 的高度。

<VBox height="215">
 <Button height="50"/>
 <Button height="50"/>
 <Button height="50"/>
 <Button height="50"/>
 <Label height="15"/>
</VBox>

如果是程序里需要动态显示和隐藏控件,那么还得程序里记住 VBox 的高度,也要重新设置一下。 如果子控件有变动了,还得回来改代码,重新编译。2333

所以还是得考虑父控件由子控件撑起来。

我看了下,我代码里的 auto 数量是 stretch 的好几倍。

roc1 avatar Jul 25 '19 12:07 roc1