Skip to content

Commit

Permalink
Merge pull request #765 from maiko3tattun/0701_TrackColor
Browse files Browse the repository at this point in the history
Add Track color
  • Loading branch information
stakira committed Jul 11, 2023
2 parents 8fa24a8 + 68e9b86 commit 7cdcca5
Show file tree
Hide file tree
Showing 23 changed files with 391 additions and 54 deletions.
13 changes: 13 additions & 0 deletions OpenUtau.Core/Commands/TrackCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,19 @@ public RenameTrackCommand(UProject project, UTrack track, string name) {
public override void Unexecute() => track.TrackName = oldName;
}

public class ChangeTrackColorCommand : TrackCommand {
readonly string newName, oldName;
public ChangeTrackColorCommand(UProject project, UTrack track, string colorName) {
this.project = project;
this.track = track;
newName = colorName;
oldName = track.TrackColor;
}
public override string ToString() => "Change track color";
public override void Execute() => track.TrackColor = newName;
public override void Unexecute() => track.TrackColor = oldName;
}

public class TrackChangeSingerCommand : TrackCommand {
readonly USinger newSinger, oldSinger;
public TrackChangeSingerCommand(UProject project, UTrack track, USinger newSinger) {
Expand Down
1 change: 1 addition & 0 deletions OpenUtau.Core/Ustx/UTrack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ public USinger Singer {
[YamlIgnore] public string SingerName => Singer != null ? Singer.DisplayName : "[No Singer]";
[YamlIgnore] public int TrackNo { set; get; }
public string TrackName { get; set; } = "New Track";
public string TrackColor { get; set; } = "Blue";
[YamlIgnore] public bool Muted { set; get; }
public bool Mute { get; set; }
public bool Solo { get; set; }
Expand Down
1 change: 1 addition & 0 deletions OpenUtau.Core/Util/Preferences.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ public class SerializablePreferences {
public bool ShowPrefs = true;
public bool ShowTips = true;
public int Theme;
public bool UseTrackColor = false;
public bool PreRender = true;
public int NumRenderThreads = 2;
public string OnnxRunner = string.Empty;
Expand Down
8 changes: 8 additions & 0 deletions OpenUtau/Colors/Brushes.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,14 @@
Color="{DynamicResource AccentColor3}" />
<SolidColorBrush x:Key="AccentBrush3Semi"
Color="{DynamicResource AccentColor3}" Opacity="0.5" />
<SolidColorBrush x:Key="SelectedTrackAccentBrush"
Color="#4EA6EA" />
<SolidColorBrush x:Key="SelectedTrackAccentLightBrush"
Color="#90CAF9" />
<SolidColorBrush x:Key="SelectedTrackAccentLightBrushSemi"
Color="#90CAF9" Opacity="0.5"/>
<SolidColorBrush x:Key="SelectedTrackAccentDarkBrush"
Color="#1E88E5" />

<LinearGradientBrush x:Key="WhiteKeyBrush" StartPoint="0%,50%" EndPoint="100%,50%">
<LinearGradientBrush.GradientStops>
Expand Down
4 changes: 2 additions & 2 deletions OpenUtau/Colors/DarkTheme.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@

<Color x:Key="SystemAccentColor">#4EA6EA</Color>
<!-- PointerOver -->
<Color x:Key="SystemAccentColorLight1">#4EA6EA</Color>
<Color x:Key="SystemAccentColorLight1">#90CAF9</Color>
<!-- Pressed -->
<Color x:Key="SystemAccentColorDark1">#4EA6EA</Color>
<Color x:Key="SystemAccentColorDark1">#1E88E5</Color>

<Color x:Key="NeutralAccentColor">#808080</Color>
<Color x:Key="NeutralAccentColorPointerOver">#A0A0A0</Color>
Expand Down
4 changes: 2 additions & 2 deletions OpenUtau/Colors/LightTheme.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@

<Color x:Key="SystemAccentColor">#4EA6EA</Color>
<!-- PointerOver -->
<Color x:Key="SystemAccentColorLight1">#4EA6EA</Color>
<Color x:Key="SystemAccentColorLight1">#90CAF9</Color>
<!-- Pressed -->
<Color x:Key="SystemAccentColorDark1">#4EA6EA</Color>
<Color x:Key="SystemAccentColorDark1">#1E88E5</Color>

<Color x:Key="NeutralAccentColor">#ADA1B3</Color>
<Color x:Key="NeutralAccentColorPointerOver">#948A99</Color>
Expand Down
42 changes: 32 additions & 10 deletions OpenUtau/Controls/TrackHeader.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,31 @@
<Style Selector="ToggleButton">
<Setter Property="Background" Value="Transparent"/>
</Style>
<Style Selector="Slider.fader">
<Setter Property="Foreground" Value="{Binding TrackColor.AccentColor}"/>

<Style Selector="^:pointerover">
<!--<Style Selector="^ /template/ Thumb">
<Setter Property="Background" Value="{Binding TrackColor.AccentColorLight}" />
</Style>-->
<Style Selector="^ /template/ RepeatButton#PART_DecreaseButton">
<Setter Property="Background" Value="{Binding TrackColor.AccentColorLight}" />
</Style>
</Style>
<Style Selector="^:pressed">
<!--<Style Selector="^ /template/ Thumb">
<Setter Property="Background" Value="{Binding TrackColor.AccentColorDark}" />
</Style>-->
<Style Selector="^ /template/ RepeatButton#PART_DecreaseButton">
<Setter Property="Background" Value="{Binding TrackColor.AccentColorDark}" />
</Style>
</Style>
</Style>
</UserControl.Styles>
<Border Margin="1,1,1,1" BorderThickness="1" BorderBrush="{DynamicResource NeutralAccentBrushSemi}" CornerRadius="2">
<Grid Background="Transparent" RowDefinitions="20,20,20,20,20,*" ColumnDefinitions="Auto,1,*,20" VerticalAlignment="Top" ClipToBounds="True">
<Grid Grid.Row="0" Grid.RowSpan="6" Grid.Column="0" VerticalAlignment="Top">
<Grid Background="Transparent" RowDefinitions="20,20,20,20,20,*" ColumnDefinitions="7,Auto,1,*,20" VerticalAlignment="Top" ClipToBounds="True">
<Border Background="{Binding TrackAccentColor}" Grid.RowSpan="6" CornerRadius="2,0,0,2" />
<Grid Grid.Row="0" Grid.RowSpan="6" Grid.Column="1" 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 Source="{Binding Avatar}" Stretch="UniformToFill" VerticalAlignment="Top" ToolTip.Tip="{Binding Singer}"/>
Expand All @@ -26,10 +47,10 @@
Text="{Binding TrackNo}" Foreground="White" VerticalAlignment="Center"/>
</Border>
</Grid>
<Button Classes="clear" Grid.Row="0" Grid.Column="2" Grid.ColumnSpan="2" Margin="1" Padding="2,1,0,0" Height="18"
<Button Classes="clear" Grid.Row="0" Grid.Column="3" Grid.ColumnSpan="2" Margin="1" Padding="2,1,0,0" Height="18"
HorizontalAlignment="Stretch" HorizontalContentAlignment="Left" Focusable="False"
Content="{Binding TrackName}" Click="TrackNameButtonClicked"/>
<Button Classes="clear" Grid.Row="1" Grid.Column="2" Margin="1" Padding="2,1,0,0" Height="18"
<Button Classes="clear" Grid.Row="1" Grid.Column="3" Margin="1" Padding="2,1,0,0" Height="18"
HorizontalAlignment="Stretch" HorizontalContentAlignment="Left" Focusable="False"
Content="{Binding Singer, TargetNullValue={StaticResource tracks.selectsinger}}" Click="SingerButtonClicked" ContextRequested="SingerButtonContextRequested"
ToolTip.Tip="{Binding Singer}">
Expand All @@ -46,7 +67,7 @@
</ContextMenu>
</Button.ContextMenu>
</Button>
<Button Classes="clear" Grid.Row="2" Grid.Column="2" Margin="1" Padding="2,1,0,0" Height="18"
<Button Classes="clear" Grid.Row="2" Grid.Column="3" Margin="1" Padding="2,1,0,0" Height="18"
HorizontalAlignment="Stretch" HorizontalContentAlignment="Left" Focusable="False"
Content="{Binding PhonemizerTag}" Click="PhonemizerButtonClicked" ContextRequested="PhonemizerButtonContextRequested"
ToolTip.Tip="{Binding Phonemizer}">
Expand All @@ -63,7 +84,7 @@
</ContextMenu>
</Button.ContextMenu>
</Button>
<Button Classes="clear" Grid.Row="3" Grid.Column="2" Margin="1" Padding="2,1,0,0" Height="18"
<Button Classes="clear" Grid.Row="3" Grid.Column="3" Margin="1" Padding="2,1,0,0" Height="18"
HorizontalAlignment="Stretch" HorizontalContentAlignment="Left" Focusable="False"
Content="{Binding Renderer}" Click="RendererButtonClicked" ContextRequested="RendererButtonContextRequested"
ToolTip.Tip="{DynamicResource tracks.selectrenderer}">
Expand All @@ -80,7 +101,7 @@
</ContextMenu>
</Button.ContextMenu>
</Button>
<ToggleButton Grid.Row="1" Grid.Column="3" Margin="1" Padding="0" Height="18"
<ToggleButton Grid.Row="1" Grid.Column="4" Margin="1" Padding="0" Height="18"
HorizontalAlignment="Stretch"
IsChecked="{Binding Mute, Mode=OneWay}" Command="{Binding ToggleMute}">
<TextBlock Text="M" TextAlignment="Center"/>
Expand All @@ -93,7 +114,7 @@
</ContextMenu>
</ToggleButton.ContextMenu>
</ToggleButton>
<ToggleButton Grid.Row="2" Grid.Column="3" Margin="1" Padding="0" Height="18"
<ToggleButton Grid.Row="2" Grid.Column="4" Margin="1" Padding="0" Height="18"
HorizontalAlignment="Stretch"
IsChecked="{Binding Solo, Mode=OneWay}" Command="{Binding ToggleSolo}">
<TextBlock Text="S" TextAlignment="Center"/>
Expand All @@ -105,7 +126,7 @@
</ContextMenu>
</ToggleButton.ContextMenu>
</ToggleButton>
<Button Grid.Row="3" Grid.Column="3" Margin="1" Padding="0" Height="18" Background="Transparent"
<Button Grid.Row="3" Grid.Column="4" Margin="1" Padding="0" Height="18" Background="Transparent"
HorizontalAlignment="Stretch" Click="TrackSettingsButtonClicked">
<Path Classes="clear" Width="24" Height="24"
Data="M12,15.5A3.5,3.5 0 0,1 8.5,12A3.5,3.5 0 0,1 12,8.5A3.5,3.5 0 0,1 15.5,12A3.5,3.5 0 0,1 12,15.5M19.43,12.97C19.47,12.65 19.5,12.33 19.5,12C19.5,11.67 19.47,11.34 19.43,11L21.54,9.37C21.73,9.22 21.78,8.95 21.66,8.73L19.66,5.27C19.54,5.05 19.27,4.96 19.05,5.05L16.56,6.05C16.04,5.66 15.5,5.32 14.87,5.07L14.5,2.42C14.46,2.18 14.25,2 14,2H10C9.75,2 9.54,2.18 9.5,2.42L9.13,5.07C8.5,5.32 7.96,5.66 7.44,6.05L4.95,5.05C4.73,4.96 4.46,5.05 4.34,5.27L2.34,8.73C2.21,8.95 2.27,9.22 2.46,9.37L4.57,11C4.53,11.34 4.5,11.67 4.5,12C4.5,12.33 4.53,12.65 4.57,12.97L2.46,14.63C2.27,14.78 2.21,15.05 2.34,15.27L4.34,18.73C4.46,18.95 4.73,19.03 4.95,18.95L7.44,17.94C7.96,18.34 8.5,18.68 9.13,18.93L9.5,21.58C9.54,21.82 9.75,22 10,22H14C14.25,22 14.46,21.82 14.5,21.58L14.87,18.93C15.5,18.67 16.04,18.34 16.56,17.94L19.05,18.95C19.27,19.03 19.54,18.95 19.66,18.73L21.66,15.27C21.78,15.05 21.73,14.78 21.54,14.63L19.43,12.97Z"
Expand All @@ -118,7 +139,7 @@
</Path.RenderTransform>
</Path>
</Button>
<Grid Grid.Row="4" Grid.Column="2" Grid.ColumnSpan="2" Height="20">
<Grid Grid.Row="4" Grid.Column="3" Grid.ColumnSpan="2">
<Slider Margin="1,0,0,0" Width="102" HorizontalAlignment="Left" Classes="fader" Minimum="-24" Maximum="12" Value="{Binding Volume}"
PointerPressed="VolumeFaderPointerPressed"
ContextRequested="VolumeFaderContextRequested" IsEnabled="{Binding !Muted}"/>
Expand Down Expand Up @@ -147,6 +168,7 @@
<MenuItem Classes="context" Header="{StaticResource tracks.moveup}" Command="{Binding MoveUp}"/>
<MenuItem Classes="context" Header="{StaticResource tracks.movedown}" Command="{Binding MoveDown}"/>
<MenuItem Classes="context" Header="{StaticResource tracks.rename}" Command="{Binding Rename}"/>
<MenuItem Classes="context" Header="{StaticResource tracks.trackcolor}" Command="{Binding SelectTrackColor}"/>
<MenuItem Classes="context" Header="{StaticResource tracks.duplicate}" Command="{Binding Duplicate}"/>
<MenuItem Classes="context" Header="{StaticResource tracks.duplicatesettings}" Command="{Binding DuplicateSettings}"/>
</ContextMenu>
Expand Down
3 changes: 3 additions & 0 deletions OpenUtau/OpenUtau.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@
<Compile Update="Views\TrackSettingsDialog.axaml.cs">
<DependentUpon>TrackSettingsDialog.axaml</DependentUpon>
</Compile>
<Compile Update="Views\TrackColorDialog.axaml.cs">
<DependentUpon>TrackColorDialog.axaml</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Update="Resources\Resources.resx">
Expand Down
2 changes: 2 additions & 0 deletions OpenUtau/Strings/Strings.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ Warning: this option removes custom presets.</system:String>
<system:String x:Key="prefs.appearance.theme">Theme</system:String>
<system:String x:Key="prefs.appearance.theme.dark">Dark</system:String>
<system:String x:Key="prefs.appearance.theme.light">Light</system:String>
<system:String x:Key="prefs.appearance.trackcolor">Use track color in UI</system:String>
<system:String x:Key="prefs.caption">Preferences</system:String>
<system:String x:Key="prefs.note.restart">Note: please restart OpenUtau after changing this item.</system:String>
<system:String x:Key="prefs.off">Off</system:String>
Expand Down Expand Up @@ -405,6 +406,7 @@ General
<system:String x:Key="tracks.solo.add">Solo additionally (which not removes solo from other tracks)</system:String>
<system:String x:Key="tracks.solo.only">Solo this only (which removes solo from other tracks)</system:String>
<system:String x:Key="tracks.solo.unsoloall">Unsolo all</system:String>
<system:String x:Key="tracks.trackcolor">Change track color</system:String>

<FontFamily x:Key="ui.fontfamily">Segoe UI,San Francisco,Helvetica Neue</FontFamily>
<FontFamily x:Key="ui.textbox.fontfamily">Microsoft YaHei,Simsun,苹方-简,宋体-简</FontFamily>
Expand Down
2 changes: 2 additions & 0 deletions OpenUtau/Strings/Strings.ja-JP.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@
<system:String x:Key="prefs.appearance.theme">テーマ</system:String>
<system:String x:Key="prefs.appearance.theme.dark">ダーク</system:String>
<system:String x:Key="prefs.appearance.theme.light">ライト</system:String>
<system:String x:Key="prefs.appearance.trackcolor">UIにトラックカラーを使用する</system:String>
<system:String x:Key="prefs.caption">環境設定</system:String>
<system:String x:Key="prefs.note.restart">Note: この設定を変更した後は、OpenUtauを再起動してください。</system:String>
<system:String x:Key="prefs.off">オフ</system:String>
Expand Down Expand Up @@ -404,6 +405,7 @@
<system:String x:Key="tracks.solo.add">ソロ (他トラックのソロを解除しない)</system:String>
<system:String x:Key="tracks.solo.only">ソロ (他トラックのソロを解除)</system:String>
<system:String x:Key="tracks.solo.unsoloall">全トラックのソロを解除</system:String>
<system:String x:Key="tracks.trackcolor">トラックカラーを変更</system:String>

<FontFamily x:Key="ui.fontfamily">Meiryo UI,Hiragino Sans,Segoe UI,San Francisco,Helvetica Neue</FontFamily>
<!--<FontFamily x:Key="ui.textbox.fontfamily">Microsoft YaHei,Simsun,苹方-简,宋体-简</FontFamily>-->
Expand Down
61 changes: 61 additions & 0 deletions OpenUtau/Styles/PianoRollStyles.axaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<Styles xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

<Style Selector="Button,ToggleButton">
<Setter Property="Focusable" Value="False"/>
</Style>

<Style Selector="CheckBox:checked /template/ Border#NormalRectangle">
<Setter Property="Background" Value="{DynamicResource SelectedTrackAccentBrush}"/>
<Setter Property="BorderBrush" Value="{DynamicResource SelectedTrackAccentBrush}"/>
</Style>
<Style Selector="CheckBox:checked:pointerover /template/ Border#NormalRectangle">
<Setter Property="Background" Value="{DynamicResource SelectedTrackAccentLightBrush}"/>
<Setter Property="BorderBrush" Value="{DynamicResource SelectedTrackAccentLightBrush}"/>
</Style>
<Style Selector="CheckBox:checked:pressed /template/ Border#NormalRectangle">
<Setter Property="Background" Value="{DynamicResource SelectedTrackAccentDarkBrush}"/>
<Setter Property="BorderBrush" Value="{DynamicResource SelectedTrackAccentDarkBrush}"/>
</Style>

<Style Selector="ComboBoxItem:selected /template/ ContentPresenter">
<Setter Property="Background" Value="{DynamicResource SelectedTrackAccentLightBrushSemi}"/>
</Style>

<Style Selector="ListBoxItem:selected /template/ ContentPresenter">
<Setter Property="Background" Value="{DynamicResource SelectedTrackAccentLightBrushSemi}"/>
</Style>

<Style Selector="Slider.fader">
<Setter Property="Foreground" Value="{DynamicResource SelectedTrackAccentBrush}"/>
</Style>
<Style Selector="Slider.fader:pointerover">
<Style Selector="^ /template/ RepeatButton#PART_DecreaseButton">
<Setter Property="Background" Value="{DynamicResource SelectedTrackAccentLightBrush}" />
</Style>
<Style Selector="^ /template/ Thumb">
<Setter Property="Background" Value="{DynamicResource SelectedTrackAccentLightBrush}" />
</Style>
</Style>
<Style Selector="Slider.fader:pressed">
<Style Selector="^ /template/ RepeatButton#PART_DecreaseButton">
<Setter Property="Background" Value="{DynamicResource SelectedTrackAccentDarkBrush}" />
</Style>
<Style Selector="^ /template/ Thumb">
<Setter Property="Background" Value="{DynamicResource SelectedTrackAccentDarkBrush}" />
</Style>
</Style>

<Style Selector="TextBox:focus /template/ Border#PART_BorderElement">
<Setter Property="BorderBrush" Value="{DynamicResource SelectedTrackAccentBrush}"/>
</Style>

<!--
<Style Selector="ToggleSwitch:pressed /template/ ">
<Setter Property="BorderBrush" Value="{DynamicResource SelectedTrackAccentBrush}"/>
</Style>
<Style Selector="ToggleSwitch:pressed:pointerover /template/ ">
<Setter Property="BorderBrush" Value="{DynamicResource SelectedTrackAccentLightBrush}"/>
</Style>
-->
</Styles>
Loading

0 comments on commit 7cdcca5

Please sign in to comment.