Add and use TwoRowColToplevelLayout

This tries to find a split point in the list of toplevels to maximize
the scale factor when calling `RowColToplevelLayout` twice. If it
doesn't get a better scale factor, it just uses a single row/column.

Some things don't seem quite right, but the existing layout is not
perfect, and this can help.

Without the added cross axis spacing, there's overlap, so there may be
something wrong with the requested sizes...
This commit is contained in:
Ian Douglas Scott 2025-03-31 11:47:50 -07:00 committed by Ian Douglas Scott
parent 1fd7a86ecc
commit 7ab1f93acf
3 changed files with 77 additions and 3 deletions

View file

@ -11,19 +11,19 @@ use cosmic::iced::{
use std::marker::PhantomData;
mod toplevel_layout;
use toplevel_layout::{LayoutToplevel, RowColToplevelLayout, ToplevelLayout};
use toplevel_layout::{LayoutToplevel, ToplevelLayout, TwoRowColToplevelLayout};
pub fn toplevels<Msg>(children: Vec<cosmic::Element<Msg>>) -> Toplevels<Msg> {
Toplevels {
// TODO configurable
layout: RowColToplevelLayout::new(Axis::Horizontal, 16),
layout: TwoRowColToplevelLayout::new(Axis::Horizontal, 16),
children,
_msg: PhantomData,
}
}
pub struct Toplevels<'a, Msg> {
layout: RowColToplevelLayout,
layout: TwoRowColToplevelLayout,
children: Vec<cosmic::Element<'a, Msg>>,
_msg: PhantomData<Msg>,
}