create VmcExtSettingWin
This commit is contained in:
parent
0df7475f57
commit
dbb208dfc4
71
src/lib.rs
71
src/lib.rs
|
@ -1070,3 +1070,74 @@ impl MessageBehavior for VmcExtSettingColor {
|
|||
return Ok(VmcExtSettingColor { color });
|
||||
}
|
||||
}
|
||||
|
||||
struct VmcExtSettingWin {
|
||||
is_top_most: bool,
|
||||
is_transparent: bool,
|
||||
window_click_through: i32,
|
||||
hide_border: i32,
|
||||
}
|
||||
|
||||
impl MessageBehavior for VmcExtSettingWin {
|
||||
fn to_osc_message(&self) -> OscMessage {
|
||||
let mut args: Vec<OscType>;
|
||||
if self.is_top_most {
|
||||
args = vec![OscType::from(1)];
|
||||
} else {
|
||||
args = vec![OscType::from(0)];
|
||||
}
|
||||
if self.is_transparent {
|
||||
args.push(OscType::from(1));
|
||||
} else {
|
||||
args.push(OscType::from(0));
|
||||
}
|
||||
args.append(&mut vec![
|
||||
OscType::from(self.window_click_through),
|
||||
OscType::from(self.hide_border),
|
||||
]);
|
||||
return OscMessage {
|
||||
addr: String::from("/VMC/Ext/Setting/Win"),
|
||||
args,
|
||||
};
|
||||
}
|
||||
fn from_osc_message(msg: OscMessage) -> Result<Self, String> {
|
||||
if msg.args.len() != 4 {
|
||||
return Err(String::from("arg count invalid"));
|
||||
}
|
||||
let mut result = Self {
|
||||
is_top_most: false,
|
||||
is_transparent: false,
|
||||
window_click_through: -1,
|
||||
hide_border: -1,
|
||||
};
|
||||
match msg.args[0] {
|
||||
OscType::Int(i) => {
|
||||
if i == 1 {
|
||||
result.is_top_most = true;
|
||||
} else if i != 0 {
|
||||
return Err(String::from("arg value invalid"));
|
||||
}
|
||||
}
|
||||
_ => return Err(String::from("arg type invalid")),
|
||||
}
|
||||
match msg.args[1] {
|
||||
OscType::Int(i) => {
|
||||
if i == 1 {
|
||||
result.is_transparent = true;
|
||||
} else if i != 0 {
|
||||
return Err(String::from("arg value invalid"));
|
||||
}
|
||||
}
|
||||
_ => return Err(String::from("arg type invalid")),
|
||||
}
|
||||
match msg.args[2] {
|
||||
OscType::Int(i) => result.window_click_through = i,
|
||||
_ => return Err(String::from("arg type invalid")),
|
||||
}
|
||||
match msg.args[2] {
|
||||
OscType::Int(i) => result.hide_border = i,
|
||||
_ => return Err(String::from("arg type invalid")),
|
||||
}
|
||||
return Ok(result);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user