Skip to content

Commit

Permalink
Create v2 main window.
Browse files Browse the repository at this point in the history
  • Loading branch information
stakira committed Sep 19, 2021
1 parent c0753fa commit e206952
Show file tree
Hide file tree
Showing 15 changed files with 404 additions and 0 deletions.
12 changes: 12 additions & 0 deletions OpenUtau.App/App.axaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<Application xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:OpenUtau.App"
x:Class="OpenUtau.App.App">
<Application.DataTemplates>
<local:ViewLocator/>
</Application.DataTemplates>

<Application.Styles>
<FluentTheme Mode="Light"/>
</Application.Styles>
</Application>
29 changes: 29 additions & 0 deletions OpenUtau.App/App.axaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using Avalonia;
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Markup.Xaml;
using OpenUtau.App.ViewModels;
using OpenUtau.App.Views;

namespace OpenUtau.App
{
public class App : Application
{
public override void Initialize()
{
AvaloniaXamlLoader.Load(this);
}

public override void OnFrameworkInitializationCompleted()
{
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
{
desktop.MainWindow = new MainWindow
{
DataContext = new MainWindowViewModel(),
};
}

base.OnFrameworkInitializationCompleted();
}
}
}
Binary file added OpenUtau.App/Assets/avalonia-logo.ico
Binary file not shown.
24 changes: 24 additions & 0 deletions OpenUtau.App/OpenUtau.App.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net5.0</TargetFramework>
<Nullable>enable</Nullable>
<Version>0.0.0</Version>
</PropertyGroup>
<ItemGroup>
<Folder Include="Models\" />
<AvaloniaResource Include="Assets\**" />
</ItemGroup>
<ItemGroup>
<AvaloniaXaml Remove="Themes\Dark.axaml" />
</ItemGroup>
<ItemGroup>
<AvaloniaResource Include="Themes\Dark.axaml" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Avalonia" Version="0.10.3" />
<PackageReference Include="Avalonia.Desktop" Version="0.10.3" />
<PackageReference Include="Avalonia.Diagnostics" Version="0.10.3" />
<PackageReference Include="Avalonia.ReactiveUI" Version="0.10.3" />
</ItemGroup>
</Project>
23 changes: 23 additions & 0 deletions OpenUtau.App/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using Avalonia;
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.ReactiveUI;
using System;

namespace OpenUtau.App
{
class Program
{
// Initialization code. Don't use any Avalonia, third-party APIs or any
// SynchronizationContext-reliant code before AppMain is called: things aren't initialized
// yet and stuff might break.
public static void Main(string[] args) => BuildAvaloniaApp()
.StartWithClassicDesktopLifetime(args);

// Avalonia configuration, don't remove; also used by visual designer.
public static AppBuilder BuildAvaloniaApp()
=> AppBuilder.Configure<App>()
.UsePlatformDetect()
.LogToTrace()
.UseReactiveUI();
}
}
63 changes: 63 additions & 0 deletions OpenUtau.App/Strings/Strings.axaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:system="clr-namespace:System;assembly=mscorlib"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<!-- Menu -->
<system:String x:Key="menu.file">_File</system:String>
<system:String x:Key="menu.file.new">_New</system:String>
<system:String x:Key="menu.file.open">_Open...</system:String>
<system:String x:Key="menu.file.openas">O_pen As</system:String>
<system:String x:Key="menu.file.save">_Save</system:String>
<system:String x:Key="menu.file.saveas">Save _As...</system:String>
<system:String x:Key="menu.file.importaudio">_Import Audio...</system:String>
<system:String x:Key="menu.file.importmidi">_Import Midi...</system:String>
<system:String x:Key="menu.file.exportall">Export All</system:String>
<system:String x:Key="menu.file.recentfiles">Open Recent</system:String>
<system:String x:Key="menu.file.exit">_Exit</system:String>

<system:String x:Key="menu.edit">_Edit</system:String>
<system:String x:Key="menu.edit.undo">_Undo</system:String>
<system:String x:Key="menu.edit.redo">_Redo</system:String>
<system:String x:Key="menu.edit.cut">Cu_t</system:String>
<system:String x:Key="menu.edit.copy">_Copy</system:String>
<system:String x:Key="menu.edit.paste">_Paste</system:String>
<system:String x:Key="menu.edit.delete">_Delete</system:String>
<system:String x:Key="menu.edit.selectall">Select _All</system:String>

<system:String x:Key="menu.tools">_Tools</system:String>
<system:String x:Key="menu.tools.singers">Singers...</system:String>
<system:String x:Key="menu.tools.singer.install">Install Singer</system:String>
<system:String x:Key="menu.tools.prefs">Preferences</system:String>

<system:String x:Key="menu.help">_Help</system:String>
<system:String x:Key="menu.help.about">About OpenUTAU</system:String>

<!-- Preferences -->
<system:String x:Key="prefs.caption">Preferences</system:String>
<system:String x:Key="prefs.general">General</system:String>
<system:String x:Key="prefs.general.paths">Paths</system:String>
<system:String x:Key="prefs.general.paths.singer">Singer Paths</system:String>
<system:String x:Key="prefs.general.paths.add">Add</system:String>
<system:String x:Key="prefs.general.paths.remove">Remove</system:String>
<system:String x:Key="prefs.audio">Audio</system:String>
<system:String x:Key="prefs.audio.playback">Playback</system:String>
<system:String x:Key="prefs.audio.rendering">Rendering</system:String>
<system:String x:Key="prefs.audio.rendering.resampler.preview">Resampler for preview</system:String>
<system:String x:Key="prefs.audio.rendering.resampler.export">Resampler for export</system:String>
<system:String x:Key="prefs.audio.rendering.resampler.note">
Note: to use external resamplers, please add the resampler DLL or EXE file in the Resamplers folder in the OpenUtau install path.
</system:String>
<system:String x:Key="prefs.appearance">Appearance</system:String>

<!-- Dialogs -->
<system:String x:Key="dialogs.noresampler.caption">No resampler</system:String>
<system:String x:Key="dialogs.noresampler.message">No resampler! Put your favourite resampler exe or dll in the Resamplers folder!</system:String>
<system:String x:Key="dialogs.about.caption">About OpenUTAU</system:String>
<system:String x:Key="dialogs.about.message">
OpenUtau aims to be an open source editing environment for UTAU community, with a modern user experience and intelligent phonological support. Visit us on Github.
</system:String>
<system:String x:Key="dialogs.export.caption">Export</system:String>
<system:String x:Key="dialogs.export.savefirst">Save project file first</system:String>

<!-- Errors -->
<system:String x:Key="errors.caption">Error</system:String>
</ResourceDictionary>
36 changes: 36 additions & 0 deletions OpenUtau.App/Themes/Dark.axaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<Styles xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Styles.Resources>
<!-- Colors -->
<Color x:Key="BackgroundColor">#000000</Color>
<Color x:Key="BackgroundColor1">#101010</Color>
<Color x:Key="NeutralColor">#404040</Color>
<Color x:Key="NeutralColor1">#606060</Color>

<!-- Avalonia brushes -->
<SolidColorBrush x:Key="BackgroundBrush" Color="{DynamicResource BackgroundColor}" />
<SolidColorBrush x:Key="BackgroundBrush1" Color="{DynamicResource BackgroundColor1}" />
<SolidColorBrush x:Key="NeutralBrush" Color="{DynamicResource NeutralColor}" />
<SolidColorBrush x:Key="NeutralBrush1" Color="{DynamicResource NeutralColor1}" />
</Styles.Resources>

<Style Selector="Menu">
<Setter Property="Height" Value="24"/>
</Style>
<Style Selector="MenuItem">
<Setter Property="Background" Value="White"/>
<Setter Property="FontSize" Value="12"/>
<Setter Property="Height" Value="24"/>
<Setter Property="Padding" Value="8,2,8,2"/>
</Style>
<Style Selector="TextBlock">
<Setter Property="FontSize" Value="12"/>
</Style>
<Style Selector="ProgressBar">
<Setter Property="Background" Value="White"/>
<Setter Property="Foreground" Value="BlueViolet"/>
</Style>
<Style Selector="ProgressBar /template/ Border">
<Setter Property="CornerRadius" Value="0,0,0,0"/>
</Style>
</Styles>
32 changes: 32 additions & 0 deletions OpenUtau.App/ViewLocator.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using Avalonia.Controls;
using Avalonia.Controls.Templates;
using OpenUtau.App.ViewModels;
using System;

namespace OpenUtau.App
{
public class ViewLocator : IDataTemplate
{
public bool SupportsRecycling => false;

public IControl Build(object data)
{
var name = data.GetType().FullName!.Replace("ViewModel", "View");
var type = Type.GetType(name);

if (type != null)
{
return (Control)Activator.CreateInstance(type)!;
}
else
{
return new TextBlock { Text = "Not Found: " + name };
}
}

public bool Match(object data)
{
return data is ViewModelBase;
}
}
}
16 changes: 16 additions & 0 deletions OpenUtau.App/ViewModels/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace OpenUtau.App.ViewModels {
public class MainWindowViewModel : ViewModelBase {
public string Greeting => "Welcome to Avalonia!";

public string AppVersion => $"OpenUtau v{System.Reflection.Assembly.GetEntryAssembly()?.GetName().Version}";

public void SeekStart() { System.Diagnostics.Debug.WriteLine("SeekStart"); }
public void SeekEnd() { System.Diagnostics.Debug.WriteLine("SeekEnd"); }
public void PlayOrPause() { System.Diagnostics.Debug.WriteLine("PlayOrPause"); }
public void Stop() { System.Diagnostics.Debug.WriteLine("Stop"); }
}
}
11 changes: 11 additions & 0 deletions OpenUtau.App/ViewModels/ViewModelBase.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using ReactiveUI;
using System;
using System.Collections.Generic;
using System.Text;

namespace OpenUtau.App.ViewModels
{
public class ViewModelBase : ReactiveObject
{
}
}
117 changes: 117 additions & 0 deletions OpenUtau.App/Views/MainWindow.axaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
<Window xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:vm="using:OpenUtau.App.ViewModels"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="OpenUtau.App.Views.MainWindow"
Icon="/Assets/avalonia-logo.ico"
Title="OpenUtau">
<Window.Styles>
<StyleInclude Source="/Themes/Dark.axaml"/>
<Style Selector="ProgressBar /template/ Border">
<Setter Property="CornerRadius" Value="0,0,0,0"/>
</Style>
<Style Selector="ScrollBar /template/ Rectangle">
<Setter Property="Fill" Value="White"/>
</Style>
<Style Selector="Border.playback">
<Setter Property="CornerRadius" Value="4"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="BorderBrush" Value="LightGray"/>
<Setter Property="Height" Value="20"/>
</Style>
<Style Selector="Border.playback TextBlock">
<Setter Property="FontSize" Value="10"/>
<Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="HorizontalAlignment" Value="Center"/>
</Style>
<Style Selector="Border.playback StackPanel">
<Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="HorizontalAlignment" Value="Center"/>
</Style>
<Style Selector="Border.playback Button">
<Setter Property="Margin" Value="0"/>
<Setter Property="Padding" Value="0"/>
<Setter Property="Width" Value="21"/>
<Setter Property="Height" Value="20"/>
<Setter Property="Background" Value="Transparent"/>
</Style>
</Window.Styles>
<Window.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceInclude Source='/Strings/Strings.axaml'/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Window.Resources>
<Design.DataContext>
<vm:MainWindowViewModel/>
</Design.DataContext>
<Grid RowDefinitions="24,1*,Auto,5" ColumnDefinitions="250,*,24" VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
<Menu Grid.Row="0" Grid.Column="0" VerticalAlignment="Top" HorizontalAlignment="Left">
<MenuItem Header="{DynamicResource menu.file}">
<MenuItem Header="{DynamicResource menu.file.new}" InputGesture="Ctrl+N"/>
<MenuItem Header="{DynamicResource menu.file.open}" InputGesture="Ctrl+O"/>
<MenuItem Header="{DynamicResource menu.file.save}" InputGesture="Ctrl+S"/>
<MenuItem Header="{DynamicResource menu.file.saveas}" IsEnabled="False"/>
<MenuItem Header="{DynamicResource menu.file.importaudio}"/>
<MenuItem Header="{DynamicResource menu.file.importmidi}"/>
<MenuItem Header="{DynamicResource menu.file.exportall}"/>
<MenuItem Header="{DynamicResource menu.file.exit}" InputGesture="Alt+F4"/>
</MenuItem>
<MenuItem Header="{DynamicResource menu.tools}">
<MenuItem Header="{DynamicResource menu.tools.singers}"/>
<MenuItem Header="{DynamicResource menu.tools.singer.install}"/>
<MenuItem Header="{DynamicResource menu.tools.prefs}"/>
</MenuItem>
<MenuItem Header="{DynamicResource menu.help}">
<MenuItem Header="{Binding AppVersion}"/>
</MenuItem>
</Menu>
<ScrollBar Grid.Row="0" Grid.Column="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="0,4,0,4" Orientation="Horizontal" AllowAutoHide="False"/>
<Border Grid.Row="0" Grid.Column="2" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="0,0,0,0" Background="AliceBlue">
</Border>
<Panel Grid.Row="1" Grid.Column="0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="0,0,0,0">
<Panel HorizontalAlignment="Stretch" VerticalAlignment="Top" Height="24">
<Border Classes="playback" Width="72" HorizontalAlignment="Left" Margin="4,0">
<TextBlock Classes="playback" PointerPressed="OnEditTempo">4/4 120.00</TextBlock>
</Border>
<Border Classes="playback" Width="88" HorizontalAlignment="Center">
<StackPanel Orientation="Horizontal">
<Button Command="{Binding SeekStart}">
<Path Fill="Black" VerticalAlignment="Center" HorizontalAlignment="Center"
Data="M 0 0 L 2 0 L 2 9 L 0 9 Z M 2 4.5 L 7 0 L 7 9 Z"/>
</Button>
<Button Command="{Binding PlayOrPause}">
<Path Fill="Black" VerticalAlignment="Center" HorizontalAlignment="Center"
Data="M 0 0 L 7 6.5 L 0 13 Z"/>
</Button>
<Button Command="{Binding Stop}">
<Path Fill="Black" VerticalAlignment="Center" HorizontalAlignment="Center"
Data="M 0 0 L 2 0 L 2 9 L 0 9 Z M 4 0 L 6 0 L 6 9 L 4 9 Z"/>
</Button>
<Button Command="{Binding SeekEnd}">
<Path Fill="Black" VerticalAlignment="Center" HorizontalAlignment="Center"
Data="M 0 0 L 5 4.5 L 0 9 Z M 5 0 L 7 0 L 7 9 L 5 9 Z"/>
</Button>
</StackPanel>
</Border>
<Border Classes="playback" Width="72" HorizontalAlignment="Right" Margin="4,0">
<TextBlock Classes="playback">00:00.000</TextBlock>
</Border>
</Panel>
<Canvas HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="0,24,0,0" Background="Wheat"/>
</Panel>
<Panel Grid.Row="1" Grid.Column="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="0,0,0,0">
<Canvas HorizontalAlignment="Stretch" VerticalAlignment="Top" Height="24" Background="AliceBlue"/>
<Border HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Background="Transparent" BoxShadow="inset 0 0 5 0.75 Gray" ClipToBounds="True">
</Border>
</Panel>
<Border Grid.Row="1" Grid.Column="2" HorizontalAlignment="Stretch" VerticalAlignment="Top" Margin="0,0,0,0" Height="24" Background="Wheat">
</Border>
<ScrollBar Grid.Row="1" Grid.Column="2" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="4,24,4,0" Orientation="Vertical" AllowAutoHide="False"/>
<TextBlock Grid.Row="2" Grid.ColumnSpan="3" VerticalAlignment="Bottom" HorizontalAlignment="Stretch" Height="15" Text="Progress"/>
<ProgressBar Grid.Row="3" Grid.ColumnSpan="3" VerticalAlignment="Bottom" HorizontalAlignment="Stretch" Height="5" Value="50"/>
</Grid>
</Window>
23 changes: 23 additions & 0 deletions OpenUtau.App/Views/MainWindow.axaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Input;
using Avalonia.Markup.Xaml;

namespace OpenUtau.App.Views {
public partial class MainWindow : Window {
public MainWindow() {
InitializeComponent();
#if DEBUG
this.AttachDevTools();
#endif
}

private void InitializeComponent() {
AvaloniaXamlLoader.Load(this);
}

void OnEditTempo(object sender, PointerPressedEventArgs args) {

}
}
}
Loading

0 comments on commit e206952

Please sign in to comment.