Skip to content

Commit

Permalink
Merge pull request #751 from maiko3tattun/0619_NoteProperty
Browse files Browse the repository at this point in the history
[WIP] Add Note Params panel
  • Loading branch information
stakira committed Jun 28, 2023
2 parents 7003524 + 3edef7c commit 43edcf9
Show file tree
Hide file tree
Showing 11 changed files with 666 additions and 37 deletions.
13 changes: 13 additions & 0 deletions OpenUtau.Core/Commands/ExpCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,19 @@ public ResetPitchPointsCommand(UVoicePart part, UNote note) : base(part) {
public override void Unexecute() => Note.pitch = oldPitch;
}

public class SetPitchPointsCommand : PitchExpCommand {
UPitch oldPitch;
UPitch newPitch;
public SetPitchPointsCommand(UVoicePart part, UNote note, UPitch pitch) : base(part) {
Note = note;
oldPitch = note.pitch;
newPitch = pitch;
}
public override string ToString() => "Set pitch points";
public override void Execute() => Note.pitch = newPitch;
public override void Unexecute() => Note.pitch = oldPitch;
}

public class SetCurveCommand : ExpCommand {
readonly UProject project;
readonly string abbr;
Expand Down
131 changes: 131 additions & 0 deletions OpenUtau/Controls/NotePropertiesControl.axaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
<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"
xmlns:vm="using:OpenUtau.App.ViewModels"
mc:Ignorable="d" d:DesignWidth="400" d:DesignHeight="600" Width="400"
x:Class="OpenUtau.App.Controls.NotePropertiesControl" KeyDown="OnKeyDown" Margin="0">
<UserControl.Styles>
<Style Selector="Button,CheckBox">
<Setter Property="Focusable" Value="False"/>
</Style>
<Style Selector="Label,TextBox,Slider,ComboBox,CheckBox">
<Setter Property="VerticalAlignment" Value="Center"/>
</Style>
</UserControl.Styles>

<Grid>
<ScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Visible">
<StackPanel Margin="10">

<HeaderedContentControl Classes="groupbox" Header="{DynamicResource notedefaults.lyric}">
<Grid ColumnDefinitions="143,*">
<Label Content="{DynamicResource notedefaults.lyric}" Grid.Column="0"/>
<TextBox Text="{Binding Lyric}" IsEnabled="{Binding IsNoteSelected}" Grid.Column="1"/>
</Grid>
</HeaderedContentControl>

<HeaderedContentControl Classes="groupbox" Header="{DynamicResource notedefaults.portamento}">
<StackPanel IsEnabled="{Binding IsNoteSelected}">
<Grid ColumnDefinitions="123,20,*">
<Label Content="{DynamicResource notedefaults.preset}"/>
<ComboBox Grid.Column="2" ItemsSource="{Binding PortamentoPresets}"
SelectedItem="{Binding ApplyPortamentoPreset}" HorizontalAlignment="Stretch"/>
</Grid>
<Grid ColumnDefinitions="123,20,*,20,*">
<Button Grid.Column="2" Content="{DynamicResource notedefaults.preset.save}"
HorizontalAlignment="Stretch" Click="OnSavePortamentoPreset"
ToolTip.Tip="{DynamicResource notedefaults.preset.save.tooltip}"/>
<Button Grid.Column="4" Content="{DynamicResource notedefaults.preset.remove}"
HorizontalAlignment="Stretch" Command="{Binding RemoveAppliedPortamentoPreset}"
ToolTip.Tip="{DynamicResource notedefaults.preset.remove.tooltip}"/>
</Grid>
<Grid ColumnDefinitions="130,20,50,20,*">
<Label Content="{DynamicResource notedefaults.portamento.length}"/>
<TextBox Grid.Column="2" Text="{Binding PortamentoLength}" />
<Slider Grid.Column="4" Classes="fader" Value="{Binding PortamentoLength}" Minimum="2" Maximum="320"
TickPlacement="BottomRight" TickFrequency="1" IsSnapToTickEnabled="true" />
</Grid>
<Grid ColumnDefinitions="130,20,50,20,*">
<Label Content="{DynamicResource notedefaults.portamento.start}"/>
<TextBox Grid.Column="2" Text="{Binding PortamentoStart}" />
<Slider Grid.Column="4" Classes="fader" Value="{Binding PortamentoStart}" Minimum="-200" Maximum="200"
TickPlacement="BottomRight" TickFrequency="1" IsSnapToTickEnabled="true" />
</Grid>
</StackPanel>
</HeaderedContentControl>

<HeaderedContentControl Classes="groupbox" Header="{DynamicResource notedefaults.vibrato}">
<StackPanel IsEnabled="{Binding IsNoteSelected}">
<ToggleSwitch IsChecked="{Binding VibratoEnable}" OnContent="{DynamicResource prefs.on}" OffContent="{DynamicResource prefs.off}"/>
<StackPanel IsEnabled="{Binding VibratoEnable}">
<Grid ColumnDefinitions="123,20,*">
<Label Content="{DynamicResource notedefaults.preset}"/>
<ComboBox Grid.Column="2" ItemsSource="{Binding VibratoPresets}"
SelectedItem="{Binding ApplyVibratoPreset}" HorizontalAlignment="Stretch" />
</Grid>
<Grid ColumnDefinitions="123,20,*,20,*">
<Button Grid.Column="2" Content="{DynamicResource notedefaults.preset.save}"
HorizontalAlignment="Stretch" Click="OnSaveVibratoPreset"
ToolTip.Tip="{DynamicResource notedefaults.preset.save.tooltip}"/>
<Button Grid.Column="4" Content="{DynamicResource notedefaults.preset.remove}"
HorizontalAlignment="Stretch" Command="{Binding RemoveAppliedVibratoPreset}"
ToolTip.Tip="{DynamicResource notedefaults.preset.remove.tooltip}"/>
</Grid>
<Grid ColumnDefinitions="130,20,50,20,*">
<Label Content="{DynamicResource notedefaults.vibrato.length}"/>
<TextBox Grid.Column="2" Text="{Binding VibratoLength}" />
<Slider Grid.Column="4" Classes="fader" Value="{Binding VibratoLength}" Minimum="0" Maximum="100"
TickPlacement="BottomRight" TickFrequency="0.1" IsSnapToTickEnabled="true" />
</Grid>
<Grid ColumnDefinitions="130,20,50,20,*">
<Label Content="{DynamicResource notedefaults.vibrato.period}"/>
<TextBox Grid.Column="2" Text="{Binding VibratoPeriod}" />
<Slider Grid.Column="4" Classes="fader" Value="{Binding VibratoPeriod}" Minimum="5" Maximum="500"
TickPlacement="BottomRight" TickFrequency="0.1" IsSnapToTickEnabled="true" />
</Grid>
<Grid ColumnDefinitions="130,20,50,20,*">
<Label Content="{DynamicResource notedefaults.vibrato.depth}"/>
<TextBox Grid.Column="2" Text="{Binding VibratoDepth}" />
<Slider Grid.Column="4" Classes="fader" Value="{Binding VibratoDepth}" Minimum="5" Maximum="200"
TickPlacement="BottomRight" TickFrequency="0.1" IsSnapToTickEnabled="true" />
</Grid>
<Grid ColumnDefinitions="130,20,50,20,*">
<Label Content="{DynamicResource notedefaults.vibrato.in}"/>
<TextBox Grid.Column="2" Text="{Binding VibratoIn}" />
<Slider Grid.Column="4" Classes="fader" Value="{Binding VibratoIn}" Minimum="0" Maximum="100"
TickPlacement="BottomRight" TickFrequency="0.1" IsSnapToTickEnabled="true" />
</Grid>
<Grid ColumnDefinitions="130,20,50,20,*">
<Label Content="{DynamicResource notedefaults.vibrato.out}"/>
<TextBox Grid.Column="2" Text="{Binding VibratoOut}" />
<Slider Grid.Column="4" Classes="fader" Value="{Binding VibratoOut}" Minimum="0" Maximum="100"
TickPlacement="BottomRight" TickFrequency="0.1" IsSnapToTickEnabled="true" />
</Grid>
<Grid ColumnDefinitions="130,20,50,20,*">
<Label Content="{DynamicResource notedefaults.vibrato.shift}"/>
<TextBox Grid.Column="2" Text="{Binding VibratoShift}" />
<Slider Grid.Column="4" Classes="fader" Value="{Binding VibratoShift}" Minimum="0" Maximum="100"
TickPlacement="BottomRight" TickFrequency="0.1" IsSnapToTickEnabled="true" />
</Grid>
<Grid ColumnDefinitions="123,20,*">
<Label Content="{DynamicResource noteproperty.setlongnote}"/>
<CheckBox Grid.Column="2" IsChecked="{Binding AutoVibratoToggle}"/>
</Grid>
<Grid ColumnDefinitions="180,20,50,20,*">
<Label Content="{DynamicResource notedefaults.vibrato.autominlength}"/>
<TextBox Grid.Column="2" IsEnabled="{Binding AutoVibratoToggle}" Text="{Binding AutoVibratoNoteLength}" />
<Slider Grid.Column="4" Classes="fader" IsEnabled="{Binding AutoVibratoToggle}" Value="{Binding AutoVibratoNoteLength}" Minimum="10" Maximum="1920"
TickPlacement="BottomRight" TickFrequency="1" IsSnapToTickEnabled="true" />
</Grid>
</StackPanel>
</StackPanel>
</HeaderedContentControl>

<HeaderedContentControl Classes="groupbox" Header="{DynamicResource exps.caption}">
<StackPanel Name="ExpressionsPanel" />
</HeaderedContentControl>
</StackPanel>
</ScrollViewer>
</Grid>
</UserControl>
77 changes: 77 additions & 0 deletions OpenUtau/Controls/NotePropertiesControl.axaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
using System;
using System.Reactive.Linq;
using Avalonia.Controls;
using Avalonia.Input;
using Avalonia.Interactivity;
using OpenUtau.App.ViewModels;
using OpenUtau.App.Views;
using OpenUtau.Core;
using OpenUtau.Core.Ustx;
using ReactiveUI;

namespace OpenUtau.App.Controls {
public partial class NotePropertiesControl : UserControl, ICmdSubscriber {
private readonly NotePropertiesViewModel ViewModel;

public NotePropertiesControl() {
InitializeComponent();
DataContext = ViewModel = new NotePropertiesViewModel();

DocManager.Inst.AddSubscriber(this);
}

private void LoadPart(UPart? part) {
ViewModel.LoadPart(part);
ExpressionsPanel.Children.Clear();
foreach (NotePropertyExpViewModel expVM in ViewModel.Expressions) {
var control = new NotePropertyExpression() { DataContext = expVM };
ExpressionsPanel.Children.Add(control);
}
}

void OnSavePortamentoPreset(object sender, RoutedEventArgs e) {
var dialog = new TypeInDialog() {
Title = ThemeManager.GetString("notedefaults.preset.namenew"),
onFinish = name => ViewModel.SavePortamentoPreset(name),
};
//dialog.ShowDialog(this);
}

void OnRemovePortamentoPreset(object sender, RoutedEventArgs e) {
ViewModel.RemoveAppliedPortamentoPreset();
}

void OnSaveVibratoPreset(object sender, RoutedEventArgs e) {
var dialog = new TypeInDialog() {
Title = ThemeManager.GetString("notedefaults.preset.namenew"),
onFinish = name => ViewModel.SaveVibratoPreset(name),
};
//dialog.ShowDialog(this);
}

void OnRemoveVibratoPreset(object sender, RoutedEventArgs e) {
ViewModel.RemoveAppliedVibratoPreset();
}

private void OnKeyDown(object? sender, KeyEventArgs e) {
switch (e.Key) {
case Key.Enter:
//OnFinish(sender, e);
e.Handled = true;
break;
case Key.Escape:
//OnCancel(sender, e);
e.Handled = true;
break;
default:
break;
}
}

public void OnNext(UCommand cmd, bool isUndo) {
if (cmd is LoadPartNotification loadPart) {
LoadPart(loadPart.part);
}
}
}
}
15 changes: 15 additions & 0 deletions OpenUtau/Controls/NotePropertyExpression.axaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<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"
xmlns:vm="using:OpenUtau.App.ViewModels"
x:Class="OpenUtau.App.Controls.NotePropertyExpression">
<Grid ColumnDefinitions="143,7,50,20,*">
<Label Content="{Binding Name}" Grid.Column="0" VerticalAlignment="Center"/>
<TextBox Text="{Binding Value}" Grid.Column="2" IsVisible="{Binding IsNumerical}" VerticalAlignment="Center" IsEnabled="{Binding IsNoteSelected}"/>
<Slider Grid.Column="4" Classes="fader" Value="{Binding Value}" Minimum="{Binding Min}" Maximum="{Binding Max}"
TickPlacement="BottomRight" TickFrequency="1" IsSnapToTickEnabled="true" IsVisible="{Binding IsNumerical}" VerticalAlignment="Center" IsEnabled="{Binding IsNoteSelected}" />
<ComboBox Grid.Column="1" Grid.ColumnSpan="4" ItemsSource="{Binding Options}"
SelectedIndex="{Binding SelectedOption}" MinWidth="120" IsVisible="{Binding IsOptions}" VerticalAlignment="Center" IsEnabled="{Binding IsNoteSelected}" />
</Grid>
</UserControl>
13 changes: 13 additions & 0 deletions OpenUtau/Controls/NotePropertyExpression.axaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Input;
using OpenUtau.App.ViewModels;

namespace OpenUtau.App.Controls {
public partial class NotePropertyExpression : UserControl {
public NotePropertyExpression() {
InitializeComponent();
}

}
}
6 changes: 6 additions & 0 deletions OpenUtau/OpenUtau.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@
<None Include="..\runtimes\linux-x64\native\**" CopyToOutputDirectory="PreserveNewest" LinkBase="." />
</ItemGroup>
<ItemGroup>
<Compile Update="Controls\NotePropertyExpression.axaml.cs">
<DependentUpon>NotePropertyExpression.axaml</DependentUpon>
</Compile>
<Compile Update="Controls\NotePropertiesControl.axaml.cs">
<DependentUpon>NotePropertiesControl.axaml</DependentUpon>
</Compile>
<Compile Update="Resources\Resources.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
Expand Down
9 changes: 8 additions & 1 deletion OpenUtau/Strings/Strings.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@
<system:String x:Key="menu.tools.singer.install">Install Singer...</system:String>
<system:String x:Key="menu.tools.singer.installadv">Install Singer (Advanced)...</system:String>
<system:String x:Key="menu.tools.singers">Singers...</system:String>

<system:String x:Key="notedefaults.lyric">Lyric</system:String>
<system:String x:Key="notedefaults.lyric.defaultlyric">Default Lyric</system:String>
<system:String x:Key="notedefaults.portamento">Portamento</system:String>
Expand All @@ -164,6 +164,12 @@ Warning: this option removes custom presets.</system:String>
<system:String x:Key="notedefaults.vibrato.period">Period</system:String>
<system:String x:Key="notedefaults.vibrato.shift">Shift</system:String>

<system:String x:Key="noteproperty.apply">Apply</system:String>
<system:String x:Key="noteproperty.cancel">Cancel</system:String>
<system:String x:Key="noteproperty.set">Set</system:String>
<system:String x:Key="noteproperty.setlongnote">Set only on long notes</system:String>
<system:String x:Key="noteproperty.vibratoenable">Enable</system:String>

<system:String x:Key="oto.alias">Alias</system:String>
<system:String x:Key="oto.color">Color</system:String>
<system:String x:Key="oto.consonant">Consonant</system:String>
Expand Down Expand Up @@ -196,6 +202,7 @@ Warning: this option removes custom presets.</system:String>
<system:String x:Key="pianoroll.menu.lyrics.removetonesuffix">Remove Tone Suffix</system:String>
<system:String x:Key="pianoroll.menu.lyrics.romajitohiragana">Romaji to Hiragana</system:String>
<system:String x:Key="pianoroll.menu.notedefaults">Note Defaults</system:String>
<system:String x:Key="pianoroll.menu.noteproperty">Note Properties</system:String>
<system:String x:Key="pianoroll.menu.notes">Notes</system:String>
<system:String x:Key="pianoroll.menu.notes.addtaildash">Add tail "-"</system:String>
<system:String x:Key="pianoroll.menu.notes.addtailrest">Add tail "R"</system:String>
Expand Down
11 changes: 9 additions & 2 deletions OpenUtau/Strings/Strings.ja-JP.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -155,15 +155,21 @@
<system:String x:Key="notedefaults.reset.tooltip">すべての値をリセットします。
警告: このオプションを実行すると、カスタムプリセットも削除されます。</system:String>
<system:String x:Key="notedefaults.vibrato">ビブラート</system:String>
<system:String x:Key="notedefaults.vibrato.autominlength">最小値</system:String>
<system:String x:Key="notedefaults.vibrato.autotoggle">最小値による自動ビブラート</system:String>
<system:String x:Key="notedefaults.vibrato.autominlength">最短の音符長</system:String>
<system:String x:Key="notedefaults.vibrato.autotoggle">長い音符に自動でビブラートをかける</system:String>
<system:String x:Key="notedefaults.vibrato.depth">深さ</system:String>
<system:String x:Key="notedefaults.vibrato.in">フェードイン</system:String>
<system:String x:Key="notedefaults.vibrato.length">長さ</system:String>
<system:String x:Key="notedefaults.vibrato.out">フェードアウト</system:String>
<system:String x:Key="notedefaults.vibrato.period">周期</system:String>
<system:String x:Key="notedefaults.vibrato.shift">位相</system:String>

<system:String x:Key="noteproperty.apply">適用</system:String>
<system:String x:Key="noteproperty.cancel">キャンセル</system:String>
<system:String x:Key="noteproperty.set">セット</system:String>
<system:String x:Key="noteproperty.setlongnote">長い音符のみセットする</system:String>
<system:String x:Key="noteproperty.vibratoenable">オン</system:String>

<system:String x:Key="oto.alias">エイリアス</system:String>
<!--<system:String x:Key="oto.color">Color</system:String>-->
<system:String x:Key="oto.consonant">子音部</system:String>
Expand Down Expand Up @@ -196,6 +202,7 @@
<system:String x:Key="pianoroll.menu.lyrics.removetonesuffix">音程のSuffixを削除</system:String>
<system:String x:Key="pianoroll.menu.lyrics.romajitohiragana">ローマ字→ひらがな</system:String>
<system:String x:Key="pianoroll.menu.notedefaults">デフォルト値を設定</system:String>
<system:String x:Key="pianoroll.menu.noteproperty">音符のプロパティ</system:String>
<system:String x:Key="pianoroll.menu.notes">音符</system:String>
<system:String x:Key="pianoroll.menu.notes.addtaildash">末尾に"-"を追加</system:String>
<system:String x:Key="pianoroll.menu.notes.addtailrest">末尾に"R"を追加</system:String>
Expand Down
Loading

0 comments on commit 43edcf9

Please sign in to comment.