forked from stakira/OpenUtau
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
174 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<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" | ||
mc:Ignorable="d" d:DesignWidth="20" d:DesignHeight="20" | ||
x:Class="OpenUtau.App.Controls.ViewScaler"> | ||
<Path Name="Path" Width="16" Height="16" Stroke="Black" StrokeThickness="1.75" | ||
StrokeLineCap="Flat" StrokeJoin="Miter"/> | ||
</UserControl> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
using System; | ||
using Avalonia; | ||
using Avalonia.Controls; | ||
using Avalonia.Controls.Shapes; | ||
using Avalonia.Markup.Xaml; | ||
using Avalonia.Media; | ||
using ReactiveUI; | ||
|
||
namespace OpenUtau.App.Controls { | ||
public partial class ViewScaler : UserControl { | ||
public static readonly DirectProperty<ViewScaler, double> MaxProperty = | ||
AvaloniaProperty.RegisterDirect<ViewScaler, double>( | ||
nameof(Max), | ||
o => o.Max, | ||
(o, v) => o.Max = v); | ||
public static readonly DirectProperty<ViewScaler, double> MinProperty = | ||
AvaloniaProperty.RegisterDirect<ViewScaler, double>( | ||
nameof(Min), | ||
o => o.Min, | ||
(o, v) => o.Min = v); | ||
public static readonly DirectProperty<ViewScaler, double> ValueProperty = | ||
AvaloniaProperty.RegisterDirect<ViewScaler, double>( | ||
nameof(Value), | ||
o => o.Value, | ||
(o, v) => o.Value = v); | ||
|
||
public double Max { | ||
get => max; | ||
set => SetAndRaise(MaxProperty, ref max, value); | ||
} | ||
public double Min { | ||
get => min; | ||
set => SetAndRaise(MinProperty, ref min, value); | ||
} | ||
public double Value { | ||
get => value_; | ||
set => SetAndRaise(ValueProperty, ref value_, value); | ||
} | ||
|
||
private double max; | ||
private double min; | ||
private double value_; | ||
|
||
private Path path; | ||
|
||
public ViewScaler() { | ||
InitializeComponent(); | ||
path = this.FindControl<Path>("Path"); | ||
} | ||
|
||
private void InitializeComponent() { | ||
AvaloniaXamlLoader.Load(this); | ||
} | ||
|
||
protected override void OnPropertyChanged<T>(AvaloniaPropertyChangedEventArgs<T> change) { | ||
base.OnPropertyChanged(change); | ||
if (!change.IsEffectiveValueChange) { | ||
return; | ||
} | ||
if (change.Property == MaxProperty || change.Property == MinProperty || change.Property == ValueProperty) { | ||
UpdatePath(); | ||
} | ||
} | ||
|
||
private void UpdatePath() { | ||
double offset = 7 * Math.Log(ViewConstants.TrackHeightMax / Value, 2) / Math.Log(ViewConstants.TrackHeightMax / ViewConstants.TrackHeightMin, 2); | ||
double size = offset < 4 ? 4 : 8 - offset; | ||
if (double.IsNaN(offset) || double.IsNaN(size) || | ||
double.IsInfinity(offset) || double.IsInfinity(size)) return; | ||
path.Data = Geometry.Parse(FormattableString.Invariant( | ||
$"M {8 - size} {offset + size} L 8 {offset} L {8 + size} {offset + size} M {8 - size} {16 - size - offset} L 8 {16 - offset} L {8 + size} {16 - size - offset}")); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using System.Collections.Generic; | ||
using System.Windows.Input; | ||
|
||
namespace OpenUtau.App.ViewModels { | ||
public class MenuItemViewModel { | ||
public string? Header { get; set; } | ||
public ICommand? Command { get; set; } | ||
public object? CommandParameter { get; set; } | ||
public IList<MenuItemViewModel>? Items { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters