Skip to content
Permalink
Browse files

Fix editor resizing and to insert auto hide minimum size (fixes #189

…and #190)
  • Loading branch information
xwellingtonx authored and xen2 committed Dec 14, 2018
1 parent 98a908b commit 3aac63f7e580dc36399936c8ffc393fcd81d5b5d
@@ -149,6 +149,10 @@ private void LoadLayoutFromSettings(MRUAdditionalData data, bool resetLayoutIfFa
BindableSelectedItemsControl.DisableBindings = true;
try
{
// This exception is normal and will trigger a reset of the layout, since no layout can be loaded from the settings file.
if (GameStudioInternalSettings.CurrentLayoutVersion != data.DockingLayoutVersion)
throw new InvalidOperationException("Layout is out of date, need reset.");

// This exception is normal and will trigger a reset of the layout, since no layout can be loaded from the settings file.
if (string.IsNullOrWhiteSpace(layout))
throw new InvalidOperationException("No layout available in the settings file.");
@@ -161,7 +165,11 @@ private void LoadLayoutFromSettings(MRUAdditionalData data, bool resetLayoutIfFa
return;

// Erase saved layout if we're unable to load it.
if (isInEditorLayout)
if (GameStudioInternalSettings.CurrentLayoutVersion != data.DockingLayoutVersion)
{
mruDataCollection.ResetAllLayouts(session.SessionFilePath);
}
else if (isInEditorLayout)
{
mruDataCollection.ResetEditorsLayout(session.SessionFilePath);
}
@@ -421,9 +421,9 @@
<xcad:LayoutPanel Orientation="Horizontal">
<xcad:LayoutPanel Orientation="Vertical">
<xcad:LayoutPanel Orientation="Horizontal">
<xcad:LayoutAnchorablePane DockWidth="240">
<xcad:LayoutAnchorablePane DockWidth="300">
<!-- SOLUTION EXPLORER -->
<xcad:LayoutAnchorable ContentId="SolutionExplorer" Title="{Binding Source={xk:Localize Solution explorer, Context=View}}"
<xcad:LayoutAnchorable AutoHideMinWidth="300" ContentId="SolutionExplorer" Title="{Binding Source={xk:Localize Solution explorer, Context=View}}"
gs:AvalonDockHelper.IsVisible="{Binding Panels.SessionExplorerPanelVisible, Mode=TwoWay,
Source={x:Static gs:GameStudioViewModel.GameStudio}, FallbackValue={xk:True}}">
<DockPanel>
@@ -557,7 +557,7 @@
</xcad:LayoutAnchorablePane>
<xcad:LayoutDocumentPane>
<!-- ASSET VIEW -->
<xcad:LayoutAnchorable ContentId="AssetView" Title="{Binding Source={xk:Localize Asset view, Context=View}}"
<xcad:LayoutAnchorable AutoHideMinWidth="300" ContentId="AssetView" Title="{Binding Source={xk:Localize Asset view, Context=View}}"
gs:AvalonDockHelper.IsVisible="{Binding Panels.AssetViewPanelVisible, Mode=TwoWay,
Source={x:Static gs:GameStudioViewModel.GameStudio}, FallbackValue={xk:True}}">
<xk:AssetViewUserControl AssetCollection="{Binding Session.ActiveAssetView}" AssetContextMenu="{StaticResource AssetContextMenu}"
@@ -576,9 +576,9 @@
</xcad:LayoutAnchorable>
</xcad:LayoutDocumentPane>
</xcad:LayoutPanel>
<xcad:LayoutAnchorablePane DockHeight="195">
<xcad:LayoutAnchorablePane DockHeight="200">
<!-- REFERENCES -->
<xcad:LayoutAnchorable ContentId="References" Title="{Binding Source={xk:Localize References, Context=View}}"
<xcad:LayoutAnchorable AutoHideMinHeight="200" ContentId="References" Title="{Binding Source={xk:Localize References, Context=View}}"
gs:AvalonDockHelper.IsVisible="{Binding Panels.ReferencesPanelVisible, Mode=TwoWay,
Source={x:Static gs:GameStudioViewModel.GameStudio}, FallbackValue={xk:True}}">
<DockPanel LastChildFill="True" x:Name="RefViewDockPanel">
@@ -606,14 +606,14 @@
</DockPanel>
</xcad:LayoutAnchorable>
<!-- ASSET LOG -->
<xcad:LayoutAnchorable ContentId="AssetLog"
<xcad:LayoutAnchorable AutoHideMinHeight="200" ContentId="AssetLog"
Title="{xk:Localize Asset error ({0}), Plural=Asset errors ({0}), Count={Binding Session.AssetLog.ErrorCount, Source={x:Static gs:GameStudioViewModel.GameStudio}}, IsStringFormat=True, Context=View}"
gs:AvalonDockHelper.IsVisible="{Binding Panels.AssetLogPanelVisible, Mode=TwoWay,
Source={x:Static gs:GameStudioViewModel.GameStudio}, FallbackValue={xk:True}}">
<xk:GridLogViewer LogMessages="{Binding Session.AssetLog.FilteredMessages}" Session="{Binding Session}" ShowDebugMessages="False" ShowVerboseMessages="False" ShowInfoMessages="False"/>
</xcad:LayoutAnchorable>
<!-- BUILD LOG -->
<xcad:LayoutAnchorable ContentId="BuildLog" Title="{Binding Debugging.OutputTitle, Source={x:Static gs:GameStudioViewModel.GameStudio}}"
<xcad:LayoutAnchorable AutoHideMinHeight="200" ContentId="BuildLog" Title="{Binding Debugging.OutputTitle, Source={x:Static gs:GameStudioViewModel.GameStudio}}"
gs:AvalonDockHelper.IsVisible="{Binding Panels.BuildLogPanelVisible, Mode=TwoWay,
Source={x:Static gs:GameStudioViewModel.GameStudio}, FallbackValue={xk:True}}">
<TabControl x:Name="LogTabControl">
@@ -656,10 +656,10 @@
</xcad:LayoutAnchorable>
</xcad:LayoutAnchorablePane>
</xcad:LayoutPanel>
<xcad:LayoutPanel Orientation="Vertical" DockWidth="400">
<xcad:LayoutAnchorablePaneGroup Orientation="Vertical" DockWidth="400">
<xcad:LayoutAnchorablePane DockHeight="2*">
<!-- PROPERTY GRID -->
<xcad:LayoutAnchorable ContentId="PropertyGrid" Title="{Binding Source={xk:Localize Property grid, Context=View}}"
<xcad:LayoutAnchorable AutoHideMinWidth="400" ContentId="PropertyGrid" Title="{Binding Source={xk:Localize Property grid, Context=View}}"
gs:AvalonDockHelper.IsVisible="{Binding Panels.PropertyGridPanelVisible, Mode=TwoWay,
Source={x:Static gs:GameStudioViewModel.GameStudio}, FallbackValue={xk:True}}">
<Grid Background="{StaticResource ToolBarBackgroundBrush}">
@@ -876,15 +876,15 @@
<xcad:LayoutAnchorablePaneGroup DockHeight="1*">
<xcad:LayoutAnchorablePane>
<!-- ASSET PREVIEW -->
<xcad:LayoutAnchorable ContentId="AssetPreview" Title="{Binding Source={xk:Localize Asset preview, Context=View}}"
<xcad:LayoutAnchorable AutoHideMinWidth="400" ContentId="AssetPreview" Title="{Binding Source={xk:Localize Asset preview, Context=View}}"
gs:AvalonDockHelper.IsVisible="{Binding Panels.AssetPreviewPanelVisible, Mode=TwoWay,
Source={x:Static gs:GameStudioViewModel.GameStudio}, FallbackValue={xk:True}}">
<DockPanel LastChildFill="True">
<ContentPresenter Content="{Binding Preview.PreviewObject}"/>
</DockPanel>
</xcad:LayoutAnchorable>
<!-- ACTION HISTORY -->
<xcad:LayoutAnchorable ContentId="ActionHistory" Title="{Binding Source={xk:Localize Edit history, Context=View}}"
<xcad:LayoutAnchorable AutoHideMinWidth="400" ContentId="ActionHistory" Title="{Binding Source={xk:Localize Edit history, Context=View}}"
gs:AvalonDockHelper.IsVisible="{Binding Panels.ActionHistoryPanelVisible, Mode=TwoWay,
Source={x:Static gs:GameStudioViewModel.GameStudio}, FallbackValue={xk:True}}">
<ListBox ItemsSource="{Binding Session.ActionHistory.Transactions}" HorizontalContentAlignment="Stretch">
@@ -913,7 +913,7 @@
</xcad:LayoutAnchorable>
</xcad:LayoutAnchorablePane>
</xcad:LayoutAnchorablePaneGroup>
</xcad:LayoutPanel>
</xcad:LayoutAnchorablePaneGroup>
</xcad:LayoutPanel>
</xcad:LayoutRoot>
</xcad:DockingManager>
@@ -13,7 +13,7 @@ public static class GameStudioInternalSettings
{
public static SettingsContainer SettingsContainer => InternalSettings.SettingsContainer;

public static SettingsKey<List<MRUAdditionalData>> MostRecentlyUsedSessionsData = new SettingsKey<List<MRUAdditionalData>>("Internal/MostRecentlyUsedSessionsData", SettingsContainer, () => new List<MRUAdditionalData>());
public static SettingsKey<List<MRUAdditionalData>> MostRecentlyUsedSessionsData = new SettingsKey<List<MRUAdditionalData>>("Internal/MostRecentlyUsedSessionsData2", SettingsContainer, () => new List<MRUAdditionalData>());
public static SettingsKey<bool> WindowMaximized = new SettingsKey<bool>("Internal/WindowMaximized", SettingsContainer, false);
public static SettingsKey<int> WindowWidth = new SettingsKey<int>("Internal/WindowWidth", SettingsContainer, (int)SystemParameters.WorkArea.Width);
public static SettingsKey<int> WindowHeight = new SettingsKey<int>("Internal/WindowHeight", SettingsContainer, (int)SystemParameters.WorkArea.Height);
@@ -31,10 +31,16 @@ public static class GameStudioInternalSettings
/// <summary>
/// Default Game Studio layout when no editors are opened.
/// </summary>
internal const string DefaultLayout = "<?xml version=\"1.0\"?><LayoutRoot xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><RootPanel Orientation=\"Horizontal\"><LayoutPanel Orientation=\"Vertical\"><LayoutPanel Orientation=\"Horizontal\"><LayoutAnchorablePane DockWidth=\"240\"><LayoutAnchorable AutoHideMinWidth=\"100\" AutoHideMinHeight=\"100\" Title=\"Solution explorer\" IsSelected=\"True\" ContentId=\"SolutionExplorer\" LastActivationTimeStamp=\"09/08/2016 20:59:42\" /></LayoutAnchorablePane><LayoutDocumentPane><LayoutAnchorable AutoHideMinWidth=\"100\" AutoHideMinHeight=\"100\" Title=\"Asset view\" IsSelected=\"True\" IsLastFocusedDocument=\"True\" ContentId=\"AssetView\" LastActivationTimeStamp=\"09/08/2016 20:59:41\" /></LayoutDocumentPane></LayoutPanel><LayoutAnchorablePane DockHeight=\"195\"><LayoutAnchorable AutoHideMinWidth=\"100\" AutoHideMinHeight=\"100\" Title=\"References\" ContentId=\"References\" /><LayoutAnchorable AutoHideMinWidth=\"100\" AutoHideMinHeight=\"100\" IsSelected=\"True\" ContentId=\"AssetLog\"/><LayoutAnchorable AutoHideMinWidth=\"100\" AutoHideMinHeight=\"100\" ContentId=\"BuildLog\"/></LayoutAnchorablePane></LayoutPanel><LayoutPanel Orientation=\"Vertical\" DockWidth=\"400\"><LayoutAnchorablePane DockHeight=\"2*\"><LayoutAnchorable AutoHideMinWidth=\"100\" AutoHideMinHeight=\"100\" Title=\"Property grid\" IsSelected=\"True\" ContentId=\"PropertyGrid\" /></LayoutAnchorablePane><LayoutAnchorablePaneGroup Orientation=\"Horizontal\"><LayoutAnchorablePane><LayoutAnchorable AutoHideMinWidth=\"100\" AutoHideMinHeight=\"100\" Title=\"Asset preview\" IsSelected=\"True\" ContentId=\"AssetPreview\" /><LayoutAnchorable AutoHideMinWidth=\"100\" AutoHideMinHeight=\"100\" Title=\"Action history\" ContentId=\"ActionHistory\" /></LayoutAnchorablePane></LayoutAnchorablePaneGroup></LayoutPanel></RootPanel><TopSide /><RightSide /><LeftSide /><BottomSide /><FloatingWindows /><Hidden /></LayoutRoot>";
internal const string DefaultLayout = "<?xml version=\"1.0\"?><LayoutRoot xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><RootPanel Orientation=\"Horizontal\"><LayoutPanel Orientation=\"Vertical\"><LayoutPanel Orientation=\"Horizontal\"><LayoutAnchorablePane DockWidth=\"300\"><LayoutAnchorable AutoHideMinWidth=\"300\" AutoHideMinHeight=\"100\" Title=\"Solution explorer\" IsSelected=\"True\" ContentId=\"SolutionExplorer\" LastActivationTimeStamp=\"09/08/2016 20:59:42\" /></LayoutAnchorablePane><LayoutDocumentPane><LayoutAnchorable AutoHideMinWidth=\"300\" AutoHideMinHeight=\"100\" Title=\"Asset view\" IsSelected=\"True\" IsLastFocusedDocument=\"True\" ContentId=\"AssetView\" LastActivationTimeStamp=\"09/08/2016 20:59:41\" /></LayoutDocumentPane></LayoutPanel><LayoutAnchorablePane DockHeight=\"200\"><LayoutAnchorable AutoHideMinWidth=\"100\" AutoHideMinHeight=\"200\" Title=\"References\" ContentId=\"References\" /><LayoutAnchorable AutoHideMinWidth=\"100\" AutoHideMinHeight=\"200\" IsSelected=\"True\" ContentId=\"AssetLog\"/><LayoutAnchorable AutoHideMinWidth=\"100\" AutoHideMinHeight=\"200\" ContentId=\"BuildLog\"/></LayoutAnchorablePane></LayoutPanel><LayoutAnchorablePaneGroup Orientation=\"Vertical\" DockWidth=\"400\"><LayoutAnchorablePane DockHeight=\"2*\"><LayoutAnchorable AutoHideMinWidth=\"400\" AutoHideMinHeight=\"100\" Title=\"Property grid\" IsSelected=\"True\" ContentId=\"PropertyGrid\" /></LayoutAnchorablePane><LayoutAnchorablePaneGroup Orientation=\"Horizontal\"><LayoutAnchorablePane><LayoutAnchorable AutoHideMinWidth=\"400\" AutoHideMinHeight=\"100\" Title=\"Asset preview\" IsSelected=\"True\" ContentId=\"AssetPreview\" /><LayoutAnchorable AutoHideMinWidth=\"400\" AutoHideMinHeight=\"100\" Title=\"Action history\" ContentId=\"ActionHistory\" /></LayoutAnchorablePane></LayoutAnchorablePaneGroup></LayoutAnchorablePaneGroup></RootPanel><TopSide /><RightSide /><LeftSide /><BottomSide /><FloatingWindows /><Hidden /></LayoutRoot>";
/// <summary>
/// Default Game Studio layout with editors opened.
/// </summary>
internal const string DefaultEditorLayout = "<?xml version=\"1.0\"?><LayoutRoot xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><RootPanel Orientation=\"Horizontal\"><LayoutPanel Orientation=\"Vertical\"><LayoutPanel Orientation=\"Horizontal\"><LayoutDocumentPane /></LayoutPanel><LayoutAnchorablePaneGroup Orientation=\"Horizontal\" DockHeight=\"300\"><LayoutAnchorablePane DockWidth=\"1*\"><LayoutAnchorable Title=\"Solution explorer\" ContentId=\"SolutionExplorer\" /></LayoutAnchorablePane><LayoutAnchorablePane DockWidth=\"3*\"><LayoutAnchorable Title=\"Asset view\" IsSelected=\"True\" ContentId=\"AssetView\"/><LayoutAnchorable ContentId=\"AssetLog\" /><LayoutAnchorable ContentId=\"BuildLog\" /></LayoutAnchorablePane></LayoutAnchorablePaneGroup></LayoutPanel><LayoutPanel Orientation=\"Vertical\" DockWidth=\"400\"><LayoutAnchorablePane DockHeight=\"4*\"><LayoutAnchorable Title=\"Property grid\" IsSelected=\"True\" ContentId=\"PropertyGrid\" /></LayoutAnchorablePane><LayoutAnchorablePaneGroup Orientation=\"Horizontal\" DockHeight=\"2*\"><LayoutAnchorablePane><LayoutAnchorable Title=\"Asset preview\" ContentId=\"AssetPreview\" /><LayoutAnchorable Title=\"Action history\" ContentId=\"ActionHistory\" /><LayoutAnchorable Title=\"References\" ContentId=\"References\" IsSelected=\"True\" /></LayoutAnchorablePane></LayoutAnchorablePaneGroup></LayoutPanel></RootPanel><TopSide /><RightSide /><LeftSide /><BottomSide /><FloatingWindows /><Hidden /></LayoutRoot>";
internal const string DefaultEditorLayout = "<?xml version=\"1.0\"?><LayoutRoot xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><RootPanel Orientation=\"Horizontal\"><LayoutPanel Orientation=\"Vertical\"><LayoutDocumentPane /><LayoutAnchorablePaneGroup Orientation=\"Horizontal\" DockHeight=\"300\"><LayoutAnchorablePane DockWidth=\"1*\"><LayoutAnchorable AutoHideMinHeight=\"300\" Title=\"Solution explorer\" ContentId=\"SolutionExplorer\" /></LayoutAnchorablePane><LayoutAnchorablePane DockWidth=\"3*\"><LayoutAnchorable AutoHideMinHeight=\"300\" Title=\"Asset view\" IsSelected=\"True\" ContentId=\"AssetView\"/><LayoutAnchorable AutoHideMinHeight=\"300\" ContentId=\"AssetLog\" /><LayoutAnchorable AutoHideMinHeight=\"300\" ContentId=\"BuildLog\" /></LayoutAnchorablePane></LayoutAnchorablePaneGroup></LayoutPanel><LayoutAnchorablePaneGroup Orientation=\"Vertical\" DockWidth=\"400\"><LayoutAnchorablePane DockHeight=\"4*\"><LayoutAnchorable AutoHideMinWidth=\"400\" Title=\"Property grid\" IsSelected=\"True\" ContentId=\"PropertyGrid\" /></LayoutAnchorablePane><LayoutAnchorablePaneGroup Orientation=\"Horizontal\" DockHeight=\"2*\"><LayoutAnchorablePane><LayoutAnchorable AutoHideMinWidth=\"400\" Title=\"Asset preview\" ContentId=\"AssetPreview\" /><LayoutAnchorable AutoHideMinWidth=\"400\" Title=\"Action history\" ContentId=\"ActionHistory\" /><LayoutAnchorable AutoHideMinWidth=\"400\" Title=\"References\" ContentId=\"References\" IsSelected=\"True\" /></LayoutAnchorablePane></LayoutAnchorablePaneGroup></LayoutAnchorablePaneGroup></RootPanel><TopSide /><RightSide /><LeftSide /><BottomSide /><FloatingWindows /><Hidden /></LayoutRoot>";

/// <summary>
/// Current version of the layout. If saved version is lower, layouts will be reset to default values.
/// </summary>
/// <remarks>Bump when making changes to layout and want to force user to reset to default version.</remarks>
internal const int CurrentLayoutVersion = 1;
}
}
@@ -53,6 +53,9 @@ public MRUAdditionalData([NotNull] UFile filePath)
[DataMember]
public IList<AssetId> OpenedAssets { get; set; } = new List<AssetId>();

[DataMember]
public int DockingLayoutVersion { get; set; }

/// <summary>
/// Game Studio layout when no editors are opened.
/// </summary>
@@ -79,6 +79,7 @@ public void ResetAllLayouts(UFile filePath)
LoadFromSettings();

var data = GetOrCreateDataPrivate(filePath);
data.DockingLayoutVersion = GameStudioInternalSettings.CurrentLayoutVersion;
data.DockingLayout = GameStudioInternalSettings.DefaultLayout;
data.DockingLayoutEditors = GameStudioInternalSettings.DefaultEditorLayout;

@@ -171,6 +172,7 @@ private MRUAdditionalData GetOrCreateDataPrivate(UFile filePath, bool createIfNo
{
DockingLayout = GameStudioInternalSettings.DefaultLayout,
DockingLayoutEditors = GameStudioInternalSettings.DefaultEditorLayout,
DockingLayoutVersion = GameStudioInternalSettings.CurrentLayoutVersion,
};
mruList.Insert(0, data);
}

0 comments on commit 3aac63f

Please sign in to comment.
You can’t perform that action at this time.