Browse Source
Merge branch 'master' into spell_other_avalonia
pull/1859/head
Steven Kirk
8 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with
60 additions and
7 deletions
-
src/Avalonia.Base/Threading/Dispatcher.cs
-
src/Avalonia.Base/Threading/IDispatcher.cs
-
src/Avalonia.Controls/Presenters/TextPresenter.cs
-
src/Avalonia.Controls/Slider.cs
-
tests/Avalonia.UnitTests/ImmediateDispatcher.cs
|
|
|
@ -92,6 +92,20 @@ namespace Avalonia.Threading |
|
|
|
return _jobRunner.InvokeAsync(function, priority); |
|
|
|
} |
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
public Task InvokeAsync(Func<Task> function, DispatcherPriority priority = DispatcherPriority.Normal) |
|
|
|
{ |
|
|
|
Contract.Requires<ArgumentNullException>(function != null); |
|
|
|
return _jobRunner.InvokeAsync(function, priority).Unwrap(); |
|
|
|
} |
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
public Task<TResult> InvokeAsync<TResult>(Func<Task<TResult>> function, DispatcherPriority priority = DispatcherPriority.Normal) |
|
|
|
{ |
|
|
|
Contract.Requires<ArgumentNullException>(function != null); |
|
|
|
return _jobRunner.InvokeAsync(function, priority).Unwrap(); |
|
|
|
} |
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
public void Post(Action action, DispatcherPriority priority = DispatcherPriority.Normal) |
|
|
|
{ |
|
|
|
|
|
|
|
@ -40,5 +40,23 @@ namespace Avalonia.Threading |
|
|
|
/// <param name="function">The method.</param>
|
|
|
|
/// <param name="priority">The priority with which to invoke the method.</param>
|
|
|
|
Task<TResult> InvokeAsync<TResult>(Func<TResult> function, DispatcherPriority priority = DispatcherPriority.Normal); |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Queues the specified work to run on the dispatcher thread and returns a proxy for the
|
|
|
|
/// task returned by <paramref name="function"/>.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="function">The work to execute asynchronously.</param>
|
|
|
|
/// <param name="priority">The priority with which to invoke the method.</param>
|
|
|
|
/// <returns>A task that represents a proxy for the task returned by <paramref name="function"/>.</returns>
|
|
|
|
Task InvokeAsync(Func<Task> function, DispatcherPriority priority = DispatcherPriority.Normal); |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Queues the specified work to run on the dispatcher thread and returns a proxy for the
|
|
|
|
/// task returned by <paramref name="function"/>.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="function">The work to execute asynchronously.</param>
|
|
|
|
/// <param name="priority">The priority with which to invoke the method.</param>
|
|
|
|
/// <returns>A task that represents a proxy for the task returned by <paramref name="function"/>.</returns>
|
|
|
|
Task<TResult> InvokeAsync<TResult>(Func<Task<TResult>> function, DispatcherPriority priority = DispatcherPriority.Normal); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -35,6 +35,11 @@ namespace Avalonia.Controls.Presenters |
|
|
|
private int _selectionEnd; |
|
|
|
private bool _caretBlink; |
|
|
|
private IBrush _highlightBrush; |
|
|
|
|
|
|
|
static TextPresenter() |
|
|
|
{ |
|
|
|
AffectsRender(PasswordCharProperty); |
|
|
|
} |
|
|
|
|
|
|
|
public TextPresenter() |
|
|
|
{ |
|
|
|
@ -49,6 +54,9 @@ namespace Avalonia.Controls.Presenters |
|
|
|
|
|
|
|
this.GetObservable(CaretIndexProperty) |
|
|
|
.Subscribe(CaretIndexChanged); |
|
|
|
|
|
|
|
this.GetObservable(PasswordCharProperty) |
|
|
|
.Subscribe(_ => InvalidateFormattedText()); |
|
|
|
} |
|
|
|
|
|
|
|
public int CaretIndex |
|
|
|
|
|
|
|
@ -171,11 +171,7 @@ namespace Avalonia.Controls |
|
|
|
/// <param name="value">Value that want to snap to closest Tick.</param>
|
|
|
|
private void MoveToNextTick(double value) |
|
|
|
{ |
|
|
|
double next = SnapToTick(Math.Max(Minimum, Math.Min(Maximum, value))); |
|
|
|
if (next != value) |
|
|
|
{ |
|
|
|
Value = next; |
|
|
|
} |
|
|
|
Value = SnapToTick(Math.Max(Minimum, Math.Min(Maximum, value))); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -194,4 +190,4 @@ namespace Avalonia.Controls |
|
|
|
return value; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -9,28 +9,45 @@ namespace Avalonia.UnitTests |
|
|
|
/// </summary>
|
|
|
|
public class ImmediateDispatcher : IDispatcher |
|
|
|
{ |
|
|
|
/// <inheritdoc/>
|
|
|
|
public bool CheckAccess() |
|
|
|
{ |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
public void Post(Action action, DispatcherPriority priority = DispatcherPriority.Normal) |
|
|
|
{ |
|
|
|
action(); |
|
|
|
} |
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
public Task InvokeAsync(Action action, DispatcherPriority priority = DispatcherPriority.Normal) |
|
|
|
{ |
|
|
|
action(); |
|
|
|
return Task.FromResult<object>(null); |
|
|
|
return Task.CompletedTask; |
|
|
|
} |
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
public Task<TResult> InvokeAsync<TResult>(Func<TResult> function, DispatcherPriority priority = DispatcherPriority.Normal) |
|
|
|
{ |
|
|
|
var result = function(); |
|
|
|
return Task.FromResult(result); |
|
|
|
} |
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
public Task InvokeAsync(Func<Task> function, DispatcherPriority priority = DispatcherPriority.Normal) |
|
|
|
{ |
|
|
|
return function(); |
|
|
|
} |
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
public Task<TResult> InvokeAsync<TResult>(Func<Task<TResult>> function, DispatcherPriority priority = DispatcherPriority.Normal) |
|
|
|
{ |
|
|
|
return function(); |
|
|
|
} |
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
public void VerifyAccess() |
|
|
|
{ |
|
|
|
} |
|
|
|
|