-
Notifications
You must be signed in to change notification settings - Fork 366
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
ListItem
2.0 (part 5): deploy to the Visualizers and Overrides UIs
#6184
Changes from all commits
f5c5132
00388a3
bf9f7d7
80a681b
4b591e8
9b16b01
002f386
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -257,28 +257,48 @@ fn edit_marker_shape_ui( | |
|
||
egui::ComboBox::from_id_source("marker_shape") | ||
.selected_text(marker_text) // TODO(emilk): Show marker shape in the selected text | ||
.width(100.0) | ||
.width(ui.available_width().at_most(100.0)) | ||
.height(320.0) | ||
.show_ui(ui, |ui| { | ||
// no spacing between list items | ||
ui.spacing_mut().item_spacing.y = 0.0; | ||
|
||
// Hack needed for ListItem to click its highlight bg rect correctly: | ||
ui.set_clip_rect( | ||
ui.clip_rect() | ||
.with_max_x(ui.max_rect().max.x + ui.spacing().menu_margin.right), | ||
let item_width = 100.0; | ||
|
||
// workaround to force `ui.max_rect()` to reflect the content size | ||
ui.allocate_space(egui::vec2(item_width, 0.0)); | ||
abey79 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
let background_x_range = ui | ||
.spacing() | ||
.menu_margin | ||
.expand_rect(ui.max_rect()) | ||
.x_range(); | ||
|
||
re_ui::list_item2::list_item_scope( | ||
ui, | ||
"marker_shape", | ||
Some(background_x_range), | ||
Comment on lines
+271
to
+280
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we could make a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. I want all of our popup menu, context menu, etc. to be reimplemented and styled after list item: I would certainly welcome your input in this area, especially around the menu logics that currently relies on custom |
||
|ui| { | ||
for marker in MarkerShape::ALL { | ||
let response = ctx | ||
.re_ui | ||
.list_item2() | ||
.selected(edit_marker == marker) | ||
.show_flat( | ||
ui, | ||
re_ui::list_item2::LabelContent::new(marker.to_string()) | ||
.min_desired_width(item_width) | ||
.with_icon_fn(|_re_ui, ui, rect, visuals| { | ||
paint_marker(ui, marker.into(), rect, visuals.text_color()); | ||
}), | ||
); | ||
Comment on lines
+283
to
+294
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This exploded in line-count quite a bit… I wonder if there is anything we can do to improve this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can't immediately think of one. One area to think about is to have some |
||
|
||
if response.clicked() { | ||
edit_marker = marker; | ||
} | ||
} | ||
}, | ||
); | ||
|
||
for marker in MarkerShape::ALL { | ||
let list_item = re_ui::ListItem::new(ctx.re_ui, marker.to_string()) | ||
.with_icon_fn(|_re_ui, ui, rect, visuals| { | ||
paint_marker(ui, marker.into(), rect, visuals.text_color()); | ||
}) | ||
.selected(edit_marker == marker); | ||
if list_item.show_flat(ui).clicked() { | ||
edit_marker = marker; | ||
} | ||
} | ||
}); | ||
|
||
if edit_marker != current_marker { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see that the doscstring of
ComboBox::width
claims it sets the with of the menu… but it doesn't. We should fix that.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's slightly more complicated than that, if I understand correctly. In my code, the width of the combobox itself can shrink a lot when squeezed:
.width(ui.available_width().at_most(100.0))
. The menu width correctly set to that size. The issue is when the menu content is larger than the provided width. In that case, the menu visually expends to accommodate its content, but doesn't reflect that in the closure'sui.available_width()
, which remains stuck tocombobox.width - inner_margins
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll try to have a repro and open an issue in egui.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here: emilk/egui#4452