Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions OpenUtau.Core/Util/Preferences.cs
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,6 @@ public class SerializablePreferences {
public bool LockUnselectedNotesPitch = true;
public bool LockUnselectedNotesVibrato = true;
public bool LockUnselectedNotesExpressions = true;
public bool LyricLivePreview = true;
public bool LyricApplySelectionOnly = true;
public bool VoicebankPublishUseIgnore = true;
public string VoicebankPublishIgnores = @"#Adobe Audition
*.pkf
Expand Down
78 changes: 78 additions & 0 deletions OpenUtau/Controls/LyricsPanel.axaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<UserControl xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="100"
x:Class="OpenUtau.App.Controls.LyricsPanel"
Focusable="True">
<UserControl.Styles>
<StyleInclude Source="/Styles/PianoRollStyles.axaml"/>
</UserControl.Styles>
<Grid Margin="10" RowDefinitions="Auto,4,*" ColumnDefinitions="*,12,Auto,4,Auto">
<TextBox Name="LyricsBox" Grid.RowSpan="3" Grid.Column="0" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"
AcceptsReturn="True" AcceptsTab="False" TextWrapping="Wrap"
Margin="0" Height="65" ScrollViewer.VerticalScrollBarVisibility="Visible"
Text="{Binding Text}" Focusable="True" IsUndoEnabled="False"/>

<StackPanel Grid.Row="0" Grid.Column="2" Orientation="Horizontal" Spacing="10">
<TextBlock Text="{DynamicResource lyrics.skipsymbols}" Margin="0,8"/>
<ToggleSwitch IsChecked="{Binding SkipSymbols}">
<ToggleSwitch.Styles>
<Style Selector="TextBlock">
<Setter Property="IsVisible" Value="False"/>
</Style>
</ToggleSwitch.Styles>
</ToggleSwitch>
</StackPanel>

<StackPanel Grid.Row="2" Grid.Column="2" Orientation="Horizontal" Spacing="4" Margin="0,0,0,6">
<TextBlock Margin="0,2">
<TextBlock.Text>
<MultiBinding StringFormat="{}{0}/{1}">
<Binding Path="CurrentCount"/>
<Binding Path="TotalCount"/>
</MultiBinding>
</TextBlock.Text>
</TextBlock>
<Border Width="6"/>

<TextBlock Text="{DynamicResource lyrics.separators}" Margin="0,2"/>
<Border CornerRadius="5"
Background="{DynamicResource MenuFlyoutItemBackgroundPointerOver}">
<TextBlock Text="⎵" Margin="0" Padding="4,2"/>
</Border>
<Border CornerRadius="5"
Background="{DynamicResource MenuFlyoutItemBackgroundPointerOver}">
<TextBlock Text="," Margin="0" Padding="4,2"/>
</Border>
<Border CornerRadius="5"
Background="{DynamicResource MenuFlyoutItemBackgroundPointerOver}">
<TextBlock Text="&quot;" Margin="0" Padding="4,2"/>
</Border>
<Border CornerRadius="5"
Background="{DynamicResource MenuFlyoutItemBackgroundPointerOver}">
<TextBlock Text="↵" Margin="0" Padding="4,2"/>
</Border>
<Border CornerRadius="5"
Background="{DynamicResource MenuFlyoutItemBackgroundPointerOver}">
<TextBlock Text="字" Margin="0" Padding="4,2"/>
</Border>
</StackPanel>

<Button Grid.Row="0" Grid.Column="4" Click="OnClose"
Width="24" Height="24" Margin="2,2,2,2"
Background="Transparent" BorderThickness="0">
<!-- icon source: https://github.com/microsoft/vscode-icons/blob/main/icons/light/close.svg -->
<Path Classes="clear" Width="16" Height="16" HorizontalAlignment="Center" VerticalAlignment="Center"
Data="M8.00028 8.70711L11.6467 12.3536L12.3538 11.6465L8.70739 8.00001L12.3538 4.35356L11.6467 3.64645L8.00028 7.2929L4.35384 3.64645L3.64673 4.35356L7.29317 8.00001L3.64673 11.6465L4.35384 12.3536L8.00028 8.70711Z"
Fill="{StaticResource NeutralAccentBrush}">
<Path.RenderTransform>
<TransformGroup>
<ScaleTransform ScaleX=".75" ScaleY=".75"/>
<TranslateTransform X="0" Y="1"/>
</TransformGroup>
</Path.RenderTransform>
</Path>
</Button>
</Grid>
</UserControl>
70 changes: 70 additions & 0 deletions OpenUtau/Controls/LyricsPanel.axaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
using Avalonia.Controls;
using Avalonia.Input;
using Avalonia.Interactivity;
using OpenUtau.App.ViewModels;
using OpenUtau.Core;

namespace OpenUtau.App.Controls {
public partial class LyricsPanel : UserControl {
private LyricsViewModel? viewModel;

public LyricsPanel() {
InitializeComponent();
IsVisible = false;

LyricsBox.AddHandler(GotFocusEvent, TextBoxGotFocus, RoutingStrategies.Tunnel | RoutingStrategies.Bubble);
LyricsBox.AddHandler(KeyDownEvent, TextBoxKeyDown, RoutingStrategies.Tunnel | RoutingStrategies.Bubble);
LyricsBox.AddHandler(LostFocusEvent, TextBoxLostFocus, RoutingStrategies.Tunnel | RoutingStrategies.Bubble);
}

public void Show(LyricsViewModel viewModel) {
DataContext = this.viewModel = viewModel;
IsVisible = true;
}

private void TextBoxGotFocus(object? sender, RoutedEventArgs e) {
if (viewModel == null) return;
DocManager.Inst.StartUndoGroup("command.note.lyric");
viewModel.IsFocused = true;
}

private void TextBoxKeyDown(object? sender, KeyEventArgs e) {
if (viewModel == null || !LyricsBox.IsFocused) return;
switch (e.Key) {
case Key.Enter:
//If Shift+Enter, insert line break (default textbox behavior).
if (e.KeyModifiers == KeyModifiers.Shift) {
return;
}
this.Focus();
e.Handled = true;
break;
case Key.Escape:
this.Focus();
Close();
e.Handled = true;
break;
default:
if (e.Key == Key.Z && e.KeyModifiers != KeyModifiers.None || e.Key == Key.Y && e.KeyModifiers != KeyModifiers.None) { // Todo: Supports shortcut remapping
// Finish lyrics editing and use the original shortcut
this.Focus();
}
break;
}
}

private void TextBoxLostFocus(object? sender, RoutedEventArgs e) {
if (viewModel == null) return;
viewModel.IsFocused = false;
DocManager.Inst.EndUndoGroup();
}

public void OnClose(object sender, RoutedEventArgs args) {
Close();
}
private void Close() {
IsVisible = false;
viewModel = null;
}
}
}
6 changes: 5 additions & 1 deletion OpenUtau/Controls/PianoRoll.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -551,11 +551,15 @@
</Border>
</Grid>
<StackPanel Grid.Row="3" Grid.Column="1" HorizontalAlignment="Left" VerticalAlignment="Bottom"
Margin="12,12,12,70" Orientation="Horizontal">
Margin="12,12,12,70">
<Border>
<c:SearchBar Name="SearchBar"/>
</Border>
</StackPanel>
<StackPanel Grid.Row="3" Grid.Column="1" HorizontalAlignment="Stretch" VerticalAlignment="Bottom"
Margin="12,12,12,70">
<c:LyricsPanel Name="LyricsPanel" Background="{DynamicResource SystemControlBackgroundAltHighBrush}"/>
</StackPanel>
<Rectangle Grid.Row="3" Grid.Column="1" HorizontalAlignment="Stretch" VerticalAlignment="Bottom"
Margin="0,0,0,60" Height="6" Opacity="0.15" IsVisible="{Binding NotesViewModel.ShowPhoneme}">
<Rectangle.Fill>
Expand Down
39 changes: 13 additions & 26 deletions OpenUtau/Controls/PianoRoll.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -413,9 +413,22 @@ void SearchNote() {
if (ViewModel.NotesViewModel.Part == null || ViewModel.NotesViewModel.Part.notes.Count == 0) {
return;
}
LyricsPanel.IsVisible = false;
SearchBar.Show(ViewModel.NotesViewModel);
}

void OnMenuEditLyrics(object? sender, RoutedEventArgs e) {
EditLyrics();
}

void EditLyrics() {
if (ViewModel.NotesViewModel.Part == null) {
return;
}
SearchBar.IsVisible = false;
LyricsPanel.Show(ViewModel.NotesViewModel.LyricsViewModel);
}

void ReplaceLyrics() {
if (ViewModel.NotesViewModel.Part == null) {
return;
Expand All @@ -440,32 +453,6 @@ void ReplaceLyrics() {
dialog.ShowDialog(RootWindow);
}

void OnMenuEditLyrics(object? sender, RoutedEventArgs e) {
EditLyrics();
}

void EditLyrics() {
if (ViewModel.NotesViewModel.Part == null) {
return;
}
if (ViewModel.NotesViewModel.Part.notes.Count < 1) {
_ = MessageBox.Show(
RootWindow,
ThemeManager.GetString("lyrics.nonote"),
ThemeManager.GetString("lyrics.caption"),
MessageBox.MessageBoxButtons.Ok);
return;
}

var vm = new LyricsViewModel();
var (notes, selection) = ViewModel.NotesViewModel.PrepareInsertLyrics();
vm.Start(ViewModel.NotesViewModel.Part, notes, selection);
var dialog = new LyricsDialog() {
DataContext = vm,
};
dialog.ShowDialog(RootWindow);
}

void OnMenuNoteDefaults(object sender, RoutedEventArgs args) {
EditNoteDefaults();
}
Expand Down
3 changes: 3 additions & 0 deletions OpenUtau/OpenUtau.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@
<None Include="..\runtimes\linux-arm64\native\**" CopyToOutputDirectory="PreserveNewest" LinkBase="." />
</ItemGroup>
<ItemGroup>
<Compile Update="Controls\LyricsPanel.axaml.cs">
<DependentUpon>LyricsPanel.axaml</DependentUpon>
</Compile>
<Compile Update="Controls\NotePropertyExpression.axaml.cs">
<DependentUpon>NotePropertyExpression.axaml</DependentUpon>
</Compile>
Expand Down
9 changes: 1 addition & 8 deletions OpenUtau/Strings/Strings.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -242,15 +242,8 @@ Do you want to continue by splitting at the nearest position after current playh
<system:String x:Key="languages.zh">Chinese</system:String>
<system:String x:Key="languages.zh-yue">Cantonese</system:String>

<system:String x:Key="lyrics.apply">Apply</system:String>
<system:String x:Key="lyrics.applyselected">Apply only to selected notes</system:String>
<system:String x:Key="lyrics.cancel">Cancel</system:String>
<system:String x:Key="lyrics.caption">Edit Lyrics</system:String>
<system:String x:Key="lyrics.livepreview">Live preview</system:String>
<system:String x:Key="lyrics.nonote">There is no note!</system:String>
<system:String x:Key="lyrics.reset">Reset</system:String>
<system:String x:Key="lyrics.selectnotes">Select some notes first!</system:String>
<system:String x:Key="lyrics.separators">Separators</system:String>
<system:String x:Key="lyrics.skipsymbols">Skip symbols such as "R" or "-"</system:String>

<system:String x:Key="lyricsreplace.after">After :</system:String>
<system:String x:Key="lyricsreplace.before">Before :</system:String>
Expand Down
Loading
Loading