Hide action panel and settings download info popups when clicking on backdrop

This commit is contained in:
Exidex 2024-08-27 21:30:25 +02:00
parent fc476dfe50
commit 74922b01ca
No known key found for this signature in database
GPG key ID: 46D8D21671EB48FA
2 changed files with 18 additions and 2 deletions

View file

@ -7,7 +7,7 @@ use anyhow::anyhow;
use iced::{Alignment, Font, Length};
use iced::alignment::Horizontal;
use iced::font::Weight;
use iced::widget::{button, checkbox, column, container, horizontal_rule, horizontal_space, image, pick_list, row, scrollable, Space, text, text_input, tooltip, vertical_rule};
use iced::widget::{button, checkbox, column, container, horizontal_rule, horizontal_space, image, pick_list, row, scrollable, Space, text, text_input, tooltip, vertical_rule, mouse_area};
use iced::widget::image::Handle;
use iced::widget::tooltip::Position;
use iced_aw::{floating_element, GridRow};
@ -1333,6 +1333,14 @@ fn render_root<'a>(
let content: Element<_> = column(vec![top_panel, top_separator, content, bottom_panel])
.into();
let content = if hide_action_panel {
content
} else {
mouse_area(content)
.on_press(ComponentWidgetEvent::ToggleActionPanel { widget_id })
.into()
};
floating_element(content, action_panel_element)
.offset(Offset::from([8.0, 40.0])) // TODO calculate based on theme
.hide(hide_action_panel)

View file

@ -3,7 +3,7 @@ use std::time::Duration;
use iced::{Alignment, alignment, Application, color, Command, executor, font, futures, Length, Padding, Settings, Size, Subscription, time, window};
use iced::advanced::Widget;
use iced::widget::{button, column, container, horizontal_rule, horizontal_space, row, scrollable, text};
use iced::widget::{button, column, container, horizontal_rule, horizontal_space, mouse_area, row, scrollable, text};
use iced_aw::{floating_element, Spinner};
use iced_aw::core::icons;
use iced_aw::floating_element::{Anchor, Offset};
@ -736,6 +736,14 @@ impl Application for ManagementAppModel {
.into()
};
let content = if !self.download_info_shown {
content
} else {
mouse_area(content)
.on_press(ManagementAppMsg::ToggleDownloadInfo)
.into()
};
floating_element(content, download_info_panel)
.offset(Offset::from([8.0, 60.0]))
.anchor(Anchor::NorthEast)