Skip to content
Open
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
12 changes: 8 additions & 4 deletions OpenUtau/Controls/PianoRoll.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -609,10 +609,14 @@
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.Items>
<ListBoxItem Classes="toolbar cursorTool"/>
<ListBoxItem Classes="toolbar penTool"/>
<!-- CurveLineTool -->
<ListBoxItem Classes="toolbar eraserTool"/>
<ListBoxItem Classes="toolbar cursorTool" ToolTip.Tip="{DynamicResource pianoroll.tool.curve.cursor}"/>
<ListBoxItem Classes="toolbar penTool" ToolTip.Tip="{DynamicResource pianoroll.tool.curve.pen}"/>
<ListBoxItem Classes="toolbar drawLinePitchTool" ToolTip.Tip="{DynamicResource pianoroll.tool.curve.line}"/>
<ListBoxItem Classes="toolbar eraserTool" ToolTip.Tip="{DynamicResource pianoroll.tool.curve.eraser}"/>
<ListBoxItem Classes="toolbar verticalStretchTool" ToolTip.Tip="{DynamicResource pianoroll.tool.curve.verticalstretch}"/>
<ListBoxItem Classes="toolbar horizontalStretchTool" ToolTip.Tip="{DynamicResource pianoroll.tool.curve.horizontalstretch}"/>
<ListBoxItem Classes="toolbar verticalShiftTool" ToolTip.Tip="{DynamicResource pianoroll.tool.curve.verticalshift}"/>
<ListBoxItem Classes="toolbar horizontalShiftTool" ToolTip.Tip="{DynamicResource pianoroll.tool.curve.horizontalshift}"/>
</ListBox.Items>
</ListBox>
<TextBlock Classes="tips" Grid.Row="5" Grid.Column="1"
Expand Down
20 changes: 18 additions & 2 deletions OpenUtau/Controls/PianoRoll.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1132,10 +1132,26 @@ public void ExpCanvasPointerPressed(object sender, PointerPressedEventArgs args)
ViewModel.CurveViewModel.ClearSelect();
editState = new ExpSetValueState(control, ViewModel, this, descriptor);
break;
case CurveTools.CurveLineTool:
ViewModel.CurveViewModel.ClearSelect();
editState = new ExpSetValueState(control, ViewModel, this, descriptor);
break;
case CurveTools.CurveEraserTool:
ViewModel.CurveViewModel.ClearSelect();
editState = new ExpResetValueState(control, ViewModel, this, descriptor, MouseButton.Left);
break;
case CurveTools.CurveVerticalStretchTool:
editState = new CurveVerticalStretchState(control, ViewModel, this, descriptor);
break;
case CurveTools.CurveHorizontalStretchTool:
editState = new CurveHorizontalStretchState(control, ViewModel, this, descriptor);
break;
case CurveTools.CurveVerticalShiftTool:
editState = new CurveVerticalShiftState(control, ViewModel, this, descriptor);
break;
case CurveTools.CurveHorizontalShiftTool:
editState = new CurveHorizontalShiftState(control, ViewModel, this, descriptor);
break;
default:
ViewModel.CurveViewModel.ClearSelect();
break;
Expand Down Expand Up @@ -1169,8 +1185,8 @@ public void ExpCanvasPointerMoved(object sender, PointerEventArgs args) {
valueTipPointerPosition = args.GetCurrentPoint(ValueTipCanvas!).Position;
}
if (editState != null) {
editState.ctrlShiftHeld = args.KeyModifiers == (cmdKey | KeyModifiers.Shift);
editState.shiftHeld = args.KeyModifiers == KeyModifiers.Shift;
editState.ctrlShiftHeld = ViewModel.CurveViewModel.CurveTool == CurveTools.CurveLineTool;
editState.shiftHeld = (args.KeyModifiers == KeyModifiers.Shift && (ViewModel.CurveViewModel.CurveTool == CurveTools.CurveLineTool || ViewModel.CurveViewModel.CurveTool == CurveTools.CurvePenTool));
editState.Update(point.Pointer, point.Position);
} else {
Cursor = null;
Expand Down
27 changes: 27 additions & 0 deletions OpenUtau/Strings/Strings.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,33 @@ Warning: this option removes custom presets.</system:String>
<system:String x:Key="pianoroll.toggle.vibrato">View Vibrato (U)</system:String>
<system:String x:Key="pianoroll.toggle.waveform">View Waveform (W)</system:String>
<system:String x:Key="pianoroll.toggle.expressions">View Expressions (L)</system:String>
<system:String x:Key="pianoroll.tool.curve.cursor">Cursor Tool
Left click to select</system:String>
<system:String x:Key="pianoroll.tool.curve.pen">Pen Tool
Left click to draw
Right click to reset</system:String>
<system:String x:Key="pianoroll.tool.curve.line">Line Tool
Left click to draw (draw straight line)
Right click to reset</system:String>
<system:String x:Key="pianoroll.tool.curve.eraser">Eraser Tool
Click to reset</system:String>
<system:String x:Key="pianoroll.tool.curve.verticalstretch">Vertical Stretch Tool
Left click to stretch the curve vertically
Right click to reset</system:String>
<system:String x:Key="pianoroll.tool.curve.horizontalstretch">Horizontal Stretch Tool
Left click to stretch the curve horizontally
Right click to reset</system:String>
<system:String x:Key="pianoroll.tool.curve.verticalshift">Vertical Shift Tool
Left click to move the curve vertically
Right click to reset</system:String>
<system:String x:Key="pianoroll.tool.curve.horizontalshift">Horizontal Shift Tool
Left click to move the curve horizontally
Right click to reset</system:String>
<system:String x:Key="pianoroll.tool.drawlinepitch">Line Draw Pitch Tool (5)
Left click to draw (draw straight line)
Right click to reset
Hold Ctrl to select
Hold Alt to smoothen</system:String>
<system:String x:Key="pianoroll.tool.drawpitch">Draw Pitch Tool (Shift + 1)
Left click to draw
Right click to reset
Expand Down
12 changes: 12 additions & 0 deletions OpenUtau/Styles/PianoRollStyles.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,18 @@
<Style Selector="ListBoxItem.cursorTool /template/ Path#PART_ToolIcon">
<Setter Property="Data" Value="M10.07,14.27C10.57,14.03 11.16,14.25 11.4,14.75L13.7,19.74L15.5,18.89L13.19,13.91C12.95,13.41 13.17,12.81 13.67,12.58L13.95,12.5L16.25,12.05L8,5.12V15.9L9.82,14.43L10.07,14.27M13.64,21.97C13.14,22.21 12.54,22 12.31,21.5L10.13,16.76L7.62,18.78C7.45,18.92 7.24,19 7,19A1,1 0 0,1 6,18V3A1,1 0 0,1 7,2C7.24,2 7.47,2.09 7.64,2.23L7.65,2.22L19.14,11.86C19.57,12.22 19.62,12.85 19.27,13.27C19.12,13.45 18.91,13.57 18.7,13.61L15.54,14.23L17.74,18.96C18,19.46 17.76,20.05 17.26,20.28L13.64,21.97Z" />
</Style>
<Style Selector="ListBoxItem.verticalStretchTool /template/ Path#PART_ToolIcon">
<Setter Property="Data" Value="M 9.55 -0.72 C 9.31 -0.72 9.08 -0.59 8.86 -0.38 L 5.68 2.81 C 5.29 3.2 5.29 3.84 5.68 4.23 C 6.07 4.62 6.7 4.62 7.09 4.23 L 8.57 2.75 V 12 V 21.25 L 7.09 19.78 C 6.7 19.39 6.07 19.39 5.68 19.78 C 5.29 20.17 5.29 20.81 5.68 21.2 L 8.86 24.38 C 9.36 24.88 10.11 24.55 10.27 24.38 L 13.45 21.2 C 13.84 20.81 13.84 20.17 13.45 19.78 C 13.06 19.39 12.43 19.39 12.04 19.78 L 10.57 21.25 V 12 V 2.75 L 12.04 4.22 C 12.43 4.61 13.06 4.61 13.45 4.22 C 13.84 3.83 13.84 3.19 13.45 2.8 L 10.28 -0.38 C 10.03 -0.62 9.79 -0.73 9.55 -0.72 Z M 15.77 8.62 C 15.12 8.58 14.75 9.36 15.21 9.84 L 15.22 9.85 L 17.27 11.93 L 15.22 14.01 L 15.21 14.02 C 14.6 14.7 15.55 15.65 16.23 15.04 L 16.24 15.03 L 18.32 12.98 L 20.4 15.03 L 20.41 15.04 C 21.09 15.66 22.04 14.7 21.43 14.02 L 21.42 14.01 L 19.37 11.93 L 21.42 9.85 L 21.43 9.84 C 22.08 9.16 21.09 8.17 20.41 8.82 L 20.4 8.83 L 18.32 10.88 L 16.24 8.83 L 16.23 8.82 C 16.1 8.7 15.94 8.63 15.77 8.62 Z" />
</Style>
<Style Selector="ListBoxItem.horizontalStretchTool /template/ Path#PART_ToolIcon">
<Setter Property="Data" Value="M 0.83 15.48 C 0.84 15.72 0.96 15.95 1.18 16.17 L 4.36 19.35 C 4.75 19.74 5.39 19.74 5.78 19.35 C 6.17 18.96 6.17 18.33 5.78 17.94 L 4.31 16.47 H 13.56 H 22.81 L 21.34 17.94 C 20.95 18.33 20.95 18.96 21.34 19.35 C 21.73 19.74 22.37 19.74 22.76 19.35 L 25.94 16.17 C 26.44 15.67 26.11 14.92 25.94 14.76 L 22.76 11.58 C 22.37 11.19 21.73 11.19 21.34 11.58 C 20.95 11.97 20.95 12.6 21.34 12.99 L 22.81 14.46 H 13.55 H 4.3 L 5.77 12.99 C 6.16 12.6 6.16 11.97 5.77 11.58 C 5.38 11.19 4.74 11.19 4.35 11.58 L 1.17 14.76 C 0.93 15 0.82 15.25 0.82 15.48 Z M 10.28 9.26 C 10.28 9.92 11.02 10.28 11.5 9.82 L 11.51 9.81 L 13.59 7.76 L 15.67 9.81 L 15.68 9.82 C 16.36 10.44 17.31 9.48 16.7 8.8 L 16.69 8.79 L 14.64 6.71 L 16.69 4.63 L 16.7 4.62 C 17.32 3.94 16.36 2.99 15.68 3.6 L 15.67 3.61 L 13.59 5.66 L 11.51 3.61 L 11.5 3.6 C 10.82 2.96 9.82 3.95 10.48 4.63 L 10.49 4.64 L 12.54 6.72 L 10.49 8.8 L 10.48 8.81 C 10.36 8.93 10.28 9.09 10.28 9.27 Z" />
</Style>
<Style Selector="ListBoxItem.verticalShiftTool /template/ Path#PART_ToolIcon">
<Setter Property="Data" Value="M 12 -0.67 A 1 1 0 0 0 11.29 -0.38 L 8.11 2.81 A 1 1 0 0 0 8.11 4.23 A 1 1 0 0 0 9.52 4.23 L 11 2.75 V 12 V 21.25 L 9.53 19.78 A 1 1 0 0 0 8.12 19.78 A 1 1 0 0 0 8.12 21.2 L 11.29 24.38 A 1 1 0 0 0 12.71 24.38 L 15.89 21.2 A 1 1 0 0 0 15.89 19.78 A 1 1 0 0 0 14.48 19.78 L 13 21.25 V 12 V 2.75 L 14.47 4.22 A 1 1 0 0 0 15.88 4.22 A 1 1 0 0 0 15.88 2.8 L 12.71 -0.38 A 1 1 0 0 0 12 -0.67 Z" />
</Style>
<Style Selector="ListBoxItem.horizontalShiftTool /template/ Path#PART_ToolIcon">
<Setter Property="Data" Value="M -0.33 12.66 L 2.85 15.84 C 3.24 16.23 3.88 16.23 4.27 15.84 C 4.66 15.45 4.66 14.82 4.27 14.43 L 2.8 12.96 H 12.05 H 21.3 L 19.83 14.43 C 19.44 14.82 19.44 15.45 19.83 15.84 C 20.22 16.23 20.86 16.23 21.25 15.84 L 24.43 12.66 C 24.93 12.16 24.6 11.41 24.43 11.25 L 21.24 8.07 C 20.85 7.68 20.21 7.68 19.82 8.07 C 19.43 8.46 19.43 9.09 19.82 9.48 L 21.29 10.95 H 12.04 H 2.79 L 4.27 9.48 C 4.66 9.09 4.66 8.46 4.27 8.07 C 3.88 7.68 3.24 7.68 2.85 8.07 L -0.33 11.25 C -0.82 11.74 -0.77 12.23 -0.33 12.66 Z" />
</Style>
<Style Selector="ListBoxItem.penTool /template/ Path#PART_ToolIcon">
<Setter Property="Data" Value="M14.06,9L15,9.94L5.92,19H5V18.08L14.06,9M17.66,3C17.41,3 17.15,3.1 16.96,3.29L15.13,5.12L18.88,8.87L20.71,7.04C21.1,6.65 21.1,6 20.71,5.63L18.37,3.29C18.17,3.09 17.92,3 17.66,3M14.06,6.19L3,17.25V21H6.75L17.81,9.94L14.06,6.19Z" />
</Style>
Expand Down
25 changes: 21 additions & 4 deletions OpenUtau/ViewModels/CurveViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,12 @@ public CurveSelectionEvent(CurveSelection selection) {
public enum CurveTools {
CurveSelectTool,
CurvePenTool,
//CurveLineTool,
CurveEraserTool
CurveLineTool,
CurveEraserTool,
CurveVerticalStretchTool,
CurveHorizontalStretchTool,
CurveVerticalShiftTool,
CurveHorizontalShiftTool
}

public class CurveViewModel : ViewModelBase, ICmdSubscriber {
Expand All @@ -46,13 +50,16 @@ public void Select(UExpressionDescriptor descriptor, int startTick, int endTick,
(int x, int y) endPoint = (endTick, curve?.Sample(endTick) ?? (int)descriptor.CustomDefaultValue);
var xs = new List<int>();
var ys = new List<int>();
int minTick = Math.Min(startTick, endTick);
int maxTick = Math.Max(startTick, endTick);

if (curve != null) {
for (int i = 0; i < curve.xs.Count; i++) {
var x = curve.xs[i];
if (endTick < x) {
if (maxTick <= x) {
break;
}
if (startTick <= x) {
if (minTick < x) {
xs.Add(x);
ys.Add(curve.ys[i]);
}
Expand Down Expand Up @@ -105,6 +112,16 @@ public void Paste(UVoicePart part, UExpressionDescriptor descriptor) {
DocManager.Inst.EndUndoGroup();
}

public bool TryGetSelection(string abbr, out CurveSelection selection) {
if (this.selection.HasValue(abbr)) {
selection = this.selection.Clone();
return true;
}

selection = new CurveSelection();
return false;
}

public void OnNext(UCommand cmd, bool isUndo) {
if (cmd is UNotification notif) {
if (cmd is LoadPartNotification || cmd is LoadProjectNotification || cmd is SelectExpressionNotification) {
Expand Down
Loading
Loading