W16 custom backgrounds: core + render layer (Settings UI pending)
Pure src/background.rs (process_background downscale→PNG, scrim_color; 5 tests), AppConfig.background/background_dim + background_path(), cached AppState.background_image, PickBackgroundFile/BackgroundFilePicked/RemoveBackground/SetBackgroundDim handlers, view_with_background stack(image Cover→scrim→ui) + transparent screen roots. Lib builds clean. Remaining: Settings UI controls + full build/clippy/test pass. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -106,6 +106,10 @@ fn default_true() -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
fn default_background_dim() -> f32 {
|
||||
crate::background::DEFAULT_DIM
|
||||
}
|
||||
|
||||
fn default_volume() -> f32 {
|
||||
1.0
|
||||
}
|
||||
@@ -185,6 +189,16 @@ pub struct AppConfig {
|
||||
/// Our chosen avatar (W4): monogram fallback or a bundled preset.
|
||||
#[serde(default)]
|
||||
pub avatar: crate::avatar::Avatar,
|
||||
/// Custom UI background image (W16): path to the downscaled PNG we wrote into
|
||||
/// the config dir (see `background_path`). `None` = use the theme background.
|
||||
/// Local-only; never sent to peers.
|
||||
#[serde(default)]
|
||||
pub background: Option<String>,
|
||||
/// Scrim strength drawn over the custom background for legibility (0.0 = image
|
||||
/// at full strength, 1.0 = fully hidden behind the theme base). See
|
||||
/// `crate::background::scrim_color`.
|
||||
#[serde(default = "default_background_dim")]
|
||||
pub background_dim: f32,
|
||||
/// What a call recording captures (mixed / per-peer stems / both).
|
||||
#[serde(default)]
|
||||
pub recording_mode: RecordingMode,
|
||||
@@ -280,6 +294,8 @@ impl Default for AppConfig {
|
||||
room_layout: RoomLayout::default(),
|
||||
theme: AppTheme::default(),
|
||||
avatar: crate::avatar::Avatar::default(),
|
||||
background: None,
|
||||
background_dim: default_background_dim(),
|
||||
recording_mode: RecordingMode::default(),
|
||||
custom_sound_self_join: None,
|
||||
custom_sound_peer_join: None,
|
||||
@@ -348,6 +364,17 @@ impl AppConfig {
|
||||
})
|
||||
}
|
||||
|
||||
/// Path the processed custom-background PNG (W16) is written to, alongside
|
||||
/// `config.json` in the app config dir. We store our own downscaled copy here
|
||||
/// (rather than base64 in the config) so the JSON stays small.
|
||||
pub fn background_path() -> Option<PathBuf> {
|
||||
dirs::config_dir().map(|mut p| {
|
||||
p.push("peerspeak");
|
||||
p.push("background.png");
|
||||
p
|
||||
})
|
||||
}
|
||||
|
||||
pub fn load() -> Self {
|
||||
if let Some(path) = Self::config_path()
|
||||
&& let Ok(contents) = fs::read_to_string(&path)
|
||||
|
||||
Reference in New Issue
Block a user