Skip to content

Commit

Permalink
Fix the formatting of the last changes
Browse files Browse the repository at this point in the history
  • Loading branch information
brianch committed Feb 5, 2024
1 parent a392d57 commit 6e41c6f
Show file tree
Hide file tree
Showing 17 changed files with 107 additions and 94 deletions.
6 changes: 4 additions & 2 deletions src/native/card.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use iced_widget::{
renderer, touch,
widget::{Operation, Tree},
Alignment, Border, Clipboard, Color, Element, Event, Layout, Length, Padding, Pixels,
Point, Rectangle, Shadow, Shell, Size, Vector, Widget
Point, Rectangle, Shadow, Shell, Size, Vector, Widget,
},
text::LineHeight,
};
Expand Down Expand Up @@ -595,7 +595,9 @@ where
.zip(layout.children())
.filter_map(|((child, state), layout)| {
layout.children().next().and_then(|child_layout| {
child.as_widget_mut().overlay(state, child_layout, renderer, translation)
child
.as_widget_mut()
.overlay(state, child_layout, renderer, translation)
})
})
.collect::<Vec<_>>();
Expand Down
12 changes: 7 additions & 5 deletions src/native/color_picker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use iced_widget::{
self,
tree::{self, Tag, Tree},
},
Clipboard, Color, Element, Event, Layout, Length, Point, Rectangle, Shell, Vector, Widget
Clipboard, Color, Element, Event, Layout, Length, Point, Rectangle, Shell, Vector, Widget,
},
renderer::Renderer,
};
Expand Down Expand Up @@ -247,10 +247,12 @@ where
let picker_state: &mut State = state.state.downcast_mut();

if !self.show_picker {
return self
.underlay
.as_widget_mut()
.overlay(&mut state.children[0], layout, renderer, translation);
return self.underlay.as_widget_mut().overlay(
&mut state.children[0],
layout,
renderer,
translation,
);
}

let bounds = layout.bounds();
Expand Down
17 changes: 10 additions & 7 deletions src/native/context_menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use iced_widget::core::{
mouse::{self, Button, Cursor},
overlay, renderer,
widget::{tree, Operation, Tree},
Clipboard, Element, Event, Layout, Length, Point, Rectangle, Shell, Vector, Widget
Clipboard, Element, Event, Layout, Length, Point, Rectangle, Shell, Vector, Widget,
};

use crate::native::overlay::ContextMenuOverlay;
Expand Down Expand Up @@ -223,10 +223,12 @@ where
let s: &mut State = state.state.downcast_mut();

if !s.show {
return self
.underlay
.as_widget_mut()
.overlay(&mut state.children[0], layout, renderer, translation);
return self.underlay.as_widget_mut().overlay(
&mut state.children[0],
layout,
renderer,
translation,
);
}

let position = s.cursor_position;
Expand All @@ -238,8 +240,9 @@ where
&mut state.children[1],
content,
self.style.clone(),
s
).overlay(),
s,
)
.overlay(),
)
}
}
Expand Down
12 changes: 7 additions & 5 deletions src/native/date_picker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use iced_widget::{
self,
tree::{Tag, Tree},
},
Clipboard, Element, Event, Layout, Length, Point, Rectangle, Shell, Vector, Widget
Clipboard, Element, Event, Layout, Length, Point, Rectangle, Shell, Vector, Widget,
},
renderer::Renderer,
text,
Expand Down Expand Up @@ -254,10 +254,12 @@ where
let picker_state: &mut State = state.state.downcast_mut();

if !self.show_picker {
return self
.underlay
.as_widget_mut()
.overlay(&mut state.children[0], layout, renderer, translation);
return self.underlay.as_widget_mut().overlay(
&mut state.children[0],
layout,
renderer,
translation,
);
}

let bounds = layout.bounds();
Expand Down
20 changes: 11 additions & 9 deletions src/native/floating_element.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use iced_widget::core::{
mouse::{self, Cursor},
overlay, renderer,
widget::{Operation, Tree},
Clipboard, Element, Event, Layout, Length, Rectangle, Shell, Vector, Widget
Clipboard, Element, Event, Layout, Length, Rectangle, Shell, Vector, Widget,
};

pub mod anchor;
Expand Down Expand Up @@ -214,25 +214,27 @@ where
translation: Vector,
) -> Option<overlay::Element<'b, Message, Theme, Renderer>> {
if self.hidden {
return self
.underlay
.as_widget_mut()
.overlay(&mut state.children[0], layout, renderer, translation);
return self.underlay.as_widget_mut().overlay(
&mut state.children[0],
layout,
renderer,
translation,
);
}

if state.children.len() == 2 {
let bounds = layout.bounds();

Some(overlay::Element::new(
Box::new(FloatingElementOverlay::new(
Some(overlay::Element::new(Box::new(
FloatingElementOverlay::new(
layout.position() + translation,
&mut state.children[1],
&mut self.element,
&self.anchor,
&self.offset,
bounds,
)),
))
),
)))
} else {
None
}
Expand Down
6 changes: 4 additions & 2 deletions src/native/grid/widget.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use iced_widget::core::{
overlay::Group,
renderer::Style,
widget::{Operation, Tree},
Clipboard, Element, Event, Layout, Length, Rectangle, Shell, Size, Vector, Widget
Clipboard, Element, Event, Layout, Length, Rectangle, Shell, Size, Vector, Widget,
};

use super::{layout::layout, types::Grid};
Expand Down Expand Up @@ -166,7 +166,9 @@ where
.zip(&mut tree.children)
.zip(layout.children())
.filter_map(|((child, state), layout)| {
child.as_widget_mut().overlay(state, layout, renderer, translation)
child
.as_widget_mut()
.overlay(state, layout, renderer, translation)
})
.collect::<Vec<_>>();

Expand Down
31 changes: 16 additions & 15 deletions src/native/modal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use iced_widget::core::{
mouse::{self, Cursor},
overlay, renderer,
widget::{Operation, Tree},
Clipboard, Element, Event, Layout, Length, Rectangle, Shell, Vector, Widget
Clipboard, Element, Event, Layout, Length, Rectangle, Shell, Vector, Widget,
};

pub use crate::style::modal::StyleSheet;
Expand Down Expand Up @@ -237,21 +237,22 @@ where
if let Some(overlay) = &mut self.overlay {
overlay.as_widget().diff(&mut state.children[1]);

Some(overlay::Element::new(
Box::new(ModalOverlay::new(
&mut state.children[1],
overlay,
self.backdrop.clone(),
self.esc.clone(),
self.style.clone(),
self.horizontal_alignment,
self.vertical_alignment,
)),
))
Some(overlay::Element::new(Box::new(ModalOverlay::new(
&mut state.children[1],
overlay,
self.backdrop.clone(),
self.esc.clone(),
self.style.clone(),
self.horizontal_alignment,
self.vertical_alignment,
))))
} else {
self.underlay
.as_widget_mut()
.overlay(&mut state.children[0], layout, renderer, translation)
self.underlay.as_widget_mut().overlay(
&mut state.children[0],
layout,
renderer,
translation,
)
}
}

Expand Down
6 changes: 1 addition & 5 deletions src/native/overlay/color_picker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -552,11 +552,7 @@ where
Message: 'static + Clone,
Theme: 'a + StyleSheet + button::StyleSheet + widget::text::StyleSheet,
{
fn layout(
&mut self,
renderer: &Renderer,
bounds: Size,
) -> Node {
fn layout(&mut self, renderer: &Renderer, bounds: Size) -> Node {
let (max_width, max_height) = if bounds.width > bounds.height {
(600.0, 300.0)
} else {
Expand Down
6 changes: 1 addition & 5 deletions src/native/overlay/context_menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,7 @@ where
Renderer: 'a + core::Renderer,
Theme: StyleSheet,
{
fn layout(
&mut self,
renderer: &Renderer,
bounds: Size,
) -> Node {
fn layout(&mut self, renderer: &Renderer, bounds: Size) -> Node {
let limits = Limits::new(Size::ZERO, bounds);
let max_size = limits.max();

Expand Down
6 changes: 1 addition & 5 deletions src/native/overlay/date_picker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -369,11 +369,7 @@ where
Theme: 'a + StyleSheet + button::StyleSheet + text::StyleSheet + container::StyleSheet,
{
#[allow(clippy::too_many_lines)]
fn layout(
&mut self,
renderer: &Renderer,
bounds: Size,
) -> Node {
fn layout(&mut self, renderer: &Renderer, bounds: Size) -> Node {
let limits = Limits::new(Size::ZERO, bounds)
.shrink(Padding::from(PADDING))
.width(Length::Fill)
Expand Down
23 changes: 14 additions & 9 deletions src/native/overlay/floating_element.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,7 @@ impl<'a, 'b, Message, Theme, Renderer> core::Overlay<Message, Theme, Renderer>
where
Renderer: core::Renderer,
{
fn layout(
&mut self,
renderer: &Renderer,
_bounds: Size,
) -> layout::Node {
fn layout(&mut self, renderer: &Renderer, _bounds: Size) -> layout::Node {
// Constrain overlay to fit inside the underlay's bounds
let limits = layout::Limits::new(Size::ZERO, self.underlay_bounds.size())
.width(Length::Fill)
Expand All @@ -81,18 +77,25 @@ where
.layout(self.state, renderer, &limits);

let position = match self.anchor {
Anchor::NorthWest => Point::new(self.position.x + self.offset.x, self.position.y + self.offset.y),
Anchor::NorthWest => Point::new(
self.position.x + self.offset.x,
self.position.y + self.offset.y,
),
Anchor::NorthEast => Point::new(
self.position.x + self.underlay_bounds.width - node.bounds().width - self.offset.x,
self.position.y + self.offset.y,
),
Anchor::SouthWest => Point::new(
self.position.x + self.offset.x,
self.position.y + self.underlay_bounds.height - node.bounds().height - self.offset.y,
self.position.y + self.underlay_bounds.height
- node.bounds().height
- self.offset.y,
),
Anchor::SouthEast => Point::new(
self.position.x + self.underlay_bounds.width - node.bounds().width - self.offset.x,
self.position.y + self.underlay_bounds.height - node.bounds().height - self.offset.y,
self.position.y + self.underlay_bounds.height
- node.bounds().height
- self.offset.y,
),
Anchor::North => Point::new(
self.position.x + self.underlay_bounds.width / 2.0 - node.bounds().width / 2.0
Expand All @@ -107,7 +110,9 @@ where
Anchor::South => Point::new(
self.position.x + self.underlay_bounds.width / 2.0 - node.bounds().width / 2.0
+ self.offset.x,
self.position.y + self.underlay_bounds.height - node.bounds().height - self.offset.y,
self.position.y + self.underlay_bounds.height
- node.bounds().height
- self.offset.y,
),
Anchor::West => Point::new(
self.position.x + self.offset.x,
Expand Down
10 changes: 3 additions & 7 deletions src/native/overlay/modal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ use iced_widget::core::{
mouse::{self, Cursor},
renderer, touch,
widget::Tree,
Alignment, Border, Clipboard, Color, Element, Event, Layout, Overlay, Rectangle, Shadow,
Shell, Size,
Alignment, Border, Clipboard, Color, Element, Event, Layout, Overlay, Rectangle, Shadow, Shell,
Size,
};

use crate::style::modal::StyleSheet;
Expand Down Expand Up @@ -69,11 +69,7 @@ where
Renderer: core::Renderer,
Theme: StyleSheet,
{
fn layout(
&mut self,
renderer: &Renderer,
bounds: Size,
) -> layout::Node {
fn layout(&mut self, renderer: &Renderer, bounds: Size) -> layout::Node {
let limits = layout::Limits::new(Size::ZERO, bounds);
let mut content = self
.content
Expand Down
6 changes: 1 addition & 5 deletions src/native/overlay/time_picker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -509,11 +509,7 @@ where
Message: 'static + Clone,
Theme: 'a + StyleSheet + button::StyleSheet + text::StyleSheet + container::StyleSheet,
{
fn layout(
&mut self,
renderer: &Renderer,
bounds: Size,
) -> Node {
fn layout(&mut self, renderer: &Renderer, bounds: Size) -> Node {
let limits = Limits::new(Size::ZERO, bounds)
.shrink(Padding::from(PADDING))
.width(Length::Fill)
Expand Down
11 changes: 7 additions & 4 deletions src/native/split.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use iced_widget::{
Operation, Tree,
},
Border, Clipboard, Color, Element, Event, Layout, Length, Padding, Point, Rectangle,
Shadow, Shell, Size, Vector, Widget
Shadow, Shell, Size, Vector, Widget,
},
Container, Row,
};
Expand Down Expand Up @@ -516,9 +516,12 @@ where
.as_widget_mut()
.overlay(&mut first_state[0], first_layout, renderer, translation)
.or_else(|| {
second
.as_widget_mut()
.overlay(&mut second_state[0], second_layout, renderer, translation)
second.as_widget_mut().overlay(
&mut second_state[0],
second_layout,
renderer,
translation,
)
})
}
}
Expand Down
11 changes: 9 additions & 2 deletions src/native/tabs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use iced_widget::{
tree::{State, Tag},
Operation, Tree,
},
Clipboard, Element, Event, Layout, Length, Point, Rectangle, Shell, Size, Vector, Widget
Clipboard, Element, Event, Layout, Length, Point, Rectangle, Shell, Size, Vector, Widget,
},
runtime::Font,
text, Row,
Expand Down Expand Up @@ -570,7 +570,14 @@ where
self.tabs
.get_mut(idx)
.map(Element::as_widget_mut)
.and_then(|w| w.overlay(&mut state.children[1].children[idx], layout, renderer, translation))
.and_then(|w| {
w.overlay(
&mut state.children[1].children[idx],
layout,
renderer,
translation,
)
})
})
}

Expand Down
Loading

0 comments on commit 6e41c6f

Please sign in to comment.