-
Notifications
You must be signed in to change notification settings - Fork 709
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Let teachingtip treat placement logically not physically #3165
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#include "pch.h" | ||
#include "pch.h" | ||
#include "common.h" | ||
#include "TeachingTip.h" | ||
#include "RuntimeProfiler.h" | ||
|
@@ -556,7 +556,7 @@ bool TeachingTip::PositionUntargetedPopup() | |
// offset property to determine the appropriate vertical and horizontal offsets of the popup that the tip is contained in. | ||
if (auto&& popup = m_popup.get()) | ||
{ | ||
switch (PreferredPlacement()) | ||
switch (GetFlowDirectionAdjustedPlacement(PreferredPlacement())) | ||
{ | ||
case winrt::TeachingTipPlacementMode::Auto: | ||
case winrt::TeachingTipPlacementMode::Bottom: | ||
|
@@ -1343,6 +1343,49 @@ void TeachingTip::ClosePopup() | |
} | ||
} | ||
|
||
winrt::TeachingTipPlacementMode TeachingTip::GetFlowDirectionAdjustedPlacement(const winrt::TeachingTipPlacementMode& placementMode) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
@jevansaks do you remember why we didn't do this for the initial check in? I know that we talked about it but I can't recall what we got hung up on. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry, unfortunately I don't remember either. |
||
{ | ||
if (FlowDirection() == winrt::FlowDirection::LeftToRight) | ||
{ | ||
return placementMode; | ||
} | ||
else | ||
{ | ||
switch (placementMode) | ||
{ | ||
case winrt::TeachingTipPlacementMode::Auto: | ||
return winrt::TeachingTipPlacementMode::Auto; | ||
case winrt::TeachingTipPlacementMode::Left: | ||
return winrt::TeachingTipPlacementMode::Right; | ||
case winrt::TeachingTipPlacementMode::Right: | ||
return winrt::TeachingTipPlacementMode::Left; | ||
case winrt::TeachingTipPlacementMode::Top: | ||
return winrt::TeachingTipPlacementMode::Top; | ||
case winrt::TeachingTipPlacementMode::Bottom: | ||
return winrt::TeachingTipPlacementMode::Bottom; | ||
case winrt::TeachingTipPlacementMode::LeftBottom: | ||
return winrt::TeachingTipPlacementMode::RightBottom; | ||
case winrt::TeachingTipPlacementMode::LeftTop: | ||
return winrt::TeachingTipPlacementMode::RightTop; | ||
case winrt::TeachingTipPlacementMode::TopLeft: | ||
return winrt::TeachingTipPlacementMode::TopRight; | ||
case winrt::TeachingTipPlacementMode::TopRight: | ||
return winrt::TeachingTipPlacementMode::TopLeft; | ||
case winrt::TeachingTipPlacementMode::RightTop: | ||
return winrt::TeachingTipPlacementMode::LeftTop; | ||
case winrt::TeachingTipPlacementMode::RightBottom: | ||
return winrt::TeachingTipPlacementMode::LeftBottom; | ||
case winrt::TeachingTipPlacementMode::BottomRight: | ||
return winrt::TeachingTipPlacementMode::BottomLeft; | ||
case winrt::TeachingTipPlacementMode::BottomLeft: | ||
return winrt::TeachingTipPlacementMode::BottomRight; | ||
case winrt::TeachingTipPlacementMode::Center: | ||
return winrt::TeachingTipPlacementMode::Center; | ||
} | ||
} | ||
return winrt::TeachingTipPlacementMode::Auto; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Is this needed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Either this or a default cause for our switch case, otherwise not all code paths would return a value according to the compiler. |
||
} | ||
|
||
void TeachingTip::OnTargetChanged() | ||
{ | ||
m_targetLayoutUpdatedRevoker.revoke(); | ||
|
@@ -1668,7 +1711,7 @@ std::tuple<winrt::TeachingTipPlacementMode, bool> TeachingTip::DetermineEffectiv | |
// SetReturnTopForOutOfWindowBounds test hook. | ||
if (!ShouldConstrainToRootBounds() && m_returnTopForOutOfWindowPlacement) | ||
{ | ||
auto const placement = PreferredPlacement(); | ||
auto const placement = GetFlowDirectionAdjustedPlacement(PreferredPlacement()); | ||
if (placement == winrt::TeachingTipPlacementMode::Auto) | ||
{ | ||
return std::make_tuple(winrt::TeachingTipPlacementMode::Top, false); | ||
|
@@ -1893,7 +1936,8 @@ std::tuple<winrt::TeachingTipPlacementMode, bool> TeachingTip::DetermineEffectiv | |
availability[winrt::TeachingTipPlacementMode::RightBottom] = false; | ||
} | ||
|
||
auto const priorities = GetPlacementFallbackOrder(PreferredPlacement()); | ||
auto const wantedDirection = GetFlowDirectionAdjustedPlacement(PreferredPlacement()); | ||
auto const priorities = GetPlacementFallbackOrder(wantedDirection); | ||
|
||
for (auto const mode : priorities) | ||
{ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really? what happens? was that the case before this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not entirely sure what the root cause is, however when running those tests locally, I noticed that the rect (and the red border we use to show it) don't always show up. The problem is that this leaves the TeachingTip to believe it has more space and fails the test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why wasn't this causing the test to fail before this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test was very unreliable on my machine before that change, only 20% of the time it actually ran through.