Skip to content

Commit 3642fe4

Browse files
committed
chore: use the new iced::theme::Theme
instead of create a new Appearance
1 parent 2452290 commit 3642fe4

File tree

14 files changed

+34
-99
lines changed

14 files changed

+34
-99
lines changed

iced_examples/bottom_panel/src/main.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ impl Panel {
6060
container(row).into()
6161
}
6262

63-
fn style(&self, theme: &iced::Theme) -> iced_layershell::Appearance {
64-
use iced_layershell::Appearance;
65-
Appearance {
63+
fn style(&self, theme: &iced::Theme) -> iced::theme::Style {
64+
use iced::theme::Style;
65+
Style {
6666
background_color: Color::TRANSPARENT,
6767
text_color: theme.palette().text,
6868
}

iced_examples/counter/src/main.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,9 @@ impl Application for Counter {
156156
.into()
157157
}
158158

159-
fn style(&self, theme: &Self::Theme) -> iced_layershell::Appearance {
160-
use iced_layershell::Appearance;
161-
Appearance {
159+
fn style(&self, theme: &Self::Theme) -> iced::theme::Style {
160+
use iced::theme::Style;
161+
Style {
162162
background_color: Color::TRANSPARENT,
163163
text_color: theme.palette().text,
164164
}

iced_examples/counter_pattern/src/main.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,9 @@ fn view(counter: &Counter) -> Element<Message> {
145145
.into()
146146
}
147147

148-
fn style(_counter: &Counter, theme: &iced::Theme) -> iced_layershell::Appearance {
149-
use iced_layershell::Appearance;
150-
Appearance {
148+
fn style(_counter: &Counter, theme: &iced::Theme) -> iced::theme::Style {
149+
use iced::theme::Style;
150+
Style {
151151
background_color: Color::TRANSPARENT,
152152
text_color: theme.palette().text,
153153
}

iced_examples/iced_virtualkeyboard/src/main.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ use iced::widget::canvas;
33
use iced::widget::canvas::{Cache, Event, Geometry, Path, Text};
44
use iced::{Color, Task as Command};
55
use iced::{Element, Length, Point, Rectangle, Renderer, Size, Theme};
6+
use iced_layershell::Application;
67
use iced_layershell::actions::LayershellCustomActions;
78
use iced_layershell::reexport::wl_keyboard::KeymapFormat;
89
use iced_layershell::reexport::{Anchor, KeyboardInteractivity};
910
use iced_layershell::settings::{LayerShellSettings, Settings, VirtualKeyboardSettings};
10-
use iced_layershell::{Appearance, Application};
1111
use std::collections::HashMap;
1212
use std::ffi::CString;
1313
use std::fs::File;
@@ -116,9 +116,9 @@ impl Application for KeyboardView {
116116
}
117117
}
118118

119-
fn style(&self, theme: &Self::Theme) -> Appearance {
120-
use iced_layershell::Appearance;
121-
Appearance {
119+
fn style(&self, theme: &Self::Theme) -> iced::theme::Style {
120+
use iced::theme::Style;
121+
Style {
122122
background_color: Color::TRANSPARENT,
123123
text_color: theme.palette().text,
124124
}

iced_layershell/examples/input_regions.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,9 @@ impl Application for InputRegionExample {
7070
.into()
7171
}
7272

73-
fn style(&self, theme: &Self::Theme) -> iced_layershell::Appearance {
74-
use iced_layershell::Appearance;
75-
Appearance {
73+
fn style(&self, theme: &Self::Theme) -> iced::theme::Style {
74+
use iced::theme::Style;
75+
Style {
7676
background_color: Color::from_rgba(0.3, 0.3, 0.3, 0.3),
7777
text_color: theme.palette().text,
7878
}

iced_layershell/src/application.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ where
7373

7474
/// Returns the `Style` variation of the `Theme`.
7575
fn style(&self, theme: &Self::Theme) -> Appearance {
76-
theme.default_style()
76+
theme.base()
7777
}
7878

7979
/// Returns the event `Subscription` for the current state of the

iced_layershell/src/build_pattern/application.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ pub trait Program: Sized {
8080
///
8181
/// [`Theme`]: Self::Theme
8282
fn style(&self, _state: &Self::State, theme: &Self::Theme) -> crate::Appearance {
83-
theme.default_style()
83+
theme.base()
8484
}
8585

8686
/// Returns the event [`Subscription`] for the current state of the

iced_layershell/src/build_pattern/daemon.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ pub trait Program: Sized {
8181
///
8282
/// [`Theme`]: Self::Theme
8383
fn style(&self, _state: &Self::State, theme: &Self::Theme) -> crate::Appearance {
84-
theme.default_style()
84+
theme.base()
8585
}
8686

8787
/// Returns the event [`Subscription`] for the current state of the

iced_layershell/src/lib.rs

Lines changed: 6 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -29,43 +29,15 @@ pub use iced_layershell_macros::to_layer_message;
2929

3030
pub use error::Error;
3131

32-
use iced::{Color, Element, Theme};
32+
use iced::Element;
3333
use iced_futures::Subscription;
3434

3535
pub use sandbox::LayerShellSandbox;
3636

3737
pub type Result = std::result::Result<(), error::Error>;
38-
/// The appearance of a program.
39-
#[derive(Debug, Clone, Copy, PartialEq)]
40-
pub struct Appearance {
41-
/// The background [`Color`] of the application.
42-
pub background_color: Color,
43-
44-
/// The default text [`Color`] of the application.
45-
pub text_color: Color,
46-
}
47-
48-
/// The default style of a [`Application`].
49-
pub trait DefaultStyle {
50-
/// Returns the default style of a [`Appearance`].
51-
fn default_style(&self) -> Appearance;
52-
}
53-
54-
impl DefaultStyle for Theme {
55-
fn default_style(&self) -> Appearance {
56-
default(self)
57-
}
58-
}
38+
use iced::theme::Style as Appearance;
5939

60-
/// The default [`Appearance`] of a [`Application`] with the built-in [`Theme`].
61-
pub fn default(theme: &Theme) -> Appearance {
62-
let palette = theme.extended_palette();
63-
64-
Appearance {
65-
background_color: palette.background.base.color,
66-
text_color: palette.background.base.text,
67-
}
68-
}
40+
use iced::theme::Base as DefaultStyle;
6941

7042
// layershell application
7143
pub trait Application: Sized {
@@ -129,7 +101,7 @@ pub trait Application: Sized {
129101
///
130102
/// [`Theme`]: Self::Theme
131103
fn style(&self, theme: &Self::Theme) -> Appearance {
132-
theme.default_style()
104+
theme.base()
133105
}
134106

135107
/// Returns the event [`Subscription`] for the current state of the
@@ -308,7 +280,7 @@ pub trait MultiApplication: Sized {
308280
///
309281
/// [`Theme`]: Self::Theme
310282
fn style(&self, theme: &Self::Theme) -> Appearance {
311-
theme.default_style()
283+
theme.base()
312284
}
313285

314286
/// Returns the event [`Subscription`] for the current state of the
@@ -447,7 +419,7 @@ mod tests {
447419
impl Application for TestApp {
448420
type Executor = iced::executor::Default;
449421
type Message = TestMessage;
450-
type Theme = Theme;
422+
type Theme = iced::Theme;
451423
type Flags = (i32, f64, String);
452424

453425
fn new(flags: Self::Flags) -> (Self, Task<Self::Message>) {
@@ -483,15 +455,6 @@ mod tests {
483455
}
484456
}
485457

486-
// Test default appearance
487-
#[test]
488-
fn test_default_appearance() {
489-
let theme = Theme::default();
490-
let appearance = theme.default_style();
491-
assert_eq!(appearance.background_color, Color::WHITE);
492-
assert_eq!(appearance.text_color, Color::BLACK);
493-
}
494-
495458
// Test namespace
496459
#[test]
497460
fn test_namespace() {

iced_layershell/src/multi_window.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ where
9191

9292
/// Returns the `Style` variation of the `Theme`.
9393
fn style(&self, theme: &Self::Theme) -> Appearance {
94-
theme.default_style()
94+
theme.base()
9595
}
9696

9797
/// Returns the event `Subscription` for the current state of the

0 commit comments

Comments
 (0)