From a5fdc25452a3c23a2c16ec3f872ddb9b0bff9615 Mon Sep 17 00:00:00 2001 From: Dorota Czaplejewicz Date: Sat, 1 Oct 2022 15:13:28 +0000 Subject: [PATCH] layout: Unbox buttons The Box was just polluting the code, and the original reason for it (passing buttons individually to C) is gone. --- src/data/parsing.rs | 4 +-- src/drawing.rs | 4 +-- src/layout.rs | 61 ++++++++++++++++++++++----------------------- 3 files changed, 34 insertions(+), 35 deletions(-) diff --git a/src/data/parsing.rs b/src/data/parsing.rs index 7a7b93ad..a1d84e44 100644 --- a/src/data/parsing.rs +++ b/src/data/parsing.rs @@ -224,7 +224,7 @@ impl Layout { let rows = view.iter().map(|row| { let buttons = row.split_ascii_whitespace() .map(|name| { - Box::new(create_button( + create_button( &self.buttons, &self.outlines, name, @@ -232,7 +232,7 @@ impl Layout { .expect("Button state not created") .clone(), &mut warning_handler, - )) + ) }); layout::Row::new( add_offsets( diff --git a/src/drawing.rs b/src/drawing.rs index 8a920c74..c792b5de 100644 --- a/src/drawing.rs +++ b/src/drawing.rs @@ -105,7 +105,7 @@ mod c { render_button_at_position( renderer, &cr, offset, - button.as_ref(), + button, state.pressed, locked, ); } @@ -126,7 +126,7 @@ mod c { render_button_at_position( renderer, &cr, offset, - button.as_ref(), + button, keyboard::PressType::Released, LockedStyle::Free, ); diff --git a/src/layout.rs b/src/layout.rs index 61cebae3..2e9041ff 100644 --- a/src/layout.rs +++ b/src/layout.rs @@ -473,14 +473,14 @@ impl Button { pub struct Row { /// Buttons together with their offset from the left relative to the row. /// ie. the first button always start at 0. - buttons: Vec<(f64, Box