Rename theme::Definition to application::StyleSheet
This commit is contained in:
parent
3e8f4cdd13
commit
7f3b7075db
12 changed files with 37 additions and 27 deletions
|
|
@ -2,6 +2,7 @@
|
|||
use crate::mouse;
|
||||
use crate::{Error, Executor, Runtime};
|
||||
|
||||
pub use iced_winit::application::StyleSheet;
|
||||
pub use iced_winit::Application;
|
||||
|
||||
use iced_graphics::window;
|
||||
|
|
@ -9,7 +10,6 @@ use iced_winit::application;
|
|||
use iced_winit::conversion;
|
||||
use iced_winit::futures;
|
||||
use iced_winit::futures::channel::mpsc;
|
||||
use iced_winit::theme::{self, Definition as _};
|
||||
use iced_winit::user_interface;
|
||||
use iced_winit::{Clipboard, Debug, Proxy, Settings};
|
||||
|
||||
|
|
@ -26,7 +26,7 @@ where
|
|||
A: Application + 'static,
|
||||
E: Executor + 'static,
|
||||
C: window::GLCompositor<Renderer = A::Renderer> + 'static,
|
||||
<A::Renderer as iced_native::Renderer>::Theme: theme::Definition,
|
||||
<A::Renderer as iced_native::Renderer>::Theme: StyleSheet,
|
||||
{
|
||||
use futures::task;
|
||||
use futures::Future;
|
||||
|
|
@ -205,7 +205,7 @@ async fn run_instance<A, E, C>(
|
|||
A: Application + 'static,
|
||||
E: Executor + 'static,
|
||||
C: window::GLCompositor<Renderer = A::Renderer> + 'static,
|
||||
<A::Renderer as iced_native::Renderer>::Theme: theme::Definition,
|
||||
<A::Renderer as iced_native::Renderer>::Theme: StyleSheet,
|
||||
{
|
||||
use glutin::event;
|
||||
use iced_winit::futures::stream::StreamExt;
|
||||
|
|
|
|||
|
|
@ -76,6 +76,7 @@ pub use iced_core::{
|
|||
Rectangle, Size, Vector,
|
||||
};
|
||||
pub use iced_futures::{executor, futures};
|
||||
pub use iced_style::application;
|
||||
pub use iced_style::theme;
|
||||
|
||||
#[doc(no_inline)]
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use crate::application;
|
||||
use crate::mouse;
|
||||
use crate::theme;
|
||||
use crate::user_interface::{self, UserInterface};
|
||||
use crate::{Clipboard, Command, Debug, Event, Point, Program, Size};
|
||||
|
||||
|
|
@ -20,7 +20,7 @@ where
|
|||
impl<P> State<P>
|
||||
where
|
||||
P: Program + 'static,
|
||||
<P::Renderer as crate::Renderer>::Theme: theme::Definition,
|
||||
<P::Renderer as crate::Renderer>::Theme: application::StyleSheet,
|
||||
{
|
||||
/// Creates a new [`State`] with the provided [`Program`], initializing its
|
||||
/// primitive with the given logical bounds and renderer.
|
||||
|
|
@ -168,7 +168,7 @@ fn build_user_interface<'a, P: Program>(
|
|||
debug: &mut Debug,
|
||||
) -> UserInterface<'a, P::Message, P::Renderer>
|
||||
where
|
||||
<P::Renderer as crate::Renderer>::Theme: theme::Definition,
|
||||
<P::Renderer as crate::Renderer>::Theme: application::StyleSheet,
|
||||
{
|
||||
debug.view_started();
|
||||
let view = program.view();
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
//! Implement your own event loop to drive a user interface.
|
||||
use crate::application;
|
||||
use crate::event::{self, Event};
|
||||
use crate::layout;
|
||||
use crate::mouse;
|
||||
use crate::renderer;
|
||||
use crate::theme::{self, Definition as _};
|
||||
use crate::{Clipboard, Element, Layout, Point, Rectangle, Shell, Size};
|
||||
|
||||
/// A set of interactive graphical elements with a specific [`Layout`].
|
||||
|
|
@ -29,7 +29,7 @@ pub struct UserInterface<'a, Message, Renderer> {
|
|||
impl<'a, Message, Renderer> UserInterface<'a, Message, Renderer>
|
||||
where
|
||||
Renderer: crate::Renderer,
|
||||
Renderer::Theme: theme::Definition,
|
||||
Renderer::Theme: application::StyleSheet,
|
||||
{
|
||||
/// Builds a user interface for an [`Element`].
|
||||
///
|
||||
|
|
@ -373,7 +373,10 @@ where
|
|||
renderer,
|
||||
theme,
|
||||
&renderer::Style {
|
||||
text_color: theme.text_color(),
|
||||
text_color: {
|
||||
use application::StyleSheet;
|
||||
theme.text_color()
|
||||
},
|
||||
},
|
||||
Layout::new(&self.base),
|
||||
base_cursor,
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
use crate::theme;
|
||||
use crate::window;
|
||||
use crate::{Command, Element, Executor, Settings, Subscription};
|
||||
|
||||
pub use iced_native::application::StyleSheet;
|
||||
|
||||
/// An interactive cross-platform application.
|
||||
///
|
||||
/// This trait is the main entrypoint of Iced. Once implemented, you can run
|
||||
|
|
@ -102,7 +103,7 @@ pub trait Application: Sized {
|
|||
type Message: std::fmt::Debug + Send;
|
||||
|
||||
/// The theme of your [`Application`].
|
||||
type Theme: Default + theme::Definition;
|
||||
type Theme: Default + StyleSheet;
|
||||
|
||||
/// The data needed to initialize your [`Application`].
|
||||
type Flags;
|
||||
|
|
|
|||
|
|
@ -174,18 +174,18 @@
|
|||
#![doc(
|
||||
html_logo_url = "https://raw.githubusercontent.com/iced-rs/iced/9ab6923e943f784985e9ef9ca28b10278297225d/docs/logo.svg"
|
||||
)]
|
||||
#![deny(missing_docs)]
|
||||
//#![deny(missing_docs)]
|
||||
#![deny(missing_debug_implementations)]
|
||||
#![deny(unused_results)]
|
||||
#![forbid(unsafe_code)]
|
||||
#![forbid(rust_2018_idioms)]
|
||||
#![cfg_attr(docsrs, feature(doc_cfg))]
|
||||
mod application;
|
||||
mod element;
|
||||
mod error;
|
||||
mod result;
|
||||
mod sandbox;
|
||||
|
||||
pub mod application;
|
||||
pub mod clipboard;
|
||||
pub mod executor;
|
||||
pub mod keyboard;
|
||||
|
|
|
|||
|
|
@ -95,9 +95,9 @@
|
|||
//! [the original widgets]: crate::widget
|
||||
//! [`button::State`]: crate::widget::button::State
|
||||
//! [impure `Application`]: crate::Application
|
||||
pub mod application;
|
||||
pub mod widget;
|
||||
|
||||
mod application;
|
||||
mod sandbox;
|
||||
|
||||
pub use application::Application;
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
use crate::pure::{self, Pure};
|
||||
use crate::theme;
|
||||
use crate::window;
|
||||
use crate::{Command, Executor, Settings, Subscription};
|
||||
|
||||
pub use iced_native::application::StyleSheet;
|
||||
|
||||
/// A pure version of [`Application`].
|
||||
///
|
||||
/// Unlike the impure version, the `view` method of this trait takes an
|
||||
|
|
@ -23,7 +24,7 @@ pub trait Application: Sized {
|
|||
type Message: std::fmt::Debug + Send;
|
||||
|
||||
/// The theme of your [`Application`].
|
||||
type Theme: Default + theme::Definition;
|
||||
type Theme: Default + StyleSheet;
|
||||
|
||||
/// The data needed to initialize your [`Application`].
|
||||
type Flags;
|
||||
|
|
|
|||
7
style/src/application.rs
Normal file
7
style/src/application.rs
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
use iced_core::Color;
|
||||
|
||||
pub trait StyleSheet {
|
||||
fn background_color(&self) -> Color;
|
||||
|
||||
fn text_color(&self) -> Color;
|
||||
}
|
||||
|
|
@ -9,6 +9,7 @@
|
|||
)]
|
||||
pub use iced_core::{Background, Color};
|
||||
|
||||
pub mod application;
|
||||
pub mod button;
|
||||
pub mod checkbox;
|
||||
pub mod container;
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ mod palette;
|
|||
|
||||
pub use self::palette::Palette;
|
||||
|
||||
use crate::application;
|
||||
use crate::button;
|
||||
use crate::slider;
|
||||
|
||||
|
|
@ -35,13 +36,7 @@ impl Default for Theme {
|
|||
}
|
||||
}
|
||||
|
||||
pub trait Definition {
|
||||
fn background_color(&self) -> Color;
|
||||
|
||||
fn text_color(&self) -> Color;
|
||||
}
|
||||
|
||||
impl Definition for Theme {
|
||||
impl application::StyleSheet for Theme {
|
||||
fn background_color(&self) -> Color {
|
||||
let palette = self.extended_palette();
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ pub use state::State;
|
|||
use crate::clipboard::{self, Clipboard};
|
||||
use crate::conversion;
|
||||
use crate::mouse;
|
||||
use crate::theme::{self, Definition as _};
|
||||
use crate::{
|
||||
Command, Debug, Error, Executor, Mode, Proxy, Runtime, Settings, Size,
|
||||
Subscription,
|
||||
|
|
@ -19,6 +18,8 @@ use iced_graphics::window;
|
|||
use iced_native::program::Program;
|
||||
use iced_native::user_interface::{self, UserInterface};
|
||||
|
||||
pub use iced_native::application::StyleSheet;
|
||||
|
||||
use std::mem::ManuallyDrop;
|
||||
|
||||
/// An interactive, native cross-platform application.
|
||||
|
|
@ -109,7 +110,7 @@ where
|
|||
A: Application + 'static,
|
||||
E: Executor + 'static,
|
||||
C: window::Compositor<Renderer = A::Renderer> + 'static,
|
||||
<A::Renderer as iced_native::Renderer>::Theme: theme::Definition,
|
||||
<A::Renderer as iced_native::Renderer>::Theme: StyleSheet,
|
||||
{
|
||||
use futures::task;
|
||||
use futures::Future;
|
||||
|
|
@ -245,7 +246,7 @@ async fn run_instance<A, E, C>(
|
|||
A: Application + 'static,
|
||||
E: Executor + 'static,
|
||||
C: window::Compositor<Renderer = A::Renderer> + 'static,
|
||||
<A::Renderer as iced_native::Renderer>::Theme: theme::Definition,
|
||||
<A::Renderer as iced_native::Renderer>::Theme: StyleSheet,
|
||||
{
|
||||
use iced_futures::futures::stream::StreamExt;
|
||||
use winit::event;
|
||||
|
|
@ -506,7 +507,7 @@ pub fn build_user_interface<'a, A: Application>(
|
|||
debug: &mut Debug,
|
||||
) -> UserInterface<'a, A::Message, A::Renderer>
|
||||
where
|
||||
<A::Renderer as crate::Renderer>::Theme: theme::Definition,
|
||||
<A::Renderer as crate::Renderer>::Theme: StyleSheet,
|
||||
{
|
||||
debug.view_started();
|
||||
let view = application.view();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue