expose wry background color option
This commit is contained in:
1 parent
11c9abcf7c
commit
1e5c220736
2 files changed
+14
No files matched your search
@@ -23,6 +23,7 @@ pub struct Config {
|
|||||||
pub(crate) custom_head: Option<String>,
|
pub(crate) custom_head: Option<String>,
|
||||||
pub(crate) custom_index: Option<String>,
|
pub(crate) custom_index: Option<String>,
|
||||||
pub(crate) root_name: String,
|
pub(crate) root_name: String,
|
||||||
|
pub(crate) background_color: Option<(u8, u8, u8, u8)>,
|
||||||
}
|
}
|
||||||
|
|
||||||
type DropHandler = Box<dyn Fn(&Window, FileDropEvent) -> bool>;
|
type DropHandler = Box<dyn Fn(&Window, FileDropEvent) -> bool>;
|
||||||
@@ -50,6 +51,7 @@ impl Config {
|
|||||||
custom_head: None,
|
custom_head: None,
|
||||||
custom_index: None,
|
custom_index: None,
|
||||||
root_name: "main".to_string(),
|
root_name: "main".to_string(),
|
||||||
|
background_color: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -137,6 +139,14 @@ impl Config {
|
|||||||
self.root_name = name.into();
|
self.root_name = name.into();
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Sets the background color of the WebView.
|
||||||
|
/// This will be set before the HTML is rendered and can be used to prevent flashing when the page loads.
|
||||||
|
/// Accepts a color in RGBA format
|
||||||
|
pub fn with_background_color(mut self, color: (u8, u8, u8, u8)) -> Self {
|
||||||
|
self.background_color = Some(color);
|
||||||
|
self
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for Config {
|
impl Default for Config {
|
||||||
|
|||||||
@@ -64,6 +64,10 @@ pub fn build(
|
|||||||
webview = webview.with_browser_accelerator_keys(false);
|
webview = webview.with_browser_accelerator_keys(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if let Some(color) = cfg.background_color {
|
||||||
|
webview = webview.with_background_color(color);
|
||||||
|
}
|
||||||
|
|
||||||
// These are commented out because wry is currently broken in wry
|
// These are commented out because wry is currently broken in wry
|
||||||
// let mut web_context = WebContext::new(cfg.data_dir.clone());
|
// let mut web_context = WebContext::new(cfg.data_dir.clone());
|
||||||
// .with_web_context(&mut web_context);
|
// .with_web_context(&mut web_context);
|
||||||
|
|||||||
Reference in new issue
Block a user