diff --git a/OpenUtau/Controls/TrackHeader.axaml b/OpenUtau/Controls/TrackHeader.axaml index 62b43053e..3134e5cc3 100644 --- a/OpenUtau/Controls/TrackHeader.axaml +++ b/OpenUtau/Controls/TrackHeader.axaml @@ -139,28 +139,41 @@ - - - - + + + + + - - - - - + + + + + + - - + + diff --git a/OpenUtau/Controls/TrackHeader.axaml.cs b/OpenUtau/Controls/TrackHeader.axaml.cs index 7570f6d67..9a98feba2 100644 --- a/OpenUtau/Controls/TrackHeader.axaml.cs +++ b/OpenUtau/Controls/TrackHeader.axaml.cs @@ -154,6 +154,85 @@ void TrackSettingsButtonClicked(object sender, RoutedEventArgs args) { } } + void VolumeButtonClicked(object sender, RoutedEventArgs args) { + if (sender is Button button && ViewModel != null) { + if (button.Parent is Grid parentGrid) { + if (parentGrid.Children[2] is TextBox volumeTextBox) { + volumeTextBox.Text = ViewModel.Volume.ToString(); + volumeTextBox.IsVisible = true; + button.IsVisible = false; + args.Handled = true; + } + } + } + } + void PanButtonClicked(object sender, RoutedEventArgs args) { + if (sender is Button button && ViewModel != null) { + if (button.Parent is Grid parentGrid) { + if (parentGrid.Children[5] is TextBox panTextBox) { + panTextBox.Text = ViewModel.Pan.ToString(); + panTextBox.IsVisible = true; + button.IsVisible = false; + args.Handled = true; + } + } + } + } + void VolumeTextBoxEnter(object sender, KeyEventArgs args) { + if (sender is TextBox textBox && ViewModel != null && Key.Enter.Equals(args.Key)) { + if (textBox.Parent is Grid parentGrid) { + if (parentGrid.Children[0] is Slider volumeSlider) { + if (double.TryParse(textBox.Text, out double number)) { + number = number > volumeSlider.Minimum ? number < volumeSlider.Maximum ? number : volumeSlider.Maximum : volumeSlider.Minimum; + ViewModel.Volume = number; + } + + } else + if (parentGrid.Children[1] is Button volumeButton) { + textBox.IsVisible = false; + volumeButton.IsVisible = true; + args.Handled = true; + } + } + } + } + void PanTextBoxEnter(object sender, KeyEventArgs args) { + if (sender is TextBox textBox && ViewModel != null && Key.Enter.Equals(args.Key)) { + if (textBox.Parent is Grid parentGrid) { + if (parentGrid.Children[3] is Slider panSlider) { + if (double.TryParse(textBox.Text, out double number)) { + number = number > panSlider.Minimum ? number < panSlider.Maximum ? number : panSlider.Maximum : panSlider.Minimum; + ViewModel.Pan = number; + } + + } else + if (parentGrid.Children[4] is Button panButton) { + textBox.IsVisible = false; + panButton.IsVisible = true; + args.Handled = true; + } + } + } + } + + void TextBoxLeave(object sender, PointerEventArgs args) { + if (sender is TextBox textBox) { + if (textBox.Parent is Grid parentGrid) { + if (parentGrid.Children[1] is Button volumeButton) { + textBox.IsVisible = false; + volumeButton.IsVisible = true; + args.Handled = true; + } + if (parentGrid.Children[4] is Button panButton) { + textBox.IsVisible = false; + panButton.IsVisible = true; + args.Handled = true; + } + } + } + } + + public void Dispose() { unbinds.ForEach(u => u.Dispose()); unbinds.Clear();