Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 06fb841

Browse files
authored
Fix some menu buttons closing unexpectedly (#11247)
### Related * Closes #11245 ### What Changes the default for `should_always_show_buttons` to true when adding a menu button. Maybe we should change the default to be always true though? I feel like usually you want to always show buttons, unless every list item has it (e.g. visibility in the blueprint tree) where it would add too much noise / use too much space. When I worked on the new ItemButtons, I defaulted to false since that was the default in LabelContent.
1 parent 48ca18a commit 06fb841

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

crates/viewer/re_ui/src/list_item/item_buttons.rs

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,8 @@ where
196196
/// The `alt_text` will also be used for the tooltip.
197197
///
198198
/// See [`Self::with_button`] for more information.
199+
///
200+
/// Sets [`Self::with_always_show_buttons`] to `true` (TODO(emilk/egui#7531)).
199201
#[inline]
200202
fn with_menu_button(
201203
self,
@@ -204,12 +206,14 @@ where
204206
add_contents: impl FnOnce(&mut egui::Ui) + 'a,
205207
) -> Self {
206208
let hover_text = alt_text.into();
207-
self.with_button(
209+
self.with_always_show_buttons(true).with_button(
208210
super::ItemMenuButton::new(icon, &hover_text, add_contents).hover_text(hover_text),
209211
)
210212
}
211213

212214
/// Set the help text tooltip to be shown in the header.
215+
///
216+
/// Sets [`Self::with_always_show_buttons`] to `true` (TODO(emilk/egui#7531)).
213217
#[inline]
214218
fn with_help_text(self, help: impl Into<egui::WidgetText> + 'a) -> Self {
215219
self.with_help_ui(|ui| {
@@ -218,6 +222,8 @@ where
218222
}
219223

220224
/// Set the help markdown tooltip to be shown in the header.
225+
///
226+
/// Sets [`Self::with_always_show_buttons`] to `true` (TODO(emilk/egui#7531)).
221227
#[inline]
222228
fn with_help_markdown(self, help: &'a str) -> Self {
223229
self.with_help_ui(|ui| {
@@ -226,8 +232,21 @@ where
226232
}
227233

228234
/// Set the help UI closure to be shown in the header.
235+
///
236+
/// Sets [`Self::with_always_show_buttons`] to `true` (TODO(emilk/egui#7531)).
229237
#[inline]
230238
fn with_help_ui(self, help: impl FnOnce(&mut egui::Ui) + 'a) -> Self {
231-
self.with_button(|ui: &mut egui::Ui| ui.help_button(help))
239+
self.with_always_show_buttons(true)
240+
.with_button(|ui: &mut egui::Ui| ui.help_button(help))
241+
}
242+
}
243+
244+
impl<'a> ListItemContentButtonsExt<'a> for ItemButtons<'a> {
245+
fn buttons(&self) -> &Self {
246+
self
247+
}
248+
249+
fn buttons_mut(&mut self) -> &mut Self {
250+
self
232251
}
233252
}

crates/viewer/re_ui/src/section_collapsing_header.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ impl SectionCollapsingHeader<'_> {
1919
Self {
2020
label: label.into(),
2121
default_open: true,
22-
buttons: ItemButtons::default(),
22+
buttons: ItemButtons::default()
23+
// Section headers should always show buttons
24+
.with_always_show_buttons(true),
2325
}
2426
}
2527

0 commit comments

Comments
 (0)