row_col_toplevel_layout: Add a new method
This commit is contained in:
parent
5349f0f3d0
commit
1fd7a86ecc
2 changed files with 6 additions and 5 deletions
|
|
@ -15,11 +15,8 @@ use toplevel_layout::{LayoutToplevel, RowColToplevelLayout, ToplevelLayout};
|
||||||
|
|
||||||
pub fn toplevels<Msg>(children: Vec<cosmic::Element<Msg>>) -> Toplevels<Msg> {
|
pub fn toplevels<Msg>(children: Vec<cosmic::Element<Msg>>) -> Toplevels<Msg> {
|
||||||
Toplevels {
|
Toplevels {
|
||||||
layout: RowColToplevelLayout {
|
// TODO configurable
|
||||||
// TODO configurable
|
layout: RowColToplevelLayout::new(Axis::Horizontal, 16),
|
||||||
spacing: 16,
|
|
||||||
axis: Axis::Horizontal,
|
|
||||||
},
|
|
||||||
children,
|
children,
|
||||||
_msg: PhantomData,
|
_msg: PhantomData,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,10 @@ pub(crate) struct RowColToplevelLayout {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RowColToplevelLayout {
|
impl RowColToplevelLayout {
|
||||||
|
pub fn new(axis: Axis, spacing: u32) -> Self {
|
||||||
|
Self { axis, spacing }
|
||||||
|
}
|
||||||
|
|
||||||
// Get total requested main axis length if widget could have all the space
|
// Get total requested main axis length if widget could have all the space
|
||||||
pub fn requested_main_total(&self, toplevels: &[LayoutToplevel<'_, AxisSize>]) -> f32 {
|
pub fn requested_main_total(&self, toplevels: &[LayoutToplevel<'_, AxisSize>]) -> f32 {
|
||||||
let total_spacing = self.spacing as usize * (toplevels.len().saturating_sub(1)).max(0);
|
let total_spacing = self.spacing as usize * (toplevels.len().saturating_sub(1)).max(0);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue