-
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
1 parent
f447759
commit 5e16238
Showing
17 changed files
with
761 additions
and
524 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
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,124 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
using Dock.Avalonia.Controls; | ||
using Dock.Model.Controls; | ||
using Dock.Model.Core; | ||
using Dock.Model.ReactiveUI; | ||
using Dock.Model.ReactiveUI.Controls; | ||
|
||
using ImeSense.ShaderPlayground.ViewModels.Docks; | ||
using ImeSense.ShaderPlayground.ViewModels.Documents; | ||
using ImeSense.ShaderPlayground.ViewModels.Toolbars; | ||
|
||
namespace ImeSense.ShaderPlayground.ViewModels; | ||
|
||
public class AppFactory : Factory { | ||
private IRootDock? _rootDock; | ||
|
||
private IDocumentDock? _shaderDock; | ||
|
||
private ITool? _viewportToolbar; | ||
private ITool? _logToolbar; | ||
|
||
public override IDocumentDock CreateDocumentDock() { | ||
return new ShaderDocumentDock(); | ||
} | ||
|
||
public override IRootDock CreateLayout() { | ||
var untitledShaderViewModel = new ShaderViewModel { | ||
Title = "Untitled", | ||
}; | ||
|
||
var viewportViewModel = new ViewportViewModel { | ||
Id = "Viewport", | ||
Title = "Viewport", | ||
}; | ||
var logViewModel = new LogViewModel { | ||
Id = "Log", | ||
Title = "Log", | ||
}; | ||
|
||
// Tabs | ||
var documentDock = new ShaderDocumentDock() { | ||
Id = "Shaders", | ||
Title = "Shaders", | ||
IsCollapsable = false, | ||
Proportion = double.NaN, | ||
ActiveDockable = untitledShaderViewModel, | ||
VisibleDockables = CreateList<IDockable>(untitledShaderViewModel), | ||
CanCreateDocument = false, | ||
}; | ||
|
||
var tools = new ProportionalDock { | ||
Proportion = 0.5, | ||
Orientation = Orientation.Vertical, | ||
VisibleDockables = CreateList<IDockable>( | ||
new ToolDock { | ||
ActiveDockable = viewportViewModel, | ||
VisibleDockables = CreateList<IDockable>(viewportViewModel), | ||
Alignment = Alignment.Right, | ||
GripMode = GripMode.Visible, | ||
}, | ||
new ProportionalDockSplitter(), | ||
new ToolDock { | ||
ActiveDockable = logViewModel, | ||
VisibleDockables = CreateList<IDockable>(logViewModel), | ||
Alignment = Alignment.Right, | ||
GripMode = GripMode.Visible, | ||
} | ||
), | ||
}; | ||
|
||
var windowLayout = CreateRootDock(); | ||
windowLayout.Title = "Default"; | ||
windowLayout.IsCollapsable = false; | ||
|
||
// Content | ||
var windowLayoutContent = new ProportionalDock { | ||
Orientation = Orientation.Horizontal, | ||
IsCollapsable = false, | ||
VisibleDockables = CreateList<IDockable>( | ||
documentDock, | ||
new ProportionalDockSplitter(), | ||
tools | ||
), | ||
}; | ||
windowLayout.VisibleDockables = CreateList<IDockable>(windowLayoutContent); | ||
windowLayout.ActiveDockable = windowLayoutContent; | ||
|
||
// Root | ||
var rootDock = CreateRootDock(); | ||
rootDock.IsCollapsable = false; | ||
rootDock.VisibleDockables = CreateList<IDockable>(windowLayout); | ||
rootDock.ActiveDockable = windowLayout; | ||
rootDock.DefaultDockable = windowLayout; | ||
|
||
_shaderDock = documentDock; | ||
_rootDock = rootDock; | ||
_viewportToolbar = viewportViewModel; | ||
_logToolbar = logViewModel; | ||
|
||
return rootDock; | ||
} | ||
|
||
public override void InitLayout(IDockable layout) { | ||
ContextLocator = new Dictionary<string, Func<object?>> { | ||
["Viewport"] = () => layout, | ||
["Log"] = () => layout | ||
}; | ||
|
||
DockableLocator = new Dictionary<string, Func<IDockable?>> { | ||
["Root"] = () => _rootDock, | ||
["Files"] = () => _shaderDock, | ||
["Viewport"] = () => _viewportToolbar, | ||
["Log"] = () => _logToolbar, | ||
}; | ||
|
||
HostWindowLocator = new Dictionary<string, Func<IHostWindow?>> { | ||
[nameof(IDockWindow)] = () => new HostWindow(), | ||
}; | ||
|
||
base.InitLayout(layout); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
src/ImeSense.ShaderPlayground/ViewModels/Docks/ShaderDocumentDock.cs
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,26 @@ | ||
using Dock.Model.ReactiveUI.Controls; | ||
|
||
using ImeSense.ShaderPlayground.ViewModels.Documents; | ||
|
||
using ReactiveUI; | ||
|
||
namespace ImeSense.ShaderPlayground.ViewModels.Docks; | ||
|
||
public class ShaderDocumentDock : DocumentDock { | ||
private void CreateNewShader() { | ||
if (!CanCreateDocument) { | ||
return; | ||
} | ||
|
||
var shader = new ShaderViewModel { | ||
Title = "Shader", | ||
}; | ||
Factory?.AddDockable(this, shader); | ||
Factory?.SetActiveDockable(shader); | ||
Factory?.SetFocusedDockable(this, shader); | ||
} | ||
|
||
public ShaderDocumentDock() { | ||
CreateDocument = ReactiveCommand.Create(CreateNewShader); | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
src/ImeSense.ShaderPlayground/ViewModels/Documents/ShaderViewModel.cs
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,6 @@ | ||
using Dock.Model.ReactiveUI.Controls; | ||
|
||
namespace ImeSense.ShaderPlayground.ViewModels.Documents; | ||
|
||
public class ShaderViewModel : Document { | ||
} |
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
6 changes: 6 additions & 0 deletions
6
src/ImeSense.ShaderPlayground/ViewModels/Toolbars/LogViewModel.cs
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,6 @@ | ||
using Dock.Model.ReactiveUI.Controls; | ||
|
||
namespace ImeSense.ShaderPlayground.ViewModels.Toolbars; | ||
|
||
public class LogViewModel : Tool { | ||
} |
39 changes: 39 additions & 0 deletions
39
src/ImeSense.ShaderPlayground/ViewModels/Toolbars/ViewportViewModel.cs
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,39 @@ | ||
using System.Windows.Input; | ||
|
||
using Dock.Model.ReactiveUI.Controls; | ||
|
||
using ReactiveUI; | ||
|
||
namespace ImeSense.ShaderPlayground.ViewModels.Toolbars; | ||
|
||
public class ViewportViewModel : Tool { | ||
public ViewportViewModel() { | ||
Resolution = "800x600"; | ||
Frame = "60"; | ||
|
||
PlayCommand = ReactiveCommand.Create(() => { | ||
}); | ||
StopCommand = ReactiveCommand.Create(() => { | ||
}); | ||
SettingsCommand = ReactiveCommand.Create(() => { | ||
}); | ||
} | ||
|
||
private string _resolution = string.Empty; | ||
|
||
public string Resolution { | ||
get => _resolution; | ||
set => this.RaiseAndSetIfChanged(ref _resolution, value); | ||
} | ||
|
||
private string _frame = string.Empty; | ||
|
||
public string Frame { | ||
get => _frame; | ||
set => this.RaiseAndSetIfChanged(ref _frame, value); | ||
} | ||
|
||
public ICommand PlayCommand { get; private set; } | ||
public ICommand StopCommand { get; private set; } | ||
public ICommand SettingsCommand { get; private set; } | ||
} |
Oops, something went wrong.