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-color: var(--md-surface-variant);
}
/* Container */

View file

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

View file

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

View file

@ -558,6 +558,7 @@ struct MetaData<T: Clone + Send> {
struct UiElements<T: Clone> {
app: Application,
window: ApplicationWindow,
background: Option<ApplicationWindow>,
search: SearchEntry,
main_box: FlowBox,
menu_rows: ArcMenuMap<T>,
@ -663,9 +664,12 @@ fn build_ui<T, P>(
.default_height(1)
.build();
let background = create_background(config);
let ui_elements = Rc::new(UiElements {
app,
window,
background,
search: SearchEntry::new(),
main_box: FlowBox::new(),
menu_rows: Arc::new(RwLock::new(HashMap::new())),
@ -742,6 +746,16 @@ fn build_ui<T, P>(
let window_start = Instant::now();
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() {
let background = ApplicationWindow::builder()
.decorated(false)
@ -753,14 +767,12 @@ fn build_ui<T, P>(
.build();
background.set_widget_name("background");
background.set_namespace(Some("worf"));
background.present();
Some(background)
} 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>>) {
ui_elements.main_box.set_widget_name("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}");
}
});
if let Some(background) = &ui.background {
background.hide();
}
ui.window.hide();
close_gui(&ui_clone.app);
}