Im trying to make a desktop email client. It has three separated vertical sections that can be resized. I implemented this with widget::pane_grid. But I found that this caused a behavior I didn’t expect. resizing the first split from the left moves the rightmost split. I want the resize actions to simply change the size of the pane to the left and right of the split that is dragged. As I understand… The only widget that supports mouse resizing is the PaneGrid. Is there some way I can get my desired behavior with PaneGrid or do I have to use some external crate?
If this Is not possible. How could I start on making a custom widget for this precise purpose (three vertical resizable panes each containing different sub widgets)? Any help or simple pointers would be much appreciated ![]()
I think it’s possible with pane_grid::State::with_configuration although it’s bit awkward, keep in mind PaneGrid is represented as a tree that stores a ratio for each split so you’ll need to arbitrarily decide which 2 nodes to group and then convert between widths in pixels to ratios (this is why it “moves” - the ratio stays the same but you expect the width to stay the same).
I would recommend using GitHub - edwloef/iced_split: resizeable splits for iced (or a row![left, mouse_area(rule::vertical()), middle, mouse_area(rule::vertical()), right], IIRC the these are essentially equivalent) which is width based, store the width of the left and right panels (so it the middle resizes when you resize the window) and split them at left_width and window - left_width - right_width (getting the window width is a little annoying, you can avoid it with the row or by vendoring the widget and tweaking it to allow specifying split relative to the left or having a single widget handle both splits).
Edit: you can also use responsive, that is more general and simpler than window size
Thank you for this. A row with MouseArea’s is perfect. I tried implementing this today. But when I was configuring the mousearea’s in the view function using .on_press(), .on_move(), and .on_release(). Rust error-ed and said I couldn’t use different closures for each of those three methods mentioned… and the compiler recommended I box my closures and/or use them as trait objects. Is there a typical best way to tackle this?
Sorry, disregard my previous reply. I was passing incorrect argument types to on_press and on_release methods in error. Thank you for the help, MouseArea’s and row layout works great!