Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<ControlTheme x:Key="PropertyExpanderTheme" TargetType="Expander">
<Setter Property="Padding" Value="10,0,0,0"/>
<Setter Property="Template">
<ControlTemplate TargetType="Expander">
<ControlTemplate>
<Border BorderThickness="0" Margin="0" Padding="0"
HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<ContentPresenter Content="{TemplateBinding Content}"
Expand All @@ -24,7 +24,7 @@
<Setter Property="HorizontalAlignment" Value="Stretch"/>
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto" />
<Setter Property="Template">
<ControlTemplate TargetType="sd:PropertyView">
<ControlTemplate>
<Border Padding="{TemplateBinding Padding}"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
Expand Down Expand Up @@ -52,7 +52,7 @@
</TreeDataTemplate>
</Setter>
<Setter Property="Template">
<ControlTemplate TargetType="sd:PropertyViewItem">
<ControlTemplate>
<Border BorderBrush="{TemplateBinding Border.BorderBrush}"
BorderThickness="{TemplateBinding Border.BorderThickness}"
IsVisible="{Binding IsVisible}">
Expand All @@ -63,9 +63,9 @@
ContentTemplate="{TemplateBinding HeaderTemplate}"
HorizontalAlignment="{TemplateBinding Control.HorizontalAlignment}"
IsVisible="{sd:MultiBinding {Binding !$parent[sd:PropertyView].((caecp:SessionObjectPropertiesViewModel)DataContext).ShowOverridesOnly, FallbackValue={sd:True}},
{Binding [IsOverridden]},
{Binding ![HasBase]},
Converter={sd:OrMulti}}"/>
{Binding [IsOverridden]},
{Binding ![HasBase]},
Converter={sd:OrMulti}}"/>
</Border>
<Expander IsEnabled="True" IsExpanded="{Binding IsExpanded, RelativeSource={RelativeSource TemplatedParent}}"
HorizontalAlignment="Stretch"
Expand All @@ -77,9 +77,9 @@
ContentTemplate="{x:Static caev:PropertyViewHelper.FooterProviders}"
HorizontalAlignment="{TemplateBinding Control.HorizontalAlignment}"
IsVisible="{sd:MultiBinding {Binding !$parent[sd:PropertyView].((caecp:SessionObjectPropertiesViewModel)DataContext).ShowOverridesOnly, FallbackValue={sd:True}},
{Binding [IsOverridden]},
{Binding ![HasBase]},
Converter={sd:OrMulti}}"/>
{Binding [IsOverridden]},
{Binding ![HasBase]},
Converter={sd:OrMulti}}"/>
</StackPanel>
</Expander>
</DockPanel>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public static SessionViewModel Instance
actionService.Resize(200);

// And initialize the actions view model
sessionViewModel.ActionHistory?.Initialize();
sessionViewModel?.ActionHistory?.Initialize();

// Copy the result of the asset loading to the log panel.
sessionViewModel?.AssetLog.AddLogger(LogKey.Get("Session"), sessionResult);
Expand Down
133 changes: 5 additions & 128 deletions sources/editor/Stride.GameStudio.Avalonia/App.axaml

Large diffs are not rendered by default.

This file was deleted.

11 changes: 8 additions & 3 deletions sources/editor/Stride.GameStudio.Avalonia/Views/MainView.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

<Grid RowDefinitions="Auto, *, 25"
Background="Transparent">
<!-- Menus -->
<Menu Grid.Row="0" Grid.Column="0"
VerticalAlignment="Top">
<!-- File menu -->
Expand Down Expand Up @@ -86,6 +87,8 @@
Command="{Binding CrashCommand}"/>
</MenuItem>
</Menu>

<!-- Session area -->
<Grid Grid.Row="1"
RowDefinitions="2*, 2, *">
<Grid Grid.Row="0"
Expand Down Expand Up @@ -169,10 +172,12 @@
</TabItem>
<TabItem Header="References">
<DockPanel>
<StackPanel DockPanel.Dock="Top" Orientation="Horizontal">
<!-- Toolbar -->
<sd:ToolBar DockPanel.Dock="Top">
<ToggleButton IsChecked="{Binding !Session.References.ShowReferencers}" Content="{sd:LocalizeString References}" MinWidth="80"/>
<ToggleButton IsChecked="{Binding Session.References.ShowReferencers}" Content="{sd:LocalizeString Referenced by}" MinWidth="80"/>
</StackPanel>
</sd:ToolBar>
<!-- Asset references -->
<Border DockPanel.Dock="Bottom"
Padding="8,4">
<TextBlock Text="{Binding Session.References.TypeCountersAsText}"
Expand Down Expand Up @@ -213,7 +218,7 @@
</Grid>
</Grid>

<!-- Status Bar -->
<!-- Status bar -->
<Grid Grid.Row="2"
IsVisible="{Binding Session, Converter={sd:ObjectToBool}}"
ColumnDefinitions="2*, Auto, *, Auto, *, 100">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
Icon="/Assets/GameStudio.ico"
Title="{Binding Title}"
Width="1280" Height="900">
<gsvw:MainView />
<gsvw:MainView />
</Window>
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Copyright (c) .NET Foundation and Contributors (https://dotnetfoundation.org/ & https://stride3d.net)
// Distributed under the MIT license. See the LICENSE.md file in the project root for more information.

using Avalonia;
using Avalonia.Controls;
using Avalonia.Layout;

namespace Stride.Core.Presentation.Avalonia.Controls;

public sealed class ToolBar : ItemsControl
{
/// <summary>
/// Defines the <see cref="Orientation"/> property.
/// </summary>
public static readonly StyledProperty<Orientation> OrientationProperty =
AvaloniaProperty.RegisterAttached<ToolBar, Orientation>(nameof(Orientation), typeof(ToolBar), coerce: CoerceOrientation);

private static Orientation CoerceOrientation(AvaloniaObject d, Orientation value)
{
ToolBarTray? toolBarTray = ((ToolBar)d).ToolBarTray;
return toolBarTray?.Orientation ?? value;
}

public Orientation Orientation
{
get => GetValue(OrientationProperty);
}

private ToolBarTray? ToolBarTray => Parent as ToolBarTray;

protected override void OnInitialized()
{
base.OnInitialized();
CoerceValue(OrientationProperty);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
// Copyright (c) .NET Foundation and Contributors (https://dotnetfoundation.org/ & https://stride3d.net)
// Distributed under the MIT license. See the LICENSE.md file in the project root for more information.

using System.Collections.ObjectModel;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Layout;
using Avalonia.Metadata;

namespace Stride.Core.Presentation.Avalonia.Controls;

public sealed class ToolBarTray : Control, IAddChild<ToolBar>
{
/// <summary>
/// Defines the <see cref="Orientation"/> property.
/// </summary>
public static readonly StyledProperty<Orientation> OrientationProperty =
AvaloniaProperty.Register<ToolBarTray, Orientation>(nameof(Orientation));

static ToolBarTray()
{
OrientationProperty.Changed.AddClassHandler<ToolBarTray>((tray, _) =>
{
foreach (var toolBar in tray.ToolBars)
{
toolBar.CoerceValue(ToolBar.OrientationProperty);
}
});
}

private readonly ToolBarCollection toolBars;

public ToolBarTray()
{
toolBars = new ToolBarCollection(this);
}

public Orientation Orientation
{
get => GetValue(OrientationProperty);
set => SetValue(OrientationProperty, value);
}

public Collection<ToolBar> ToolBars => toolBars;

void IAddChild<ToolBar>.AddChild(ToolBar child)
{
ToolBars.Add(child);
}

// Note: for now follow a similar layouting than StackPanel
protected override Size MeasureOverride(Size availableSize)
{
Size trayDesiredSize = new();
Size toolBarConstraint = availableSize;
bool isHorizontal = Orientation == Orientation.Horizontal;
toolBarConstraint = isHorizontal
? toolBarConstraint.WithWidth(double.PositiveInfinity)
: toolBarConstraint.WithHeight(double.PositiveInfinity);

foreach (var toolBar in toolBars)
{
// Measure the toolbar
toolBar.Measure(toolBarConstraint);
var toolBarDesiredSize = toolBar.DesiredSize;

// Accumulate the size
if (isHorizontal)
{
trayDesiredSize = trayDesiredSize.WithWidth(trayDesiredSize.Width + toolBarDesiredSize.Width);
trayDesiredSize = trayDesiredSize.WithHeight(Math.Max(trayDesiredSize.Height, toolBarDesiredSize.Height));
}
else
{
trayDesiredSize = trayDesiredSize.WithWidth(Math.Max(trayDesiredSize.Width, toolBarDesiredSize.Width));
trayDesiredSize = trayDesiredSize.WithHeight(trayDesiredSize.Height + toolBarDesiredSize.Height);
}
}

return trayDesiredSize;
}

// Note: for now follow a similar layouting than StackPanel
protected override Size ArrangeOverride(Size finalSize)
{
bool isHorizontal = Orientation == Orientation.Horizontal;
Rect rcToolBar = new(finalSize);
double previousDimension = 0.0;

foreach (var toolBar in toolBars)
{
if (!toolBar.IsVisible) continue;

if (isHorizontal)
{
rcToolBar = rcToolBar.WithX(rcToolBar.X + previousDimension);
previousDimension = toolBar.DesiredSize.Width;
rcToolBar = rcToolBar.WithWidth(previousDimension);
rcToolBar = rcToolBar.WithHeight(Math.Max(finalSize.Height, toolBar.DesiredSize.Height));
}
else
{
rcToolBar = rcToolBar.WithY(rcToolBar.Y + previousDimension);
previousDimension = toolBar.DesiredSize.Height;
rcToolBar = rcToolBar.WithHeight(previousDimension);
rcToolBar = rcToolBar.WithWidth(Math.Max(finalSize.Width, toolBar.DesiredSize.Width));
}

toolBar.Arrange(rcToolBar);
}

return finalSize;
}

private sealed class ToolBarCollection : Collection<ToolBar>
{
private readonly ToolBarTray parent;

public ToolBarCollection(ToolBarTray parent)
{
this.parent = parent;
}

protected override void ClearItems()
{
var count = Count;
if (count > 0)
{
for (var i = 0; i < count; i++)
{
var toolBar = this[i];
parent.VisualChildren.Remove(toolBar);
parent.LogicalChildren.Remove(toolBar);
}

parent.InvalidateMeasure();
}

base.ClearItems();
}

protected override void InsertItem(int index, ToolBar toolBar)
{
base.InsertItem(index, toolBar);

parent.LogicalChildren.Add(toolBar);
parent.VisualChildren.Add(toolBar);

parent.InvalidateMeasure();
}

protected override void RemoveItem(int index)
{
var toolBar = this[index];
base.RemoveItem(index);

parent.VisualChildren.Remove(toolBar);
parent.LogicalChildren.Remove(toolBar);

parent.InvalidateMeasure();
}

protected override void SetItem(int index, ToolBar toolBar)
{
var currentToolBar = this[index];
if (toolBar != currentToolBar)
{
base.SetItem(index, toolBar);

// remove current toolBar
parent.VisualChildren.Remove(currentToolBar);
parent.LogicalChildren.Remove(currentToolBar);

// add new toolBar
parent.LogicalChildren.Add(toolBar);
parent.VisualChildren.Add(toolBar);

parent.InvalidateMeasure();
}
}
}
}
Loading
Loading