summaryrefslogtreecommitdiffstats
path: root/graphics
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2021-10-18 15:19:04 +0700
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2021-10-18 15:19:04 +0700
commitedea093350e1b576e2b7db50c525e7fa5c3bea9f (patch)
treebcc93c11a804d04e5842cef6c2088911fd4ef822 /graphics
parent54a9a232f8110364972a8eef966b7b7477573f4f (diff)
downloadiced-edea093350e1b576e2b7db50c525e7fa5c3bea9f.tar.gz
iced-edea093350e1b576e2b7db50c525e7fa5c3bea9f.tar.bz2
iced-edea093350e1b576e2b7db50c525e7fa5c3bea9f.zip
Move `Defaults` from `iced_graphics` to `iced_native`
Diffstat (limited to 'graphics')
-rw-r--r--graphics/src/defaults.rs32
-rw-r--r--graphics/src/lib.rs4
-rw-r--r--graphics/src/renderer.rs12
-rw-r--r--graphics/src/widget/canvas.rs6
-rw-r--r--graphics/src/widget/qr_code.rs9
5 files changed, 16 insertions, 47 deletions
diff --git a/graphics/src/defaults.rs b/graphics/src/defaults.rs
deleted file mode 100644
index 11718a87..00000000
--- a/graphics/src/defaults.rs
+++ /dev/null
@@ -1,32 +0,0 @@
-//! Use default styling attributes to inherit styles.
-use iced_native::Color;
-
-/// Some default styling attributes.
-#[derive(Debug, Clone, Copy)]
-pub struct Defaults {
- /// Text styling
- pub text: Text,
-}
-
-impl Default for Defaults {
- fn default() -> Defaults {
- Defaults {
- text: Text::default(),
- }
- }
-}
-
-/// Some default text styling attributes.
-#[derive(Debug, Clone, Copy)]
-pub struct Text {
- /// The default color of text
- pub color: Color,
-}
-
-impl Default for Text {
- fn default() -> Text {
- Text {
- color: Color::BLACK,
- }
- }
-}
diff --git a/graphics/src/lib.rs b/graphics/src/lib.rs
index 9c113da6..dbd94e99 100644
--- a/graphics/src/lib.rs
+++ b/graphics/src/lib.rs
@@ -13,15 +13,14 @@
mod antialiasing;
mod error;
mod primitive;
-mod renderer;
mod transformation;
mod viewport;
pub mod backend;
-pub mod defaults;
pub mod font;
pub mod layer;
pub mod overlay;
+pub mod renderer;
pub mod triangle;
pub mod widget;
pub mod window;
@@ -31,7 +30,6 @@ pub use widget::*;
pub use antialiasing::Antialiasing;
pub use backend::Backend;
-pub use defaults::Defaults;
pub use error::Error;
pub use layer::Layer;
pub use primitive::Primitive;
diff --git a/graphics/src/renderer.rs b/graphics/src/renderer.rs
index 7ed06151..8d623868 100644
--- a/graphics/src/renderer.rs
+++ b/graphics/src/renderer.rs
@@ -1,8 +1,10 @@
use crate::backend::{self, Backend};
-use crate::{Defaults, Primitive, Vector};
+use crate::{Primitive, Vector};
use iced_native::layout;
use iced_native::renderer;
-use iced_native::{Color, Element, Font, Rectangle};
+use iced_native::{Element, Font, Rectangle};
+
+pub use iced_native::renderer::Style;
/// A backend-agnostic renderer that supports all the built-in widgets.
#[derive(Debug)]
@@ -33,8 +35,6 @@ impl<B> iced_native::Renderer for Renderer<B>
where
B: Backend,
{
- type Defaults = Defaults;
-
fn layout<'a, Message>(
&mut self,
element: &Element<'a, Message, Self>,
@@ -97,8 +97,8 @@ where
self.primitives.push(Primitive::Text {
content: text.content.to_string(),
bounds: text.bounds,
- size: text.size.unwrap_or(f32::from(self.backend.default_size())),
- color: text.color.unwrap_or(Color::BLACK),
+ size: text.size,
+ color: text.color,
font: text.font,
horizontal_alignment: text.horizontal_alignment,
vertical_alignment: text.vertical_alignment,
diff --git a/graphics/src/widget/canvas.rs b/graphics/src/widget/canvas.rs
index 7bf00ca5..3990c2b9 100644
--- a/graphics/src/widget/canvas.rs
+++ b/graphics/src/widget/canvas.rs
@@ -3,7 +3,9 @@
//! A [`Canvas`] widget can be used to draw different kinds of 2D shapes in a
//! [`Frame`]. It can be used for animation, data visualization, game graphics,
//! and more!
-use crate::{Backend, Defaults, Renderer};
+use crate::renderer::{self, Renderer};
+use crate::Backend;
+
use iced_native::layout;
use iced_native::{
Clipboard, Element, Hasher, Layout, Length, Point, Rectangle, Size, Widget,
@@ -187,7 +189,7 @@ where
fn draw(
&self,
_renderer: &mut Renderer<B>,
- _defaults: &Defaults,
+ _style: &renderer::Style,
_layout: Layout<'_>,
_cursor_position: Point,
_viewport: &Rectangle,
diff --git a/graphics/src/widget/qr_code.rs b/graphics/src/widget/qr_code.rs
index a809d99f..364b636b 100644
--- a/graphics/src/widget/qr_code.rs
+++ b/graphics/src/widget/qr_code.rs
@@ -1,10 +1,11 @@
//! Encode and display information in a QR code.
use crate::canvas;
-use crate::{Backend, Defaults, Renderer};
+use crate::renderer::{self, Renderer};
+use crate::Backend;
+use iced_native::layout;
use iced_native::{
- layout, Color, Element, Hasher, Layout, Length, Point, Rectangle, Size,
- Widget,
+ Color, Element, Hasher, Layout, Length, Point, Rectangle, Size, Widget,
};
use thiserror::Error;
@@ -81,7 +82,7 @@ where
fn draw(
&self,
_renderer: &mut Renderer<B>,
- _defaults: &Defaults,
+ _style: &renderer::Style,
_layout: Layout<'_>,
_cursor_position: Point,
_viewport: &Rectangle,