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

Add clear method to LTerm_widget.box #44

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

bonkf
Copy link
Contributor

@bonkf bonkf commented Oct 9, 2016

This PR adds a method to clear all widgets from a LTerm_widget.box.

Writing some_box#clear is easier and faster than writing

List.iter some_box#remove some_box#children

since the box only needs to be redrawn once.

I also updated my example from PR#42 to demonstrate the usage, although I'm not sure if there's any point in doing so; it's fairly self-explanatory and using #clear in this case isn't even the fastest way to do it (see the comment in double_editor.ml).

List.iter (fun child -> child.widget#set_parent None) children;
children <- [];
self#compute_size_request;
self#compute_allocations;
Copy link
Contributor Author

@bonkf bonkf Oct 9, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The calls to #compute_size_request and #compute_allocations are currently not needed since children is empty at this point; I wasn't sure if I could leave them out since some boxes may have custom implementations that depend on values other than children.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Scratch that, they are still necessary, although they could theoretically be replaced with default values there is not much to be gained here.

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.

1 participant