adamdruppe / arsd

This is a collection of modules that I've released over the years. Most of them stand alone, or have just one or two dependencies in here, so you don't have to download this whole repo.
http://arsd-official.dpldocs.info/arsd.html
530 stars 125 forks source link

minigui: ScrollableContainerWidget scrollbars showing incorrect height #309

Closed andre2007 closed 2 years ago

andre2007 commented 2 years ago

I am adding dynamically buttons to a ScrollableContainerWidget. Sometimes the vertical scrollbar is correct, sometimes it looks like the user can scroll vertically although there is nothing to scroll.

Here is an example:

/+ dub.sdl:
    name "application"
    dependency "arsd-official:minigui" version="10.3.10"
+/

import arsd.minigui;

void main()
{      
    new MyWindow().loop();
}

class MyWindow: MainWindow
{
    this()
    {
        super("sample", 161*4, 372);

        auto hLayout = new HorizontalLayout(this);
        auto vLayoutButtons = new VerticalLayout(hLayout);
        auto scrollContainer = new ScrollableContainerWidget(hLayout);
        auto vLayoutTopics = new VerticalLayout(scrollContainer);
        auto vLayoutLessons = new VerticalLayout(scrollContainer);
        auto vLayoutAssignments = new VerticalLayout(scrollContainer);
        vLayoutLessons.hide();
        vLayoutAssignments.hide();

        auto btnHome = new Button("Home", vLayoutButtons);
        auto btnCourses = new Button("Courses", vLayoutButtons);
        foreach(topic; ["Click here"])
        {
            auto btnCourse = new Button(topic, vLayoutTopics);
            btnCourse.addEventListener("triggered", () {
                vLayoutLessons.removeAllChildren();

                auto btnBack = new Button("Back", vLayoutLessons);
                btnBack.addEventListener("triggered", () {
                    vLayoutLessons.hide();
                    vLayoutTopics.show();
                });

                foreach(lesson; ["lessonA"])
                {
                    auto btnLesson = new Button(lesson, vLayoutLessons);
                    btnLesson.addEventListener("triggered", () {
                        vLayoutAssignments.removeAllChildren();

                        auto btnAssignmentsBack = new Button("Back", vLayoutAssignments);
                        btnAssignmentsBack.addEventListener("triggered", () {
                            vLayoutAssignments.hide();
                            vLayoutLessons.show();
                        });

                        auto btnAssignment = new Button("Assignment A", vLayoutAssignments);

                        vLayoutLessons.hide();
                        vLayoutAssignments.show();
                    });
                }

                vLayoutTopics.hide;
                vLayoutLessons.show();
            });
        } 
    }
}

Execute it with dub sample.d and click on button click here.

image

adamdruppe commented 2 years ago

hmm lemme get back to you on this.

adamdruppe commented 2 years ago

i see the bug it is windows specific which means i probably just forgot to initialize a variable on the native window handle or something. and actually as you click through the problem eventually goes away which definitely smells like i forgot to initialize something then it got set later.

adamdruppe commented 2 years ago

I went back and read the docs and saw Windows rounds off and then I was thinking maybe I just need to set these values in opposite direction.... it seems to actually work, look at that commit diff lol.

Took forever to find tho.

But I did notice the original thing doesn't resize if you change the window size then unhide something. I'm gonna see if I can fix that too. I think when I hide or unhide I need to queue up a size recalculation.

andre2007 commented 2 years ago

Thanks a lot Adam

adamdruppe commented 2 years ago

ok i think i fixed that too. possibility of regressions though i touched a particularly ugly part of the code....

and that ugly part of the code needs more work. tempted to do a breaking change there too but wanna avoid that since arsd 11 isn't scheduled until next summer. (but it is an undocumented function so odds are nobody would notice.... just it is also public.)

adamdruppe commented 2 years ago

passed my simple tests i can do with baby on me tho

so pushed up, if you use it let me know either regressions or lack thereof

andre2007 commented 2 years ago

Thanks a lot, it is working fine now.