Skip to content

Conversation

@gspencergoog
Copy link
Contributor

@gspencergoog gspencergoog commented Apr 26, 2019

Description

This is a re-land of #31561, after fixing performance regressions.

Added change listening to the MouseTracker so that the Listener and tooltip can react to whether or not a mouse is connected at all. Added a change check to make sure Listener only repaints when something changed.

Here's a gist with the changes since the original change.

Fixes #22817

@gspencergoog gspencergoog force-pushed the fix_tooltip_hover branch 2 times, most recently from 2b02910 to 956c577 Compare April 26, 2019 23:05
@gspencergoog gspencergoog marked this pull request as ready for review April 26, 2019 23:09
@goderbauer goderbauer added f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels. labels Apr 29, 2019
@gspencergoog gspencergoog force-pushed the fix_tooltip_hover branch 5 times, most recently from c2b5a00 to 3ba2d9b Compare April 29, 2019 22:52
@gspencergoog
Copy link
Contributor Author

OK, @HansMuller, this is ready for another round. I've updated this with the code to not even wrap the Listener widget in the tooltip unless there is a mouse connected, and also changed the Listener to not add the layer unless a mouse is connected.

@gspencergoog gspencergoog requested a review from HansMuller April 29, 2019 22:59
@gspencergoog gspencergoog force-pushed the fix_tooltip_hover branch 3 times, most recently from ea3b74a to c80d1b2 Compare May 1, 2019 17:12
Copy link
Contributor

@HansMuller HansMuller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Just some random comments to prove that I read through all of it.

/// {@macro flutter.widgets.child}
final Widget child;

/// Specifies the decoration of the tooltip window.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tooltip's shape and background color?

If I'm not mistaken, there's no window here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was in the everythings-a-window sense. :-)

No, no window. Fixed.

/// Specifies the decoration of the tooltip window.
///
/// If not specified, defaults to a rounded rectangle with a border radius of
/// 4.0, and a color derived from the text theme.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are three text themes in ThemeData: textTheme, primaryTextTheme, accentTextTheme. Assuming that we're referring to the first one, then maybe mention [ThemeData.textTheme].

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, it's theme.textTheme or theme.primaryTextTheme, depending upon whether it's a dark theme or not. I didn't change the logic, and I wanted to say loosely what it was based on, but without repeating the conditionals. Probably better to just be explicit, though.

kind: kind,
pointer: pointer ?? _getNextPointer(),
);
await gesture.addPointer();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like a non-trivial change. Should the doc for the method reflect it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I removed it and moved it into the test, since I think that the createGesture should probably not assume anything about the events a test might need. I may introduce a startHover method that will do it, but for now I'll just put the addPointer into the test.

/// In a test, send a move event that moves the pointer by the given offset.
@visibleForTesting
Future<void> updateWithCustomEvent(PointerEvent event, { Duration timeStamp = Duration.zero }) {
Future<void> updateWithCustomEvent(PointerEvent event, {Duration timeStamp = Duration.zero}) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{ Duration timeStamp = Duration.zero } I think I mentioned this earlier. Flutter sources generally include the spaces before named parameters.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this is dartfmt really not helping me. Fixed everywhere in this file.

@gspencergoog gspencergoog merged commit 11e0a72 into flutter:master May 3, 2019
@gspencergoog gspencergoog deleted the fix_tooltip_hover branch May 15, 2019 16:29
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 6, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for showing tooltip on mouse hover

4 participants