Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion WindowTranslator.Abstractions/UserSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ public class TargetSettings
/// </summary>
public bool IsOneShotMode { get; set; }

/// <summary>
/// マウスポインター判定の余白(ピクセル)
/// </summary>
public double MousePointerHitTestPadding { get; set; }

/// <summary>
/// プラグインの選択
/// </summary>
Expand Down Expand Up @@ -128,4 +133,4 @@ public enum OverlaySwitch
/// トグル
/// </summary>
Toggle,
}
}
10 changes: 10 additions & 0 deletions WindowTranslator/Controls/OverlayTextsControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,15 @@ public double Scale
public static readonly DependencyProperty ScaleProperty =
DependencyProperty.Register(nameof(Scale), typeof(double), typeof(OverlayTextsControl), new PropertyMetadata(1.0));

public double MousePointerHitTestPadding
{
get => (double)GetValue(MousePointerHitTestPaddingProperty);
set => SetValue(MousePointerHitTestPaddingProperty, value);
}

/// <summary>Identifies the <see cref="MousePointerHitTestPadding"/> dependency property.</summary>
public static readonly DependencyProperty MousePointerHitTestPaddingProperty =
DependencyProperty.Register(nameof(MousePointerHitTestPadding), typeof(double), typeof(OverlayTextsControl), new PropertyMetadata(0.0));


}
6 changes: 5 additions & 1 deletion WindowTranslator/Data/TextOverlayVisibilityConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,15 @@ public sealed class TextOverlayVisibilityConverter : IMultiValueConverter

public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
{
if (values is not [TextRect rect, Point pos, double scale, bool isSwap])
if (values is not [TextRect rect, Point pos, double scale, bool isSwap, double padding])
{
return Visibility.Visible;
}
var r = new Rect(rect.X * scale, rect.Y * scale, rect.Width * scale, rect.Height * scale);
if (padding > 0)
{
r.Inflate(padding * scale, padding * scale);
}
return r.Contains(pos) ^ isSwap ? Visibility.Collapsed : Visibility.Visible;
}

Expand Down
3 changes: 3 additions & 0 deletions WindowTranslator/Modules/Main/MainViewModelBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public abstract partial class MainViewModelBase : IDisposable
private readonly double fontScale;
private readonly double overlayOpacity;
private readonly bool isOneShotModeEnabled;
private readonly double mousePointerHitTestPadding;
private TextRect[]? lastRequested;
private bool isFirstCapture = true;

Expand All @@ -62,6 +63,7 @@ public abstract partial class MainViewModelBase : IDisposable

public ObservableCollection<TextRect> OcrTexts { get; } = [];
public string Font { get; }
public double MousePointerHitTestPadding => this.mousePointerHitTestPadding;

public MainViewModelBase(
IPresentationService presentationService,
Expand All @@ -82,6 +84,7 @@ public MainViewModelBase(
this.fontScale = options.Value.FontScale;
this.overlayOpacity = options.Value.OverlayOpacity;
this.isOneShotModeEnabled = options.Value.IsOneShotMode;
this.mousePointerHitTestPadding = options.Value.MousePointerHitTestPadding;
this.DisplayBusy = options.Value.DisplayBusy;
this.capture = capture ?? throw new ArgumentNullException(nameof(capture));
this.capture.Captured += Capture_CapturedAsync;
Expand Down
1 change: 1 addition & 0 deletions WindowTranslator/Modules/Main/OverlayMainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
x:Name="overlay"
FontFamily="{Binding Font, Mode=OneWay}"
IsSwapVisibility="{Binding IsSwapVisibility, ElementName=host, Mode=OneWay}"
MousePointerHitTestPadding="{Binding MousePointerHitTestPadding, Mode=OneWay}"
MousePos="{Binding MousePos, ElementName=host, Mode=OneWay}"
RectHeight="{Binding Height}"
RectWidth="{Binding Width}"
Expand Down
8 changes: 8 additions & 0 deletions WindowTranslator/Modules/Settings/AllSettingsViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ public async Task SaveAsync(object window)
DisplayBusy = t.DisplayBusy,
IsOneShotMode = t.IsOneShotMode,
OverlayOpacity = t.OverlayOpacity,
MousePointerHitTestPadding = t.MousePointerHitTestPadding,
}),
};

Expand Down Expand Up @@ -466,6 +467,13 @@ public partial class TargetSettingsViewModel(
[ObservableProperty]
private bool isOneShotMode = settings.IsOneShotMode;

[property: Category("SettingsViewModel|Misc")]
[property: LocalizedDescription(typeof(Resources), $"{nameof(MousePointerHitTestPadding)}_Desc")]
[property: Spinnable(Minimum = 0, Maximum = 100)]
[property: SortIndex(10)]
[ObservableProperty]
private double mousePointerHitTestPadding = settings.MousePointerHitTestPadding;

public IReadOnlyList<IPluginParam> Params { get; } = sp.GetServices<IPluginParam>().Select(p =>
{
var configureType = typeof(IConfigureNamedOptions<>).MakeGenericType(p.GetType());
Expand Down
8 changes: 7 additions & 1 deletion WindowTranslator/Properties/Resources.ar.resx
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,12 @@
<data name="IsOverlayPointSwap" xml:space="preserve">
<value>عرض الترجمة فقط للنص تحت المؤشر</value>
</data>
<data name="MousePointerHitTestPadding" xml:space="preserve">
<value>هامش اختبار مؤشر الماوس</value>
</data>
<data name="MousePointerHitTestPadding_Desc" xml:space="preserve">
<value>عدد وحدات البكسل المضافة حول منطقة اختبار مؤشر الماوس</value>
</data>
<data name="OverlayOpacity" xml:space="preserve">
<value>شفافية خلفية الطبقة العلوية</value>
</data>
Expand Down Expand Up @@ -447,4 +453,4 @@

</value>
</data>
</root>
</root>
8 changes: 7 additions & 1 deletion WindowTranslator/Properties/Resources.de.resx
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,12 @@
<data name="IsOverlayPointSwap" xml:space="preserve">
<value>Overlay-Übersetzung nur für Text an der Mauszeiger-Position anzeigen</value>
</data>
<data name="MousePointerHitTestPadding" xml:space="preserve">
<value>Trefferbereichspuffer des Mauszeigers</value>
</data>
<data name="MousePointerHitTestPadding_Desc" xml:space="preserve">
<value>Zusätzliche Pixel um den Trefferbereich des Mauszeigers</value>
</data>
<data name="OverlayOpacity" xml:space="preserve">
<value>Overlay-Hintergrund-Deckkraft</value>
</data>
Expand Down Expand Up @@ -456,4 +462,4 @@ Monitore werden nicht unterstützt.

</value>
</data>
</root>
</root>
8 changes: 7 additions & 1 deletion WindowTranslator/Properties/Resources.en.resx
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,12 @@
<data name="IsOverlayPointSwap" xml:space="preserve">
<value>Display overlay translation only for text at mouse pointer position</value>
</data>
<data name="MousePointerHitTestPadding" xml:space="preserve">
<value>Mouse pointer hit test padding</value>
</data>
<data name="MousePointerHitTestPadding_Desc" xml:space="preserve">
<value>Additional pixels added around the mouse pointer hit test area</value>
</data>
<data name="OverlayOpacity" xml:space="preserve">
<value>Overlay background opacity</value>
</data>
Expand Down Expand Up @@ -456,4 +462,4 @@ Monitors are not supported.

</value>
</data>
</root>
</root>
8 changes: 7 additions & 1 deletion WindowTranslator/Properties/Resources.es.resx
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,12 @@
<data name="IsOverlayPointSwap" xml:space="preserve">
<value>Mostrar traducción solo para texto bajo el puntero</value>
</data>
<data name="MousePointerHitTestPadding" xml:space="preserve">
<value>Margen de prueba del puntero del ratón</value>
</data>
<data name="MousePointerHitTestPadding_Desc" xml:space="preserve">
<value>Píxeles adicionales alrededor del área de prueba del puntero del ratón</value>
</data>
<data name="OverlayOpacity" xml:space="preserve">
<value>Opacidad del fondo de superposición</value>
</data>
Expand Down Expand Up @@ -447,4 +453,4 @@

</value>
</data>
</root>
</root>
10 changes: 8 additions & 2 deletions WindowTranslator/Properties/Resources.fil.resx
Original file line number Diff line number Diff line change
Expand Up @@ -312,8 +312,14 @@
<data name="IsOverlayPointSwap" xml:space="preserve">
<value>Ipakita ang overlay translation para sa teksto sa posisyon ng mouse pointer lamang</value>
</data>
<data name="MousePointerHitTestPadding" xml:space="preserve">
<value>Padding ng hit test ng mouse pointer</value>
</data>
<data name="MousePointerHitTestPadding_Desc" xml:space="preserve">
<value>Karagdagang mga pixel sa paligid ng hit test area ng mouse pointer</value>
</data>
<data name="OverlayOpacity" xml:space="preserve">
<value>Opacity ng background ng overlay</value>
<value>Opasidad ng background ng overlay</value>
</data>
<data name="SendReportToolTip" xml:space="preserve">
<value>Ipadala ang error information sa reporting system. Ang sumusunod na impormasyon ay ipapadala:
Expand Down Expand Up @@ -456,4 +462,4 @@ Ang monitor ay hindi suportado.

</value>
</data>
</root>
</root>
8 changes: 7 additions & 1 deletion WindowTranslator/Properties/Resources.fr.resx
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,12 @@
<data name="IsOverlayPointSwap" xml:space="preserve">
<value>Afficher la traduction uniquement pour le texte sous le pointeur</value>
</data>
<data name="MousePointerHitTestPadding" xml:space="preserve">
<value>Marge de test du pointeur de souris</value>
</data>
<data name="MousePointerHitTestPadding_Desc" xml:space="preserve">
<value>Pixels supplémentaires autour de la zone de test du pointeur de souris</value>
</data>
<data name="OverlayOpacity" xml:space="preserve">
<value>Opacité de l'arrière-plan de superposition</value>
</data>
Expand Down Expand Up @@ -447,4 +453,4 @@

</value>
</data>
</root>
</root>
16 changes: 11 additions & 5 deletions WindowTranslator/Properties/Resources.id.resx
Original file line number Diff line number Diff line change
Expand Up @@ -304,16 +304,22 @@
<value>Terapkan</value>
</data>
<data name="DisplayBusy" xml:space="preserve">
<value>Show busy icon</value>
<value>Tampilkan ikon sibuk</value>
</data>
<data name="IsOneShotMode" xml:space="preserve">
<value>Terjemahkan hanya saat hamparan diaktifkan</value>
</data>
<data name="IsOverlayPointSwap" xml:space="preserve">
<value>Tampilkan terjemahan hamparan hanya untuk teks di posisi pointer mouse</value>
</data>
<data name="MousePointerHitTestPadding" xml:space="preserve">
<value>Padding uji hit pointer mouse</value>
</data>
<data name="MousePointerHitTestPadding_Desc" xml:space="preserve">
<value>Jumlah piksel tambahan di sekitar area uji hit pointer mouse</value>
</data>
<data name="OverlayOpacity" xml:space="preserve">
<value>Overlay background opacity</value>
<value>Opasitas latar belakang hamparan</value>
</data>
<data name="SendReportToolTip" xml:space="preserve">
<value>Kirim informasi kesalahan ke sistem laporan. Informasi berikut akan dikirim:
Expand All @@ -326,10 +332,10 @@
&gt; %{color:red}**Informasi pribadi tidak akan dikirim, tetapi pastikan informasi pribadi tidak termasuk dalam layar target terjemahan.**%</value>
</data>
<data name="SendRerpot" xml:space="preserve">
<value>Send Information</value>
<value>Kirim informasi</value>
</data>
<data name="Sent" xml:space="preserve">
<value>Sent</value>
<value>Terkirim</value>
</data>
<data name="Copy" xml:space="preserve">
<value>Salin Informasi</value>
Expand Down Expand Up @@ -455,4 +461,4 @@ Monitor tidak didukung.</value>

</value>
</data>
</root>
</root>
8 changes: 7 additions & 1 deletion WindowTranslator/Properties/Resources.ko.resx
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,12 @@
<data name="IsOverlayPointSwap" xml:space="preserve">
<value>마우스 포인터 위치의 텍스트에만 오버레이 번역을 표시</value>
</data>
<data name="MousePointerHitTestPadding" xml:space="preserve">
<value>마우스 포인터 판정 여백</value>
</data>
<data name="MousePointerHitTestPadding_Desc" xml:space="preserve">
<value>마우스 포인터 판정 영역에 추가하는 픽셀 수</value>
</data>
<data name="OverlayOpacity" xml:space="preserve">
<value>오버레이 배경 불투명도</value>
</data>
Expand Down Expand Up @@ -456,4 +462,4 @@

</value>
</data>
</root>
</root>
16 changes: 11 additions & 5 deletions WindowTranslator/Properties/Resources.ms.resx
Original file line number Diff line number Diff line change
Expand Up @@ -304,16 +304,22 @@
<value>Guna</value>
</data>
<data name="DisplayBusy" xml:space="preserve">
<value>Show busy icon</value>
<value>Tunjukkan ikon sibuk</value>
</data>
<data name="IsOneShotMode" xml:space="preserve">
<value>Terjemah hanya apabila hamparan didayakan</value>
</data>
<data name="IsOverlayPointSwap" xml:space="preserve">
<value>Paparkan terjemahan hamparan hanya untuk teks pada kedudukan penunjuk tetikus</value>
</data>
<data name="MousePointerHitTestPadding" xml:space="preserve">
<value>Padding ujian sentuh penunjuk tetikus</value>
</data>
<data name="MousePointerHitTestPadding_Desc" xml:space="preserve">
<value>Bilangan piksel tambahan di sekeliling kawasan ujian sentuh penunjuk tetikus</value>
</data>
<data name="OverlayOpacity" xml:space="preserve">
<value>Overlay background opacity</value>
<value>Kelegapan latar belakang hamparan</value>
</data>
<data name="SendReportToolTip" xml:space="preserve">
<value>Hantar maklumat ralat ke sistem laporan. Maklumat berikut akan dihantar:
Expand All @@ -326,10 +332,10 @@
&gt; %{color:red}**Maklumat peribadi tidak akan dihantar, tetapi sila pastikan maklumat peribadi tidak disertakan dalam skrin sasaran terjemahan.**%</value>
</data>
<data name="SendRerpot" xml:space="preserve">
<value>Send Information</value>
<value>Hantar maklumat</value>
</data>
<data name="Sent" xml:space="preserve">
<value>Sent</value>
<value>Dihantar</value>
</data>
<data name="Copy" xml:space="preserve">
<value>Salin Maklumat</value>
Expand Down Expand Up @@ -455,4 +461,4 @@ Monitor tidak disokong.</value>

</value>
</data>
</root>
</root>
8 changes: 7 additions & 1 deletion WindowTranslator/Properties/Resources.pl.resx
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,12 @@
<data name="IsOverlayPointSwap" xml:space="preserve">
<value>Wyświetlaj tłumaczenie nakładki tylko dla tekstu pod pozycją wskaźnika myszy</value>
</data>
<data name="MousePointerHitTestPadding" xml:space="preserve">
<value>Margines testu trafienia wskaźnika myszy</value>
</data>
<data name="MousePointerHitTestPadding_Desc" xml:space="preserve">
<value>Dodatkowe piksele wokół obszaru testu trafienia wskaźnika myszy</value>
</data>
<data name="OverlayOpacity" xml:space="preserve">
<value>Krycie tła nakładki</value>
</data>
Expand Down Expand Up @@ -456,4 +462,4 @@ Monitory nie są obsługiwane.

</value>
</data>
</root>
</root>
Loading