This commit is contained in:
Moritz Ruth 2024-02-01 16:21:53 +01:00
parent b5a7ab3c6b
commit ebb0552a13
Signed by: moritzruth
GPG key ID: C9BBAB79405EE56D
9 changed files with 186 additions and 36 deletions

View file

@ -6,10 +6,10 @@ use either::Either;
use serde::de::DeserializeOwned;
use thiserror::Error;
use deckster_shared::handler_communication::HandlerInitializationResultMessage;
pub use deckster_shared::handler_communication::{HandlerEvent, HandlerInitializationError, InitialHandlerMessage};
pub use deckster_shared::path::*;
pub use deckster_shared::state::{KeyStyleByStateMap, KnobStyleByStateMap};
pub use deckster_shared as shared;
use deckster_shared::handler_communication::{
HandlerCommand, HandlerEvent, HandlerInitializationError, HandlerInitializationResultMessage, InitialHandlerMessage,
};
#[derive(Debug, Error)]
pub enum RunError {
@ -86,3 +86,7 @@ pub fn run<
Ok(())
}
pub fn send_command(command: HandlerCommand) {
println!("{}", serde_json::to_string(&command).unwrap());
}

View file

@ -24,7 +24,7 @@ fn parse_rgb8_from_hex_str(s: &str) -> Result<RGB8, ParsingError> {
}
fn fmt_rgb8_as_hex_string(v: &RGB8, f: &mut Formatter<'_>) -> std::fmt::Result {
f.write_fmt(format_args!("{:#04x}{:#04x}{:#04x}", v.r, v.g, v.b))
f.write_fmt(format_args!("#{:02x}{:02x}{:02x}", v.r, v.g, v.b))
}
fn parse_rgba8_from_hex_str(s: &str) -> Result<RGBA8, ParsingError> {
@ -42,7 +42,7 @@ fn parse_rgba8_from_hex_str(s: &str) -> Result<RGBA8, ParsingError> {
}
fn fmt_rgba8_as_hex_string(v: &RGBA8, f: &mut Formatter<'_>) -> std::fmt::Result {
f.write_fmt(format_args!("{:#04x}{:#04x}{:#04x}{:#04x}", v.r, v.g, v.b, v.a))
f.write_fmt(format_args!("#{:02x}{:02x}{:02x}{:02x}", v.r, v.g, v.b, v.a))
}
fn parse_rgb8_with_optional_alpha_from_hex_str(s: &str, fallback_alpha: u8) -> Result<RGBA8, ParsingError> {

View file

@ -422,7 +422,9 @@ impl PaThread {
fn set_state(current_state: &RwLock<Option<Arc<PaVolumeState>>>, state_tx: &broadcast::Sender<Arc<PaVolumeState>>, value: Arc<PaVolumeState>) {
let mut s = current_state.write().unwrap();
*s = Some(Arc::clone(&value));
state_tx.send(value).unwrap();
// If there are no subscribers, thats ok.
_ = state_tx.send(value);
}
fn run_single_mainloop_iteration(&mut self, block: bool) {