Removed the titlebar logic. Let's try to get the core code working first.

This commit is contained in:
Pietro Gagliardi 2016-11-01 14:57:44 -04:00
parent 0311679e37
commit 4c429d5b7f
1 changed files with 6 additions and 40 deletions

View File

@ -59,30 +59,13 @@ static void minMaxAutoLayoutSizes(NSWindow *w, NSSize *min, NSSize *max)
static void handleResizeLeft(NSRect *frame, NSPoint old, NSPoint new) static void handleResizeLeft(NSRect *frame, NSPoint old, NSPoint new)
{ {
frame->origin.x += new.x - old.x; frame->origin.x += new.x - old.x;
frame->size.width -= new.x - old.x;
} }
// TODO properly handle crossing the menubar; this just stops at the menubar // TODO properly handle the menubar
static void handleResizeTop(NSRect *frame, NSPoint old, NSPoint new) static void handleResizeTop(NSRect *frame, NSPoint old, NSPoint new)
{ {
CGFloat offset; frame->size.height += new.y - old.y;
CGFloat newHeight;
CGFloat oldTop, newTop;
NSRect mainWorkArea;
CGFloat menubarBottom;
offset = new.y - old.y;
newHeight = frame->size.height + offset;
// we have gone too high if we started under the menubar AND we are about to cross it
oldTop = frame->origin.y + frame->size.height;
newTop = frame->origin.y + newHeight;
mainWorkArea = [[NSScreen mainScreen] visibleFrame];
menubarBottom = mainWorkArea.origin.y + mainWorkArea.size.height;
if (oldTop < menubarBottom)
if (newTop >= menubarBottom)
newTop = menubarBottom; // TODO
frame->size.height = newHeight;
} }
static void handleResizeRight(NSRect *frame, NSPoint old, NSPoint new) static void handleResizeRight(NSRect *frame, NSPoint old, NSPoint new)
@ -91,28 +74,11 @@ static void handleResizeRight(NSRect *frame, NSPoint old, NSPoint new)
} }
// TODO properly handle crossing the menubar; this just stops at the menubar // TODO properly handle the menubar
static void handleResizeBottom(NSRect *frame, NSPoint old, NSPoint new) static void handleResizeBottom(NSRect *frame, NSPoint old, NSPoint new)
{ {
CGFloat offset; frame->origin.y += new.y - old.y;
CGFloat newY, newHeight; frame->size.height -= new.y - old.y;
NSRect mainFrame;
CGFloat menubarTop;
offset = new.y - old.y;
newY = frame->origin.y + offset;
newHeight = frame->size.height - offset;
// we have gone too low if we started above the menubar AND we are about to cross it
mainFrame = [[NSScreen mainScreen] frame];
menubarTop = mainFrame.origin.y + mainFrame.size.height;
if (frame->origin.y >= menubarTop)
if (newY < menubarTop)
newY = menubarTop;
// TODO change newHeight too?
frame->origin.y = newY;
frame->size.height = newHeight;
} }
struct onResizeDragParams { struct onResizeDragParams {