diff options
| author | 2022-11-03 05:09:07 +0100 | |
|---|---|---|
| committer | 2022-11-03 05:09:07 +0100 | |
| commit | 921c94162e50b09604fafeeb319c4a424d64be0e (patch) | |
| tree | eff2e63d6cbef2732bd9f29c5733181191ef0a12 /native/src/widget | |
| parent | 93e309f491a8941bafb919e75d660e65071475f4 (diff) | |
| parent | 231d2fd8454eb9d24ba970131d4d7339cc0c8d51 (diff) | |
| download | iced-921c94162e50b09604fafeeb319c4a424d64be0e.tar.gz iced-921c94162e50b09604fafeeb319c4a424d64be0e.tar.bz2 iced-921c94162e50b09604fafeeb319c4a424d64be0e.zip | |
Merge branch 'master' into fear/linear-gradients
Diffstat (limited to '')
| -rw-r--r-- | native/src/widget/pane_grid.rs | 46 | ||||
| -rw-r--r-- | native/src/widget/pane_grid/content.rs | 17 | ||||
| -rw-r--r-- | native/src/widget/pick_list.rs | 6 | ||||
| -rw-r--r-- | native/src/widget/text_input.rs | 8 | 
4 files changed, 43 insertions, 34 deletions
| diff --git a/native/src/widget/pane_grid.rs b/native/src/widget/pane_grid.rs index d84fb7a0..96cf78ef 100644 --- a/native/src/widget/pane_grid.rs +++ b/native/src/widget/pane_grid.rs @@ -341,6 +341,7 @@ where                          cursor_position,                          viewport,                          renderer, +                        self.on_drag.is_some(),                      )                  })                  .max() @@ -648,7 +649,7 @@ pub fn mouse_interaction(      resize_leeway: Option<u16>,  ) -> Option<mouse::Interaction> {      if action.picked_pane().is_some() { -        return Some(mouse::Interaction::Grab); +        return Some(mouse::Interaction::Grabbing);      }      let resize_axis = @@ -756,27 +757,12 @@ pub fn draw<Renderer, T>(          cursor_position      }; +    let mut render_picked_pane = None; +      for ((id, pane), layout) in elements.zip(layout.children()) {          match picked_pane {              Some((dragging, origin)) if id == dragging => { -                let bounds = layout.bounds(); - -                renderer.with_translation( -                    cursor_position -                        - Point::new(bounds.x + origin.x, bounds.y + origin.y), -                    |renderer| { -                        renderer.with_layer(bounds, |renderer| { -                            draw_pane( -                                pane, -                                renderer, -                                default_style, -                                layout, -                                pane_cursor_position, -                                viewport, -                            ); -                        }); -                    }, -                ); +                render_picked_pane = Some((pane, origin, layout));              }              _ => {                  draw_pane( @@ -791,6 +777,28 @@ pub fn draw<Renderer, T>(          }      } +    // Render picked pane last +    if let Some((pane, origin, layout)) = render_picked_pane { +        let bounds = layout.bounds(); + +        renderer.with_translation( +            cursor_position +                - Point::new(bounds.x + origin.x, bounds.y + origin.y), +            |renderer| { +                renderer.with_layer(bounds, |renderer| { +                    draw_pane( +                        pane, +                        renderer, +                        default_style, +                        layout, +                        pane_cursor_position, +                        viewport, +                    ); +                }); +            }, +        ); +    }; +      if let Some((axis, split_region, is_picked)) = picked_split {          let highlight = if is_picked {              theme.picked_split(style) diff --git a/native/src/widget/pane_grid/content.rs b/native/src/widget/pane_grid/content.rs index 98ce2c4b..c236d820 100644 --- a/native/src/widget/pane_grid/content.rs +++ b/native/src/widget/pane_grid/content.rs @@ -115,25 +115,25 @@ where              let show_controls = bounds.contains(cursor_position); -            title_bar.draw( -                &tree.children[1], +            self.body.as_widget().draw( +                &tree.children[0],                  renderer,                  theme,                  style, -                title_bar_layout, +                body_layout,                  cursor_position,                  viewport, -                show_controls,              ); -            self.body.as_widget().draw( -                &tree.children[0], +            title_bar.draw( +                &tree.children[1],                  renderer,                  theme,                  style, -                body_layout, +                title_bar_layout,                  cursor_position,                  viewport, +                show_controls,              );          } else {              self.body.as_widget().draw( @@ -238,6 +238,7 @@ where          cursor_position: Point,          viewport: &Rectangle,          renderer: &Renderer, +        drag_enabled: bool,      ) -> mouse::Interaction {          let (body_layout, title_bar_interaction) =              if let Some(title_bar) = &self.title_bar { @@ -247,7 +248,7 @@ where                  let is_over_pick_area = title_bar                      .is_over_pick_area(title_bar_layout, cursor_position); -                if is_over_pick_area { +                if is_over_pick_area && drag_enabled {                      return mouse::Interaction::Grab;                  } diff --git a/native/src/widget/pick_list.rs b/native/src/widget/pick_list.rs index c334804e..896f5b35 100644 --- a/native/src/widget/pick_list.rs +++ b/native/src/widget/pick_list.rs @@ -348,9 +348,9 @@ where              let state = state();              let event_status = if state.is_open { -                // TODO: Encode cursor availability in the type system -                state.is_open = -                    cursor_position.x < 0.0 || cursor_position.y < 0.0; +                // Event wasn't processed by overlay, so cursor was clicked either outside it's +                // bounds or on the drop-down, either way we close the overlay. +                state.is_open = false;                  event::Status::Captured              } else if layout.bounds().contains(cursor_position) { diff --git a/native/src/widget/text_input.rs b/native/src/widget/text_input.rs index c2d25520..54a6aaf8 100644 --- a/native/src/widget/text_input.rs +++ b/native/src/widget/text_input.rs @@ -92,7 +92,7 @@ where              is_secure: false,              font: Default::default(),              width: Length::Fill, -            padding: Padding::ZERO, +            padding: Padding::new(5),              size: None,              on_change: Box::new(on_change),              on_paste: None, @@ -712,14 +712,14 @@ where                  }                  return event::Status::Captured; +            } else { +                state.is_pasting = None;              }          }          Event::Keyboard(keyboard::Event::ModifiersChanged(modifiers)) => {              let state = state(); -            if state.is_focused { -                state.keyboard_modifiers = modifiers; -            } +            state.keyboard_modifiers = modifiers;          }          _ => {}      } | 
