Skip to content

Commit

Permalink
reformat
Browse files Browse the repository at this point in the history
fix clippy suggestions
  • Loading branch information
xarvic committed Jan 15, 2023
1 parent 7d0fef1 commit 198892f
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 10 deletions.
8 changes: 3 additions & 5 deletions druid/examples/viewport_header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
10 changes: 5 additions & 5 deletions druid/src/widget/align.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ impl<T> Align<T> {
/// 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
}
Expand All @@ -113,10 +113,10 @@ impl<T> Align<T> {
// 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();
Expand Down
6 changes: 6 additions & 0 deletions druid/src/widget/flex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}

Expand All @@ -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,
}

Expand Down
2 changes: 2 additions & 0 deletions druid/src/widget/viewport_header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit 198892f

Please sign in to comment.