dlangui icon indicating copy to clipboard operation
dlangui copied to clipboard

Wrongly calculated widget sizes

Open FreeSlave opened this issue 7 years ago • 13 comments

screenshot from 2017-05-25 03-26-18 Here's screenshot of example1 starting on Linux LXDE. As you can see buttons and some other widgets are not big enough to hold their contents.

FreeSlave avatar May 25 '17 00:05 FreeSlave

Try increasing window height.

buggins avatar May 25 '17 08:05 buggins

It becomes ok if I increase window height. But I don't remember such issue on Windows. So something different in Linux version.

FreeSlave avatar May 25 '17 11:05 FreeSlave

Font height is handled a bit different in Win32 font engine and FreeType. Probably, FreeType font is bigger for the same requested height

buggins avatar May 30 '17 07:05 buggins

I think it makes sense to fix either Win32 or FreeType engine to produce exactly the same font size and line height for requested font size.

buggins avatar Jun 07 '17 06:06 buggins

Maybe better is just change window height and/or width when mainWidget need more area? The same font family name on different platforms can have different visual representation.

and3md avatar Jun 08 '17 17:06 and3md

It's hard to measure widget if some of its parts are stretched (FILL_PARENT)

buggins avatar Jun 10 '17 06:06 buggins

Now when window is too small widgets are shrink so I think we know how much more space is needed. https://github.com/buggins/dlangui/blob/master/src/dlangui/widgets/layouts.d#L177

I think there should be three options (flag in window):

  • shrink widgets (now implemented in layouts)
  • resize window
  • add scrollbars to window (on some platforms we can't just resize window, or when window will be bigger than screen)

Maybe we should add special layout to window that will be the invisible window root widget. That layout will manage mainWidget, shrink it or change Window size, eventually add scrollbars to window. That is only idea. Need more investigation what is possible, what will be break. What do you think about it?

and3md avatar Jun 10 '17 08:06 and3md

I made some more investigation and I probably know how to implement behavior like in above comment. Do you working on this issue? Please let me know. I can make some prototype but I don't want overlap your work.

and3md avatar Jun 19 '17 19:06 and3md

I'm not working on this issue now.

buggins avatar Jun 21 '17 06:06 buggins

OK, I start working on this issue.

and3md avatar Jun 21 '17 16:06 and3md

Solution in #379.

and3md avatar Jun 25 '17 16:06 and3md

There is one issue in current implementation. When widget width depends on height - width can be incorrect. For example WidgetList width is too small when scrollbar appears. Thinking how to fix that without API change.

and3md avatar Sep 01 '17 15:09 and3md

I made big refactoring on my devel branch. Not ready for merge yet, but maybe someone want to check/test ;) Some controls need more work and there will be API break:

  • separate measurement of the minimum size,
  • flag to set control height depend on width,
  • do not stretch widgets' height in horizontal layout
  • do not stretch widgets' width in vertical layout
  • possibility to word wrap in checkbox
  • possibility to word wrap in radiobutton
  • layoutWeight determines the ratio of free space that the control will take
  • measuredContent -> adjustMeasuredSize
  • alignments in linearlayout
  • word wrap in edits (but need more work)
  • currently it works only in SDL

It is currently used in my Agile Commander from version 1.1.0 (because old algorithm has a lot of problems).

and3md avatar Apr 12 '18 16:04 and3md