fixed comment into code
This commit is contained in:
@@ -7,9 +7,9 @@ using CursorLang.ViewModels;
|
||||
namespace CursorLang.Views;
|
||||
|
||||
/// <summary>
|
||||
/// Всплывающая подсказка с коротким именем раскладки.
|
||||
/// Отвечает только за показ, размер и место на экране: когда её убрать,
|
||||
/// решает <see cref="Services.LayoutPopupService"/>.
|
||||
/// The popup with the short name of the layout.
|
||||
/// Responsible only for showing it, its size and its place on screen: when to take it
|
||||
/// down is decided by <see cref="Services.LayoutPopupService"/>.
|
||||
/// </summary>
|
||||
public partial class LayoutPopupWindow : Window
|
||||
{
|
||||
@@ -23,25 +23,25 @@ public partial class LayoutPopupWindow : Window
|
||||
DataContext = viewModel;
|
||||
_settings = settings;
|
||||
|
||||
// Создаём окно заранее, чтобы задать его границы до первого показа:
|
||||
// иначе оно на мгновение появляется в размере по умолчанию
|
||||
// We create the window in advance to set its bounds before the first show:
|
||||
// otherwise it appears at the default size for a moment
|
||||
new WindowInteropHelper(this).EnsureHandle();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Показывает подсказку в месте, заданном настройками.
|
||||
/// Shows the popup at the place set by the settings.
|
||||
/// </summary>
|
||||
public void ShowPopup()
|
||||
{
|
||||
MeasureContent();
|
||||
|
||||
// Уже созданное окно ставим на место до показа, чтобы оно не мелькнуло
|
||||
// на старой позиции; при самом первом вызове хэндла ещё нет
|
||||
// An already created window is put in place before the show so that it does
|
||||
// not flash in its old position; on the very first call there is no handle yet
|
||||
ApplyBounds();
|
||||
Show();
|
||||
|
||||
// Повторяем после показа: до него окно подчиняется системному минимальному
|
||||
// размеру окна и получается заметно крупнее текста
|
||||
// We repeat it after the show: before that the window is subject to the system
|
||||
// minimum window size and comes out noticeably larger than its text
|
||||
ApplyBounds();
|
||||
}
|
||||
|
||||
@@ -52,9 +52,9 @@ public partial class LayoutPopupWindow : Window
|
||||
PopupWindowNative.MakePassive(new WindowInteropHelper(this).Handle);
|
||||
}
|
||||
|
||||
// Размер содержимого нужен до показа: от него зависит и размер окна,
|
||||
// и позиция для углов. Рамок у окна нет, поэтому размер окна равен размеру
|
||||
// содержимого
|
||||
// The content size is needed before the show: both the window size and the corner
|
||||
// position depend on it. The window has no frame, so the window size equals the
|
||||
// content size
|
||||
private void MeasureContent()
|
||||
{
|
||||
var content = (FrameworkElement)Content;
|
||||
@@ -63,9 +63,9 @@ public partial class LayoutPopupWindow : Window
|
||||
_contentSize = content.DesiredSize;
|
||||
}
|
||||
|
||||
// Всё считается в физических пикселях: у мониторов разный масштаб, а
|
||||
// Window.Left/Top/Width/Height пересчитываются по DPI того монитора,
|
||||
// где окно сейчас, и на соседнем мониторе дают промах
|
||||
// Everything is computed in physical pixels: monitors have different scaling,
|
||||
// while Window.Left/Top/Width/Height are converted using the DPI of the monitor
|
||||
// the window is on right now, which misses the target on a neighbouring monitor
|
||||
private void ApplyBounds()
|
||||
{
|
||||
IntPtr handle = new WindowInteropHelper(this).Handle;
|
||||
@@ -84,8 +84,8 @@ public partial class LayoutPopupWindow : Window
|
||||
}
|
||||
}
|
||||
|
||||
// Точка привязки: каретка в поле ввода либо курсор мыши. Курсор — это
|
||||
// прямоугольник нулевого размера, поэтому расчёт углов у них общий
|
||||
// The anchor point: the caret in the input field or the mouse cursor. The cursor
|
||||
// is a rectangle of zero size, so the corner computation is shared by both
|
||||
private PopupWindowNative.Rect GetAnchor()
|
||||
{
|
||||
if (_settings.PlacementMode == PopupPlacementMode.AtCaret &&
|
||||
@@ -109,7 +109,7 @@ public partial class LayoutPopupWindow : Window
|
||||
var anchorPoint = new PopupWindowNative.Point { X = anchor.Left, Y = anchor.Top };
|
||||
double scale = PopupWindowNative.GetScaleAt(anchorPoint);
|
||||
|
||||
// У каждого режима привязки своя сторона и свой отступ
|
||||
// Every anchor mode has a side and an offset of its own
|
||||
bool atCaret = _settings.PlacementMode == PopupPlacementMode.AtCaret;
|
||||
AnchorSide side = atCaret ? _settings.CaretSide : _settings.CursorSide;
|
||||
int offset = ToPixels(atCaret ? _settings.CaretOffset : _settings.CursorOffset, scale);
|
||||
|
||||
Reference in New Issue
Block a user