Skip to content
Merged
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
32 changes: 31 additions & 1 deletion OpenUtau/Controls/TrackHeader.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,30 @@
<Style Selector="ToggleButton">
<Setter Property="Background" Value="Transparent"/>
</Style>
<Style Selector="Button.fxButton">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="Padding" Value="0"/>
<Setter Property="HorizontalContentAlignment" Value="Center"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Style Selector="^:pointerover /template/ ContentPresenter#PART_ContentPresenter">
<Setter Property="Background" Value="{DynamicResource NeutralAccentBrush}" />
</Style>
<Style Selector="^:pressed /template/ ContentPresenter#PART_ContentPresenter">
<Setter Property="Background" Value="{DynamicResource NeutralAccentBrushPointerOver}" />
</Style>
</Style>
<Style Selector="Button.fxButton.fxOn">
<Style Selector="^ /template/ ContentPresenter#PART_ContentPresenter">
<Setter Property="Background" Value="{DynamicResource NeutralAccentBrushSemi}" />
</Style>
<Style Selector="^:pointerover /template/ ContentPresenter#PART_ContentPresenter">
<Setter Property="Background" Value="{DynamicResource NeutralAccentBrush}" />
</Style>
<Style Selector="^:pressed /template/ ContentPresenter#PART_ContentPresenter">
<Setter Property="Background" Value="{DynamicResource NeutralAccentBrushPointerOver}" />
</Style>
</Style>
<Style Selector="Slider.fader">
<Setter Property="Foreground" Value="{Binding TrackColor.AccentColor}"/>

Expand Down Expand Up @@ -207,8 +231,14 @@
</ContextMenu>
</ToggleButton.ContextMenu>
</ToggleButton>
<Button Grid.Row="3" Grid.Column="3" Classes="toolbar fxButton" Margin="1" Height="17"
HorizontalAlignment="Stretch" ToolTip.Tip="{DynamicResource tracks.mixfx}"
Classes.fxOn="{Binding MixFxEnabled}"
Command="{Binding OpenMixFxDialog}">
<TextBlock Text="fx" FontSize="11" FontWeight="SemiBold" VerticalAlignment="Center" HorizontalAlignment="Center"/>
</Button>
<Separator Background="Transparent" Height="17" Margin="1" IsVisible="{Binding IsRendererVisible}"/>
<Button Grid.Row="3" Grid.Column="3" Margin="1" Padding="0" Height="17" Background="Transparent"
<Button Grid.Row="4" Grid.Column="3" Margin="1" Padding="0" Height="17" Background="Transparent"
HorizontalAlignment="Stretch" Click="TrackSettingsButtonClicked" IsVisible="{Binding IsRendererVisible}"
ToolTip.Tip="{DynamicResource tracks.tracksettings}">
<Path Classes="clear" Width="24" Height="24"
Expand Down
8 changes: 8 additions & 0 deletions OpenUtau/Controls/TrackHeaderCanvas.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,14 @@ public TrackHeaderCanvas() {
}
}
});
MessageBus.Current.Listen<MixFxChangedNotification>()
.Subscribe(e => {
foreach (var (track, header) in trackHeaders) {
if (header.ViewModel != null && track.TrackNo == e.trackNo) {
header.ViewModel.ManuallyRaise();
}
}
});
MessageBus.Current.Listen<TrackSelectionEvent>()
.Subscribe(e => {
var selectedTracks = new HashSet<UTrack>(e.selectedTracks);
Expand Down
16 changes: 12 additions & 4 deletions OpenUtau/ViewModels/TrackHeaderViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public class TrackHeaderViewModel : ViewModelBase, IActivatableViewModel {
[Reactive] public bool IsSingerVisible { get; set; }
[Reactive] public bool IsPhonemizerVisible { get; set; }
[Reactive] public bool IsRendererVisible { get; set; }
[Reactive] public bool MixFxEnabled { get; set; }
[Reactive] public IBrush HeaderBorderBrush { get; set; } = ThemeManager.NeutralAccentBrushSemi;

public ViewModelActivator Activator { get; }
Expand Down Expand Up @@ -123,6 +124,7 @@ public TrackHeaderViewModel(UTrack track) {
Mute = track.Mute;
Muted = track.Muted;
Solo = track.Solo;
MixFxEnabled = track.MixFx?.Enabled ?? false;
this.WhenAnyValue(x => x.Volume)
.Subscribe(volume => {
track.Volume = volume;
Expand All @@ -146,6 +148,14 @@ public TrackHeaderViewModel(UTrack track) {
.Subscribe(solo => {
track.Solo = solo;
});
this.WhenAnyValue(x => x.MixFxEnabled)
.Subscribe(enabled => {
if (track.MixFx != null) {
track.MixFx.Enabled = enabled;
} else if (enabled) {
track.MixFx = new UMixFx { Enabled = true };
}
});
this.WhenAnyValue(x => x.IsSelected)
.Subscribe(_ => RefreshSelectionStyle());

Expand Down Expand Up @@ -181,10 +191,6 @@ public void ToggleMute() {
JudgeMuted();
}

public void ToggleApplyMixFx() {
// Legacy stub kept so any leftover XAML binding still resolves.
// The FX dialog (right-click → Track Polish) is the new entry point.
}
public void ToggleMute(bool mute) {
if (mute) {
Mute = true;
Expand Down Expand Up @@ -491,6 +497,8 @@ public void ManuallyRaise() {
this.RaisePropertyChanged(nameof(Mute));
this.RaisePropertyChanged(nameof(Muted));
this.RaisePropertyChanged(nameof(Solo));
MixFxEnabled = track.MixFx?.Enabled ?? false;
this.RaisePropertyChanged(nameof(MixFxEnabled));
this.RaisePropertyChanged(nameof(Volume));
this.RaisePropertyChanged(nameof(Pan));
RefreshAvatar();
Expand Down
6 changes: 6 additions & 0 deletions OpenUtau/ViewModels/TracksViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ public TracksMuteEvent(int trackNo, bool allmute) {
this.allmute = allmute;
}
}
public class MixFxChangedNotification {
public readonly int trackNo;
public MixFxChangedNotification(int trackNo) {
this.trackNo = trackNo;
}
}
public class TrackSelectionEvent {
public readonly UTrack[] selectedTracks;
public TrackSelectionEvent(UTrack[] selectedTracks) {
Expand Down
7 changes: 7 additions & 0 deletions OpenUtau/Views/MixFxDialog.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,20 @@
using Avalonia.Controls;
using Avalonia.Interactivity;
using OpenUtau.App.ViewModels;
using OpenUtau.Core;
using OpenUtau.Core.Ustx;
using ReactiveUI;

namespace OpenUtau.App.Views {
public partial class MixFxDialog : Window {
readonly MixFxViewModel viewModel;
readonly UTrack? track;

public MixFxDialog() : this(null) { }

public MixFxDialog(UTrack? track) {
InitializeComponent();
this.track = track;
DataContext = viewModel = new MixFxViewModel(track);
viewModel.AskForName = PromptForNameAsync;
}
Expand All @@ -32,6 +36,9 @@ public MixFxDialog(UTrack? track) {

void OnOkClicked(object sender, RoutedEventArgs e) {
viewModel.Apply();
if (track != null) {
MessageBus.Current.SendMessage(new MixFxChangedNotification(track.TrackNo));
}
Close();
}

Expand Down
Loading