yglukhov / nimx

GUI library
MIT License
1.08k stars 76 forks source link

Autosized buttons #505

Open dodopod opened 1 year ago

dodopod commented 1 year ago

Is there any way to make a button that sizes itself to its text? This seems like it should be really simple, but I can't seem to figure it out. As far as I can tell, the examples all just manually set the size of the button. The best I've been able to figure out is something like this, which is really inelegant:

- Button:
  width == systemFont().sizeOfString("hello").width + 10
  height == systemFont().sizeOfString("hello").height + 10

  title: "hello"
yglukhov commented 1 year ago

Currently there is no automatic sizing based on text size, though that's definitely something that should be done eventually.