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

Expose GUI ordering API #91

Merged
merged 3 commits into from
Aug 28, 2023
Merged

Expose GUI ordering API #91

merged 3 commits into from
Aug 28, 2023

Conversation

brentyi
Copy link
Collaborator

@brentyi brentyi commented Aug 28, 2023

  1. We move away from setting order base on time.time(), which I imagine would fail in Windows. In Windows, time.time() uses 16ms increments; we've replaced this with a global counter.

  2. We expose the .order property for GUI handles and the order= argument for "add GUI" methods. These will make it easier to, as an example, add a new GUI element between two existing ones or in place of an existing one.

@brentyi brentyi requested a review from kerrj August 28, 2023 04:54
@kerrj
Copy link
Collaborator

kerrj commented Aug 28, 2023

To add an element between one you would have to manually update the orders of all elements right? What happens if you accidentally specify the same order

@brentyi
Copy link
Collaborator Author

brentyi commented Aug 28, 2023

Like between two existing GUI elements?

If you have gui_a and gui_b, you could create a new GUI element at order=(gui_a.order + gui_b.order) / 2.0. The global counter's an integer but the order argument will take floats.

What happens if you accidentally specify the same order

I'm fairly confident that elements will just follow insertion order, but I think we can consider this undefined behavior.

Copy link
Collaborator

@kerrj kerrj left a comment

Choose a reason for hiding this comment

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

nice

@brentyi brentyi merged commit 5bd1d2e into main Aug 28, 2023
@brentyi brentyi deleted the brent/gui_order branch August 28, 2023 06:00
yzslab pushed a commit to yzslab/viser that referenced this pull request Oct 20, 2024
* Expose GUI order API

* Revert accident

* Fix example
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.

2 participants