// Copyright (C) 2026 SharpEmu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later using Avalonia; using Avalonia.Controls; using Avalonia.Controls.Primitives; using Avalonia.Media; namespace SharpEmu.GUI; public sealed class SettingRow : ContentControl { public static readonly StyledProperty LabelProperty = AvaloniaProperty.Register(nameof(Label)); public static readonly StyledProperty DescriptionProperty = AvaloniaProperty.Register(nameof(Description)); public static readonly StyledProperty LabelFontFamilyProperty = AvaloniaProperty.Register(nameof(LabelFontFamily)); private TextBlock? _label; public string? Label { get => GetValue(LabelProperty); set => SetValue(LabelProperty, value); } public string? Description { get => GetValue(DescriptionProperty); set => SetValue(DescriptionProperty, value); } public FontFamily? LabelFontFamily { get => GetValue(LabelFontFamilyProperty); set => SetValue(LabelFontFamilyProperty, value); } protected override void OnApplyTemplate(TemplateAppliedEventArgs e) { base.OnApplyTemplate(e); _label = e.NameScope.Find("PART_Label"); UpdateLabelFont(); } protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change) { base.OnPropertyChanged(change); if (change.Property == LabelFontFamilyProperty) { UpdateLabelFont(); } } private void UpdateLabelFont() { if (_label is not null && LabelFontFamily is { } family) { _label.FontFamily = family; } } }