forked from Misaki/GhostEngine
Updating ProjectBrowser
This commit is contained in:
@@ -10,6 +10,7 @@ using Ghost.Editor.ViewModels.Windows;
|
||||
using Ghost.Engine;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.UI.Dispatching;
|
||||
using Microsoft.UI.Xaml;
|
||||
using System.Diagnostics;
|
||||
using WinUIEx;
|
||||
@@ -116,6 +117,9 @@ public partial class App : Application
|
||||
|
||||
EditorApplication.Initialize(Host.Services, arguments.ProjectPath, arguments.ProjectName);
|
||||
|
||||
// NOTE: We must call DispatcherQueue.GetForCurrentThread() on the UI thread before any await.
|
||||
EditorApplication.SetDispatcherQueue(DispatcherQueue.GetForCurrentThread());
|
||||
|
||||
var splashWindow = new SplashWindow();
|
||||
splashWindow.Activate();
|
||||
Window = splashWindow;
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using Ghost.Editor.Core;
|
||||
using Ghost.Editor.Core.Controls;
|
||||
using Ghost.Editor.Core.Inspector;
|
||||
using Ghost.Engine.Components;
|
||||
|
||||
@@ -183,6 +183,9 @@
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="ContextMenu\" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals" />
|
||||
|
||||
<!--
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:controls="using:Microsoft.UI.Xaml.Controls"
|
||||
xmlns:internal="using:Ghost.Editor.Controls.Internal"
|
||||
xmlns:ghost="using:Ghost.Editor.Controls"
|
||||
xmlns:local="using:Ghost.Editor.Core">
|
||||
|
||||
<ResourceDictionary.ThemeDictionaries>
|
||||
@@ -38,7 +38,7 @@
|
||||
<x:Double x:Key="NavigationViewItemOnLeftMinHeight">32</x:Double>
|
||||
|
||||
<!-- Control override -->
|
||||
<Style TargetType="internal:NavigationTabView">
|
||||
<Style TargetType="ghost:NavigationTabView">
|
||||
<Setter Property="TabWidthMode" Value="Compact" />
|
||||
</Style>
|
||||
<Style TargetType="NumberBox" />
|
||||
|
||||
23
Ghost.Editor/View/Controls/ProjectBrowser.Menu.cs
Normal file
23
Ghost.Editor/View/Controls/ProjectBrowser.Menu.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using Ghost.Editor.Core;
|
||||
|
||||
namespace Ghost.Editor.View.Controls;
|
||||
|
||||
internal partial class ProjectBrowser
|
||||
{
|
||||
[ContextMenuItem("project-browser", "Show in Explorer")]
|
||||
private static void ShowInExplorer()
|
||||
{
|
||||
var path = LastFocused?.ViewModel.CurrentDirectoryPath;
|
||||
if (!Directory.Exists(path))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo()
|
||||
{
|
||||
FileName = path,
|
||||
UseShellExecute = true,
|
||||
Verb = "open"
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<UserControl
|
||||
x:Class="Ghost.Editor.Controls.ProjectBrowser"
|
||||
x:Class="Ghost.Editor.View.Controls.ProjectBrowser"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:community="using:CommunityToolkit.WinUI.Controls"
|
||||
xmlns:converter="using:Ghost.Editor.Utilities.Converters"
|
||||
xmlns:ctc="using:CommunityToolkit.WinUI.Controls"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="using:Ghost.Editor.Controls"
|
||||
xmlns:ghost="using:Ghost.Editor.Core.Controls"
|
||||
xmlns:local="using:Ghost.Editor.View.Controls"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:model="using:Ghost.Editor.Models"
|
||||
xmlns:sys="using:System"
|
||||
@@ -164,13 +165,13 @@
|
||||
</MenuFlyout>
|
||||
</Grid.ContextFlyout>
|
||||
|
||||
<ctc:ConstrainedBox Grid.Row="0" AspectRatio="1:1">
|
||||
<community:ConstrainedBox Grid.Row="0" AspectRatio="1:1">
|
||||
<Image HorizontalAlignment="Center">
|
||||
<Image.Source>
|
||||
<BitmapImage DecodePixelWidth="48" UriSource="{x:Bind Converter={StaticResource ExplorerItemToIconUriConverter}}" />
|
||||
</Image.Source>
|
||||
</Image>
|
||||
</ctc:ConstrainedBox>
|
||||
</community:ConstrainedBox>
|
||||
<TextBlock
|
||||
Grid.Row="1"
|
||||
HorizontalAlignment="Center"
|
||||
@@ -190,7 +191,7 @@
|
||||
MinRowSpacing="4" />
|
||||
</ItemsView.Layout>
|
||||
<ItemsView.ContextFlyout>
|
||||
<MenuFlyout>
|
||||
<ghost:ContextFlyout Tag="project-browser">
|
||||
<MenuFlyoutSubItem Text="Create">
|
||||
<MenuFlyoutItem Text="Folder" />
|
||||
<MenuFlyoutItem Text="Script" />
|
||||
@@ -199,11 +200,8 @@
|
||||
<MenuFlyoutItem Text="Volume Profile" />
|
||||
</MenuFlyoutSubItem>
|
||||
</MenuFlyoutSubItem>
|
||||
<MenuFlyoutItem Text="Show in Explorer" />
|
||||
<MenuFlyoutSeparator />
|
||||
<MenuFlyoutItem Text="Refresh" />
|
||||
<MenuFlyoutItem Text="Reimport All" />
|
||||
</MenuFlyout>
|
||||
</ghost:ContextFlyout>
|
||||
</ItemsView.ContextFlyout>
|
||||
</ItemsView>
|
||||
|
||||
|
||||
@@ -3,11 +3,18 @@ using Ghost.Editor.Models;
|
||||
using Ghost.Editor.ViewModels.Controls;
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
using Microsoft.UI.Xaml.Input;
|
||||
|
||||
namespace Ghost.Editor.Controls;
|
||||
namespace Ghost.Editor.View.Controls;
|
||||
|
||||
internal sealed partial class ProjectBrowser : UserControl
|
||||
{
|
||||
public static ProjectBrowser? LastFocused
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
private readonly IInspectorService _inspectorService;
|
||||
private bool _isUpdatingSelection = false;
|
||||
|
||||
@@ -25,6 +32,18 @@ internal sealed partial class ProjectBrowser : UserControl
|
||||
|
||||
Loaded += ProjectBrowser_Loaded;
|
||||
Unloaded += ProjectBrowser_Unloaded;
|
||||
|
||||
GettingFocus += ProjectBrowser_GettingFocus;
|
||||
}
|
||||
|
||||
private void ProjectBrowser_GettingFocus(UIElement sender, GettingFocusEventArgs args)
|
||||
{
|
||||
if (_isUpdatingSelection)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
LastFocused = this;
|
||||
}
|
||||
|
||||
private void ProjectBrowser_Loaded(object sender, RoutedEventArgs e)
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:internal="using:Ghost.Editor.Controls.Internal"
|
||||
xmlns:internal="using:Ghost.Editor.Controls"
|
||||
xmlns:local="using:Ghost.Editor.View.Pages.EngineEditor"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:sg="using:Ghost.Editor.Core.SceneGraph"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Ghost.Editor.Controls.Internal;
|
||||
using Ghost.Editor.Controls;
|
||||
using Ghost.Editor.Core.Contracts;
|
||||
using Ghost.Editor.Core.SceneGraph;
|
||||
using Ghost.Editor.ViewModels.Pages.EngineEditor;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:internal="using:Ghost.Editor.Controls.Internal"
|
||||
xmlns:internal="using:Ghost.Editor.Controls"
|
||||
xmlns:local="using:Ghost.Editor.View.Pages.EngineEditor"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d">
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Ghost.Editor.Controls.Internal;
|
||||
using Ghost.Editor.Controls;
|
||||
using Ghost.Editor.ViewModels.Pages.EngineEditor;
|
||||
|
||||
namespace Ghost.Editor.View.Pages.EngineEditor;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:internal="using:Ghost.Editor.Controls.Internal"
|
||||
xmlns:internal="using:Ghost.Editor.Controls"
|
||||
xmlns:local="using:Ghost.Editor.View.Pages.EngineEditor"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d">
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Ghost.Editor.Controls.Internal;
|
||||
using Ghost.Editor.Controls;
|
||||
//using Ghost.Graphics.Contracts;
|
||||
//using Microsoft.UI.Xaml;
|
||||
//using Microsoft.UI.Xaml.Controls;
|
||||
|
||||
@@ -4,12 +4,12 @@
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:behaviors="using:CommunityToolkit.WinUI.Behaviors"
|
||||
xmlns:controls="using:CommunityToolkit.WinUI.Controls"
|
||||
xmlns:controls1="using:Ghost.Editor.Controls"
|
||||
xmlns:controls="using:Ghost.Editor.View.Controls"
|
||||
xmlns:ctc="using:CommunityToolkit.WinUI.Controls"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:ee="using:Ghost.Editor.View.Pages.EngineEditor"
|
||||
xmlns:ghost="using:Ghost.Editor.Controls"
|
||||
xmlns:interactivity="using:Microsoft.Xaml.Interactivity"
|
||||
xmlns:internal="using:Ghost.Editor.Controls.Internal"
|
||||
xmlns:local="using:Ghost.Editor.View.Windows"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:winex="using:WinUIEx"
|
||||
@@ -43,25 +43,25 @@
|
||||
Grid.Row="1"
|
||||
Padding="4,0,4,4"
|
||||
Background="{ThemeResource AcrylicBackgroundFillColorBaseBrush}">
|
||||
<controls:TabbedCommandBar>
|
||||
<controls:TabbedCommandBar.MenuItems>
|
||||
<controls:TabbedCommandBarItem Header="Home">
|
||||
<ctc:TabbedCommandBar>
|
||||
<ctc:TabbedCommandBar.MenuItems>
|
||||
<ctc:TabbedCommandBarItem Header="Home">
|
||||
<AppBarButton Label="Undo" />
|
||||
<AppBarButton Label="Redo" />
|
||||
<AppBarButton Label="Paste" />
|
||||
</controls:TabbedCommandBarItem>
|
||||
<controls:TabbedCommandBarItem Header="Home">
|
||||
</ctc:TabbedCommandBarItem>
|
||||
<ctc:TabbedCommandBarItem Header="Home">
|
||||
<AppBarButton Label="Undo" />
|
||||
<AppBarButton Label="Redo" />
|
||||
<AppBarButton Label="Paste" />
|
||||
</controls:TabbedCommandBarItem>
|
||||
<controls:TabbedCommandBarItem Header="Home">
|
||||
</ctc:TabbedCommandBarItem>
|
||||
<ctc:TabbedCommandBarItem Header="Home">
|
||||
<AppBarButton Label="Undo" />
|
||||
<AppBarButton Label="Redo" />
|
||||
<AppBarButton Label="Paste" />
|
||||
</controls:TabbedCommandBarItem>
|
||||
</controls:TabbedCommandBar.MenuItems>
|
||||
</controls:TabbedCommandBar>
|
||||
</ctc:TabbedCommandBarItem>
|
||||
</ctc:TabbedCommandBar.MenuItems>
|
||||
</ctc:TabbedCommandBar>
|
||||
</Grid>
|
||||
|
||||
<!-- Editor -->
|
||||
@@ -78,52 +78,52 @@
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<internal:NavigationTabView
|
||||
<ghost:NavigationTabView
|
||||
Grid.Column="0"
|
||||
Width="350"
|
||||
HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="Stretch">
|
||||
<internal:NavigationTabView.TabItems>
|
||||
<ghost:NavigationTabView.TabItems>
|
||||
<ee:HierarchyPage Header="Hierarchy">
|
||||
<ee:HierarchyPage.IconSource>
|
||||
<FontIconSource Glyph="" />
|
||||
</ee:HierarchyPage.IconSource>
|
||||
</ee:HierarchyPage>
|
||||
</internal:NavigationTabView.TabItems>
|
||||
</internal:NavigationTabView>
|
||||
</ghost:NavigationTabView.TabItems>
|
||||
</ghost:NavigationTabView>
|
||||
|
||||
<internal:NavigationTabView Grid.Column="1">
|
||||
<internal:NavigationTabView.TabItems>
|
||||
<ghost:NavigationTabView Grid.Column="1">
|
||||
<ghost:NavigationTabView.TabItems>
|
||||
<ee:ScenePage Header="Scene">
|
||||
<ee:ScenePage.IconSource>
|
||||
<FontIconSource Glyph="" />
|
||||
</ee:ScenePage.IconSource>
|
||||
</ee:ScenePage>
|
||||
</internal:NavigationTabView.TabItems>
|
||||
</internal:NavigationTabView>
|
||||
</ghost:NavigationTabView.TabItems>
|
||||
</ghost:NavigationTabView>
|
||||
|
||||
<internal:NavigationTabView
|
||||
<ghost:NavigationTabView
|
||||
Grid.Column="2"
|
||||
Width="350"
|
||||
HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="Stretch">
|
||||
<internal:NavigationTabView.TabItems>
|
||||
<ghost:NavigationTabView.TabItems>
|
||||
<ee:InspectorPage Header="Inspector">
|
||||
<ee:InspectorPage.IconSource>
|
||||
<FontIconSource Glyph="" />
|
||||
</ee:InspectorPage.IconSource>
|
||||
</ee:InspectorPage>
|
||||
</internal:NavigationTabView.TabItems>
|
||||
</internal:NavigationTabView>
|
||||
</ghost:NavigationTabView.TabItems>
|
||||
</ghost:NavigationTabView>
|
||||
</Grid>
|
||||
|
||||
<internal:NavigationTabView Grid.Row="1" Height="350">
|
||||
<internal:NavigationTabView.TabItems>
|
||||
<ghost:NavigationTabView Grid.Row="1" Height="350">
|
||||
<ghost:NavigationTabView.TabItems>
|
||||
<TabViewItem Header="Project">
|
||||
<TabViewItem.IconSource>
|
||||
<FontIconSource Glyph="" />
|
||||
</TabViewItem.IconSource>
|
||||
<controls1:ProjectBrowser />
|
||||
<controls:ProjectBrowser />
|
||||
</TabViewItem>
|
||||
<TabViewItem Header="Console">
|
||||
<TabViewItem.IconSource>
|
||||
@@ -131,8 +131,8 @@
|
||||
</TabViewItem.IconSource>
|
||||
<ee:ConsolePage />
|
||||
</TabViewItem>
|
||||
</internal:NavigationTabView.TabItems>
|
||||
</internal:NavigationTabView>
|
||||
</ghost:NavigationTabView.TabItems>
|
||||
</ghost:NavigationTabView>
|
||||
</Grid>
|
||||
|
||||
<!-- Status Bar -->
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using Ghost.Editor.Core;
|
||||
using Microsoft.UI.Xaml;
|
||||
using Windows.ApplicationModel;
|
||||
using Windows.Storage;
|
||||
using WinUIEx;
|
||||
|
||||
namespace Ghost.Editor.View.Windows;
|
||||
@@ -20,7 +19,7 @@ internal sealed partial class SplashWindow : WindowEx
|
||||
IsMinimizable = false;
|
||||
ExtendsContentIntoTitleBar = true;
|
||||
|
||||
//this.CenterOnScreen(750, 400);
|
||||
this.CenterOnScreen(750, 400);
|
||||
}
|
||||
|
||||
private void MainGrid_Loaded(object sender, RoutedEventArgs e)
|
||||
|
||||
@@ -35,6 +35,11 @@ internal partial class ProjectBrowserViewModel : ObservableObject
|
||||
}
|
||||
}
|
||||
|
||||
public string CurrentDirectoryPath
|
||||
{
|
||||
get; set;
|
||||
} = string.Empty;
|
||||
|
||||
public ProjectBrowserViewModel(IInspectorService inspectorService)
|
||||
{
|
||||
_inspectorService = inspectorService;
|
||||
@@ -84,6 +89,8 @@ internal partial class ProjectBrowserViewModel : ObservableObject
|
||||
var fileItem = new ExplorerItem(Path.GetFileName(file), file, false);
|
||||
Files.Add(fileItem);
|
||||
}
|
||||
|
||||
CurrentDirectoryPath = path;
|
||||
}
|
||||
|
||||
internal (ExplorerItem?, int) OpenSelected()
|
||||
|
||||
Reference in New Issue
Block a user