From 8bff54f7b474feef31b45e79e6e89e6c5aa412fb Mon Sep 17 00:00:00 2001 From: Hennadii Chernyshchyk Date: Thu, 10 Oct 2024 20:01:32 +0300 Subject: [PATCH] Rework constructors for `Negate` --- src/input_context/input_modifier.rs | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/src/input_context/input_modifier.rs b/src/input_context/input_modifier.rs index 65ce3c4..e91a48a 100644 --- a/src/input_context/input_modifier.rs +++ b/src/input_context/input_modifier.rs @@ -357,7 +357,7 @@ pub enum SmoothingMethod { /// Inverts value per axis. /// -/// Inverses all axes by default. +/// By default, all axes are inverted. #[derive(Debug)] pub struct Negate { pub x: bool, @@ -366,30 +366,39 @@ pub struct Negate { } impl Negate { - /// Returns [`Self`] with only x negated. - pub fn x() -> Self { + /// Returns [`Self`] with invertion for all axes set to `invert` + pub fn all(invert: bool) -> Self { Self { - x: true, + x: invert, + y: invert, + z: invert, + } + } + + /// Returns [`Self`] with invertion for x set to `invert` + pub fn x(invert: bool) -> Self { + Self { + x: invert, y: false, z: false, } } - /// Returns [`Self`] with only y negated. - pub fn y() -> Self { + /// Returns [`Self`] with invertion for y set to `invert` + pub fn y(invert: bool) -> Self { Self { x: false, - y: true, + y: invert, z: false, } } - /// Returns [`Self`] with only z negated. - pub fn z() -> Self { + /// Returns [`Self`] with invertion for z set to `invert` + pub fn z(invert: bool) -> Self { Self { x: false, y: false, - z: true, + z: invert, } } }