Revert ab29ec8: container==content auto-fit made it worse — back to alpha-crop with the container at element size
The container tracks the element's own Width/Height again; the crop stays in the bitmap.
This commit is contained in:
@@ -2290,11 +2290,6 @@ public class MainViewModel : ViewModelBase
|
||||
_ = RedesignateBackgroundAsync($"{MonitorKeyPrefix}{display.Index}");
|
||||
}
|
||||
|
||||
// True while the user is dragging/resizing an element on the preview canvas
|
||||
// (set by MainWindow code-behind). Suppresses the web source's auto-fit so it
|
||||
// doesn't fight the gesture mid-drag.
|
||||
public bool IsPreviewDragging { get; set; }
|
||||
|
||||
public void InitWebView2(Panel hostPanel)
|
||||
{
|
||||
_webView2Manager = new WebView2Manager(hostPanel, System.Windows.Application.Current.Dispatcher);
|
||||
@@ -2302,26 +2297,11 @@ public class MainViewModel : ViewModelBase
|
||||
RegisterLoadedWebSources();
|
||||
}
|
||||
|
||||
private void OnWebView2PreviewBitmapChanged(string sourceId, WriteableBitmap bitmap, double canvasW, double canvasH)
|
||||
private void OnWebView2PreviewBitmapChanged(string sourceId, WriteableBitmap bitmap)
|
||||
{
|
||||
foreach (var scene in Scenes)
|
||||
foreach (var el in scene.Elements.OfType<Source>().Where(s => s.Id == sourceId))
|
||||
{
|
||||
el.VideoImageSource = bitmap;
|
||||
|
||||
// The container must equal the content: size the element grid
|
||||
// (and therefore the selection box) to the cropped frame's canvas
|
||||
// extent. Skipped while the user is dragging/resizing the element
|
||||
// so the gesture isn't fought mid-drag.
|
||||
if (IsPreviewDragging || canvasW < 1 || canvasH < 1) continue;
|
||||
var w = Math.Clamp(Math.Round(canvasW), 1, 1920);
|
||||
var h = Math.Clamp(Math.Round(canvasH), 1, 1080);
|
||||
if (Math.Abs(el.Width - w) > 1 || Math.Abs(el.Height - h) > 1)
|
||||
{
|
||||
el.Width = w;
|
||||
el.Height = h;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Shutdown()
|
||||
|
||||
Reference in New Issue
Block a user