Skip to content

Improve ViewBox and support of pointers for transformed views - #2392

Merged
mergify[bot] merged 24 commits into
masterfrom
dev/dr/ViewBox
Jan 6, 2020
Merged

mergify[bot] merged 24 commits into
masterfrom
dev/dr/ViewBox

Conversation

@dr1rrb

@dr1rrb dr1rrb commented Dec 23, 2019

Copy link
Copy Markdown
Member

GitHub Issue:
fixes #2257
fixes #2256
fixes #2135
#2266

Bugfix / Feature

Improve the ViewBox to better support new pointer events

What is the current behavior?

  1. On Android, the over events are taking in consideration the "static transform" (a.k.a. RenderTransform)
  2. On Android, the ACTION_HOVER_MOVE and the ACTION_HOVER_EXIT might not be dispatched to the right control (so they are muted) if 2 siblings are transformed.
  3. The ViewBox alters the RenderTransform of its Child
  4. The default alignments of the ViewBox are not the same as UWP (centered / centered)
  5. Each platform has its own implementation of UIElement.TransformToVisual. On iOS and Android the implementation are only applying a translate of the bounds, but does not apply the full transformation.

What is the new behavior?

  1. The opposite...
  2. The opposite...
  3. The opposite...
  4. The opposite...
  5. The WASM implementation of the UIElement.TransformToVisual has been multi-targeted and pointer events are now using it on each platform to compute the Location of the pointer relative to another control.

PR Checklist

  • Tested code with current supported SDKs
  • Docs have been added/updated which fit documentation template (for bug fixes / features)
  • Unit Tests and/or UI Tests for the changes have been added (for bug fixes / features) (if applicable)
  • Wasm UI Tests are not showing unexpected any differences. Validate PR Screenshots Compare Test Run results.
  • Contains NO breaking changes
  • Updated the Release Notes
  • Associated with an issue (GitHub or internal)

@dr1rrb dr1rrb added the platform/android 🤖 Categorizes an issue or PR as relevant to the Android platform label Dec 23, 2019
@dr1rrb dr1rrb self-assigned this Dec 23, 2019
@gitpod-io

gitpod-io Bot commented Dec 23, 2019 •

Copy link
Copy Markdown

@dr1rrb dr1rrb added the platform/ios 🍎 Categorizes an issue or PR as relevant to the iOS platform label Dec 23, 2019
@github-actions github-actions Bot added area/automation Categorizes an issue or PR as relevant to project automation area/build Categorizes an issue or PR as relevant to build infrastructure platform/wasm 🌐 Categorizes an issue or PR as relevant to the WebAssembly platform kind/documentation labels Dec 23, 2019
@dr1rrb

dr1rrb commented Dec 23, 2019 •

Copy link
Copy Markdown
Member Author

Note: This PR currently includes the changes of #2249 which is expected to be merged before merging this one!

[EDIT] ==> Now ready to review :)

@dr1rrb dr1rrb changed the title Dev/dr/view box Improve ViewBox and support of pointers for transformed views Dec 23, 2019
@dr1rrb
dr1rrb marked this pull request as ready for review December 24, 2019 11:16
@dr1rrb dr1rrb added the ready-to-merge Automatically merge the PR once all '.mergify.yml' policies are met label Dec 24, 2019
@dr1rrb
dr1rrb requested review from carldebilly, davidjohnoliver and jeromelaban and removed request for jeromelaban December 24, 2019 11:27
@dr1rrb

dr1rrb commented Dec 24, 2019

Copy link
Copy Markdown
Member Author

/app run

@jeromelaban jeromelaban left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

A unit/runtime test for the transform may be interesting.

// (For instance on a HOVER_MOVE, if the pointer goes out of the current "cached target" we still make sure to
// send it to this "cached target" the event in order to raise the HOVER_EXIT)
private View _cachedTarget;
final View getCachedTarget() { return _cachedTarget; }

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Cached means "current" ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Kind of, as this "current" is relative to a given sequence (down / move / up or hover enter / move / exit) and it might be cleared depending of various factor (for instance when moving pointer over a sibling). I preferred the name "cached" as it really just to avoid re-calculation in that case ... but meh 🤷‍♂️ ...

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I will rename it in my next PR (multi touch) as I also change this file.

@dr1rrb

dr1rrb commented Jan 6, 2020

Copy link
Copy Markdown
Member Author

/azp run

{
private readonly double _epsilon;

public static RectCloseComparer Default { get; } = new RectCloseComparer(double.Epsilon);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I guess you're probably not using this one, but be aware that double.Epsilon is not a good epsilon ;) (It's much smaller than 'machine epsilon')

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yeah ... I learned it the hard way since a while ;)


final boolean isDown = event.getAction() == MotionEvent.ACTION_DOWN;
if (isDown) {
final boolean isBeginOfSequence = isDown || event.getAction() == MotionEvent.ACTION_HOVER_ENTER;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
final boolean isBeginOfSequence = isDown || event.getAction() == MotionEvent.ACTION_HOVER_ENTER;
final boolean isBeginningOfSequence = isDown || event.getAction() == MotionEvent.ACTION_HOVER_ENTER;

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes makes sense!

But like the comment from Jérôme, I'll fix it in my next PR as I already did some changes in that file (and especially I changed this variable usage).

final boolean isDown = event.getAction() == MotionEvent.ACTION_DOWN;
if (isDown) {
final boolean isBeginOfSequence = isDown || event.getAction() == MotionEvent.ACTION_HOVER_ENTER;
if (isBeginOfSequence) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
if (isBeginOfSequence) {
if (isBeginningOfSequence) {

}

if (isDown && !isMotionInView(event, view)) {
if (isBeginOfSequence && !isMotionInView(event, view)) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
if (isBeginOfSequence && !isMotionInView(event, view)) {
if (isBeginningOfSequence && !isMotionInView(event, view)) {

// to other controls.
// Note: We do this check only when starting a new manipulation (isDown), so the whole down->move->up sequence is ignored;
// Warning: We should also do this check for events that does not have strong sequence concept (e.g. Hover)
// Note: We do this check only when starting a new manipulation (isBeginOfSequence), so the whole down->move->up sequence is ignored;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
// Note: We do this check only when starting a new manipulation (isBeginOfSequence), so the whole down->move->up sequence is ignored;
// Note: We do this check only when starting a new manipulation (isBeginningOfSequence), so the whole down->move->up sequence is ignored;

@carldebilly carldebilly removed the ready-to-merge Automatically merge the PR once all '.mergify.yml' policies are met label Jan 6, 2020
@dr1rrb

dr1rrb commented Jan 6, 2020

Copy link
Copy Markdown
Member Author

/azp run

@dr1rrb dr1rrb added the ready-to-merge Automatically merge the PR once all '.mergify.yml' policies are met label Jan 6, 2020
@nventive-devops

Copy link
Copy Markdown
Contributor

The build 11315 found UI Test snapshots differences.

  • android-28: 2 changed over 219

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • PopupWithOverlay_After
    • ToggleSwitch_TemplateReuseTest_UITests_Shared_Windows_UI_Xaml_Controls_ToggleSwitchControl_ToggleSwitch_TemplateReuse
  • android-28-Snap: 15 changed over 638

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • Button_ComboBox_Simple_Uno_UI_Samples_Content_UITests_ButtonTestsControl_ComboBox_Simple
    • DefaultCategory_Grid_DataBound_ColumnRow_Definitions_Uno_UI_Samples_Content_UITests_GridTestsControl_Grid_DataBound_ColumnRow_Definitions
    • GridTestsControl_CenteredGridinGridwiththreefixedsizechildren_Uno_UI_Samples_Content_UITests_GridTestsControl_CenteredGridinGridwiththreefixedsizechildren
    • Animations_Sequential_Animations_SamplesApp_Windows_UI_Xaml_Media_Animation_SequentialAnimationsPage
    • ComboBox_UITests_Shared_Windows_UI_Xaml_Controls_ComboBox_ComboBox_DropDownPlacement_UITests_Shared_Windows_UI_Xaml_Controls_ComboBox_ComboBox_DropDownPlacement
    • ImageBrushTestControl_ImageBrush_StreamSource_Uno_UI_Samples_UITests_ImageBrushTestControl_ImageBrush_StreamSource
    • ListView_ListView_WithScrollViewer_SamplesApp_Windows_UI_Xaml_Controls_ListView_ListView_WithScrollViewer
    • Image_Image_Stretch_None_ScrollViewer_Uno_UI_Samples_UITests_ImageTestsControl_Image_Stretch_None_Containers
    • ListView_ListViewGroupedLargeLegacy_SamplesApp_Windows_UI_Xaml_Controls_ListView_ListViewGroupedLargeLegacy
    • ListView_ListViewResizableText_UITests_Shared_Windows_UI_Xaml_Controls_ListView_ListViewResizableText
    • TextBlockControl_TextBlock_FixedWidth_With_DataBound_Run_Uno_UI_Samples_Content_UITests_TextBlockControl_TextBlock_FixedWidth_With_DataBound_Run
    • TextBox_TextBox_Padding_In_Style_Uno_UI_Samples_Content_UITests_TextBoxControl_TextBox_Padding_In_Style
    • TextBox_Uno_UI_Samples_Content_UITests_TextBoxControl_PasswordBox_Reveal_Scroll_Uno_UI_Samples_Content_UITests_TextBoxControl_PasswordBox_Reveal_Scroll
    • TextBlockControl_TextBlockMultilineInStarStackPanel_Uno_UI_Samples_Content_UITests_TextBlockControl_TextBlockMultilineInStarStackPanel
    • UIElement_TransformToVisual_Transform_UITests_Shared_Windows_UI_Xaml_UIElementTests_TransformToVisual_Transform
  • ios: 7 changed over 109

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • Keyboard_Textbox_InsideScrollViewer_Validation_1_-_Remove_Focus_on_filledTextBox
    • Keyboard_Textbox_InsideScrollViewer_Validation_4_-_Remove_Focus_on_multilineTextBox
    • Keyboard_Textbox_NoScrollViewer_Validation_0_-_Remove_Focus_on_normalTextBox
    • Keyboard_Textbox_NoScrollViewer_Validation_2_-_Remove_Focus_on_placeholderTextTextBox
    • Keyboard_Textbox_NoScrollViewer_Validation_5_-_Remove_Focus_on_numberTextBox
    • DatePickerFlyout_Unloaded_UITests_Shared_Windows_UI_Xaml_Controls_DatePicker_DatePicker_SampleContent
    • Keyboard_Textbox_InsideScrollViewer_Validation_2_-_Remove_Focus_on_placeholderTextTextBox
  • ios-Snap: 9 changed over 629

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • Button_AppBarToggleButtonTest_Uno_UI_Samples_Content_UITests_ButtonTestsControl_AppBarToggleButtonTest
    • Button_ComboBox_Simple_Uno_UI_Samples_Content_UITests_ButtonTestsControl_ComboBox_Simple
    • CommandBar_CommandBar_Xaml_Automated_UITests_Shared_Windows_UI_Xaml_Controls_CommandBar_CommandBar_Xaml_Automated
    • MediaPlayerElement_Using__3gp_UITests_Shared_Windows_UI_Xaml_Controls_MediaPlayerElement_MediaPlayerElement_3gp_Extension
    • ImageBrushTestControl_ImageBrushWithCompositeTransform_Uno_UI_Samples_UITests_ImageBrushTestControl_ImageBrushWithCompositeTransform
    • Image_Uno_UI_Samples_UITests_Image_Image_Stretch_Alignment_Taller_Uno_UI_Samples_UITests_Image_Image_Stretch_Alignment_Taller
    • NavigationView_NavigationViewSample_SamplesApp_Samples_NavigationViewSample_NavigationViewSample
    • UIElement_TransformToVisual_Transform_UITests_Shared_Windows_UI_Xaml_UIElementTests_TransformToVisual_Transform
    • WebView_WebView_NavigateToUri_Uno_UI_Samples_Content_UITests_WebView_WebView_NavigateToUri
  • wasm: 6 changed over 642

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • SamplesApp.Samples.NavigationViewSample.NavigationViewSample
    • SamplesApp.Windows_UI_Xaml_Media.Animation.SequentialAnimationsPage
    • UITests.Shared.Windows_UI_Xaml.UIElementTests.TransformToVisual_Transform
    • UITests.Shared.Windows_UI_Xaml_Controls.CommandBar.CommandBar_Xaml_Automated
    • Uno.UI.Samples.Content.UITests.ButtonTestsControl.AppBarToggleButtonTest
    • Uno.UI.Samples.Content.UITests.CommandBar.CommandBar_Examples
  • wasm-automated: 10 changed over 288

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • LoadEmptyContentControl_ContentControlNoTemplateNoContent_-_bntContentClear
    • PopupWithOverlay_During
    • SequentialAnimations_SamplesApp_Windows_UI_Xaml_Media_Animation_SequentialAnimationsPage
    • When_TransformToVisual_ScrollViewer_UITests_Shared_Windows_UI_Xaml_UIElementTests_TransformToVisual_ScrollViewer
    • When_TransformToVisual_Transform_UITests_Shared_Windows_UI_Xaml_UIElementTests_TransformToVisual_Transform
    • XamlCommandBar_Automated_AfterClickMe
    • XamlCommandBar_Automated_AfterPlay
    • XamlCommandBar_Automated_AfterShuffle
    • XamlCommandBar_Automated_Initial
    • XamlCommandBar_Automated_UITests_Shared_Windows_UI_Xaml_Controls_CommandBar_CommandBar_Xaml_Automated

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 11332 found UI Test snapshots differences.

  • android-28: 2 changed over 219

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • PopupWithOverlay_After
    • ToggleSwitch_TemplateReuseTest_UITests_Shared_Windows_UI_Xaml_Controls_ToggleSwitchControl_ToggleSwitch_TemplateReuse
  • android-28-Snap: 11 changed over 638

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • Button_Custom_Button_With_ContentTemplate_Uno_UI_Samples_Content_UITests_ButtonTestsControl_Custom_Button_With_ContentTemplate
    • Animations_Sequential_Animations_SamplesApp_Windows_UI_Xaml_Media_Animation_SequentialAnimationsPage
    • ComboBox_UITests_Shared_Windows_UI_Xaml_Controls_ComboBox_ComboBox_DropDownPlacement_UITests_Shared_Windows_UI_Xaml_Controls_ComboBox_ComboBox_DropDownPlacement
    • ListView_ListViewGroupedLargeLegacy_SamplesApp_Windows_UI_Xaml_Controls_ListView_ListViewGroupedLargeLegacy
    • Image_Uno_UI_Samples_UITests_Image_Image_Stretch_Alignment_Bigger_Uno_UI_Samples_UITests_Image_Image_Stretch_Alignment_Bigger
    • ListView_ListViewResizableText_UITests_Shared_Windows_UI_Xaml_Controls_ListView_ListViewResizableText
    • ListView_ListView_WithScrollViewer_SamplesApp_Windows_UI_Xaml_Controls_ListView_ListView_WithScrollViewer
    • TextBlockControl_TextBoxSizeChanging_Uno_UI_Samples_Content_UITests_TextBlockControl_TextBoxSizeChanging
    • UIElement_TransformToVisual_Transform_UITests_Shared_Windows_UI_Xaml_UIElementTests_TransformToVisual_Transform
    • TextBox_Uno_UI_Samples_Content_UITests_TextBoxControl_PasswordBox_Reveal_Scroll_Uno_UI_Samples_Content_UITests_TextBoxControl_PasswordBox_Reveal_Scroll
    • WebView_Javascript_AlertConfirmPrompt_Uno_UI_Samples_Content_UITests_WebView_WebViewControlJavaScriptAlertConfirmPrompt
  • ios: 5 changed over 109

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • Keyboard_Textbox_NoScrollViewer_Validation_1_-_Remove_Focus_on_filledTextBox
    • Keyboard_Textbox_NoScrollViewer_Validation_5_-_Remove_Focus_on_numberTextBox
    • DatePickerFlyout_Unloaded_UITests_Shared_Windows_UI_Xaml_Controls_DatePicker_DatePicker_SampleContent
    • Keyboard_Textbox_InsideScrollViewer_Validation_0_-_Remove_Focus_on_normalTextBox
    • Keyboard_Textbox_NoScrollViewer_Validation_2_-_Remove_Focus_on_placeholderTextTextBox
  • ios-Snap: 11 changed over 629

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • Button_AppBarToggleButtonTest_Uno_UI_Samples_Content_UITests_ButtonTestsControl_AppBarToggleButtonTest
    • Button_ComboBox_Simple_Uno_UI_Samples_Content_UITests_ButtonTestsControl_ComboBox_Simple
    • ContentControlTestsControl_ContentControl_Nested_TemplatedParent_Uno_UI_Samples_Content_UITests_ContentControlTestsControl_ContentControl_Nested_TemplatedParent
    • CommandBar_CommandBar_Xaml_Automated_UITests_Shared_Windows_UI_Xaml_Controls_CommandBar_CommandBar_Xaml_Automated
    • DefaultCategory_Grid_DataBound_ColumnRow_Definitions_Uno_UI_Samples_Content_UITests_GridTestsControl_Grid_DataBound_ColumnRow_Definitions
    • Default_Uno_UI_Samples_UITests_Image_Image_Stretch_Uno_UI_Samples_UITests_Image_Image_Stretch
    • GridTestsControl_CenteredGridinGridwiththreefixedsizechildren_Uno_UI_Samples_Content_UITests_GridTestsControl_CenteredGridinGridwiththreefixedsizechildren
    • Image_Uno_UI_Samples_UITests_Image_Image_Stretch_Alignment_Equal_Uno_UI_Samples_UITests_Image_Image_Stretch_Alignment_Equal
    • NavigationView_NavigationViewSample_SamplesApp_Samples_NavigationViewSample_NavigationViewSample
    • UIElement_TransformToVisual_Transform_UITests_Shared_Windows_UI_Xaml_UIElementTests_TransformToVisual_Transform
    • WebView_WebView_NavigateToUri_Uno_UI_Samples_Content_UITests_WebView_WebView_NavigateToUri
  • wasm: 7 changed over 642

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • SamplesApp.Samples.NavigationViewSample.NavigationViewSample
    • SamplesApp.Windows_UI_Xaml_Media.Animation.SequentialAnimationsPage
    • SamplesApp.Windows_UI_Xaml_Controls.ListView.ListView_Image
    • UITests.Shared.Windows_UI_Xaml.UIElementTests.TransformToVisual_Transform
    • Uno.UI.Samples.Content.UITests.ButtonTestsControl.AppBarToggleButtonTest
    • UITests.Shared.Windows_UI_Xaml_Controls.CommandBar.CommandBar_Xaml_Automated
    • Uno.UI.Samples.Content.UITests.CommandBar.CommandBar_Examples
  • wasm-automated: 7 changed over 288

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • When_TransformToVisual_ScrollViewer_UITests_Shared_Windows_UI_Xaml_UIElementTests_TransformToVisual_ScrollViewer
    • When_TransformToVisual_Transform_UITests_Shared_Windows_UI_Xaml_UIElementTests_TransformToVisual_Transform
    • XamlCommandBar_Automated_AfterClickMe
    • XamlCommandBar_Automated_AfterPlay
    • XamlCommandBar_Automated_AfterShuffle
    • XamlCommandBar_Automated_Initial
    • XamlCommandBar_Automated_UITests_Shared_Windows_UI_Xaml_Controls_CommandBar_CommandBar_Xaml_Automated

@mergify
mergify Bot merged commit ef77519 into master Jan 6, 2020
@delete-merged-branch
delete-merged-branch Bot deleted the dev/dr/ViewBox branch January 6, 2020 23:35
@dr1rrb dr1rrb mentioned this pull request Jan 7, 2020
5 of 7 tasks
@dr1rrb

dr1rrb commented Jan 7, 2020 •

Copy link
Copy Markdown
Member Author

This is also expected to fix https://stackoverflow.com/questions/59027861/content-not-centered-in-viewbox-and-incorect-mouse-coord-in-viewbox/59180616

Stack Overflow
Hi I am trying to port an app to android with uno platform. I am having a strange behavior of the viewbox in android, the following code work as expected in uwp version of the uno app I created for

@dr1rrb dr1rrb mentioned this pull request Jan 7, 2020
2 of 7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/automation Categorizes an issue or PR as relevant to project automation area/build Categorizes an issue or PR as relevant to build infrastructure platform/android 🤖 Categorizes an issue or PR as relevant to the Android platform platform/ios 🍎 Categorizes an issue or PR as relevant to the iOS platform platform/wasm 🌐 Categorizes an issue or PR as relevant to the WebAssembly platform ready-to-merge Automatically merge the PR once all '.mergify.yml' policies are met

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pointer events has wrong location when in a ViewBox on Android ViewBox default alignment ViewBox is altering the RenderTransform of its child

5 participants