feat: blur
This commit is contained in:
parent
1e49511fcf
commit
6bd07a6363
5 changed files with 119 additions and 95 deletions
29
src/main.rs
29
src/main.rs
|
|
@ -678,7 +678,7 @@ impl App {
|
|||
|
||||
// Update terminal window background color
|
||||
{
|
||||
let color = Color::from(theme.cosmic().background.base);
|
||||
let color = Color::from(theme.cosmic().background(theme.transparent).base);
|
||||
let bytes = color.into_rgba8();
|
||||
let data = u32::from(bytes[2])
|
||||
| (u32::from(bytes[1]) << 8)
|
||||
|
|
@ -1326,6 +1326,7 @@ impl App {
|
|||
}
|
||||
|
||||
fn settings(&self) -> Element<'_, Message> {
|
||||
let t = self.core().system_theme();
|
||||
let app_theme_selected = match self.config.app_theme {
|
||||
AppTheme::Dark => 1,
|
||||
AppTheme::Light => 2,
|
||||
|
|
@ -1409,13 +1410,13 @@ impl App {
|
|||
}),
|
||||
),
|
||||
)
|
||||
.add(
|
||||
.add_maybe((!t.transparent).then(|| {
|
||||
widget::settings::item::builder(fl!("opacity"))
|
||||
.description(format!("{}%", self.config.opacity))
|
||||
.control(widget::slider(0..=100, self.config.opacity, |opacity| {
|
||||
Message::Opacity(opacity)
|
||||
})),
|
||||
);
|
||||
}))
|
||||
}));
|
||||
|
||||
let mut font_section = widget::settings::section()
|
||||
.title(fl!("font"))
|
||||
|
|
@ -2954,7 +2955,9 @@ impl Application for App {
|
|||
let pos_y = _position.y as i32;
|
||||
|
||||
tasks.push(cosmic::task::message(Message::Surface(
|
||||
cosmic::surface::action::app_popup(move |_app: &mut Self| {
|
||||
cosmic::surface::action::app_popup(
|
||||
|_| Default::default(),
|
||||
move |_app: &mut Self| {
|
||||
use cosmic::cctk::wayland_protocols::xdg::shell::client::xdg_positioner::{Anchor, Gravity};
|
||||
use cosmic::iced::runtime::platform_specific::wayland::popup::{SctkPopupSettings, SctkPositioner};
|
||||
|
||||
|
|
@ -3425,7 +3428,9 @@ impl Application for App {
|
|||
|
||||
/// Creates a view after each update.
|
||||
fn view(&self) -> Element<'_, Self::Message> {
|
||||
let cosmic_theme::Spacing { space_xxs, .. } = self.core().system_theme().cosmic().spacing;
|
||||
let t = self.core().system_theme();
|
||||
let cosmic = t.cosmic();
|
||||
let cosmic_theme::Spacing { space_xxs, .. } = cosmic.spacing;
|
||||
|
||||
let pane_grid = PaneGrid::new(&self.pane_model.panes, |pane, tab_model, _is_maximized| {
|
||||
let mut tab_column = widget::column::with_capacity(1);
|
||||
|
|
@ -3445,10 +3450,10 @@ impl Application for App {
|
|||
.class(style::Container::Custom(Box::new(|theme| {
|
||||
let cosmic = theme.cosmic();
|
||||
cosmic::iced::widget::container::Style {
|
||||
icon_color: Some(Color::from(cosmic.background.on)),
|
||||
text_color: Some(Color::from(cosmic.background.on)),
|
||||
icon_color: Some(Color::from(cosmic.background(theme.transparent).on)),
|
||||
text_color: Some(Color::from(cosmic.background(theme.transparent).on)),
|
||||
background: Some(iced::Background::Color(
|
||||
cosmic.background.base.into(),
|
||||
cosmic.background(theme.transparent).base.into(),
|
||||
)),
|
||||
border: iced::Border::default(),
|
||||
shadow: iced::Shadow::default(),
|
||||
|
|
@ -3475,7 +3480,11 @@ impl Application for App {
|
|||
.on_open_hyperlink(Some(Box::new(Message::LaunchUrl)))
|
||||
.on_window_focused(|| Message::WindowFocused)
|
||||
.on_window_unfocused(|| Message::WindowUnfocused)
|
||||
.opacity(self.config.opacity_ratio())
|
||||
.opacity(if t.transparent {
|
||||
t.cosmic().alpha_map.blurred_alpha(t.cosmic().frosted)
|
||||
} else {
|
||||
self.config.opacity_ratio()
|
||||
})
|
||||
.padding(space_xxs)
|
||||
.sharp_corners(self.core.window.sharp_corners)
|
||||
.show_headerbar(self.config.show_headerbar);
|
||||
|
|
|
|||
13
src/menu.rs
13
src/menu.rs
|
|
@ -3,7 +3,7 @@
|
|||
use cosmic::iced::Point;
|
||||
use cosmic::widget::menu::key_bind::KeyBind;
|
||||
use cosmic::widget::menu::{Item as MenuItem, menu_button};
|
||||
use cosmic::widget::{Column, space};
|
||||
use cosmic::widget::space;
|
||||
use cosmic::{
|
||||
Element,
|
||||
app::Core,
|
||||
|
|
@ -45,7 +45,7 @@ pub fn context_menu<'a>(
|
|||
String::new()
|
||||
};
|
||||
fn key_style(theme: &cosmic::Theme) -> TextStyle {
|
||||
let mut color = theme.cosmic().background.component.on;
|
||||
let mut color = theme.cosmic().background(theme.transparent).component.on;
|
||||
color.alpha *= 0.75;
|
||||
TextStyle {
|
||||
color: Some(color.into()),
|
||||
|
|
@ -123,13 +123,13 @@ pub fn context_menu<'a>(
|
|||
);
|
||||
rows.insert(2, Element::from(divider::horizontal::light()));
|
||||
}
|
||||
let content = Column::with_children(rows);
|
||||
let content = widget::menu::menu_column::MenuColumn::with_children(rows);
|
||||
widget::container(content)
|
||||
.padding(1)
|
||||
//TODO: move style to libcosmic
|
||||
.style(|theme| {
|
||||
let cosmic = theme.cosmic();
|
||||
let component = &cosmic.background.component;
|
||||
let component = &cosmic.background(theme.transparent).component;
|
||||
widget::container::Style {
|
||||
icon_color: Some(component.on.into()),
|
||||
text_color: Some(component.on.into()),
|
||||
|
|
@ -154,7 +154,8 @@ pub fn color_scheme_menu<'a>(
|
|||
let menu_item =
|
||||
|label, message| menu_button(vec![widget::text(label).into()]).on_press(message);
|
||||
|
||||
let mut column = widget::column::with_capacity(if id_opt.is_some() { 3 } else { 1 });
|
||||
let mut column =
|
||||
widget::menu::menu_column::MenuColumn::with_capacity(if id_opt.is_some() { 3 } else { 1 });
|
||||
if let Some(id) = id_opt {
|
||||
column = column.push(menu_item(
|
||||
fl!("rename"),
|
||||
|
|
@ -177,7 +178,7 @@ pub fn color_scheme_menu<'a>(
|
|||
//TODO: move style to libcosmic
|
||||
.style(|theme| {
|
||||
let cosmic = theme.cosmic();
|
||||
let component = &cosmic.background.component;
|
||||
let component = &cosmic.background(theme.transparent).component;
|
||||
widget::container::Style {
|
||||
icon_color: Some(component.on.into()),
|
||||
text_color: Some(component.on.into()),
|
||||
|
|
|
|||
|
|
@ -756,7 +756,7 @@ where
|
|||
let scrollbar_color: Color = if pressed {
|
||||
// pressed_state_color, 0.5
|
||||
cosmic_theme
|
||||
.background
|
||||
.background(theme.transparent)
|
||||
.component
|
||||
.pressed
|
||||
.without_alpha()
|
||||
|
|
@ -766,7 +766,7 @@ where
|
|||
} else if hover {
|
||||
// hover_state_color, 0.2
|
||||
cosmic_theme
|
||||
.background
|
||||
.background(theme.transparent)
|
||||
.component
|
||||
.hover
|
||||
.without_alpha()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue