Skip to content

Commit

Permalink
Crop: do not apply cached aspect ratio for FreeRatio option
Browse files Browse the repository at this point in the history
  • Loading branch information
d2phap committed Nov 1, 2024
1 parent 00fc579 commit 0791ea8
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions Source/ImageGlass/Tools/FrmCrop.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ protected override void OnLoad(EventArgs e)
Local.FrmMain.KeyDown += FrmMain_KeyDown;
Local.FrmMain.KeyUp += FrmMain_KeyUp;
Local.ImageSaved += Local_ImageSaved;
Local.ImageLoading += Local_ImageLoading;
Local.FrmMain.PicMain.SelectionChanged += PicMain_OnImageSelecting;
Local.FrmMain.PicMain.ImageLoading += PicMain_ImageLoading;
Local.FrmMain.PicMain.ImageDrawn += PicMain_ImageDrawn;
Expand All @@ -130,7 +131,8 @@ protected override void OnLoad(EventArgs e)

TableTop.Enabled =
TableBottom.Enabled = Local.FrmMain.PicMain.Source != ImageSource.Null
&& !Local.FrmMain.PicMain.CanImageAnimate;
&& !Local.FrmMain.PicMain.CanImageAnimate
&& !Local.FrmMain.PicMain.UseWebview2;

base.OnLoad(e);

Expand All @@ -141,6 +143,7 @@ protected override void OnLoad(EventArgs e)
ApplyLanguage();
}


protected override int OnUpdateHeight(bool performUpdate = true)
{
var baseHeight = base.OnUpdateHeight(false);
Expand Down Expand Up @@ -176,6 +179,7 @@ protected override void OnToolFormClosing(ToolFormClosingEventArgs e)
Local.FrmMain.KeyDown -= FrmMain_KeyDown;
Local.FrmMain.KeyUp -= FrmMain_KeyUp;
Local.ImageSaved -= Local_ImageSaved;
Local.ImageLoading -= Local_ImageLoading;
Local.FrmMain.PicMain.SelectionChanged -= PicMain_OnImageSelecting;
Local.FrmMain.PicMain.ImageLoading -= PicMain_ImageLoading;
Local.FrmMain.PicMain.ImageDrawn -= PicMain_ImageDrawn;
Expand Down Expand Up @@ -455,7 +459,9 @@ private void LoadDefaultSelectionSetting(bool drawSelection)


// update selection size according to the ratio
if (Settings.AspectRatioValues[0] > 0 && Settings.AspectRatioValues[1] > 0)
if (Settings.AspectRatio != SelectionAspectRatio.FreeRatio
&& Settings.AspectRatioValues[0] > 0
&& Settings.AspectRatioValues[1] > 0)
{
var ratioSize = GetSizeWithAspectRatio(new Size(w, h));

Expand Down Expand Up @@ -602,6 +608,10 @@ private void PicMain_OnImageSelecting(object? sender, Viewer.SelectionEventArgs
BtnCopy.Enabled = !e.SourceSelection.IsEmpty;
}

private void Local_ImageLoading(ImageLoadingEventArgs e)
{
TableTop.Enabled = TableBottom.Enabled = !e.UseWebview2;
}

private void PicMain_ImageLoading(object? sender, EventArgs e)
{
Expand Down

0 comments on commit 0791ea8

Please sign in to comment.