- ButtonHandler: Removed MapText/TextColor/Font (not in production), fixed namespace - LabelHandler: Added CharacterSpacing/LayoutAlignment/FormattedText, ConnectHandler gesture logic - EntryHandler: Added CharacterSpacing/ClearButtonVisibility/VerticalTextAlignment - EditorHandler: Created from decompiled (was missing) - SliderHandler: Fixed namespace, added ConnectHandler init calls - SwitchHandler: Added OffTrackColor logic, fixed namespace - CheckBoxHandler: Added VerticalLayoutAlignment/HorizontalLayoutAlignment - ProgressBarHandler: Added ConnectHandler/DisconnectHandler IsVisible tracking - PickerHandler: Created from decompiled with collection changed tracking - ActivityIndicatorHandler: Removed IsEnabled/BackgroundColor (not in production) - All handlers now use namespace Microsoft.Maui.Platform.Linux.Handlers - All handlers have proper null checks on PlatformView - Updated MERGE_TRACKING.md with accurate status 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
153 lines
4.6 KiB
C#
153 lines
4.6 KiB
C#
// Licensed to the .NET Foundation under one or more agreements.
|
|
// The .NET Foundation licenses this file to you under the MIT license.
|
|
|
|
using System;
|
|
using Microsoft.Maui.Graphics;
|
|
using Microsoft.Maui.Handlers;
|
|
|
|
namespace Microsoft.Maui.Platform.Linux.Handlers;
|
|
|
|
/// <summary>
|
|
/// Linux handler for Slider control.
|
|
/// </summary>
|
|
public class SliderHandler : ViewHandler<ISlider, SkiaSlider>
|
|
{
|
|
public static IPropertyMapper<ISlider, SliderHandler> Mapper = new PropertyMapper<ISlider, SliderHandler>(ViewHandler.ViewMapper)
|
|
{
|
|
["Minimum"] = MapMinimum,
|
|
["Maximum"] = MapMaximum,
|
|
["Value"] = MapValue,
|
|
["MinimumTrackColor"] = MapMinimumTrackColor,
|
|
["MaximumTrackColor"] = MapMaximumTrackColor,
|
|
["ThumbColor"] = MapThumbColor,
|
|
["Background"] = MapBackground,
|
|
["IsEnabled"] = MapIsEnabled
|
|
};
|
|
|
|
public static CommandMapper<ISlider, SliderHandler> CommandMapper = new(ViewHandler.ViewCommandMapper);
|
|
|
|
public SliderHandler() : base(Mapper, CommandMapper)
|
|
{
|
|
}
|
|
|
|
public SliderHandler(IPropertyMapper? mapper, CommandMapper? commandMapper = null)
|
|
: base(mapper ?? Mapper, commandMapper ?? CommandMapper)
|
|
{
|
|
}
|
|
|
|
protected override SkiaSlider CreatePlatformView()
|
|
{
|
|
return new SkiaSlider();
|
|
}
|
|
|
|
protected override void ConnectHandler(SkiaSlider platformView)
|
|
{
|
|
base.ConnectHandler(platformView);
|
|
platformView.ValueChanged += OnValueChanged;
|
|
platformView.DragStarted += OnDragStarted;
|
|
platformView.DragCompleted += OnDragCompleted;
|
|
|
|
if (VirtualView != null)
|
|
{
|
|
MapMinimum(this, VirtualView);
|
|
MapMaximum(this, VirtualView);
|
|
MapValue(this, VirtualView);
|
|
MapIsEnabled(this, VirtualView);
|
|
}
|
|
}
|
|
|
|
protected override void DisconnectHandler(SkiaSlider platformView)
|
|
{
|
|
platformView.ValueChanged -= OnValueChanged;
|
|
platformView.DragStarted -= OnDragStarted;
|
|
platformView.DragCompleted -= OnDragCompleted;
|
|
base.DisconnectHandler(platformView);
|
|
}
|
|
|
|
private void OnValueChanged(object? sender, SliderValueChangedEventArgs e)
|
|
{
|
|
if (VirtualView != null && PlatformView != null && Math.Abs(VirtualView.Value - e.NewValue) > 0.0001)
|
|
{
|
|
VirtualView.Value = e.NewValue;
|
|
}
|
|
}
|
|
|
|
private void OnDragStarted(object? sender, EventArgs e)
|
|
{
|
|
VirtualView?.DragStarted();
|
|
}
|
|
|
|
private void OnDragCompleted(object? sender, EventArgs e)
|
|
{
|
|
VirtualView?.DragCompleted();
|
|
}
|
|
|
|
public static void MapMinimum(SliderHandler handler, ISlider slider)
|
|
{
|
|
if (handler.PlatformView != null)
|
|
{
|
|
handler.PlatformView.Minimum = slider.Minimum;
|
|
}
|
|
}
|
|
|
|
public static void MapMaximum(SliderHandler handler, ISlider slider)
|
|
{
|
|
if (handler.PlatformView != null)
|
|
{
|
|
handler.PlatformView.Maximum = slider.Maximum;
|
|
}
|
|
}
|
|
|
|
public static void MapValue(SliderHandler handler, ISlider slider)
|
|
{
|
|
if (handler.PlatformView != null && Math.Abs(handler.PlatformView.Value - slider.Value) > 0.0001)
|
|
{
|
|
handler.PlatformView.Value = slider.Value;
|
|
}
|
|
}
|
|
|
|
public static void MapMinimumTrackColor(SliderHandler handler, ISlider slider)
|
|
{
|
|
if (handler.PlatformView != null && slider.MinimumTrackColor != null)
|
|
{
|
|
handler.PlatformView.ActiveTrackColor = slider.MinimumTrackColor.ToSKColor();
|
|
}
|
|
}
|
|
|
|
public static void MapMaximumTrackColor(SliderHandler handler, ISlider slider)
|
|
{
|
|
if (handler.PlatformView != null && slider.MaximumTrackColor != null)
|
|
{
|
|
handler.PlatformView.TrackColor = slider.MaximumTrackColor.ToSKColor();
|
|
}
|
|
}
|
|
|
|
public static void MapThumbColor(SliderHandler handler, ISlider slider)
|
|
{
|
|
if (handler.PlatformView != null && slider.ThumbColor != null)
|
|
{
|
|
handler.PlatformView.ThumbColor = slider.ThumbColor.ToSKColor();
|
|
}
|
|
}
|
|
|
|
public static void MapBackground(SliderHandler handler, ISlider slider)
|
|
{
|
|
if (handler.PlatformView != null)
|
|
{
|
|
if (slider.Background is SolidPaint solidPaint && solidPaint.Color != null)
|
|
{
|
|
handler.PlatformView.BackgroundColor = solidPaint.Color.ToSKColor();
|
|
}
|
|
}
|
|
}
|
|
|
|
public static void MapIsEnabled(SliderHandler handler, ISlider slider)
|
|
{
|
|
if (handler.PlatformView != null)
|
|
{
|
|
handler.PlatformView.IsEnabled = slider.IsEnabled;
|
|
handler.PlatformView.Invalidate();
|
|
}
|
|
}
|
|
}
|