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

ScrollingArea text wrapping #401

Open
mischnic opened this issue Jul 18, 2018 · 4 comments
Open

ScrollingArea text wrapping #401

mischnic opened this issue Jul 18, 2018 · 4 comments
Milestone

Comments

@mischnic
Copy link
Contributor

mischnic commented Jul 18, 2018

On macOS, the text isn't getting wrapped at all (only newlines are handled):

bildschirmfoto 2018-07-18 um 12 43 55

GTK:
bildschirmfoto 2018-07-18 um 13 00 12

Windows:
scrolling ong

Code:

diff --git a/examples/drawtext/main.c b/examples/drawtext/main.c
index d94d2572..544d44e9 100644
--- a/examples/drawtext/main.c
+++ b/examples/drawtext/main.c
@@ -208,7 +208,7 @@ int main(void)
        uiComboboxOnSelected(alignment, onComboboxSelected, NULL);
        uiFormAppend(form, "Alignment", uiControl(alignment), 0);

-       area = uiNewArea(&handler);
+       area = uiNewScrollingArea(&handler, 500, 1000);
        uiBoxAppend(hbox, uiControl(area), 1);

        uiControlShow(uiControl(mainwin));
@mischnic
Copy link
Contributor Author

mischnic commented Jul 18, 2018

My bad, params.Width = p->AreaWidth simply doesn't work for a scrolling area.

@andlabs andlabs reopened this Jul 18, 2018
@andlabs
Copy link
Owner

andlabs commented Jul 18, 2018

I'm not fully satisfied with how I did scrolling areas in the current system anyway. Will keep open until that's resolved.

@mischnic
Copy link
Contributor Author

mischnic commented Jul 19, 2018

Currently trying to calculate the scrolling canvas size for a text programatically:

  1. render a normal area to determine its width
  2. use that width as uiDrawTextLayoutParams.width to get the text's height using uiDrawTextLayoutExtents
  3. replace the area with a scrolling area with the width and height from 2.

Is there a better way to do this (without the first area)? Why is uiAreaDrawParams.AreaWidth & AreaHeight 0 for scrolling areas? They have a ”viewport size" (= AreaWidth) and a canvas size (= the one in the uiNewScrollingArea constructor, the only one affected by uiAreaSetSize)

@RangerMauve
Copy link

What's the correct approach for handling text-wrapping?

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

No branches or pull requests

3 participants