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

minigui: win32 updates very slow #293

Open
WebFreak001 opened this issue Jun 30, 2021 · 11 comments
Open

minigui: win32 updates very slow #293

WebFreak001 opened this issue Jun 30, 2021 · 11 comments

Comments

@WebFreak001
Copy link
Contributor

check this code, any interaction with it or recreating checkboxes takes multiple seconds of unresponsiveness to load:

/+ dub.sdl:
dependency "arsd-official:minigui" version="~>10.1.0"
+/

import arsd.minigui;
import std.conv;
import std.stdio;

void main(string[] args)
{
	auto window = new MainWindow();

	auto layout = new VerticalLayout(window);

	new TextLabel("Count:", layout);

	int[] counts= [32, 64];

	auto dropdown = new DropDownSelection(layout);
	foreach (count; counts)
		dropdown.addOption(count.to!string);

	auto scroll = new ScrollableWidget(layout);
	auto list = new VerticalLayout(scroll);

	dropdown.addEventListener(EventType.change, (v) {
		foreach_reverse (child; list.children)
			child.removeWidget();
		if (v.intValue >= 0 && v.intValue < counts.length)
			foreach (i; 0 .. counts[v.intValue])
			{
				auto pair = new HorizontalLayout(list);
				new LineEdit(pair).content = text("Checkbox ", i + 1);
				auto cb = new Checkbox("active", pair);
				cb.addEventListener(EventType.change, (v) {
					writeln("change ", i, " to ", cb.isChecked);
				});
			}
	});

	window.loop();
}
@adamdruppe
Copy link
Owner

my suspicion here is each change redoes all the layout in n^2 time cuz each change of children redoes it for all remaining children.

i'm tempted to queue that to make it asynchronous like painting. but then various fields won't be updated immediately and that might be a breaking change... im not sure how relevant that will be...

@WebFreak001
Copy link
Contributor Author

also on first interaction with the UI (checking a checkbox, changing input lines, etc) it seems to rerender everything because it lags again then

@adamdruppe
Copy link
Owner

adamdruppe commented Jun 30, 2021 via email

@adamdruppe
Copy link
Owner

adamdruppe commented Jun 30, 2021 via email

@WebFreak001
Copy link
Contributor Author

here is a video what it's doing: https://streamable.com/b5y7ij

@adamdruppe
Copy link
Owner

adamdruppe commented Jun 30, 2021 via email

@WebFreak001
Copy link
Contributor Author

WebFreak001 commented Jun 30, 2021

I would also be fine if I could do it virtually and then submit it all at once to you. (Like working on a widget and then only when done adding it as child to the list)

I think that would be a better approach actually, although additionally also batching would make this easier for things like whole lists.

@adamdruppe
Copy link
Owner

new methods

                list.beginBatchUpdate;
                scope(exit)
                        list.finishBatchUpdate;

make a huge difference on this speed thing. so it coming together.

but the max height is still broken in all this. i clamp max height for individual widgets but when there's 64, no one thing goes over the limit but the rest do and then it breaks layout

adding a new native container window also helps the scroll and click stuff working.

so slowly making this not suck.

@adamdruppe
Copy link
Owner

lastshot

no more weird visual artifacts, drawing fast. just overlaps if the window too small which is of course what scroll is supposed to handle!

@adamdruppe
Copy link
Owner

actually i think i can auto-batch it fairly effectively by just hooking it into the (required anyway) batched redraw event.

@adamdruppe
Copy link
Owner

I think I'll push live pretty soon, it is a LOT better than it was now though still a little slow to add/remove; you notice the lag but still. I think it is actually the remove all that is a bit slow but it actually works and isn't too terrible.

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