Skip to content

Commit d60f403

Browse files
committed
upgrade to avalonia 11 and fix compilation
1 parent bda13a6 commit d60f403

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+387
-434
lines changed

OpenUtau.Test/OpenUtau.Test.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
2121
<PrivateAssets>all</PrivateAssets>
2222
</PackageReference>
23-
<PackageReference Include="coverlet.collector" Version="3.2.0">
23+
<PackageReference Include="coverlet.collector" Version="6.0.0">
2424
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
2525
<PrivateAssets>all</PrivateAssets>
2626
</PackageReference>

OpenUtau/App.axaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@
2525
<ResourceInclude Source="/Strings/Strings.zh-TW.axaml"/>
2626
<ResourceInclude Source="/Strings/Strings.th-TH.axaml"/>
2727
<ResourceInclude Source="/Strings/Strings.axaml"/>
28-
<ResourceInclude Source="/Colors/LightTheme.axaml"/>
2928
<ResourceInclude Source="/Colors/DarkTheme.axaml"/>
29+
<ResourceInclude Source="/Colors/LightTheme.axaml"/>
3030
<ResourceInclude Source="/Colors/Brushes.axaml"/>
3131
</ResourceDictionary.MergedDictionaries>
3232
</ResourceDictionary>
3333
</Application.Resources>
3434
<Application.Styles>
35-
<StyleInclude Source="avares://Avalonia.Themes.Fluent/FluentLight.xaml"/>
35+
<FluentTheme />
3636
<StyleInclude Source="avares://Avalonia.Controls.DataGrid/Themes/Fluent.xaml"/>
3737
<StyleInclude Source="/Styles/Styles.axaml"/>
3838
</Application.Styles>

OpenUtau/App.axaml.cs

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
using Avalonia;
88
using Avalonia.Controls.ApplicationLifetimes;
99
using Avalonia.Markup.Xaml;
10-
using Avalonia.Markup.Xaml.MarkupExtensions;
10+
using Avalonia.Markup.Xaml.Styling;
1111
using OpenUtau.App.Views;
1212
using OpenUtau.Classic;
1313
using OpenUtau.Core;
@@ -38,16 +38,16 @@ public void InitializeCulture() {
3838
Log.Information("Initializing culture.");
3939
string sysLang = CultureInfo.InstalledUICulture.Name;
4040
string prefLang = Core.Util.Preferences.Default.Language;
41-
var languages = GetLanguages();
42-
if (languages.TryGetValue(prefLang, out var res)) {
43-
SetLanguage(res);
44-
} else if (languages.TryGetValue(sysLang, out res)) {
45-
SetLanguage(res);
46-
Core.Util.Preferences.Default.Language = sysLang;
47-
Core.Util.Preferences.Save();
48-
} else {
49-
SetLanguage(languages["en-US"]);
50-
}
41+
//var languages = GetLanguages();
42+
//if (languages.TryGetValue(prefLang, out var res)) {
43+
// SetLanguage(res);
44+
//} else if (languages.TryGetValue(sysLang, out res)) {
45+
// SetLanguage(res);
46+
// Core.Util.Preferences.Default.Language = sysLang;
47+
// Core.Util.Preferences.Save();
48+
//} else {
49+
// SetLanguage(languages["en-US"]);
50+
//}
5151

5252
// Force using InvariantCulture to prevent issues caused by culture dependent string conversion, especially for floating point numbers.
5353
Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
@@ -94,19 +94,19 @@ static void InitializeTheme() {
9494
}
9595

9696
public static void SetTheme() {
97-
var light = Current.Resources.MergedDictionaries
98-
.Select(res => (ResourceInclude)res)
99-
.FirstOrDefault(d => d.Source!.OriginalString.Contains("LightTheme"));
100-
var dark = Current.Resources.MergedDictionaries
101-
.Select(res => (ResourceInclude)res)
102-
.FirstOrDefault(d => d.Source!.OriginalString.Contains("DarkTheme"));
103-
if (Core.Util.Preferences.Default.Theme == 0) {
104-
Current.Resources.MergedDictionaries.Remove(light);
105-
Current.Resources.MergedDictionaries.Add(light);
106-
} else {
107-
Current.Resources.MergedDictionaries.Remove(dark);
108-
Current.Resources.MergedDictionaries.Add(dark);
109-
}
97+
//var light = Current.Resources.MergedDictionaries
98+
// .Select(res => (ResourceInclude)res)
99+
// .FirstOrDefault(d => d.Source!.OriginalString.Contains("LightTheme"));
100+
//var dark = Current.Resources.MergedDictionaries
101+
// .Select(res => (ResourceInclude)res)
102+
// .FirstOrDefault(d => d.Source!.OriginalString.Contains("DarkTheme"));
103+
//if (Core.Util.Preferences.Default.Theme == 0) {
104+
// Current.Resources.MergedDictionaries.Remove(light);
105+
// Current.Resources.MergedDictionaries.Add(light);
106+
//} else {
107+
// Current.Resources.MergedDictionaries.Remove(dark);
108+
// Current.Resources.MergedDictionaries.Add(dark);
109+
//}
110110
ThemeManager.LoadTheme();
111111
}
112112

OpenUtau/Controls/ExpSelector.axaml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<Grid Height="22" Width="60" Background="{Binding Background}" PointerPressed="TextBlockPointerPressed">
1111
<ComboBox VerticalAlignment="Center" HorizontalAlignment="Left" Height="22"
1212
Focusable="False" Foreground="{Binding TagBrush}" Background="Transparent" Width="20"
13-
SelectedItem="{Binding Descriptor}" Items="{Binding Descriptors}" SelectedIndex="{Binding SelectedIndex}">
13+
SelectedItem="{Binding Descriptor}" ItemsSource="{Binding Descriptors}" SelectedIndex="{Binding SelectedIndex}">
1414
<ComboBox.Styles>
1515
<Style Selector="ComboBox">
1616
<Setter Property="Padding" Value="{DynamicResource ComboBoxPadding}" />
@@ -77,12 +77,6 @@
7777
CornerRadius="{DynamicResource OverlayCornerRadius}">
7878
<ScrollViewer HorizontalScrollBarVisibility="{TemplateBinding ScrollViewer.HorizontalScrollBarVisibility}"
7979
VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}">
80-
<ItemsPresenter Name="PART_ItemsPresenter"
81-
Items="{TemplateBinding Items}"
82-
Margin="{DynamicResource ComboBoxDropdownContentMargin}"
83-
ItemsPanel="{TemplateBinding ItemsPanel}"
84-
ItemTemplate="{TemplateBinding ItemTemplate}"
85-
VirtualizationMode="{TemplateBinding VirtualizationMode}" />
8680
</ScrollViewer>
8781
</Border>
8882
</Popup>

OpenUtau/Controls/ExpSelector.axaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public ExpSelector() {
2525
((ExpSelectorViewModel)DataContext!).Index = Index;
2626
}
2727

28-
protected override void OnPropertyChanged<T>(AvaloniaPropertyChangedEventArgs<T> change) {
28+
protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change) {
2929
base.OnPropertyChanged(change);
3030
if (change.Property == IndexProperty) {
3131
((ExpSelectorViewModel)DataContext!).Index = Index;

OpenUtau/Controls/ExpressionCanvas.cs

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
namespace OpenUtau.App.Controls {
1313
public enum ExpDisMode { Hidden, Visible, Shadow };
1414

15-
class ExpressionCanvas : Canvas {
15+
class ExpressionCanvas : Control {
1616
public static readonly DirectProperty<ExpressionCanvas, double> TickWidthProperty =
1717
AvaloniaProperty.RegisterDirect<ExpressionCanvas, double>(
1818
nameof(TickWidth),
@@ -75,11 +75,8 @@ public ExpressionCanvas() {
7575
});
7676
}
7777

78-
protected override void OnPropertyChanged<T>(AvaloniaPropertyChangedEventArgs<T> change) {
78+
protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change) {
7979
base.OnPropertyChanged(change);
80-
if (!change.IsEffectiveValueChange) {
81-
return;
82-
}
8380
InvalidateVisual();
8481
}
8582

@@ -135,7 +132,7 @@ public override void Render(DrawingContext context) {
135132
double y2 = defaultHeight - Bounds.Height * (value2 - descriptor.defaultValue) / (descriptor.max - descriptor.min);
136133
var pen = value1 == descriptor.defaultValue && value2 == descriptor.defaultValue ? lPen : lPen2;
137134
context.DrawLine(pen, new Point(x1, y1), new Point(x2, y2));
138-
//using (var state = context.PushPreTransform(Matrix.CreateTranslation(x1, y1))) {
135+
//using (var state = context.PushTransform(Matrix.CreateTranslation(x1, y1))) {
139136
// context.DrawGeometry(brush, null, pointGeometry);
140137
//}
141138
index++;
@@ -166,13 +163,13 @@ public override void Render(DrawingContext context) {
166163
double zeroHeight = Math.Round(Bounds.Height - Bounds.Height * (0f - descriptor.min) / (descriptor.max - descriptor.min));
167164
context.DrawLine(vPen, new Point(x1 + 0.5, zeroHeight + 0.5), new Point(x1 + 0.5, valueHeight + 3));
168165
context.DrawLine(hPen, new Point(x1 + 3, valueHeight), new Point(Math.Max(x1 + 3, x2 - 3), valueHeight));
169-
using (var state = context.PushPreTransform(Matrix.CreateTranslation(x1 + 0.5, valueHeight))) {
166+
using (var state = context.PushTransform(Matrix.CreateTranslation(x1 + 0.5, valueHeight))) {
170167
context.DrawGeometry(overriden ? brush : ThemeManager.BackgroundBrush, vPen, pointGeometry);
171168
}
172169
} else if (descriptor.type == UExpressionType.Options) {
173170
for (int i = 0; i < descriptor.options.Length; ++i) {
174171
double y = optionHeight * (descriptor.options.Length - 1 - i + 0.5);
175-
using (var state = context.PushPreTransform(Matrix.CreateTranslation(x1 + 4.5, y))) {
172+
using (var state = context.PushTransform(Matrix.CreateTranslation(x1 + 4.5, y))) {
176173
if ((int)value == i) {
177174
context.DrawGeometry(brush, null, pointGeometry);
178175
context.DrawGeometry(null, hPen, circleGeometry);
@@ -190,15 +187,15 @@ public override void Render(DrawingContext context) {
190187
option = "\"\"";
191188
}
192189
var textLayout = TextLayoutCache.Get(option, ThemeManager.ForegroundBrush, 12);
193-
double y = optionHeight * (descriptor.options.Length - 1 - i + 0.5) - textLayout.Size.Height * 0.5;
190+
double y = optionHeight * (descriptor.options.Length - 1 - i + 0.5) - textLayout.Height * 0.5;
194191
y = Math.Round(y);
195-
var size = new Size(textLayout.Size.Width + 8, textLayout.Size.Height + 2);
196-
using (var state = context.PushPreTransform(Matrix.CreateTranslation(12, y))) {
192+
var size = new Size(textLayout.Width + 8, textLayout.Height + 2);
193+
using (var state = context.PushTransform(Matrix.CreateTranslation(12, y))) {
197194
context.DrawRectangle(
198195
ThemeManager.BackgroundBrush,
199196
ThemeManager.NeutralAccentPenSemi,
200197
new Rect(new Point(-4, -0.5), size), 4, 4);
201-
textLayout.Draw(context);
198+
textLayout.Draw(context, new Point());
202199
}
203200
}
204201
}

OpenUtau/Controls/LyricBox.axaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
VerticalAlignment="Stretch" HorizontalAlignment="Stretch"
1919
BorderThickness="0" Background="Transparent"
2020
Margin="{DynamicResource AutoCompleteListPadding}"
21-
Items="{Binding Suggestions}" SelectedItem="{Binding SelectedSuggestion}"
21+
ItemsSource="{Binding Suggestions}" SelectedItem="{Binding SelectedSuggestion}"
2222
KeyDown="ListBox_KeyDown">
2323
<ListBox.Styles>
2424
<Style Selector="ListBoxItem">

OpenUtau/Controls/LyricBox.axaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ public void EndEdit(bool commit = false) {
177177
viewModel.NoteOrPhoneme = null;
178178
viewModel.IsVisible = false;
179179
viewModel.Text = string.Empty;
180-
KeyboardDevice.Instance.SetFocusedElement(null, NavigationMethod.Unspecified, KeyModifiers.None);
180+
//KeyboardDevice.Instance.SetFocusedElement(null, NavigationMethod.Unspecified, KeyModifiers.None);
181181
}
182182
}
183183
}

OpenUtau/Controls/NotesCanvas.cs

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
using ReactiveUI;
1212

1313
namespace OpenUtau.App.Controls {
14-
class NotesCanvas : Canvas {
14+
class NotesCanvas : Control {
1515
public static readonly DirectProperty<NotesCanvas, double> TickWidthProperty =
1616
AvaloniaProperty.RegisterDirect<NotesCanvas, double>(
1717
nameof(TickWidth),
@@ -134,11 +134,8 @@ void RefreshGhostNotes() {
134134
.ToList();
135135
}
136136

137-
protected override void OnPropertyChanged<T>(AvaloniaPropertyChangedEventArgs<T> change) {
137+
protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change) {
138138
base.OnPropertyChanged(change);
139-
if (!change.IsEffectiveValueChange) {
140-
return;
141-
}
142139
InvalidateVisual();
143140
}
144141

@@ -210,17 +207,17 @@ private void RenderNoteBody(UNote note, NotesViewModel viewModel, DrawingContext
210207
}
211208
string displayLyric = note.lyric;
212209
var textLayout = TextLayoutCache.Get(displayLyric, Brushes.White, 12);
213-
if (textLayout.Size.Width + 5 > size.Width) {
210+
if (textLayout.Width + 5 > size.Width) {
214211
displayLyric = displayLyric[0] + "..";
215212
textLayout = TextLayoutCache.Get(displayLyric, Brushes.White, 12);
216-
if (textLayout.Size.Width + 5 > size.Width) {
213+
if (textLayout.Width + 5 > size.Width) {
217214
return;
218215
}
219216
}
220217
Point textPosition = leftTop.WithX(leftTop.X + 5)
221-
.WithY(Math.Round(leftTop.Y + (size.Height - textLayout.Size.Height) / 2));
222-
using (var state = context.PushPreTransform(Matrix.CreateTranslation(textPosition.X, textPosition.Y))) {
223-
textLayout.Draw(context);
218+
.WithY(Math.Round(leftTop.Y + (size.Height - textLayout.Height) / 2));
219+
using (var state = context.PushTransform(Matrix.CreateTranslation(textPosition.X, textPosition.Y))) {
220+
textLayout.Draw(context, new Point());
224221
}
225222
}
226223

@@ -256,7 +253,7 @@ private void RenderPitchBend(UNote note, NotesViewModel viewModel, DrawingContex
256253

257254
var brush = note.pitch.snapFirst ? ThemeManager.AccentBrush3 : null;
258255
var pen = ThemeManager.AccentPen3;
259-
using (var state = context.PushPreTransform(Matrix.CreateTranslation(p0.X, p0.Y))) {
256+
using (var state = context.PushTransform(Matrix.CreateTranslation(p0.X, p0.Y))) {
260257
context.DrawGeometry(brush, pen, pointGeometry);
261258
}
262259

@@ -283,7 +280,7 @@ private void RenderPitchBend(UNote note, NotesViewModel viewModel, DrawingContex
283280
}
284281
}
285282
p0 = p1;
286-
using (var state = context.PushPreTransform(Matrix.CreateTranslation(p0.X, p0.Y))) {
283+
using (var state = context.PushTransform(Matrix.CreateTranslation(p0.X, p0.Y))) {
287284
context.DrawGeometry(null, pen, pointGeometry);
288285
}
289286
}
@@ -318,7 +315,7 @@ private void RenderVibratoToggle(UNote note, NotesViewModel viewModel, DrawingCo
318315
var togglePos = vibrato.GetToggle(note);
319316
Point icon = viewModel.TickToneToPoint(togglePos.X, togglePos.Y);
320317
var pen = ThemeManager.BarNumberPen;
321-
using (var state = context.PushPreTransform(Matrix.CreateTranslation(icon.X - 10, icon.Y))) {
318+
using (var state = context.PushTransform(Matrix.CreateTranslation(icon.X - 10, icon.Y))) {
322319
context.DrawGeometry(vibrato.length == 0 ? null : pen.Brush, pen, vibratoIcon);
323320
}
324321
}
@@ -336,13 +333,13 @@ private void RenderVibratoControl(UNote note, NotesViewModel viewModel, DrawingC
336333
context.DrawLine(pen, start, fadeIn);
337334
context.DrawLine(pen, fadeIn, fadeOut);
338335
context.DrawLine(pen, fadeOut, end);
339-
using (var state = context.PushPreTransform(Matrix.CreateTranslation(start))) {
336+
using (var state = context.PushTransform(Matrix.CreateTranslation(start))) {
340337
context.DrawGeometry(pen.Brush, pen, pointGeometry);
341338
}
342-
using (var state = context.PushPreTransform(Matrix.CreateTranslation(fadeIn))) {
339+
using (var state = context.PushTransform(Matrix.CreateTranslation(fadeIn))) {
343340
context.DrawGeometry(pen.Brush, pen, pointGeometry);
344341
}
345-
using (var state = context.PushPreTransform(Matrix.CreateTranslation(fadeOut))) {
342+
using (var state = context.PushTransform(Matrix.CreateTranslation(fadeOut))) {
346343
context.DrawGeometry(pen.Brush, pen, pointGeometry);
347344
}
348345
vibrato.GetPeriodStartEnd(DocManager.Inst.Project, note, out var periodStartPos, out var periodEndPos);

OpenUtau/Controls/PartControl.cs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,8 @@ public PartControl(UPart part, PartsCanvas canvas) {
130130
}
131131
}
132132

133-
protected override void OnPropertyChanged<T>(AvaloniaPropertyChangedEventArgs<T> change) {
133+
protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change) {
134134
base.OnPropertyChanged(change);
135-
if (!change.IsEffectiveValueChange) {
136-
return;
137-
}
138135
if (change.Property == OffsetProperty ||
139136
change.Property == TrackHeightProperty ||
140137
change.Property == TickWidthProperty) {
@@ -169,9 +166,9 @@ public override void Render(DrawingContext context) {
169166

170167
// Text
171168
var textLayout = TextLayoutCache.Get(Text, Foreground!, 12);
172-
using (var state = context.PushPreTransform(Matrix.CreateTranslation(3, 2))) {
173-
context.DrawRectangle(backgroundBrush, null, new Rect(new Point(0, 0), textLayout.Size));
174-
textLayout.Draw(context);
169+
using (var state = context.PushTransform(Matrix.CreateTranslation(3, 2))) {
170+
context.DrawRectangle(backgroundBrush, null, new Rect(new Point(0, 0), new Size(textLayout.Width, textLayout.Height)));
171+
textLayout.Draw(context, new Point());
175172
}
176173

177174
if (part == null) {
@@ -186,7 +183,7 @@ public override void Render(DrawingContext context) {
186183
minTone -= additional;
187184
maxTone += additional;
188185
}
189-
using var pushedState = context.PushPreTransform(Matrix.CreateScale(1, trackHeight / (maxTone - minTone)));
186+
using var pushedState = context.PushTransform(Matrix.CreateScale(1, trackHeight / (maxTone - minTone)));
190187
foreach (var note in voicePart.notes) {
191188
var start = new Point((int)(note.position * tickWidth), maxTone - note.tone);
192189
var end = new Point((int)(note.End * tickWidth), maxTone - note.tone);

0 commit comments

Comments
 (0)