mirror of
https://github.com/Leonmmcoset/CMLeonOS.git
synced 2026-04-21 19:24:00 +00:00
最大化动画
This commit is contained in:
@@ -1 +1 @@
|
|||||||
2026-04-04 13:32:14
|
2026-04-04 13:54:37
|
||||||
@@ -1 +1 @@
|
|||||||
636f3f1
|
2f9df41
|
||||||
@@ -25,6 +25,7 @@ namespace CMLeonOS.UILib.Animations
|
|||||||
internal abstract class Animation
|
internal abstract class Animation
|
||||||
{
|
{
|
||||||
internal Action Completed { get; set; }
|
internal Action Completed { get; set; }
|
||||||
|
internal Action Advanced { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The easing type of the animation.
|
/// The easing type of the animation.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -58,6 +58,7 @@ namespace CMLeonOS.UILib.Animations
|
|||||||
{
|
{
|
||||||
control.Render();
|
control.Render();
|
||||||
}
|
}
|
||||||
|
Advanced?.Invoke();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -73,6 +74,7 @@ namespace CMLeonOS.UILib.Animations
|
|||||||
{
|
{
|
||||||
control.Render();
|
control.Render();
|
||||||
}
|
}
|
||||||
|
Advanced?.Invoke();
|
||||||
}
|
}
|
||||||
return Finished;
|
return Finished;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -150,6 +150,7 @@ namespace CMLeonOS.Gui.UILib
|
|||||||
|
|
||||||
private bool maximised = false;
|
private bool maximised = false;
|
||||||
private bool closeAnimationRunning = false;
|
private bool closeAnimationRunning = false;
|
||||||
|
private bool resizeAnimationRunning = false;
|
||||||
private int originalX;
|
private int originalX;
|
||||||
private int originalY;
|
private int originalY;
|
||||||
private int originalWidth;
|
private int originalWidth;
|
||||||
@@ -197,7 +198,7 @@ namespace CMLeonOS.Gui.UILib
|
|||||||
|
|
||||||
private void StartCloseAnimation()
|
private void StartCloseAnimation()
|
||||||
{
|
{
|
||||||
if (closeAnimationRunning)
|
if (closeAnimationRunning || resizeAnimationRunning)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -227,9 +228,85 @@ namespace CMLeonOS.Gui.UILib
|
|||||||
animation.Start();
|
animation.Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Rectangle GetMaximizedBounds()
|
||||||
|
{
|
||||||
|
var taskbar = ProcessManager.GetProcess<ShellComponents.Taskbar>();
|
||||||
|
int taskbarHeight = taskbar.GetTaskbarHeight();
|
||||||
|
|
||||||
|
var dock = ProcessManager.GetProcess<ShellComponents.Dock.Dock>();
|
||||||
|
int dockHeight = dock.GetDockHeight();
|
||||||
|
|
||||||
|
return new Rectangle(
|
||||||
|
0,
|
||||||
|
taskbarHeight + titlebarHeight,
|
||||||
|
(int)wm.ScreenWidth,
|
||||||
|
(int)wm.ScreenHeight - titlebarHeight - taskbarHeight - dockHeight
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void StartResizeAnimation(Rectangle targetBounds)
|
||||||
|
{
|
||||||
|
if (resizeAnimationRunning)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
resizeAnimationRunning = true;
|
||||||
|
|
||||||
|
Rectangle startWindow = new Rectangle(X, Y, Width, Height);
|
||||||
|
Rectangle startDecoration = new Rectangle(decorationWindow.X, decorationWindow.Y, decorationWindow.Width, decorationWindow.Height);
|
||||||
|
Rectangle targetDecoration = new Rectangle(0, -titlebarHeight, targetBounds.Width, titlebarHeight);
|
||||||
|
|
||||||
|
int completedCount = 0;
|
||||||
|
Action finish = () =>
|
||||||
|
{
|
||||||
|
completedCount++;
|
||||||
|
if (completedCount < 2)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
MoveAndResize(targetBounds.X, targetBounds.Y, targetBounds.Width, targetBounds.Height, sendWMEvent: false);
|
||||||
|
decorationWindow.MoveAndResize(targetDecoration.X, targetDecoration.Y, targetDecoration.Width, targetDecoration.Height, sendWMEvent: false);
|
||||||
|
|
||||||
|
resizeAnimationRunning = false;
|
||||||
|
UserResized?.Invoke();
|
||||||
|
RefreshWindowTree();
|
||||||
|
ProcessManager.GetProcess<WindowManager>().RerenderAll();
|
||||||
|
};
|
||||||
|
|
||||||
|
MovementAnimation windowAnimation = new MovementAnimation(this)
|
||||||
|
{
|
||||||
|
From = startWindow,
|
||||||
|
To = targetBounds,
|
||||||
|
Duration = 14,
|
||||||
|
EasingType = EasingType.Sine,
|
||||||
|
EasingDirection = EasingDirection.Out,
|
||||||
|
Completed = finish
|
||||||
|
};
|
||||||
|
windowAnimation.Advanced = () =>
|
||||||
|
{
|
||||||
|
UserResized?.Invoke();
|
||||||
|
RefreshWindowTree();
|
||||||
|
};
|
||||||
|
|
||||||
|
MovementAnimation decorationAnimation = new MovementAnimation(decorationWindow)
|
||||||
|
{
|
||||||
|
From = startDecoration,
|
||||||
|
To = targetDecoration,
|
||||||
|
Duration = 14,
|
||||||
|
EasingType = EasingType.Sine,
|
||||||
|
EasingDirection = EasingDirection.Out,
|
||||||
|
Completed = finish
|
||||||
|
};
|
||||||
|
|
||||||
|
windowAnimation.Start();
|
||||||
|
decorationAnimation.Start();
|
||||||
|
}
|
||||||
|
|
||||||
private void DecorationClicked(int x, int y)
|
private void DecorationClicked(int x, int y)
|
||||||
{
|
{
|
||||||
if (closeAnimationRunning)
|
if (closeAnimationRunning || resizeAnimationRunning)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -245,41 +322,17 @@ namespace CMLeonOS.Gui.UILib
|
|||||||
if (maximised)
|
if (maximised)
|
||||||
{
|
{
|
||||||
maximised = false;
|
maximised = false;
|
||||||
|
StartResizeAnimation(new Rectangle(originalX, originalY, originalWidth, originalHeight));
|
||||||
MoveAndResize(originalX, originalY, originalWidth, originalHeight, sendWMEvent: false);
|
|
||||||
|
|
||||||
decorationWindow.Resize(originalWidth, titlebarHeight, sendWMEvent: false);
|
|
||||||
|
|
||||||
UserResized?.Invoke();
|
|
||||||
ProcessManager.GetProcess<WindowManager>().RerenderAll();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
maximised = true;
|
maximised = true;
|
||||||
|
|
||||||
var taskbar = ProcessManager.GetProcess<ShellComponents.Taskbar>();
|
|
||||||
int taskbarHeight = taskbar.GetTaskbarHeight();
|
|
||||||
|
|
||||||
var dock = ProcessManager.GetProcess<ShellComponents.Dock.Dock>();
|
|
||||||
int dockHeight = dock.GetDockHeight();
|
|
||||||
|
|
||||||
originalX = X;
|
originalX = X;
|
||||||
originalY = Y;
|
originalY = Y;
|
||||||
originalWidth = Width;
|
originalWidth = Width;
|
||||||
originalHeight = Height;
|
originalHeight = Height;
|
||||||
|
StartResizeAnimation(GetMaximizedBounds());
|
||||||
MoveAndResize(
|
|
||||||
0,
|
|
||||||
taskbarHeight + titlebarHeight,
|
|
||||||
(int)wm.ScreenWidth,
|
|
||||||
(int)wm.ScreenHeight - titlebarHeight - taskbarHeight - dockHeight,
|
|
||||||
sendWMEvent: false
|
|
||||||
);
|
|
||||||
|
|
||||||
decorationWindow.Resize((int)wm.ScreenWidth, titlebarHeight, sendWMEvent: false);
|
|
||||||
|
|
||||||
UserResized?.Invoke();
|
|
||||||
ProcessManager.GetProcess<WindowManager>().RerenderAll();
|
|
||||||
}
|
}
|
||||||
RenderDecoration();
|
RenderDecoration();
|
||||||
}
|
}
|
||||||
@@ -297,7 +350,7 @@ namespace CMLeonOS.Gui.UILib
|
|||||||
buttonSpace += titlebarHeight;
|
buttonSpace += titlebarHeight;
|
||||||
}
|
}
|
||||||
if (x >= Width - buttonSpace || maximised || !_canMove) return;
|
if (x >= Width - buttonSpace || maximised || !_canMove) return;
|
||||||
if (closeAnimationRunning) return;
|
if (closeAnimationRunning || resizeAnimationRunning) return;
|
||||||
|
|
||||||
uint startMouseX = MouseManager.X;
|
uint startMouseX = MouseManager.X;
|
||||||
uint startMouseY = MouseManager.Y;
|
uint startMouseY = MouseManager.Y;
|
||||||
|
|||||||
Reference in New Issue
Block a user