Implement basic cursor availability

This commit is contained in:
Héctor Ramón Jiménez 2023-06-08 20:11:59 +02:00
parent c15f1b5f65
commit 34451bff18
No known key found for this signature in database
GPG key ID: 140CC052C94F138E
55 changed files with 731 additions and 886 deletions

View file

@ -8,8 +8,8 @@ use crate::core::text;
use crate::core::touch;
use crate::core::widget::Tree;
use crate::core::{
Alignment, Clipboard, Element, Layout, Length, Pixels, Point, Rectangle,
Shell, Widget,
Alignment, Clipboard, Element, Layout, Length, Pixels, Rectangle, Shell,
Widget,
};
use crate::{Row, Text};
@ -204,7 +204,7 @@ where
_tree: &mut Tree,
event: Event,
layout: Layout<'_>,
cursor_position: Point,
cursor: mouse::Cursor,
_renderer: &Renderer,
_clipboard: &mut dyn Clipboard,
shell: &mut Shell<'_, Message>,
@ -212,7 +212,7 @@ where
match event {
Event::Mouse(mouse::Event::ButtonPressed(mouse::Button::Left))
| Event::Touch(touch::Event::FingerPressed { .. }) => {
let mouse_over = layout.bounds().contains(cursor_position);
let mouse_over = cursor.is_over(&layout.bounds());
if mouse_over {
shell.publish((self.on_toggle)(!self.is_checked));
@ -230,11 +230,11 @@ where
&self,
_tree: &Tree,
layout: Layout<'_>,
cursor_position: Point,
cursor: mouse::Cursor,
_viewport: &Rectangle,
_renderer: &Renderer,
) -> mouse::Interaction {
if layout.bounds().contains(cursor_position) {
if cursor.is_over(&layout.bounds()) {
mouse::Interaction::Pointer
} else {
mouse::Interaction::default()
@ -248,11 +248,10 @@ where
theme: &Renderer::Theme,
style: &renderer::Style,
layout: Layout<'_>,
cursor_position: Point,
cursor: mouse::Cursor,
_viewport: &Rectangle,
) {
let bounds = layout.bounds();
let is_mouse_over = bounds.contains(cursor_position);
let is_mouse_over = cursor.is_over(&layout.bounds());
let mut children = layout.children();