@@ -297,44 +297,66 @@ struct CalloutComponentView
297297 CompositionUIService::ComponentFromReactTag (
298298 m_reactContext.Handle (), Props ()->target .AsInt64 ());
299299 auto targetPos = ViewToScreenOffset (targetView);
300+ auto targetScaleFactor =
301+ targetView.LayoutMetrics ().PointScaleFactor ;
302+ auto targetWidthPx = static_cast <int32_t >(
303+ targetView.LayoutMetrics ().Frame .Width * targetScaleFactor);
304+ auto targetHeightPx = static_cast <int32_t >(
305+ targetView.LayoutMetrics ().Frame .Height * targetScaleFactor);
306+ auto targetRight = targetPos.X + targetWidthPx;
307+ auto targetBottom = targetPos.Y + targetHeightPx;
308+ auto targetCenterX = targetPos.X + targetWidthPx / 2 ;
309+ auto targetCenterY = targetPos.Y + targetHeightPx / 2 ;
300310
301311 POINT anchorPoint{targetPos.X , targetPos.Y };
302312 SIZE windowSize{clientWidthPx, clientHeightPx};
303313
304- RECT excludeRect{targetPos.X , targetPos.Y ,
305- targetPos.X + targetView.LayoutMetrics ().Frame .Width ,
306- targetPos.Y + targetView.LayoutMetrics ().Frame .Height };
314+ RECT excludeRect{targetPos.X , targetPos.Y , targetRight, targetBottom};
307315
308316 UINT flags = 0 ;
309317
310318 if (m_directionalHint == DirectionalHint::LeftTopEdge) {
311- flags = TPM_LEFTALIGN | TPM_TOPALIGN | TPM_HORIZONTAL ;
319+ anchorPoint = {targetPos.X , targetPos.Y };
320+ flags = TPM_RIGHTALIGN | TPM_TOPALIGN | TPM_HORIZONTAL ;
312321 } else if (m_directionalHint == DirectionalHint::LeftCenter) {
313- flags = TPM_LEFTALIGN | TPM_VCENTERALIGN | TPM_HORIZONTAL ;
322+ anchorPoint = {targetPos.X , targetCenterY};
323+ flags = TPM_RIGHTALIGN | TPM_VCENTERALIGN | TPM_HORIZONTAL ;
314324 } else if (m_directionalHint == DirectionalHint::LeftBottomEdge) {
315- flags = TPM_LEFTALIGN | TPM_BOTTOMALIGN | TPM_HORIZONTAL ;
325+ anchorPoint = {targetPos.X , targetBottom};
326+ flags = TPM_RIGHTALIGN | TPM_BOTTOMALIGN | TPM_HORIZONTAL ;
316327 } else if (m_directionalHint == DirectionalHint::TopLeftEdge) {
317- flags = TPM_LEFTALIGN | TPM_TOPALIGN | TPM_VERTICAL ;
328+ anchorPoint = {targetPos.X , targetPos.Y };
329+ flags = TPM_LEFTALIGN | TPM_BOTTOMALIGN | TPM_VERTICAL ;
318330 } else if (m_directionalHint == DirectionalHint::TopAutoEdge) {
319- flags = TPM_LEFTALIGN | TPM_TOPALIGN | TPM_VERTICAL ;
331+ anchorPoint = {targetPos.X , targetPos.Y };
332+ flags = TPM_LEFTALIGN | TPM_BOTTOMALIGN | TPM_VERTICAL ;
320333 } else if (m_directionalHint == DirectionalHint::TopCenter) {
321- flags = TPM_CENTERALIGN | TPM_TOPALIGN | TPM_VERTICAL ;
334+ anchorPoint = {targetCenterX, targetPos.Y };
335+ flags = TPM_CENTERALIGN | TPM_BOTTOMALIGN | TPM_VERTICAL ;
322336 } else if (m_directionalHint == DirectionalHint::TopRightEdge) {
323- flags = TPM_RIGHTALIGN | TPM_TOPALIGN | TPM_VERTICAL ;
337+ anchorPoint = {targetRight, targetPos.Y };
338+ flags = TPM_RIGHTALIGN | TPM_BOTTOMALIGN | TPM_VERTICAL ;
324339 } else if (m_directionalHint == DirectionalHint::RightTopEdge) {
325- flags = TPM_RIGHTALIGN | TPM_TOPALIGN | TPM_HORIZONTAL ;
340+ anchorPoint = {targetRight, targetPos.Y };
341+ flags = TPM_LEFTALIGN | TPM_TOPALIGN | TPM_HORIZONTAL ;
326342 } else if (m_directionalHint == DirectionalHint::RightCenter) {
327- flags = TPM_RIGHTALIGN | TPM_VCENTERALIGN | TPM_HORIZONTAL ;
343+ anchorPoint = {targetRight, targetCenterY};
344+ flags = TPM_LEFTALIGN | TPM_VCENTERALIGN | TPM_HORIZONTAL ;
328345 } else if (m_directionalHint == DirectionalHint::RightBottomEdge) {
329- flags = TPM_RIGHTALIGN | TPM_BOTTOMALIGN | TPM_HORIZONTAL ;
346+ anchorPoint = {targetRight, targetBottom};
347+ flags = TPM_LEFTALIGN | TPM_BOTTOMALIGN | TPM_HORIZONTAL ;
330348 } else if (m_directionalHint == DirectionalHint::BottomLeftEdge) {
331- flags = TPM_LEFTALIGN | TPM_BOTTOMALIGN | TPM_VERTICAL ;
349+ anchorPoint = {targetPos.X , targetBottom};
350+ flags = TPM_LEFTALIGN | TPM_TOPALIGN | TPM_VERTICAL ;
332351 } else if (m_directionalHint == DirectionalHint::BottomAutoEdge) {
333- flags = TPM_LEFTALIGN | TPM_BOTTOMALIGN | TPM_VERTICAL ;
352+ anchorPoint = {targetPos.X , targetBottom};
353+ flags = TPM_LEFTALIGN | TPM_TOPALIGN | TPM_VERTICAL ;
334354 } else if (m_directionalHint == DirectionalHint::BottomCenter) {
335- flags = TPM_CENTERALIGN | TPM_BOTTOMALIGN | TPM_VERTICAL ;
355+ anchorPoint = {targetCenterX, targetBottom};
356+ flags = TPM_CENTERALIGN | TPM_TOPALIGN | TPM_VERTICAL ;
336357 } else if (m_directionalHint == DirectionalHint::BottomRightEdge) {
337- flags = TPM_RIGHTALIGN | TPM_BOTTOMALIGN | TPM_VERTICAL ;
358+ anchorPoint = {targetRight, targetBottom};
359+ flags = TPM_RIGHTALIGN | TPM_TOPALIGN | TPM_VERTICAL ;
338360 }
339361
340362 flags |= TPM_WORKAREA ;
0 commit comments