From 7483f314d8759a320ff2a86d46f799964dfd333b Mon Sep 17 00:00:00 2001 From: PLYSHKA Date: Sun, 7 Jan 2024 19:34:29 +0000 Subject: [PATCH] feat: add offset x/y to wivrn profile --- src/file_builders/wivrn_config.rs | 10 +++++ .../factories/wivrn_encoder_group_factory.rs | 40 +++++++++++++++++++ test/files/wivrn_config.json | 4 +- 3 files changed, 53 insertions(+), 1 deletion(-) diff --git a/src/file_builders/wivrn_config.rs b/src/file_builders/wivrn_config.rs index 71ad055..1131db6 100644 --- a/src/file_builders/wivrn_config.rs +++ b/src/file_builders/wivrn_config.rs @@ -85,6 +85,10 @@ pub struct WivrnConfEncoder { #[serde(skip_serializing_if = "Option::is_none")] pub height: Option, #[serde(skip_serializing_if = "Option::is_none")] + pub offset_x: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub offset_y: Option, + #[serde(skip_serializing_if = "Option::is_none")] pub group: Option, } @@ -96,6 +100,8 @@ impl Default for WivrnConfEncoder { bitrate: None, width: None, height: None, + offset_x: None, + offset_y: None, group: None, } } @@ -118,6 +124,8 @@ impl Default for WivrnConfig { bitrate: Some(100000000), width: Some(1.0), height: Some(1.0), + offset_x: Some(0.0), + offset_y: Some(0.0), group: None, }], } @@ -162,5 +170,7 @@ mod tests { assert_eq!(conf.encoders.get(0).unwrap().bitrate, Some(100000000)); assert_eq!(conf.encoders.get(0).unwrap().width, Some(1.0)); assert_eq!(conf.encoders.get(0).unwrap().height, Some(1.0)); + assert_eq!(conf.encoders.get(0).unwrap().offset_x, Some(0.0)); + assert_eq!(conf.encoders.get(0).unwrap().offset_y, Some(0.0)); } } diff --git a/src/ui/factories/wivrn_encoder_group_factory.rs b/src/ui/factories/wivrn_encoder_group_factory.rs index 6fd84a2..7b51a73 100644 --- a/src/ui/factories/wivrn_encoder_group_factory.rs +++ b/src/ui/factories/wivrn_encoder_group_factory.rs @@ -24,6 +24,8 @@ pub enum WivrnEncoderModelMsg { BitrateChanged(Option), WidthChanged(Option), HeightChanged(Option), + OffsetXChanged(Option), + OffsetYChanged(Option), GroupChanged(Option), Delete, } @@ -134,6 +136,38 @@ impl AsyncFactoryComponent for WivrnEncoderModel { } } ) -> adw::SpinRow, + add: offset_x_row = &spin_row( + "Offset X", + None, + self.encoder_conf.offset_x.unwrap_or(0.0).into(), + 0.0, + 1.0, + 0.01, + { + let sender = sender.clone(); + move |adj| { + sender.input(Self::Input::OffsetXChanged( + Some(adj.value() as f32) + )); + } + } + ) -> adw::SpinRow, + add: offset_y_row = &spin_row( + "Offset Y", + None, + self.encoder_conf.offset_y.unwrap_or(0.0).into(), + 0.0, + 1.0, + 0.01, + { + let sender = sender.clone(); + move |adj| { + sender.input(Self::Input::OffsetYChanged( + Some(adj.value() as f32) + )); + } + } + ) -> adw::SpinRow, add: group_row = &spin_row( "Group", None, @@ -170,6 +204,12 @@ impl AsyncFactoryComponent for WivrnEncoderModel { Self::Input::HeightChanged(val) => { self.encoder_conf.height = val; } + Self::Input::OffsetXChanged(val) => { + self.encoder_conf.offset_x = val; + } + Self::Input::OffsetYChanged(val) => { + self.encoder_conf.offset_y = val; + } Self::Input::GroupChanged(val) => { self.encoder_conf.group = val; } diff --git a/test/files/wivrn_config.json b/test/files/wivrn_config.json index 4a38e87..aafcfd0 100644 --- a/test/files/wivrn_config.json +++ b/test/files/wivrn_config.json @@ -6,7 +6,9 @@ "codec": "h264", "bitrate": 100000000, "width": 1.0, - "height": 1.0 + "height": 1.0, + "offset_x": 0.0, + "offset_y": 0.0 } ] }