From 198892f61e18543c78b196a4ecdaaf574e9fe93f Mon Sep 17 00:00:00 2001 From: xarvic Date: Sun, 15 Jan 2023 12:21:50 +0100 Subject: [PATCH] reformat fix clippy suggestions --- druid/examples/viewport_header.rs | 8 +++----- druid/src/widget/align.rs | 10 +++++----- druid/src/widget/flex.rs | 6 ++++++ druid/src/widget/viewport_header.rs | 2 ++ 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/druid/examples/viewport_header.rs b/druid/examples/viewport_header.rs index 1e36b4021..db8d6e63c 100755 --- a/druid/examples/viewport_header.rs +++ b/druid/examples/viewport_header.rs @@ -18,15 +18,13 @@ // On Windows platform, don't show a console when opening the app. #![windows_subsystem = "windows"] -use druid::lens::Unit; use druid::widget::prelude::*; use druid::widget::{ - BackgroundBrush, Button, ClipBox, Controller, Flex, Label, List, Padding, Side, Slider, Tabs, - TextBox, ViewportHeader, + Button, Controller, Flex, Label, List, Side, TextBox, ViewportHeader, }; use druid::{ - AppLauncher, Color, Data, Insets, Lens, LocalizedString, Point, Rect, RoundedRectRadii, - Selector, Vec2, WidgetExt, WidgetPod, WindowDesc, + AppLauncher, Color, Data, Insets, Lens, LocalizedString, RoundedRectRadii, + Selector, WidgetExt, WindowDesc, }; use im::Vector; use std::sync::Arc; diff --git a/druid/src/widget/align.rs b/druid/src/widget/align.rs index c48b0c652..a6f6c2f85 100644 --- a/druid/src/widget/align.rs +++ b/druid/src/widget/align.rs @@ -91,7 +91,7 @@ impl Align { /// When the `Align` widget is fully visible, this option has no effect. When the align widget /// gets scrolled out of view, the wrapped widget will move to stay inside the visible area. /// The wrapped widget will always stay inside the bounds of the `Align` widget. - fn in_viewport(mut self) -> Self { + pub fn in_viewport(mut self) -> Self { self.in_viewport = true; self } @@ -113,10 +113,10 @@ impl Align { // Essentially Rect::intersect but if the two rectangles dont intersect this // implementation chooses the point closed to viewpor inside extra_space to always give // the child a valid origin. - extra_space.x0 = extra_space.x0.max(viewport.x0).min(extra_space.x1); - extra_space.y0 = extra_space.y0.max(viewport.y0).min(extra_space.y1); - extra_space.x1 = extra_space.x1.min(viewport.x1).max(extra_space.x0); - extra_space.y1 = extra_space.y1.min(viewport.y1).max(extra_space.y0); + extra_space.x0 = extra_space.x0.clamp(viewport.x0, extra_space.x1); + extra_space.y0 = extra_space.y0.clamp(viewport.y0, extra_space.y1); + extra_space.x1 = extra_space.x1.clamp(extra_space.x0, viewport.x1); + extra_space.y1 = extra_space.y1.clamp(extra_space.y0, viewport.y1); } let origin = self.align.resolve(extra_space).expand(); diff --git a/druid/src/widget/flex.rs b/druid/src/widget/flex.rs index b072acce3..e2287e628 100644 --- a/druid/src/widget/flex.rs +++ b/druid/src/widget/flex.rs @@ -202,7 +202,9 @@ pub enum Axis { /// This value is useful combination with an axis to indicate a side of a Rectangle. #[derive(Data, Debug, Clone, Copy, PartialEq, Eq)] pub enum Orientation { + /// Start Start, + /// End End, } @@ -219,9 +221,13 @@ impl Orientation { /// Represents one of the sides of a Rectangle. #[derive(Data, Debug, Clone, Copy, PartialEq, Eq)] pub enum Side { + /// The top side of a rectangle (y0). Top, + /// The left side of a rectangle (x0). Left, + /// The right side of a rectangle (x1). Right, + /// The bottom side of a rectangle (y1). Bottom, } diff --git a/druid/src/widget/viewport_header.rs b/druid/src/widget/viewport_header.rs index daf356d1e..3a8ee3a04 100644 --- a/druid/src/widget/viewport_header.rs +++ b/druid/src/widget/viewport_header.rs @@ -45,6 +45,8 @@ impl ViewportHeaderConfig { } } + /// The minimum visible content constrained by the the actual size of the content on that + /// axis. pub fn minimum_visible(&self) -> f64 { self.minimum_visible_content .min(self.header_side.axis().major(self.content_size))