modified each other mode has own side and offset
This commit is contained in:
@@ -109,15 +109,30 @@ public partial class LayoutPopupWindow : Window
|
||||
var anchorPoint = new PopupWindowNative.Point { X = anchor.Left, Y = anchor.Top };
|
||||
double scale = PopupWindowNative.GetScaleAt(anchorPoint);
|
||||
|
||||
// У каждого режима привязки своя сторона и свой отступ
|
||||
bool atCaret = _settings.PlacementMode == PopupPlacementMode.AtCaret;
|
||||
AnchorSide side = atCaret ? _settings.CaretSide : _settings.CursorSide;
|
||||
int offset = ToPixels(atCaret ? _settings.CaretOffset : _settings.CursorOffset, scale);
|
||||
|
||||
int width = ToPixels(_contentSize.Width, scale);
|
||||
int height = ToPixels(_contentSize.Height, scale);
|
||||
int offset = ToPixels(_settings.CursorOffset, scale);
|
||||
|
||||
bool toRight = _settings.CursorCorner is CursorCorner.BottomRight or CursorCorner.TopRight;
|
||||
bool toBottom = _settings.CursorCorner is CursorCorner.BottomRight or CursorCorner.BottomLeft;
|
||||
int toLeftOf = anchor.Left - offset - width;
|
||||
int toRightOf = anchor.Right + offset;
|
||||
int above = anchor.Top - offset - height;
|
||||
int below = anchor.Bottom + offset;
|
||||
// Для сторон «слева» и «справа» подсказка встаёт вровень с точкой привязки
|
||||
int middle = anchor.Top + (((anchor.Bottom - anchor.Top) - height) / 2);
|
||||
|
||||
int x = toRight ? anchor.Right + offset : anchor.Left - offset - width;
|
||||
int y = toBottom ? anchor.Bottom + offset : anchor.Top - offset - height;
|
||||
(int x, int y) = side switch
|
||||
{
|
||||
AnchorSide.TopLeft => (toLeftOf, above),
|
||||
AnchorSide.TopRight => (toRightOf, above),
|
||||
AnchorSide.Left => (toLeftOf, middle),
|
||||
AnchorSide.Right => (toRightOf, middle),
|
||||
AnchorSide.BottomLeft => (toLeftOf, below),
|
||||
_ => (toRightOf, below),
|
||||
};
|
||||
|
||||
PopupWindowNative.SetBounds(handle, x, y, width, height);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user