mirror of
https://github.com/pinnacle-comp/pinnacle.git
synced 2025-01-14 08:01:14 +01:00
Add scale setting to Rust API
This commit is contained in:
parent
dfc7a1351e
commit
1907381d99
2 changed files with 51 additions and 3 deletions
|
@ -12,7 +12,10 @@
|
||||||
use futures::FutureExt;
|
use futures::FutureExt;
|
||||||
use pinnacle_api_defs::pinnacle::output::{
|
use pinnacle_api_defs::pinnacle::output::{
|
||||||
self,
|
self,
|
||||||
v0alpha1::{output_service_client::OutputServiceClient, SetLocationRequest, SetModeRequest},
|
v0alpha1::{
|
||||||
|
output_service_client::OutputServiceClient, set_scale_request::AbsoluteOrRelative,
|
||||||
|
SetLocationRequest, SetModeRequest, SetScaleRequest,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
use tonic::transport::Channel;
|
use tonic::transport::Channel;
|
||||||
|
|
||||||
|
@ -390,6 +393,51 @@ impl OutputHandle {
|
||||||
.unwrap();
|
.unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Set this output's scaling factor.
|
||||||
|
///
|
||||||
|
/// # Examples
|
||||||
|
///
|
||||||
|
/// ```
|
||||||
|
/// output.get_focused()?.set_scale(1.5);
|
||||||
|
/// ```
|
||||||
|
pub fn set_scale(&self, scale: f32) {
|
||||||
|
let mut client = self.output_client.clone();
|
||||||
|
block_on_tokio(client.set_scale(SetScaleRequest {
|
||||||
|
output_name: Some(self.name.clone()),
|
||||||
|
absolute_or_relative: Some(AbsoluteOrRelative::Absolute(scale)),
|
||||||
|
}))
|
||||||
|
.unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Increase this output's scaling factor by `increase_by`.
|
||||||
|
///
|
||||||
|
/// # Examples
|
||||||
|
///
|
||||||
|
/// ```
|
||||||
|
/// output.get_focused()?.increase_scale(0.25);
|
||||||
|
/// ```
|
||||||
|
pub fn increase_scale(&self, increase_by: f32) {
|
||||||
|
let mut client = self.output_client.clone();
|
||||||
|
block_on_tokio(client.set_scale(SetScaleRequest {
|
||||||
|
output_name: Some(self.name.clone()),
|
||||||
|
absolute_or_relative: Some(AbsoluteOrRelative::Relative(increase_by)),
|
||||||
|
}))
|
||||||
|
.unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Decrease this output's scaling factor by `decrease_by`.
|
||||||
|
///
|
||||||
|
/// This simply calls [`OutputHandle::increase_scale`] with the negative of `decrease_by`.
|
||||||
|
///
|
||||||
|
/// # Examples
|
||||||
|
///
|
||||||
|
/// ```
|
||||||
|
/// output.get_focused()?.decrease_scale(0.25);
|
||||||
|
/// ```
|
||||||
|
pub fn decrease_scale(&self, decrease_by: f32) {
|
||||||
|
self.increase_scale(-decrease_by);
|
||||||
|
}
|
||||||
|
|
||||||
/// Get all properties of this output.
|
/// Get all properties of this output.
|
||||||
///
|
///
|
||||||
/// # Examples
|
/// # Examples
|
||||||
|
|
Loading…
Reference in a new issue