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
20 changes: 19 additions & 1 deletion OpenUtau/Controls/ExpressionCanvas.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,27 @@ public ExpressionCanvas() {

protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change) {
base.OnPropertyChanged(change);
if (change.Property == KeyProperty || change.Property == PartProperty) {
InvalidateMeasure();
}
InvalidateVisual();
}

protected override Size MeasureOverride(Size availableSize) {
double requiredHeight = 0;
if (Part != null && !string.IsNullOrEmpty(Key)) {
var project = DocManager.Inst.Project;
if (project.tracks[Part.trackNo].TryGetExpDescriptor(project, Key, out var descriptor)) {
if (descriptor.type == UExpressionType.Options) {
requiredHeight = descriptor.options.Length * 24;
}
}
}
return new Size(
double.IsInfinity(availableSize.Width) ? 0 : availableSize.Width,
requiredHeight
);
}
public override void Render(DrawingContext context) {
base.Render(context);
if (Part == null) {
Expand All @@ -118,7 +136,7 @@ public override void Render(DrawingContext context) {
double leftTick = TickOffset - 480;
double rightTick = TickOffset + Bounds.Width / TickWidth + 480;
double optionHeight = descriptor.type == UExpressionType.Options
? Bounds.Height / descriptor.options.Length
? Math.Max(Bounds.Height / descriptor.options.Length, 24.0)
: 0;
if (descriptor.type == UExpressionType.Curve) {
var curve = Part.curves.FirstOrDefault(c => c.descriptor == descriptor);
Expand Down
26 changes: 14 additions & 12 deletions OpenUtau/Controls/PianoRoll.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -659,18 +659,20 @@
Part="{Binding NotesViewModel.Part}"
Key="{Binding NotesViewModel.SecondaryKey}"
ShowRealCurve="False"/>
<c:ExpressionCanvas Grid.Row="5" Grid.Column="1"
IsVisible="{Binding NotesViewModel.ShowExpressions}"
Margin="0,24,0,0"
Bounds="{Binding NotesViewModel.ExpBounds, Mode=OneWayToSource}"
TickWidth="{Binding NotesViewModel.TickWidth}"
TickOffset="{Binding NotesViewModel.TickOffset}"
Part="{Binding NotesViewModel.Part}"
Key="{Binding NotesViewModel.PrimaryKey}"
ShowRealCurve="True"
PointerPressed="ExpCanvasPointerPressed"
PointerMoved="ExpCanvasPointerMoved"
PointerReleased="ExpCanvasPointerReleased"/>
<ScrollViewer Name="ExpScrollViewer" Grid.Row="5" Grid.Column="1" Margin="0,24,0,0" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled">
<c:ExpressionCanvas IsVisible="{Binding NotesViewModel.ShowExpressions}"
Bounds="{Binding NotesViewModel.ExpBounds, Mode=OneWayToSource}"
TickWidth="{Binding NotesViewModel.TickWidth}"
TickOffset="{Binding NotesViewModel.TickOffset}"
Part="{Binding NotesViewModel.Part}"
Key="{Binding NotesViewModel.PrimaryKey}"
ShowRealCurve="True"
MinHeight="{Binding #ExpScrollViewer.Bounds.Height}"
VerticalAlignment="Top"
PointerPressed="ExpCanvasPointerPressed"
PointerMoved="ExpCanvasPointerMoved"
PointerReleased="ExpCanvasPointerReleased"/>
</ScrollViewer>
<ListBox Grid.Row="5" Grid.Column="1" HorizontalAlignment="Left" VerticalAlignment="Top" Classes="toolbox"
SelectedIndex="{Binding CurveViewModel.CurveToolIndex}" IsVisible="{Binding NotesViewModel.ShowCurveToolbox, Mode=OneWay}">
<ListBox.ItemsPanel>
Expand Down
Loading