Skip to content

Commit

Permalink
redo look of track color
Browse files Browse the repository at this point in the history
  • Loading branch information
stakira committed Jul 13, 2023
1 parent cfeaa62 commit e75fc6e
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
2 changes: 1 addition & 1 deletion OpenUtau/Controls/TrackHeader.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
<Grid Grid.Row="0" Grid.RowSpan="6" Grid.Column="0" VerticalAlignment="Top">
<Border BorderThickness="0,0,1,1" Height="101" Width="101" VerticalAlignment="Top" CornerRadius="0,0,2,0"
BorderBrush="{DynamicResource NeutralAccentBrushSemi}" ClipToBounds="True">
<Image Margin="7,0,0,0" Source="{Binding Avatar}" Stretch="UniformToFill" VerticalAlignment="Top" ToolTip.Tip="{Binding Singer}"/>
<Image Source="{Binding Avatar}" Stretch="UniformToFill" VerticalAlignment="Top" ToolTip.Tip="{Binding Singer}"/>
</Border>
<Border Background="{Binding TrackAccentColor}" Height="16" Width="22" CornerRadius="1,0,2,0"
HorizontalAlignment="Left" VerticalAlignment="Top">
Expand Down
19 changes: 18 additions & 1 deletion OpenUtau/ViewModels/NotesViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public class NotesViewModel : ViewModelBase, ICmdSubscriber {
[Reactive] public double ExpTrackHeight { get; set; }
[Reactive] public double ExpShadowOpacity { get; set; }
[Reactive] public UVoicePart? Part { get; set; }
[Reactive] public Bitmap? Avatar { get; set; }
[Reactive] public Bitmap? Portrait { get; set; }
[Reactive] public IBrush? PortraitMask { get; set; }
[Reactive] public string WindowTitle { get; set; } = "Piano Roll";
Expand Down Expand Up @@ -381,12 +382,28 @@ private void LoadPart(UPart part, UProject project) {
private void LoadPortrait(UPart? part, UProject? project) {
if (part == null || project == null) {
lock (portraitLock) {
Avatar = null;
Portrait = null;
portraitSource = null;
}
return;
}
var singer = project.tracks[part.trackNo].Singer;
lock (portraitLock) {
Avatar?.Dispose();
Avatar = null;
if (singer != null && singer.AvatarData != null) {
try {
using (var stream = new MemoryStream(singer.AvatarData)) {
Avatar = new Bitmap(stream);
}
} catch (Exception e) {
Avatar?.Dispose();
Avatar = null;
Log.Error(e, $"Failed to load Avatar {singer.Avatar}");
}
}
}
if (singer == null || string.IsNullOrEmpty(singer.Portrait) || !Preferences.Default.ShowPortrait) {
lock (portraitLock) {
Portrait = null;
Expand All @@ -396,14 +413,14 @@ private void LoadPortrait(UPart? part, UProject? project) {
}
if (portraitSource != singer.Portrait) {
lock (portraitLock) {
Portrait?.Dispose();
Portrait = null;
portraitSource = null;
}
PortraitMask = new SolidColorBrush(Colors.White, singer.PortraitOpacity);
Task.Run(() => {
lock (portraitLock) {
try {
Portrait?.Dispose();
var data = singer.LoadPortrait();
if (data == null) {
Portrait = null;
Expand Down
10 changes: 7 additions & 3 deletions OpenUtau/Views/PianoRollWindow.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,13 @@
<ColumnDefinition Width="24"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Border Background="Wheat" Grid.Column="0" Grid.Row="0" Grid.RowSpan="2">
<Rectangle HorizontalAlignment="Left" VerticalAlignment="Stretch" Width="12" Fill="AliceBlue"/>
</Border>
<Grid Grid.Column="0" Grid.Row="0" Grid.RowSpan="2">
<Rectangle HorizontalAlignment="Left" VerticalAlignment="Stretch" Width="12" Fill="{Binding NotesViewModel.TrackAccentColor}"/>
<Border Margin="12,0,0,0" Width="48" Height="48" ClipToBounds="True">
<Image HorizontalAlignment="Center" VerticalAlignment="Center"
Width="50" Height="50" Stretch="None" Source="{Binding NotesViewModel.Avatar}"/>
</Border>
</Grid>
<ScrollBar Name="HScrollBar" Classes="music" Grid.Row="0" Grid.Column="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
Margin="0,4,0,4" Orientation="Horizontal" AllowAutoHide="False"
DataContext="{Binding NotesViewModel}"
Expand Down

0 comments on commit e75fc6e

Please sign in to comment.