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

Improve datastore browser column header UI #7344

Merged
merged 4 commits into from
Sep 3, 2024

Conversation

abey79
Copy link
Member

@abey79 abey79 commented Sep 3, 2024

What

Uses the new egui::Sides API to display the sort arrow. Note that the truncation behaviour is not quite perfect yet.

image

Checklist

  • I have read and agree to Contributor Guide and the Code of Conduct
  • I've included a screenshot or gif (if applicable)
  • I have tested the web demo (if applicable):
  • The PR title and labels are set such as to maximize their usefulness for the next release's CHANGELOG
  • If applicable, add a new check to the release checklist!
  • If have noted any breaking changes to the log API in CHANGELOG.md and the migration guide

To run all checks from main, comment on the PR with @rerun-bot full-check.

Uses the new `egui::Sides` API. Note that the truncation behavior is not quite perfect yet.
@abey79 abey79 added ui concerns graphical user interface exclude from changelog PRs with this won't show up in CHANGELOG.md labels Sep 3, 2024
Comment on lines 59 to 63
ui.label(match (is_sorted, direction) {
(true, SortDirection::Ascending) => "↓",
(true, SortDirection::Descending) => "↑",
_ => "",
});
Copy link
Member

Choose a reason for hiding this comment

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

I would expect this arrow to be clickable

Copy link
Member Author

Choose a reason for hiding this comment

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

Makes sense.

Interestingly, this brings up a small paper cut with the current Sides api: I can't mutably borrow anything in both closure, so I'm forced to do something like this:

    let mut toggle_left = false;
    let mut toggle_right = false;

    egui::Sides::new()
        .height(re_ui::DesignTokens::table_line_height())
        .show(
            ui,
            |ui| {
                ui.style_mut().wrap_mode = Some(egui::TextWrapMode::Truncate);

                toggle_left = ui.button(egui::WidgetText::from(label).strong()).clicked();
            },
            |ui| {
                toggle_right = ui
                    .button(match (is_sorted, direction) {
                        (true, SortDirection::Ascending) => "↓",
                        (true, SortDirection::Descending) => "↑",
                        _ => "",
                    })
                    .clicked();
            },
        );

At a minimum, Sides::show() should return a tuple of (R1, R2) generic types corresponding to the return value of each closure.

Copy link
Member Author

Choose a reason for hiding this comment

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

crates/viewer/re_chunk_store_ui/src/sort.rs Outdated Show resolved Hide resolved
abey79 added a commit to emilk/egui that referenced this pull request Sep 3, 2024
This addresses this comment:
- rerun-io/rerun#7344 (comment)


* [x] I have followed the instructions in the PR template
@abey79 abey79 merged commit 8464acb into main Sep 3, 2024
34 checks passed
@abey79 abey79 deleted the antoine/improve-column-header-ui branch September 3, 2024 15:00
hacknus pushed a commit to hacknus/egui that referenced this pull request Oct 30, 2024
This addresses this comment:
- rerun-io/rerun#7344 (comment)


* [x] I have followed the instructions in the PR template
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
exclude from changelog PRs with this won't show up in CHANGELOG.md ui concerns graphical user interface
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants