Skip to content

Commit e75fc6e

Browse files
committed
redo look of track color
1 parent cfeaa62 commit e75fc6e

File tree

3 files changed

+26
-5
lines changed

3 files changed

+26
-5
lines changed

OpenUtau/Controls/TrackHeader.axaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
<Grid Grid.Row="0" Grid.RowSpan="6" Grid.Column="0" VerticalAlignment="Top">
3939
<Border BorderThickness="0,0,1,1" Height="101" Width="101" VerticalAlignment="Top" CornerRadius="0,0,2,0"
4040
BorderBrush="{DynamicResource NeutralAccentBrushSemi}" ClipToBounds="True">
41-
<Image Margin="7,0,0,0" Source="{Binding Avatar}" Stretch="UniformToFill" VerticalAlignment="Top" ToolTip.Tip="{Binding Singer}"/>
41+
<Image Source="{Binding Avatar}" Stretch="UniformToFill" VerticalAlignment="Top" ToolTip.Tip="{Binding Singer}"/>
4242
</Border>
4343
<Border Background="{Binding TrackAccentColor}" Height="16" Width="22" CornerRadius="1,0,2,0"
4444
HorizontalAlignment="Left" VerticalAlignment="Top">

OpenUtau/ViewModels/NotesViewModel.cs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ public class NotesViewModel : ViewModelBase, ICmdSubscriber {
7171
[Reactive] public double ExpTrackHeight { get; set; }
7272
[Reactive] public double ExpShadowOpacity { get; set; }
7373
[Reactive] public UVoicePart? Part { get; set; }
74+
[Reactive] public Bitmap? Avatar { get; set; }
7475
[Reactive] public Bitmap? Portrait { get; set; }
7576
[Reactive] public IBrush? PortraitMask { get; set; }
7677
[Reactive] public string WindowTitle { get; set; } = "Piano Roll";
@@ -381,12 +382,28 @@ private void LoadPart(UPart part, UProject project) {
381382
private void LoadPortrait(UPart? part, UProject? project) {
382383
if (part == null || project == null) {
383384
lock (portraitLock) {
385+
Avatar = null;
384386
Portrait = null;
385387
portraitSource = null;
386388
}
387389
return;
388390
}
389391
var singer = project.tracks[part.trackNo].Singer;
392+
lock (portraitLock) {
393+
Avatar?.Dispose();
394+
Avatar = null;
395+
if (singer != null && singer.AvatarData != null) {
396+
try {
397+
using (var stream = new MemoryStream(singer.AvatarData)) {
398+
Avatar = new Bitmap(stream);
399+
}
400+
} catch (Exception e) {
401+
Avatar?.Dispose();
402+
Avatar = null;
403+
Log.Error(e, $"Failed to load Avatar {singer.Avatar}");
404+
}
405+
}
406+
}
390407
if (singer == null || string.IsNullOrEmpty(singer.Portrait) || !Preferences.Default.ShowPortrait) {
391408
lock (portraitLock) {
392409
Portrait = null;
@@ -396,14 +413,14 @@ private void LoadPortrait(UPart? part, UProject? project) {
396413
}
397414
if (portraitSource != singer.Portrait) {
398415
lock (portraitLock) {
416+
Portrait?.Dispose();
399417
Portrait = null;
400418
portraitSource = null;
401419
}
402420
PortraitMask = new SolidColorBrush(Colors.White, singer.PortraitOpacity);
403421
Task.Run(() => {
404422
lock (portraitLock) {
405423
try {
406-
Portrait?.Dispose();
407424
var data = singer.LoadPortrait();
408425
if (data == null) {
409426
Portrait = null;

OpenUtau/Views/PianoRollWindow.axaml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,13 @@
3131
<ColumnDefinition Width="24"/>
3232
<ColumnDefinition Width="Auto"/>
3333
</Grid.ColumnDefinitions>
34-
<Border Background="Wheat" Grid.Column="0" Grid.Row="0" Grid.RowSpan="2">
35-
<Rectangle HorizontalAlignment="Left" VerticalAlignment="Stretch" Width="12" Fill="AliceBlue"/>
36-
</Border>
34+
<Grid Grid.Column="0" Grid.Row="0" Grid.RowSpan="2">
35+
<Rectangle HorizontalAlignment="Left" VerticalAlignment="Stretch" Width="12" Fill="{Binding NotesViewModel.TrackAccentColor}"/>
36+
<Border Margin="12,0,0,0" Width="48" Height="48" ClipToBounds="True">
37+
<Image HorizontalAlignment="Center" VerticalAlignment="Center"
38+
Width="50" Height="50" Stretch="None" Source="{Binding NotesViewModel.Avatar}"/>
39+
</Border>
40+
</Grid>
3741
<ScrollBar Name="HScrollBar" Classes="music" Grid.Row="0" Grid.Column="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
3842
Margin="0,4,0,4" Orientation="Horizontal" AllowAutoHide="False"
3943
DataContext="{Binding NotesViewModel}"

0 commit comments

Comments
 (0)