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

Fix for #354 - wrongly calculated widget sizes. #379

Merged
merged 10 commits into from
Jun 26, 2017

Conversation

and3md
Copy link
Collaborator

@and3md and3md commented Jun 25, 2017

This PR improve DlangUI widgets measure and window content support. Now it's possible to do something like this:

dlangui_scrollwindow

Widget measure

This can't be done without change some widget measure behavior. Now widgets are increasing when has FILL_PARENT flags - not shrinking to window size. We must measure widget size not content size for some of widgets like Grid, TreeView, EditBox, EditLine. Most of this widgets need optimizations - content size can be measured only when content is changed. I don't do that in this PR.

ScrollWidgetBase and inherited

I added minimumVisibleContentSize() which is used to get minimal sensible size.

EditLine

I deliberated long time how to do it. And I think the best way is to get width and height of some standard text. I used "aaaaa" but there is _textToSetWidgetSize and in the future we can add property to set it to something else. Using string gives certainty that changing font will make widget enough big.

That fixes not only getting minimal size but also widget don't grow when you write letters in some cases (for example when there are 2 widgets in horizontal layout with FILL_PARENT flag in one line).

EditBox

Analogous to EditLine but it uses "aaaaa/naaaaa". There should be minimum 2 lines of text.

ListWidget

This is a little tricky because it is used for menu. First measure returns 100,100 second measure returns real size (only because of menu).

WindowOrContentResizeMode enum

I not found better name, maybe someone gives something shorter.
There are three algorithms:

  • shrinkWidgets - something like in previous version of DlangUI
  • resizeWindow - window is resized to fit content (not working in X11 now because Window.windowResize() is not implemented in X11
  • scrollWindow - now default, if widgets are bigger than window adds scrollbars to window

Warnings

  1. I tested this solution on Linux and Windows (X11, SDL, win32 platforms).
  2. Tested with example1, DlangIDE and my own project
  3. Some windows may need some tweaks because now widgets are increasing when has FILL_PARENT flags not shrinking to window size. Usually some layouts needs set FILL_PARENT flag.
  4. Need more tests.

Extra fixes

Fixed theme change on X11.

@buggins
Copy link
Owner

buggins commented Jun 26, 2017

let me review it...

@buggins buggins merged commit 418c4a6 into buggins:master Jun 26, 2017
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

2 participants