Fix uiAreaBeginUserWindowResize on macOS
This commit is contained in:
parent
cda991b7e2
commit
26ab668d7d
|
@ -113,14 +113,14 @@ static void minMaxAutoLayoutSizes(NSWindow *w, NSSize *min, NSSize *max)
|
||||||
cw = uiprivMkConstraint(contentView, NSLayoutAttributeWidth,
|
cw = uiprivMkConstraint(contentView, NSLayoutAttributeWidth,
|
||||||
NSLayoutRelationEqual,
|
NSLayoutRelationEqual,
|
||||||
nil, NSLayoutAttributeNotAnAttribute,
|
nil, NSLayoutAttributeNotAnAttribute,
|
||||||
0, CGFLOAT_MAX,
|
0, 100000,
|
||||||
@"window maximum width finding constraint");
|
@"window maximum width finding constraint");
|
||||||
[cw setPriority:NSLayoutPriorityDragThatCanResizeWindow];
|
[cw setPriority:NSLayoutPriorityDragThatCanResizeWindow];
|
||||||
[contentView addConstraint:cw];
|
[contentView addConstraint:cw];
|
||||||
ch = uiprivMkConstraint(contentView, NSLayoutAttributeHeight,
|
ch = uiprivMkConstraint(contentView, NSLayoutAttributeHeight,
|
||||||
NSLayoutRelationEqual,
|
NSLayoutRelationEqual,
|
||||||
nil, NSLayoutAttributeNotAnAttribute,
|
nil, NSLayoutAttributeNotAnAttribute,
|
||||||
0, CGFLOAT_MAX,
|
0, 100000,
|
||||||
@"window maximum height finding constraint");
|
@"window maximum height finding constraint");
|
||||||
[ch setPriority:NSLayoutPriorityDragThatCanResizeWindow];
|
[ch setPriority:NSLayoutPriorityDragThatCanResizeWindow];
|
||||||
[contentView addConstraint:ch];
|
[contentView addConstraint:ch];
|
||||||
|
@ -206,15 +206,40 @@ static void onResizeDrag(struct onResizeDragParams *p, NSEvent *e)
|
||||||
|
|
||||||
// constrain
|
// constrain
|
||||||
// TODO should we constrain against anything else as well? minMaxAutoLayoutSizes() already gives us nonnegative sizes, but...
|
// TODO should we constrain against anything else as well? minMaxAutoLayoutSizes() already gives us nonnegative sizes, but...
|
||||||
if (frame.size.width < p->min.width)
|
if (frame.size.width < p->min.width){
|
||||||
|
if(p->edge == uiWindowResizeEdgeLeft ||
|
||||||
|
p->edge == uiWindowResizeEdgeTopLeft ||
|
||||||
|
p->edge == uiWindowResizeEdgeBottomLeft) {
|
||||||
|
frame.origin.x += frame.size.width - p->min.width;
|
||||||
|
}
|
||||||
frame.size.width = p->min.width;
|
frame.size.width = p->min.width;
|
||||||
if (frame.size.height < p->min.height)
|
}
|
||||||
|
if (frame.size.height < p->min.height){
|
||||||
|
if(p->edge == uiWindowResizeEdgeBottom ||
|
||||||
|
p->edge == uiWindowResizeEdgeBottomLeft ||
|
||||||
|
p->edge == uiWindowResizeEdgeBottomRight) {
|
||||||
|
frame.origin.y += frame.size.height - p->min.height;
|
||||||
|
}
|
||||||
frame.size.height = p->min.height;
|
frame.size.height = p->min.height;
|
||||||
|
}
|
||||||
|
|
||||||
// TODO > or >= ?
|
// TODO > or >= ?
|
||||||
if (frame.size.width > p->max.width)
|
if (frame.size.width > p->max.width){
|
||||||
|
if(p->edge == uiWindowResizeEdgeLeft ||
|
||||||
|
p->edge == uiWindowResizeEdgeTopLeft ||
|
||||||
|
p->edge == uiWindowResizeEdgeBottomLeft) {
|
||||||
|
frame.origin.x -= p->max.width - frame.size.width;
|
||||||
|
}
|
||||||
frame.size.width = p->max.width;
|
frame.size.width = p->max.width;
|
||||||
if (frame.size.height > p->max.height)
|
}
|
||||||
|
if (frame.size.height > p->max.height){
|
||||||
|
if(p->edge == uiWindowResizeEdgeBottom ||
|
||||||
|
p->edge == uiWindowResizeEdgeBottomLeft ||
|
||||||
|
p->edge == uiWindowResizeEdgeBottomRight) {
|
||||||
|
frame.origin.y -= p->max.height - frame.size.height;
|
||||||
|
}
|
||||||
frame.size.height = p->max.height;
|
frame.size.height = p->max.height;
|
||||||
|
}
|
||||||
|
|
||||||
[p->w setFrame:frame display:YES]; // and do reflect the new frame immediately
|
[p->w setFrame:frame display:YES]; // and do reflect the new frame immediately
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue