Skip to content

Commit

Permalink
comment: cleanup imports
Browse files Browse the repository at this point in the history
  • Loading branch information
nicksenger committed Jun 8, 2023
1 parent 204c9d6 commit 56eacdb
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 65 deletions.
7 changes: 2 additions & 5 deletions examples/loading_spinners/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ edition = "2021"
publish = false

[dependencies]
flo_curves = "0.7"
iced = { path = "../..", features = ["canvas"] }
iced_core = { path = "../../core" }
iced_widget = { path = "../../widget" }
iced = { path = "../..", features = ["advanced", "canvas"] }
lyon_algorithms = "1"
once_cell = "1"
lyon = "1"
63 changes: 30 additions & 33 deletions examples/loading_spinners/src/circular.rs
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
//! Show a circular progress indicator.
use iced::widget::canvas::{self, Cursor, Program, Renderer as CanvasRenderer};
use iced::window;
use iced_core::event::{self, Event};
use iced_core::time::Instant;
use iced_core::widget::tree::{self, Tree};
use iced_core::window::RedrawRequest;
use iced_core::{layout, Size};
use iced_core::{renderer, Vector};
use iced_core::{
Background, Clipboard, Color, Element, Layout, Length, Point, Rectangle,
Renderer, Shell, Widget,
};
use iced::advanced::layout;
use iced::advanced::renderer;
use iced::advanced::widget::tree::{self, Tree};
use iced::advanced::{Clipboard, Layout, Renderer, Shell, Widget};
use iced::event;
use iced::time::Instant;
use iced::widget::canvas::{self, Cursor, Program};
use iced::window::{self, RedrawRequest};
use iced::{Background, Color, Element, Rectangle};
use iced::{Event, Length, Point, Size, Vector};

use super::easing::{self, Easing};

use std::f32::consts::PI;
use std::time::Duration;

type R<Theme> = iced_widget::renderer::Renderer<Theme>;
type R<Theme> = iced::Renderer<Theme>;

const MIN_RADIANS: f32 = PI / 8.0;
const WRAP_RADIANS: f32 = 2.0 * PI - PI / 4.0;
Expand Down Expand Up @@ -249,7 +247,7 @@ where

fn layout(
&self,
_renderer: &iced_widget::renderer::Renderer<Theme>,
_renderer: &iced::Renderer<Theme>,
limits: &layout::Limits,
) -> layout::Node {
let limits = limits.width(self.size).height(self.size);
Expand All @@ -264,7 +262,7 @@ where
event: Event,
_layout: Layout<'_>,
_cursor_position: Point,
_renderer: &iced_widget::renderer::Renderer<Theme>,
_renderer: &iced::Renderer<Theme>,
_clipboard: &mut dyn Clipboard,
shell: &mut Shell<'_, Message>,
) -> event::Status {
Expand Down Expand Up @@ -299,22 +297,22 @@ where
renderer.with_translation(
Vector::new(bounds.x, bounds.y),
|renderer| {
renderer.draw(<StateWithStyle<Theme> as Program<
Message,
R<Theme>,
>>::draw(
&StateWithStyle {
state,
style: &self.style,
bar_height: self.bar_height,
easing: self.easing,
},
&(),
canvas::Renderer::draw(
renderer,
theme,
bounds,
Cursor::Unavailable,
));
<StateWithStyle<Theme> as Program<Message, R<Theme>>>::draw(
&StateWithStyle {
state,
style: &self.style,
bar_height: self.bar_height,
easing: self.easing,
},
&(),
renderer,
theme,
bounds,
Cursor::Unavailable,
),
);
},
);
}
Expand Down Expand Up @@ -384,8 +382,7 @@ where
bar_height: f32,
}

impl<'a, Message, Theme>
canvas::Program<Message, iced_widget::renderer::Renderer<Theme>>
impl<'a, Message, Theme> Program<Message, iced::Renderer<Theme>>
for StateWithStyle<'a, Theme>
where
Theme: StyleSheet,
Expand All @@ -405,7 +402,7 @@ where
fn draw(
&self,
_state: &Self::State,
renderer: &iced_widget::renderer::Renderer<Theme>,
renderer: &iced::Renderer<Theme>,
theme: &Theme,
bounds: Rectangle,
_cursor: canvas::Cursor,
Expand Down
21 changes: 11 additions & 10 deletions examples/loading_spinners/src/easing.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
use iced_core::Point;
use lyon::algorithms::measure::PathMeasurements;
use lyon::path::builder::NoAttributes;
use lyon::path::path::BuilderImpl;
use lyon::path::Path;
use iced::Point;

use lyon_algorithms::measure::PathMeasurements;
use lyon_algorithms::path::{builder::NoAttributes, path::BuilderImpl, Path};
use once_cell::sync::Lazy;

pub static EMPHASIZED: Lazy<Easing> = Lazy::new(|| {
Expand Down Expand Up @@ -56,7 +54,7 @@ impl Easing {
pub fn y_at_x(&self, x: f32) -> f32 {
let mut sampler = self.measurements.create_sampler(
&self.path,
lyon::algorithms::measure::SampleType::Normalized,
lyon_algorithms::measure::SampleType::Normalized,
);
let sample = sampler.sample(x);

Expand All @@ -69,7 +67,7 @@ pub struct Builder(NoAttributes<BuilderImpl>);
impl Builder {
pub fn new() -> Self {
let mut builder = Path::builder();
builder.begin(lyon::geom::point(0.0, 0.0));
builder.begin(lyon_algorithms::geom::point(0.0, 0.0));

Self(builder)
}
Expand Down Expand Up @@ -110,7 +108,7 @@ impl Builder {
}

pub fn build(mut self) -> Easing {
self.0.line_to(lyon::geom::point(1.0, 1.0));
self.0.line_to(lyon_algorithms::geom::point(1.0, 1.0));
self.0.end(false);

let path = self.0.build();
Expand All @@ -119,9 +117,12 @@ impl Builder {
Easing { path, measurements }
}

fn point(p: impl Into<Point>) -> lyon::geom::Point<f32> {
fn point(p: impl Into<Point>) -> lyon_algorithms::geom::Point<f32> {
let p: Point = p.into();
lyon::geom::point(p.x.min(1.0).max(0.0), p.y.min(1.0).max(0.0))
lyon_algorithms::geom::point(
p.x.min(1.0).max(0.0),
p.y.min(1.0).max(0.0),
)
}
}

Expand Down
32 changes: 15 additions & 17 deletions examples/loading_spinners/src/linear.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
//! Show a linear progress indicator.
use iced::window;
use iced_core::event::{self, Event};
use iced_core::renderer;
use iced_core::time::Instant;
use iced_core::widget::tree::{self, Tree};
use iced_core::window::RedrawRequest;
use iced_core::{layout, Size};
use iced_core::{
Background, Clipboard, Color, Element, Layout, Length, Point, Rectangle,
Shell, Widget,
};
use iced::advanced::layout;
use iced::advanced::renderer::{self, Quad};
use iced::advanced::widget::tree::{self, Tree};
use iced::advanced::{Clipboard, Layout, Shell, Widget};
use iced::event;
use iced::time::Instant;
use iced::window::{self, RedrawRequest};
use iced::{Background, Color, Element, Rectangle};
use iced::{Event, Length, Point, Size};

use super::easing::{self, Easing};

Expand All @@ -18,7 +16,7 @@ use std::time::Duration;
#[allow(missing_debug_implementations)]
pub struct Linear<'a, Renderer>
where
Renderer: iced_core::Renderer,
Renderer: iced::advanced::Renderer,
Renderer::Theme: StyleSheet,
{
width: Length,
Expand All @@ -30,7 +28,7 @@ where

impl<'a, Renderer> Linear<'a, Renderer>
where
Renderer: iced_widget::core::Renderer,
Renderer: iced::advanced::Renderer,
Renderer::Theme: StyleSheet,
{
/// Creates a new [`Linear`] with the given content.
Expand Down Expand Up @@ -80,7 +78,7 @@ where

impl<'a, Renderer> Default for Linear<'a, Renderer>
where
Renderer: iced_core::Renderer,
Renderer: iced::advanced::Renderer,
Renderer::Theme: StyleSheet,
{
fn default() -> Self {
Expand Down Expand Up @@ -156,7 +154,7 @@ impl State {
impl<'a, Message, Renderer> Widget<Message, Renderer> for Linear<'a, Renderer>
where
Message: 'a + Clone,
Renderer: 'a + iced_core::Renderer,
Renderer: 'a + iced::advanced::Renderer,
Renderer::Theme: StyleSheet,
{
fn tag(&self) -> tree::Tag {
Expand Down Expand Up @@ -253,7 +251,7 @@ where
),

State::Contracting { progress, .. } => renderer.fill_quad(
renderer::Quad {
Quad {
bounds: Rectangle {
x: bounds.x
+ self.easing.y_at_x(*progress) * bounds.width,
Expand All @@ -276,7 +274,7 @@ impl<'a, Message, Renderer> From<Linear<'a, Renderer>>
for Element<'a, Message, Renderer>
where
Message: Clone + 'a,
Renderer: iced_core::Renderer + 'a,
Renderer: iced::advanced::Renderer + 'a,
Renderer::Theme: StyleSheet,
{
fn from(linear: Linear<'a, Renderer>) -> Self {
Expand Down

0 comments on commit 56eacdb

Please sign in to comment.