Skip to content

Commit

Permalink
Merge pull request #1266 from zdman2022/AnimationChain_NewWindow
Browse files Browse the repository at this point in the history
Animation chain new window
  • Loading branch information
vchelaru authored Feb 2, 2024
2 parents 54de320 + 436a4ff commit 4c4c909
Show file tree
Hide file tree
Showing 11 changed files with 214 additions and 113 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ public async Task SaveElementAsync(GlueElement element, TaskExecutionPreference
throw new ArgumentNullException(nameof(element));
}

if(GlueState.Self.CurrentGlueProject.FileVersion >= (int)GlueProjectSave.GluxVersions.SeparateJsonFilesForElements)
if(GlueState.Self.CurrentGlueProject?.FileVersion >= (int)GlueProjectSave.GluxVersions.SeparateJsonFilesForElements)
{
await TaskManager.Self.AddAsync(async () =>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ private static void CreateViewIfNecessary()
{
View = new AchxPreviewView();
ViewModel = new AchxViewModel();
ViewModel.IsShowGuidesChecked = true;
ViewModel.PropertyChanged += HandleViewModelPropertyChanged;
View.DataContext = ViewModel;
View.Initialize(new SpritePlugin.Managers.CameraLogic(), new SpritePlugin.Managers.CameraLogic());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,40 +1,13 @@
using FlatRedBall.Glue.MVVM;
using OfficialPlugins.Common.ViewModels;
using OfficialPlugins.TreeViewPlugin.ViewModels;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace OfficialPlugins.AnimationChainPlugin.ViewModels
{
internal class AchxViewModel : ViewModel, ICameraZoomViewModel
internal class AchxViewModel : ViewModel
{
[DependsOn(nameof(CurrentZoomPercent))]
public float CurrentZoomScale => CurrentZoomPercent / 100.0f;

public float CurrentZoomPercent
{
get => Get<float>();
set
{
Set(value);
}
}

public float CurrentAnimationZoomPercent
{
get => Get<float>();
set
{
Set(value);
}
}

public List<int> ZoomPercentages { get; set; } =
new List<int> { 4000, 2000, 1500, 1000, 750, 500, 350, 200, 100, 75, 50, 25, 10, 5 };
public ZoomViewModel WholeZoom { get; set; }
public ZoomViewModel SingleZoom { get; set; }

public int ResolutionWidth
{
Expand Down Expand Up @@ -86,6 +59,12 @@ public AnimationChainViewModel SelectedAnimationChain
}
}

public bool IsShowGuidesChecked
{
get => Get<bool>();
set => Set(value);
}

[DependsOn(nameof(SelectedItem))]
public AnimationFrameViewModel SelectedAnimationFrame =>
SelectedItem as AnimationFrameViewModel;
Expand All @@ -96,7 +75,11 @@ public AnimationChainViewModel SelectedAnimationChain

public AchxViewModel()
{
CurrentZoomPercent = 100;
WholeZoom = new ZoomViewModel();
SingleZoom = new ZoomViewModel();

WholeZoom.CurrentZoomPercent = 100;
SingleZoom.CurrentZoomPercent = 100;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,18 @@ public float BottomCoordinate
set => Set(value);
}

public bool FlipHorizontal
{
get => Get<bool>();
set => Set(value);
}

public bool FlipVertical
{
get => Get<bool>();
set => Set(value);
}

public ObservableCollection<ShapeViewModel> VisibleChildren
{
get => Get<ObservableCollection<ShapeViewModel>>();
Expand Down Expand Up @@ -93,6 +105,10 @@ public void SetFrom(AnimationChainViewModel parent, AnimationFrameSave animation
ResolutionWidth = resolutionWidth;
ResolutionHeight = resolutionHeight;

FlipHorizontal = animationFrame.FlipHorizontal;
FlipVertical = animationFrame.FlipVertical;


var rectangles = animationFrame.ShapeCollectionSave?.AxisAlignedRectangleSaves;
if (rectangles != null)
foreach (var rect in rectangles)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using FlatRedBall.Glue.MVVM;
using OfficialPlugins.Common.ViewModels;
using System.Collections.Generic;

namespace OfficialPlugins.AnimationChainPlugin.ViewModels
{
internal class ZoomViewModel : ViewModel, ICameraZoomViewModel
{
[DependsOn(nameof(CurrentZoomPercent))]
public float CurrentZoomScale => CurrentZoomPercent / 100.0f;

public float CurrentZoomPercent
{
get => Get<float>();
set
{
Set(value);
}
}

public float CurrentAnimationZoomPercent
{
get => Get<float>();
set
{
Set(value);
}
}

public List<int> ZoomPercentages { get; set; } =
new List<int> { 4000, 2000, 1500, 1000, 750, 500, 350, 200, 100, 75, 50, 25, 10, 5 };
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,31 +52,41 @@

<Grid Grid.Column="2">
<Grid.RowDefinitions>
<RowDefinition></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="5"></RowDefinition>
<RowDefinition></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<wpf1:GumSKElement x:Name="GumCanvas" Grid.Row="0"
MouseDown="GumCanvas_MouseDown"
MouseMove="GumCanvas_MouseMove"
MouseWheel="GumCanvas_MouseWheel"
></wpf1:GumSKElement>
<GridSplitter Grid.Row="1"
Background="#cccccc"
HorizontalAlignment="Stretch"
VerticalAlignment="Center"
Background="Black"
ResizeBehavior="PreviousAndNext"
ShowsPreview="True"
Height="2"
Height="5"
/>
<wpf1:GumSKElement x:Name="GumCanvasAnimation" Grid.Row="2"
MouseDown="GumAnimationCanvas_MouseDown"
MouseMove="GumAnimationCanvas_MouseMove"
MouseWheel="GumAnimationCanvas_MouseWheel"
></wpf1:GumSKElement>
<StackPanel Grid.Row="3" Orientation="Horizontal">
<Label Content="{Binding ResolutionDisplay, FallbackValue=300x500}" ></Label>
</StackPanel>
<Grid x:Name="BottomHalfGrid" Grid.Row="2">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
</Grid.RowDefinitions>
<StackPanel Grid.Row="0" Orientation="Horizontal">
<CheckBox IsChecked="{Binding IsShowGuidesChecked}">Show Guides</CheckBox>
</StackPanel>
<wpf1:GumSKElement x:Name="GumCanvasAnimation" Grid.Row="1"
MouseDown="GumAnimationCanvas_MouseDown"
MouseMove="GumAnimationCanvas_MouseMove"
MouseWheel="GumAnimationCanvas_MouseWheel"
></wpf1:GumSKElement>
<StackPanel Grid.Row="2" Orientation="Horizontal">
<Label Content="{Binding ResolutionDisplay, FallbackValue=300x500}" ></Label>
</StackPanel>
</Grid>
</Grid>
</Grid>
</UserControl>
Loading

0 comments on commit 4c4c909

Please sign in to comment.