2025-12-19 09:30:16 +00:00
|
|
|
// Licensed to the .NET Foundation under one or more agreements.
|
|
|
|
|
// The .NET Foundation licenses this file to you under the MIT license.
|
|
|
|
|
|
|
|
|
|
using Microsoft.Maui.Handlers;
|
|
|
|
|
using Microsoft.Maui.Graphics;
|
|
|
|
|
using SkiaSharp;
|
|
|
|
|
|
|
|
|
|
namespace Microsoft.Maui.Platform.Linux.Handlers;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Handler for CheckBox on Linux using Skia rendering.
|
|
|
|
|
/// Maps ICheckBox interface to SkiaCheckBox platform view.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public partial class CheckBoxHandler : ViewHandler<ICheckBox, SkiaCheckBox>
|
|
|
|
|
{
|
|
|
|
|
public static IPropertyMapper<ICheckBox, CheckBoxHandler> Mapper = new PropertyMapper<ICheckBox, CheckBoxHandler>(ViewHandler.ViewMapper)
|
|
|
|
|
{
|
|
|
|
|
[nameof(ICheckBox.IsChecked)] = MapIsChecked,
|
|
|
|
|
[nameof(ICheckBox.Foreground)] = MapForeground,
|
|
|
|
|
[nameof(IView.Background)] = MapBackground,
|
Major production merge: GTK support, context menus, and dispatcher fixes
Core Infrastructure:
- Add Dispatching folder with LinuxDispatcher, LinuxDispatcherProvider, LinuxDispatcherTimer
- Add Native folder with P/Invoke wrappers (GTK, GLib, GDK, Cairo, WebKit)
- Add GTK host window system with GtkHostWindow and GtkSkiaSurfaceWidget
- Update LinuxApplication with GTK mode, theme handling, and icon support
- Fix duplicate LinuxDispatcher in LinuxMauiContext
Handlers:
- Add GtkWebViewManager and GtkWebViewPlatformView for GTK WebView
- Add FlexLayoutHandler and GestureManager
- Update multiple handlers with ToViewHandler fix and missing mappers
- Add MauiHandlerExtensions with ToViewHandler extension method
Views:
- Add SkiaContextMenu with hover, keyboard, and dark theme support
- Add LinuxDialogService with context menu management
- Add SkiaFlexLayout for flex container support
- Update SkiaShell with RefreshTheme, MauiShell, ContentRenderer
- Update SkiaWebView with SetMainWindow, ProcessGtkEvents
- Update SkiaImage with LoadFromBitmap method
Services:
- Add AppInfoService, ConnectivityService, DeviceDisplayService, DeviceInfoService
- Add GtkHostService, GtkContextMenuService, MauiIconGenerator
Window:
- Add CursorType enum and GtkHostWindow
- Update X11Window with SetIcon, SetCursor methods
Build: SUCCESS (0 errors)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-01 11:19:58 -05:00
|
|
|
[nameof(IView.IsEnabled)] = MapIsEnabled,
|
2025-12-21 13:26:56 -05:00
|
|
|
[nameof(IView.VerticalLayoutAlignment)] = MapVerticalLayoutAlignment,
|
|
|
|
|
[nameof(IView.HorizontalLayoutAlignment)] = MapHorizontalLayoutAlignment,
|
2025-12-19 09:30:16 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
public static CommandMapper<ICheckBox, CheckBoxHandler> CommandMapper = new(ViewHandler.ViewCommandMapper)
|
|
|
|
|
{
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
public CheckBoxHandler() : base(Mapper, CommandMapper)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public CheckBoxHandler(IPropertyMapper? mapper, CommandMapper? commandMapper = null)
|
|
|
|
|
: base(mapper ?? Mapper, commandMapper ?? CommandMapper)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override SkiaCheckBox CreatePlatformView()
|
|
|
|
|
{
|
|
|
|
|
return new SkiaCheckBox();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void ConnectHandler(SkiaCheckBox platformView)
|
|
|
|
|
{
|
|
|
|
|
base.ConnectHandler(platformView);
|
|
|
|
|
platformView.CheckedChanged += OnCheckedChanged;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void DisconnectHandler(SkiaCheckBox platformView)
|
|
|
|
|
{
|
|
|
|
|
platformView.CheckedChanged -= OnCheckedChanged;
|
|
|
|
|
base.DisconnectHandler(platformView);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnCheckedChanged(object? sender, Platform.CheckedChangedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (VirtualView is not null && VirtualView.IsChecked != e.IsChecked)
|
|
|
|
|
{
|
|
|
|
|
VirtualView.IsChecked = e.IsChecked;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void MapIsChecked(CheckBoxHandler handler, ICheckBox checkBox)
|
|
|
|
|
{
|
|
|
|
|
if (handler.PlatformView is null) return;
|
|
|
|
|
handler.PlatformView.IsChecked = checkBox.IsChecked;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void MapForeground(CheckBoxHandler handler, ICheckBox checkBox)
|
|
|
|
|
{
|
|
|
|
|
if (handler.PlatformView is null) return;
|
|
|
|
|
|
|
|
|
|
if (checkBox.Foreground is SolidPaint solidPaint && solidPaint.Color is not null)
|
|
|
|
|
{
|
2026-01-16 04:54:03 +00:00
|
|
|
handler.PlatformView.CheckColor = solidPaint.Color;
|
2025-12-19 09:30:16 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void MapBackground(CheckBoxHandler handler, ICheckBox checkBox)
|
|
|
|
|
{
|
|
|
|
|
if (handler.PlatformView is null) return;
|
|
|
|
|
|
|
|
|
|
if (checkBox.Background is SolidPaint solidPaint && solidPaint.Color is not null)
|
|
|
|
|
{
|
2026-01-16 04:54:03 +00:00
|
|
|
handler.PlatformView.Color = solidPaint.Color;
|
2025-12-19 09:30:16 +00:00
|
|
|
}
|
|
|
|
|
}
|
2025-12-21 13:26:56 -05:00
|
|
|
|
Major production merge: GTK support, context menus, and dispatcher fixes
Core Infrastructure:
- Add Dispatching folder with LinuxDispatcher, LinuxDispatcherProvider, LinuxDispatcherTimer
- Add Native folder with P/Invoke wrappers (GTK, GLib, GDK, Cairo, WebKit)
- Add GTK host window system with GtkHostWindow and GtkSkiaSurfaceWidget
- Update LinuxApplication with GTK mode, theme handling, and icon support
- Fix duplicate LinuxDispatcher in LinuxMauiContext
Handlers:
- Add GtkWebViewManager and GtkWebViewPlatformView for GTK WebView
- Add FlexLayoutHandler and GestureManager
- Update multiple handlers with ToViewHandler fix and missing mappers
- Add MauiHandlerExtensions with ToViewHandler extension method
Views:
- Add SkiaContextMenu with hover, keyboard, and dark theme support
- Add LinuxDialogService with context menu management
- Add SkiaFlexLayout for flex container support
- Update SkiaShell with RefreshTheme, MauiShell, ContentRenderer
- Update SkiaWebView with SetMainWindow, ProcessGtkEvents
- Update SkiaImage with LoadFromBitmap method
Services:
- Add AppInfoService, ConnectivityService, DeviceDisplayService, DeviceInfoService
- Add GtkHostService, GtkContextMenuService, MauiIconGenerator
Window:
- Add CursorType enum and GtkHostWindow
- Update X11Window with SetIcon, SetCursor methods
Build: SUCCESS (0 errors)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-01 11:19:58 -05:00
|
|
|
public static void MapIsEnabled(CheckBoxHandler handler, ICheckBox checkBox)
|
|
|
|
|
{
|
|
|
|
|
if (handler.PlatformView is null) return;
|
|
|
|
|
handler.PlatformView.IsEnabled = checkBox.IsEnabled;
|
|
|
|
|
}
|
|
|
|
|
|
2025-12-21 13:26:56 -05:00
|
|
|
public static void MapVerticalLayoutAlignment(CheckBoxHandler handler, ICheckBox checkBox)
|
|
|
|
|
{
|
|
|
|
|
if (handler.PlatformView is null) return;
|
|
|
|
|
|
|
|
|
|
handler.PlatformView.VerticalOptions = checkBox.VerticalLayoutAlignment switch
|
|
|
|
|
{
|
|
|
|
|
Primitives.LayoutAlignment.Start => LayoutOptions.Start,
|
|
|
|
|
Primitives.LayoutAlignment.Center => LayoutOptions.Center,
|
|
|
|
|
Primitives.LayoutAlignment.End => LayoutOptions.End,
|
|
|
|
|
Primitives.LayoutAlignment.Fill => LayoutOptions.Fill,
|
|
|
|
|
_ => LayoutOptions.Fill
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void MapHorizontalLayoutAlignment(CheckBoxHandler handler, ICheckBox checkBox)
|
|
|
|
|
{
|
|
|
|
|
if (handler.PlatformView is null) return;
|
|
|
|
|
|
|
|
|
|
handler.PlatformView.HorizontalOptions = checkBox.HorizontalLayoutAlignment switch
|
|
|
|
|
{
|
|
|
|
|
Primitives.LayoutAlignment.Start => LayoutOptions.Start,
|
|
|
|
|
Primitives.LayoutAlignment.Center => LayoutOptions.Center,
|
|
|
|
|
Primitives.LayoutAlignment.End => LayoutOptions.End,
|
|
|
|
|
Primitives.LayoutAlignment.Fill => LayoutOptions.Fill,
|
|
|
|
|
_ => LayoutOptions.Start
|
|
|
|
|
};
|
|
|
|
|
}
|
2025-12-19 09:30:16 +00:00
|
|
|
}
|