Revert "improved documentation and refactored naming to be more self-explanatory"

This reverts commit adfbb6c380.
This commit is contained in:
Pascal committed 2023-12-07 17:11:56 +01:00
1 parent adfbb6c380
commit 906c466e78
91 files changed
+1553 -1663

No files matched your search

+5 -7
View File
@@ -36,7 +36,7 @@ pub struct Config {
pub(crate) root_name: String,
pub(crate) background_color: Option<(u8, u8, u8, u8)>,
pub(crate) last_window_close_behaviour: WindowCloseBehaviour,
pub(crate) enable_default_menu_bar: bool,
pub(crate) disable_default_menu_bar: bool,
}
type DropHandler = Box<dyn Fn(&Window, FileDropEvent) -> bool>;
@@ -66,15 +66,13 @@ impl Config {
root_name: "main".to_string(),
background_color: None,
last_window_close_behaviour: WindowCloseBehaviour::LastWindowExitsApp,
enable_default_menu_bar: true,
disable_default_menu_bar: false,
}
}
/// Set whether the default menu bar should be enabled.
///
/// > Note: `enable` is `true` by default. To disable the default menu bar pass `false`.
pub fn with_default_menu_bar(mut self, enable: bool) -> Self {
self.enable_default_menu_bar = enable;
/// Set whether the default menu bar should be disabled.
pub fn with_disable_default_menu_bar(mut self, disable: bool) -> Self {
self.disable_default_menu_bar = disable;
self
}
+9 -11
View File
@@ -240,20 +240,18 @@ pub fn launch_with_props<P: 'static>(root: Component<P>, props: P, cfg: Config)
Event::UserEvent(event) => match event.0 {
#[cfg(all(feature = "hot-reload", debug_assertions))]
EventData::HotReloadEvent(msg) => {
match msg {
dioxus_hot_reload::HotReloadMsg::UpdateTemplate(template) => {
for webview in webviews.values_mut() {
webview.dom.replace_template(template);
EventData::HotReloadEvent(msg) => match msg {
dioxus_hot_reload::HotReloadMsg::UpdateTemplate(template) => {
for webview in webviews.values_mut() {
webview.dom.replace_template(template);
poll_vdom(webview);
}
}
dioxus_hot_reload::HotReloadMsg::Shutdown => {
*control_flow = ControlFlow::Exit;
poll_vdom(webview);
}
}
}
dioxus_hot_reload::HotReloadMsg::Shutdown => {
*control_flow = ControlFlow::Exit;
}
},
EventData::CloseWindow => {
webviews.remove(&event.1);
+4 -8
View File
@@ -19,8 +19,8 @@ pub fn build(
let index_file = cfg.custom_index.clone();
let root_name = cfg.root_name.clone();
if cfg.enable_default_menu_bar {
builder = builder.with_menu(build_default_menu_bar());
if !cfg.disable_default_menu_bar {
builder = builder.with_menu(create_default_menu_bar());
}
let window = builder.with_visible(false).build(event_loop).unwrap();
@@ -103,12 +103,8 @@ pub fn build(
(webview.build().unwrap(), web_context)
}
/// Builds a standard menu bar depending on the users platform. It may be used as a starting point
/// to further customize the menu bar and pass it to a [`WindowBuilder`](tao::window::WindowBuilder).
/// > Note: The default menu bar enables macOS shortcuts like cut/copy/paste.
/// > The menu bar differs per platform because of constraints introduced
/// > by [`MenuItem`](tao::menu::MenuItem).
pub fn build_default_menu_bar() -> MenuBar {
/// Creates a standard menu bar depending on the platform
fn create_default_menu_bar() -> MenuBar {
let mut menu_bar = MenuBar::new();
// since it is uncommon on windows to have an "application menu"