mirror of
https://github.com/par274/sharpemu.git
synced 2026-08-02 07:59:44 +08:00
a7ec3d5a77
* [GUI] Add inline per-game settings and unify options styling * [GUI] Update options styling & add scrollable area * [GUI] Remove focus and pointover styles for options
66 lines
1.8 KiB
C#
66 lines
1.8 KiB
C#
// 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<string?> LabelProperty =
|
|
AvaloniaProperty.Register<SettingRow, string?>(nameof(Label));
|
|
|
|
public static readonly StyledProperty<string?> DescriptionProperty =
|
|
AvaloniaProperty.Register<SettingRow, string?>(nameof(Description));
|
|
|
|
public static readonly StyledProperty<FontFamily?> LabelFontFamilyProperty =
|
|
AvaloniaProperty.Register<SettingRow, FontFamily?>(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<TextBlock>("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;
|
|
}
|
|
}
|
|
}
|