diff --git a/src/data.rs b/src/data.rs index c3cf5345..2c3fd353 100644 --- a/src/data.rs +++ b/src/data.rs @@ -459,14 +459,14 @@ impl Layout { &mut warning_handler, )) }); - layout::Row { - buttons: add_offsets( + layout::Row::new( + add_offsets( buttons, |button| button.size.width, ).collect() - } + ) }); - let rows = add_offsets(rows, |row| row.get_height()) + let rows = add_offsets(rows, |row| row.get_size().height) .collect(); ( name.clone(), @@ -484,8 +484,8 @@ impl Layout { name, ( layout::c::Point { - x: (total_size.width - view.get_width()) / 2.0, - y: (total_size.height - view.get_height()) / 2.0, + x: (total_size.width - view.get_size().width) / 2.0, + y: (total_size.height - view.get_size().height) / 2.0, }, view, ), @@ -824,7 +824,7 @@ mod tests { assert_eq!( out.views["base"].1 .get_rows()[0].1 - .buttons[0].1 + .get_buttons()[0].1 .label, ::layout::Label::Text(CString::new("test").unwrap()) ); @@ -839,7 +839,7 @@ mod tests { assert_eq!( out.views["base"].1 .get_rows()[0].1 - .buttons[0].1 + .get_buttons()[0].1 .label, ::layout::Label::Text(CString::new("test").unwrap()) ); @@ -855,7 +855,7 @@ mod tests { assert_eq!( out.views["base"].1 .get_rows()[0].1 - .buttons[0].1 + .get_buttons()[0].1 .state.borrow() .keycodes.len(), 2 diff --git a/src/layout.rs b/src/layout.rs index b1cae8ee..2fa09112 100644 --- a/src/layout.rs +++ b/src/layout.rs @@ -493,38 +493,63 @@ pub struct Button { } /// The graphical representation of a row of buttons +#[derive(Clone, Debug)] pub struct Row { - /// Buttons together with their offset from the left - pub buttons: Vec<(f64, Box