Skip to content

Commit

Permalink
UIのアクセントカラーを設定できるようにした
Browse files Browse the repository at this point in the history
  • Loading branch information
yuto-trd committed Sep 5, 2023
1 parent b677c8c commit 23cac81
Show file tree
Hide file tree
Showing 11 changed files with 421 additions and 89 deletions.
24 changes: 23 additions & 1 deletion src/Beutl.Configuration/ViewConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ public sealed class ViewConfig : ConfigurationBase
public static readonly CoreProperty<(int X, int Y)?> WindowPositionProperty;
public static readonly CoreProperty<(int Width, int Height)?> WindowSizeProperty;
public static readonly CoreProperty<bool?> IsWindowMaximizedProperty;
public static readonly CoreProperty<bool> UseCustomAccentColorProperty;
public static readonly CoreProperty<string?> CustomAccentColorProperty;
public static readonly CoreProperty<CoreList<string>> PrimaryPropertiesProperty;
public static readonly CoreProperty<CoreList<string>> RecentFilesProperty;
public static readonly CoreProperty<CoreList<string>> RecentProjectsProperty;
Expand Down Expand Up @@ -51,6 +53,14 @@ static ViewConfig()
.DefaultValue(null)
.Register();

UseCustomAccentColorProperty = ConfigureProperty<bool, ViewConfig>(nameof(UseCustomAccentColor))
.DefaultValue(false)
.Register();

CustomAccentColorProperty = ConfigureProperty<string?, ViewConfig>(nameof(CustomAccentColor))
.DefaultValue(null)
.Register();

PrimaryPropertiesProperty = ConfigureProperty<CoreList<string>, ViewConfig>(nameof(PrimaryProperties))
.Accessor(o => o.PrimaryProperties, (o, v) => o.PrimaryProperties = v)
.Register();
Expand Down Expand Up @@ -109,6 +119,18 @@ public bool? IsWindowMaximized
set => SetValue(IsWindowMaximizedProperty, value);
}

public bool UseCustomAccentColor
{
get => GetValue(UseCustomAccentColorProperty);
set => SetValue(UseCustomAccentColorProperty,value);
}

public string? CustomAccentColor
{
get => GetValue(CustomAccentColorProperty);
set => SetValue(CustomAccentColorProperty,value);
}

[NotAutoSerialized()]
public CoreList<string> PrimaryProperties
{
Expand Down Expand Up @@ -238,7 +260,7 @@ public void ResetPrimaryProperties()
protected override void OnPropertyChanged(PropertyChangedEventArgs args)
{
base.OnPropertyChanged(args);
if (args.PropertyName is "Theme" or "UICulture" or "HidePrimaryProperties")
if (args.PropertyName is nameof(Theme) or nameof(UICulture) or nameof(HidePrimaryProperties) or nameof(UseCustomAccentColor) or nameof(CustomAccentColor))
{
OnChanged();
}
Expand Down
27 changes: 27 additions & 0 deletions src/Beutl.Language/SettingsPage.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions src/Beutl.Language/SettingsPage.ja.resx
Original file line number Diff line number Diff line change
Expand Up @@ -216,4 +216,13 @@
<data name="DecoderPriority_Description" xml:space="preserve">
<value>デコーダーの優先順位を変更できます。上のデコーダーが優先されます。</value>
</data>
<data name="AccentColor" xml:space="preserve">
<value>アクセントカラー</value>
</data>
<data name="CustomColor" xml:space="preserve">
<value>ユーザー設定の色</value>
</data>
<data name="UseCustomAccentColor" xml:space="preserve">
<value>アクセントカラーをカスタマイズ</value>
</data>
</root>
9 changes: 9 additions & 0 deletions src/Beutl.Language/SettingsPage.resx
Original file line number Diff line number Diff line change
Expand Up @@ -216,4 +216,13 @@
<data name="DecoderPriority_Description" xml:space="preserve">
<value>You can change the priority order of decoders. The upper decoder has priority.</value>
</data>
<data name="AccentColor" xml:space="preserve">
<value>Accent color</value>
</data>
<data name="CustomColor" xml:space="preserve">
<value>Custom color</value>
</data>
<data name="UseCustomAccentColor" xml:space="preserve">
<value>Use custom accent color</value>
</data>
</root>
9 changes: 9 additions & 0 deletions src/Beutl.Language/Strings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/Beutl.Language/Strings.ja.resx
Original file line number Diff line number Diff line change
Expand Up @@ -943,4 +943,7 @@ b-editorがダウンロードURLを管理します。</value>
<data name="RemoveAnimation" xml:space="preserve">
<value>アニメーションを削除</value>
</data>
<data name="ColorPallete" xml:space="preserve">
<value>カラーパレット</value>
</data>
</root>
3 changes: 3 additions & 0 deletions src/Beutl.Language/Strings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -943,4 +943,7 @@ and b-editor maintains the download URL.</value>
<data name="RemoveAnimation" xml:space="preserve">
<value>Remove animation</value>
</data>
<data name="ColorPallete" xml:space="preserve">
<value>Color Pallete</value>
</data>
</root>
11 changes: 10 additions & 1 deletion src/Beutl/App.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ public override void Initialize()
Color[] colors = colorProperties.Select(p => p.GetValue(null)).OfType<Color>().ToArray();

GlobalConfiguration config = GlobalConfiguration.Instance;
config.Restore(GlobalConfiguration.DefaultFilePath);
ViewConfig view = config.ViewConfig;
CultureInfo.CurrentUICulture = view.UICulture;

Expand Down Expand Up @@ -69,6 +68,11 @@ public override void Initialize()
}
}, DispatcherPriority.Send);
});

if (view.UseCustomAccentColor && Color.TryParse(view.CustomAccentColor, out Color customColor))
{
_theme.CustomAccentColor = customColor;
}
}

public override void RegisterServices()
Expand Down Expand Up @@ -121,6 +125,11 @@ public override void OnFrameworkInitializationCompleted()
};
}

public static FluentAvaloniaTheme? GetFATheme()
{
return (Current as App)?._theme;
}

private MainViewModel GetMainViewModel()
{
return _mainViewModel ??= new MainViewModel();
Expand Down
Loading

0 comments on commit 23cac81

Please sign in to comment.