2025-12-21 13:26:56 -05: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;
|
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
|
|
|
using Microsoft.Maui.Platform.Linux.Hosting;
|
2026-03-06 22:06:08 -05:00
|
|
|
using Microsoft.Maui.Platform.Linux.Services;
|
2025-12-21 13:26:56 -05:00
|
|
|
|
|
|
|
|
namespace Microsoft.Maui.Platform.Linux.Handlers;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Handler for ScrollView on Linux using SkiaScrollView.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public partial class ScrollViewHandler : ViewHandler<IScrollView, SkiaScrollView>
|
|
|
|
|
{
|
|
|
|
|
public static IPropertyMapper<IScrollView, ScrollViewHandler> Mapper =
|
|
|
|
|
new PropertyMapper<IScrollView, ScrollViewHandler>(ViewMapper)
|
|
|
|
|
{
|
|
|
|
|
[nameof(IScrollView.Content)] = MapContent,
|
|
|
|
|
[nameof(IScrollView.HorizontalScrollBarVisibility)] = MapHorizontalScrollBarVisibility,
|
|
|
|
|
[nameof(IScrollView.VerticalScrollBarVisibility)] = MapVerticalScrollBarVisibility,
|
|
|
|
|
[nameof(IScrollView.Orientation)] = MapOrientation,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
public static CommandMapper<IScrollView, ScrollViewHandler> CommandMapper =
|
|
|
|
|
new(ViewCommandMapper)
|
|
|
|
|
{
|
|
|
|
|
[nameof(IScrollView.RequestScrollTo)] = MapRequestScrollTo
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
public ScrollViewHandler() : base(Mapper, CommandMapper)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ScrollViewHandler(IPropertyMapper? mapper)
|
|
|
|
|
: base(mapper ?? Mapper, CommandMapper)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override SkiaScrollView CreatePlatformView()
|
|
|
|
|
{
|
|
|
|
|
return new SkiaScrollView();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void MapContent(ScrollViewHandler handler, IScrollView scrollView)
|
|
|
|
|
{
|
|
|
|
|
if (handler.PlatformView == null || handler.MauiContext == null)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
var content = scrollView.PresentedContent;
|
|
|
|
|
if (content != null)
|
|
|
|
|
{
|
2026-03-06 22:06:08 -05:00
|
|
|
DiagnosticLog.Debug("ScrollViewHandler", $"MapContent: {content.GetType().Name}");
|
2025-12-21 13:26:56 -05:00
|
|
|
|
|
|
|
|
// Create handler for content if it doesn't exist
|
|
|
|
|
if (content.Handler == null)
|
|
|
|
|
{
|
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
|
|
|
content.Handler = content.ToViewHandler(handler.MauiContext);
|
2025-12-21 13:26:56 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (content.Handler?.PlatformView is SkiaView skiaContent)
|
|
|
|
|
{
|
2026-03-06 22:06:08 -05:00
|
|
|
DiagnosticLog.Debug("ScrollViewHandler", $"Setting content: {skiaContent.GetType().Name}");
|
2025-12-21 13:26:56 -05:00
|
|
|
handler.PlatformView.Content = skiaContent;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
handler.PlatformView.Content = null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void MapHorizontalScrollBarVisibility(ScrollViewHandler handler, IScrollView scrollView)
|
|
|
|
|
{
|
|
|
|
|
handler.PlatformView.HorizontalScrollBarVisibility = scrollView.HorizontalScrollBarVisibility switch
|
|
|
|
|
{
|
|
|
|
|
Microsoft.Maui.ScrollBarVisibility.Always => ScrollBarVisibility.Always,
|
|
|
|
|
Microsoft.Maui.ScrollBarVisibility.Never => ScrollBarVisibility.Never,
|
|
|
|
|
_ => ScrollBarVisibility.Default
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void MapVerticalScrollBarVisibility(ScrollViewHandler handler, IScrollView scrollView)
|
|
|
|
|
{
|
|
|
|
|
handler.PlatformView.VerticalScrollBarVisibility = scrollView.VerticalScrollBarVisibility switch
|
|
|
|
|
{
|
|
|
|
|
Microsoft.Maui.ScrollBarVisibility.Always => ScrollBarVisibility.Always,
|
|
|
|
|
Microsoft.Maui.ScrollBarVisibility.Never => ScrollBarVisibility.Never,
|
|
|
|
|
_ => ScrollBarVisibility.Default
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void MapOrientation(ScrollViewHandler handler, IScrollView scrollView)
|
|
|
|
|
{
|
|
|
|
|
handler.PlatformView.Orientation = scrollView.Orientation switch
|
|
|
|
|
{
|
|
|
|
|
Microsoft.Maui.ScrollOrientation.Horizontal => ScrollOrientation.Horizontal,
|
|
|
|
|
Microsoft.Maui.ScrollOrientation.Both => ScrollOrientation.Both,
|
|
|
|
|
Microsoft.Maui.ScrollOrientation.Neither => ScrollOrientation.Neither,
|
|
|
|
|
_ => ScrollOrientation.Vertical
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void MapRequestScrollTo(ScrollViewHandler handler, IScrollView scrollView, object? args)
|
|
|
|
|
{
|
|
|
|
|
if (args is ScrollToRequest request)
|
|
|
|
|
{
|
|
|
|
|
// Instant means no animation, so we pass !Instant for animated parameter
|
|
|
|
|
handler.PlatformView.ScrollTo((float)request.HorizontalOffset, (float)request.VerticalOffset, !request.Instant);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|