pub struct GridParams {
pub x: i32,
pub y: i32,
pub width: i32,
pub height: i32,
}Expand description
Parameters required when adding an item to a Grid container.
Fields§
§x: i32Index of the column this item is starting from.
y: i32Index of the row this item is starting from.
width: i32Number of columns this item spans.
height: i32Number of rows this item spans.
Implementations§
Source§impl GridParams
impl GridParams
Sourcepub fn new(x: i32, y: i32, width: i32, height: i32) -> GridParams
pub fn new(x: i32, y: i32, width: i32, height: i32) -> GridParams
Create grid parameters with the given values.
§Panics
When debug assertions are on, panics if the width or height is less than or equal to zero or if x or y is negative.
Examples found in repository?
examples/calc.rs (line 220)
204fn app_logic(data: &mut Calculator) -> impl WidgetView<Calculator> + use<> {
205 grid(
206 (
207 // Display
208 centered_flex_row((
209 FlexSpacer::Flex(0.1),
210 display_label(data.numbers[0].as_ref()),
211 data.operation
212 .map(|operation| display_label(operation.as_str())),
213 display_label(data.numbers[1].as_ref()),
214 data.result.is_some().then(|| display_label("=")),
215 data.result
216 .as_ref()
217 .map(|result| display_label(result.as_ref())),
218 FlexSpacer::Flex(0.1),
219 ))
220 .grid_item(GridParams::new(0, 0, 4, 1)),
221 // Top row
222 expanded_button(
223 label("CE").color(if data.get_current_number().is_empty() {
224 palette::css::MEDIUM_VIOLET_RED
225 } else {
226 palette::css::WHITE
227 }),
228 Calculator::clear_entry,
229 )
230 .grid_pos(0, 1),
231 expanded_button(label("C"), Calculator::clear_all).grid_pos(1, 1),
232 expanded_button(label("DEL"), Calculator::on_delete).grid_pos(2, 1),
233 operator_button(MathOperator::Divide).grid_pos(3, 1),
234 num_row(["7", "8", "9"], 2),
235 operator_button(MathOperator::Multiply).grid_pos(3, 2),
236 num_row(["4", "5", "6"], 3),
237 operator_button(MathOperator::Subtract).grid_pos(3, 3),
238 num_row(["1", "2", "3"], 4),
239 operator_button(MathOperator::Add).grid_pos(3, 4),
240 // bottom row
241 expanded_button(label("±"), Calculator::negate).grid_pos(0, 5),
242 digit_button("0").grid_pos(1, 5),
243 expanded_button(label("."), |data: &mut Calculator| {
244 data.on_entered_digit(".");
245 })
246 .grid_pos(2, 5),
247 expanded_button(label("="), Calculator::on_equals).grid_pos(3, 5),
248 ),
249 4,
250 6,
251 )
252 .spacing(GRID_GAP)
253}Trait Implementations§
Source§impl Clone for GridParams
impl Clone for GridParams
Source§fn clone(&self) -> GridParams
fn clone(&self) -> GridParams
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for GridParams
Source§impl Debug for GridParams
impl Debug for GridParams
Source§impl Default for GridParams
impl Default for GridParams
Source§fn default() -> GridParams
fn default() -> GridParams
Returns the “default value” for a type. Read more
Source§impl PartialEq for GridParams
impl PartialEq for GridParams
Source§fn eq(&self, other: &GridParams) -> bool
fn eq(&self, other: &GridParams) -> bool
Tests for
self and other values to be equal, and is used by ==.impl StructuralPartialEq for GridParams
Auto Trait Implementations§
impl Freeze for GridParams
impl RefUnwindSafe for GridParams
impl Send for GridParams
impl Sync for GridParams
impl Unpin for GridParams
impl UnsafeUnpin for GridParams
impl UnwindSafe for GridParams
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T> Brush for T
impl<T> CloneAny for T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.