feat: Tooltips and Better Surface Management

This commit is contained in:
Ashley Wulber 2025-03-14 11:56:21 -04:00 committed by GitHub
parent c7edd37b03
commit 337b80d4ca
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
90 changed files with 3651 additions and 977 deletions

View file

@ -1,7 +1,7 @@
use ashpd::desktop::settings::{ColorScheme, Contrast};
use ashpd::desktop::Color;
use iced::futures::{self, select, FutureExt, SinkExt, StreamExt};
use iced_futures::{stream, subscription};
use iced_futures::stream;
use tracing::error;
#[derive(Debug, Clone)]
@ -27,7 +27,7 @@ pub fn desktop_settings() -> iced_futures::Subscription<Desktop> {
.await;
#[cfg(not(feature = "tokio"))]
{
pending::<()>().await;
futures::future::pending::<()>().await;
unreachable!();
}
attempts += 1;

View file

@ -756,9 +756,7 @@ impl slider::Catalog for Theme {
impl menu::Catalog for Theme {
type Class<'a> = ();
fn default<'a>() -> <Self as menu::Catalog>::Class<'a> {
()
}
fn default<'a>() -> <Self as menu::Catalog>::Class<'a> {}
fn style(&self, class: &<Self as menu::Catalog>::Class<'_>) -> menu::Style {
let cosmic = self.cosmic();
@ -779,9 +777,7 @@ impl menu::Catalog for Theme {
impl pick_list::Catalog for Theme {
type Class<'a> = ();
fn default<'a>() -> <Self as pick_list::Catalog>::Class<'a> {
()
}
fn default<'a>() -> <Self as pick_list::Catalog>::Class<'a> {}
fn style(
&self,
@ -824,9 +820,7 @@ impl pick_list::Catalog for Theme {
impl radio::Catalog for Theme {
type Class<'a> = ();
fn default<'a>() -> Self::Class<'a> {
()
}
fn default<'a>() -> Self::Class<'a> {}
fn style(&self, class: &Self::Class<'_>, status: radio::Status) -> radio::Style {
let theme = self.cosmic();
@ -878,9 +872,7 @@ impl radio::Catalog for Theme {
impl toggler::Catalog for Theme {
type Class<'a> = ();
fn default<'a>() -> Self::Class<'a> {
()
}
fn default<'a>() -> Self::Class<'a> {}
fn style(&self, class: &Self::Class<'_>, status: toggler::Status) -> toggler::Style {
let cosmic = self.cosmic();
@ -935,9 +927,7 @@ impl toggler::Catalog for Theme {
impl pane_grid::Catalog for Theme {
type Class<'a> = ();
fn default<'a>() -> <Self as pane_grid::Catalog>::Class<'a> {
()
}
fn default<'a>() -> <Self as pane_grid::Catalog>::Class<'a> {}
fn style(&self, class: &<Self as pane_grid::Catalog>::Class<'_>) -> pane_grid::Style {
let theme = self.cosmic();

View file

@ -1,6 +1,8 @@
// From iced_aw, license MIT
//! Change the appearance of menu bars and their menus.
use std::sync::Arc;
use crate::Theme;
use iced_widget::core::Color;
@ -33,19 +35,19 @@ pub trait StyleSheet {
}
/// The style of a menu bar and its menus
#[derive(Default)]
#[derive(Default, Clone)]
#[allow(missing_debug_implementations)]
pub enum MenuBarStyle {
/// The default style.
#[default]
Default,
/// A [`Theme`] that uses a `Custom` palette.
Custom(Box<dyn StyleSheet<Style = Theme>>),
Custom(Arc<dyn StyleSheet<Style = Theme>>),
}
impl From<fn(&Theme) -> Appearance> for MenuBarStyle {
fn from(f: fn(&Theme) -> Appearance) -> Self {
Self::Custom(Box::new(f))
Self::Custom(Arc::new(f))
}
}

View file

@ -31,3 +31,8 @@ pub use self::segmented_button::SegmentedButton;
mod text_input;
#[doc(inline)]
pub use self::text_input::TextInput;
#[cfg(all(feature = "wayland", feature = "winit"))]
pub mod tooltip;
#[cfg(all(feature = "wayland", feature = "winit"))]
pub use tooltip::Tooltip;

View file

@ -0,0 +1,31 @@
use iced::Color;
use crate::widget::wayland::tooltip::Catalog;
#[derive(Default)]
pub enum Tooltip {
#[default]
Default,
}
impl Catalog for crate::Theme {
type Class = Tooltip;
fn style(&self, style: &Self::Class) -> crate::widget::wayland::tooltip::Style {
let cosmic = self.cosmic();
match style {
Tooltip::Default => crate::widget::wayland::tooltip::Style {
text_color: cosmic.on_bg_color().into(),
background: None,
border_width: 0.0,
border_radius: cosmic.corner_radii.radius_0.into(),
border_color: Color::TRANSPARENT,
shadow_offset: iced::Vector::default(),
outline_width: Default::default(),
outline_color: Color::TRANSPARENT,
icon_color: None,
},
}
}
}