mirror of
https://github.com/narrrl/proton-drive-linux.git
synced 2026-11-13 09:27:03 +01:00
fix(gui): context menus size to fit instead of scrolling
A popover is sized and placed again when its parent's layout manager allocates it. Context menus were parented to the outermost list view, and the keyboard menu to the ScrolledWindow; neither has a layout manager, so a menu kept the size it was first given and often opened too short, with a scrollbar. The host is now the first widget from the list view up that has a layout manager, which still keeps menus out of list items and the theme rules that style their insides.
This commit is contained in:
1 parent
19854b2d76
commit
ad49e32de9
1 file changed
+23
-9
@@ -128,20 +128,34 @@ impl ActionMenu {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Where a menu opened over `anchor` should live in the widget tree: the
|
/// Where a menu opened over `anchor` should live in the widget tree.
|
||||||
/// outermost grid or list view around it, or `anchor` itself. CSS descendant
|
///
|
||||||
/// selectors reach through a popover to its parent, and themes style the
|
/// Not inside a list item: CSS descendant selectors reach through a popover to
|
||||||
/// insides of list items (`gridview > child box { margin: 12px }` in
|
/// its parent, and themes style the insides of list items (`gridview > child
|
||||||
/// Catppuccin); a menu parented to a tile picks those rules up and puts a wide
|
/// box { margin: 12px }` in Catppuccin); a menu parented to a tile picks those
|
||||||
/// margin around every section. Under the view itself it is no item's child.
|
/// rules up and puts a wide margin around every section. So the search starts
|
||||||
|
/// at the outermost grid or list view around `anchor`.
|
||||||
|
///
|
||||||
|
/// Not on a widget without a layout manager either: a popover is sized and
|
||||||
|
/// placed again when its parent's layout manager allocates it. The list views
|
||||||
|
/// and `ScrolledWindow` have none, so a menu parented there kept the size it was
|
||||||
|
/// first given, often too small, and opened scrolling. The host is the first
|
||||||
|
/// widget from there up that has one.
|
||||||
fn popover_host(anchor: >k4::Widget) -> gtk4::Widget {
|
fn popover_host(anchor: >k4::Widget) -> gtk4::Widget {
|
||||||
let mut host = anchor.clone();
|
let mut start = anchor.clone();
|
||||||
let mut widget = anchor.parent();
|
let mut widget = anchor.parent();
|
||||||
while let Some(w) = widget {
|
while let Some(w) = widget {
|
||||||
widget = w.parent();
|
widget = w.parent();
|
||||||
if w.is::<gtk4::GridView>() || w.is::<gtk4::ListView>() || w.is::<gtk4::ColumnView>() {
|
if w.is::<gtk4::GridView>() || w.is::<gtk4::ListView>() || w.is::<gtk4::ColumnView>() {
|
||||||
host = w;
|
start = w;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
host
|
let mut host = Some(start.clone());
|
||||||
|
while let Some(w) = host {
|
||||||
|
if w.layout_manager().is_some() {
|
||||||
|
return w;
|
||||||
|
}
|
||||||
|
host = w.parent();
|
||||||
|
}
|
||||||
|
start
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user