hide background with main window

This commit is contained in:
Alexander Mohr 2025-06-03 22:43:32 +02:00
parent c8724a9068
commit db2ae90268
4 changed files with 26 additions and 18 deletions

View file

@ -25,7 +25,6 @@ body {
} }
#background { #background {
background-color: var(--md-surface-variant);
} }
/* Container */ /* Container */

View file

@ -6,7 +6,7 @@ content_halign="Center"
height="105%" height="105%"
width="100%" width="100%"
valign="Start" valign="Start"
blurred_background=false blurred_background=true
line_max_chars=32 line_max_chars=32
key_detection_type="Code" key_detection_type="Code"
term="kitty -e" term="kitty -e"

View file

@ -16,7 +16,7 @@
} }
#background { #background {
background-color: rgba(33, 33, 33, 0.25); background-color: rgba(33, 33, 33, 0.1);
backdrop-filter: blur(12px); backdrop-filter: blur(12px);
width: 100vw; width: 100vw;
height: 100vh; height: 100vh;
@ -29,16 +29,13 @@
#window { #window {
all: unset; all: unset;
background-color: rgba(33, 33, 33, 0.1); /* #212121BB */ background-color: transparent;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;
width: 100%; width: 100%;
max-width: 1200px; max-width: 1200px;
margin-top: 2em; margin: 2em 15em 5em;
margin-left: 15em;
margin-right: 15em;
margin-bottom: 5em;
} }
/* Outer-box is the app container grid */ /* Outer-box is the app container grid */
@ -63,10 +60,7 @@
border-radius: 6px; border-radius: 6px;
text-align: center; text-align: center;
outline: none; outline: none;
margin-left: 25em; margin: 2em 25em 5em;
margin-right: 25em;
margin-bottom: 5em;
margin-top: 2em;
} }
#input:focus, #input:focus,

View file

@ -558,6 +558,7 @@ struct MetaData<T: Clone + Send> {
struct UiElements<T: Clone> { struct UiElements<T: Clone> {
app: Application, app: Application,
window: ApplicationWindow, window: ApplicationWindow,
background: Option<ApplicationWindow>,
search: SearchEntry, search: SearchEntry,
main_box: FlowBox, main_box: FlowBox,
menu_rows: ArcMenuMap<T>, menu_rows: ArcMenuMap<T>,
@ -663,9 +664,12 @@ fn build_ui<T, P>(
.default_height(1) .default_height(1)
.build(); .build();
let background = create_background(config);
let ui_elements = Rc::new(UiElements { let ui_elements = Rc::new(UiElements {
app, app,
window, window,
background,
search: SearchEntry::new(), search: SearchEntry::new(),
main_box: FlowBox::new(), main_box: FlowBox::new(),
menu_rows: Arc::new(RwLock::new(HashMap::new())), menu_rows: Arc::new(RwLock::new(HashMap::new())),
@ -742,6 +746,16 @@ fn build_ui<T, P>(
let window_start = Instant::now(); let window_start = Instant::now();
ui_elements.window.present(); ui_elements.window.present();
if let Some(background) = &ui_elements.background {
background.present();
}
log::debug!("window show took {:?}", window_start.elapsed());
log::debug!("Building UI took {:?}", start.elapsed(),);
}
fn create_background(config: &Config) -> Option<ApplicationWindow> {
if config.blurred_background() { if config.blurred_background() {
let background = ApplicationWindow::builder() let background = ApplicationWindow::builder()
.decorated(false) .decorated(false)
@ -753,14 +767,12 @@ fn build_ui<T, P>(
.build(); .build();
background.set_widget_name("background"); background.set_widget_name("background");
background.set_namespace(Some("worf")); background.set_namespace(Some("worf"));
Some(background)
background.present(); } else {
None
}
} }
log::debug!("window show took {:?}", window_start.elapsed());
log::debug!("Building UI took {:?}", start.elapsed(),);
}
fn build_main_box<T: Clone + 'static>(config: &Config, ui_elements: &Rc<UiElements<T>>) { fn build_main_box<T: Clone + 'static>(config: &Config, ui_elements: &Rc<UiElements<T>>) {
ui_elements.main_box.set_widget_name("inner-box"); ui_elements.main_box.set_widget_name("inner-box");
ui_elements.main_box.set_css_classes(&["inner-box"]); ui_elements.main_box.set_css_classes(&["inner-box"]);
@ -1359,6 +1371,9 @@ fn send_selected_item<T>(
log::error!("failed to send message {e}"); log::error!("failed to send message {e}");
} }
}); });
if let Some(background) = &ui.background {
background.hide();
}
ui.window.hide(); ui.window.hide();
close_gui(&ui_clone.app); close_gui(&ui_clone.app);
} }