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

TextBox - box is not wide enough for the string value argument #120

Open
xemjeff opened this issue Jun 19, 2022 · 5 comments
Open

TextBox - box is not wide enough for the string value argument #120

xemjeff opened this issue Jun 19, 2022 · 5 comments

Comments

@xemjeff
Copy link

xemjeff commented Jun 19, 2022

When I pass in the default text to the TextBox constructor, I end up with a TextBox that is too short for the text.
I did not see a way to override the width. Is there some setting I am missing, or is nanogui miscalculating the string width based on font?

Looks like I can mess with the TextBox::preferred_size method, but I would like hear if this is known problem before I dig in.

        Window* window = new Window(screen, "Matrix Settings");
        window->set_layout(new BoxLayout(Orientation::Vertical, Alignment::Middle, 6, 6));
        new Label(window, "Rows", "sans");

        TextBox* editRows = new TextBox(window, "32");
        editRows->set_editable(true);

        new Label(window, "Cols", "sans");
        
        TextBox* editCols = new TextBox(window, "64");
        editCols->set_editable(true);;

        TextBox* editDisplayText = new TextBox(window, "Default text to edit");
        editDisplayText->set_editable(true);

WindowCapture

Details:
Windows 10, VS2019, clang-cl
git: master branch, last commit was Feb 5,2022 : c650530

@xemjeff
Copy link
Author

xemjeff commented Jun 19, 2022

I pulled and built on my macbook pro (BigSur) and see the same problem:

image

@xemjeff
Copy link
Author

xemjeff commented Jun 19, 2022

Another issue is that the rendered text will be cutoff when combined with the "units" string.
As seen here. The number is 29.1234

image

@xemjeff
Copy link
Author

xemjeff commented Jun 19, 2022

I made changes to both preferred_size() and draw() in text box to accommodate the undersizing estimate of the text.
The fix shows in the images below. I can post the code change here, or submit a PR - let me know what's best.

image

image

@wjakob
Copy link
Member

wjakob commented Oct 24, 2022

Sorry for taking a long time to respond. Could you post here what fixes you've made?

@xemjeff
Copy link
Author

xemjeff commented Oct 25, 2022

pulling an image snapshot from my fork of nanogui, commit 0eb28e5 : (from June 19th).

image

Comments:
the first section near : @@ -76,7 +76,7
The textbox extends the nvg estimated length by 20% to avoid clipping.

the second section near: @@ -189,7 +189,10
The draw now includes the width of units in determining the size and placement of the text.

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

2 participants