Skip to content

Commit

Permalink
fixed floating element
Browse files Browse the repository at this point in the history
  • Loading branch information
genusistimelord committed Nov 7, 2023
1 parent 74579cf commit fed6e4b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ default = [
"number_input",
"date_picker",
"color_picker",
#"floating_element",
"floating_element",
#"icon_text",
#"grid",
#"modal",
Expand Down Expand Up @@ -89,8 +89,8 @@ members = [
#"examples/cupertino/cupertino_spinner",
#"examples/cupertino/cupertino_switch",
"examples/date_picker",
#"examples/floating_element",
#"examples/floating_element_anchors",
"examples/floating_element",
"examples/floating_element_anchors",
#"examples/grid",
#"examples/modal",
#"examples/modal_component",
Expand Down
6 changes: 4 additions & 2 deletions src/native/floating_element.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,10 @@ where
self.underlay.as_widget().height()
}

fn layout(&self, renderer: &Renderer, limits: &Limits) -> Node {
self.underlay.as_widget().layout(renderer, limits)
fn layout(&self, tree: &mut Tree, renderer: &Renderer, limits: &Limits) -> Node {
self.underlay
.as_widget()
.layout(&mut tree.children[0], renderer, limits)
}

fn on_event(
Expand Down
7 changes: 5 additions & 2 deletions src/native/overlay/floating_element.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,15 @@ impl<'a, 'b, Message, Renderer> core::Overlay<Message, Renderer>
where
Renderer: core::Renderer,
{
fn layout(&self, renderer: &Renderer, _bounds: Size, position: Point) -> layout::Node {
fn layout(&mut self, renderer: &Renderer, _bounds: Size, position: Point) -> 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)
.height(Length::Fill);
let mut node = self.element.as_widget().layout(renderer, &limits);
let mut node = self
.element
.as_widget()
.layout(&mut self.state, renderer, &limits);

Check failure on line 67 in src/native/overlay/floating_element.rs

View workflow job for this annotation

GitHub Actions / all

this expression creates a reference which is immediately dereferenced by the compiler

let position = match self.anchor {
Anchor::NorthWest => Point::new(position.x + self.offset.x, position.y + self.offset.y),
Expand Down

0 comments on commit fed6e4b

Please sign in to comment.