diff options
author | Alex Merry <alex.merry@cs.ox.ac.uk> | 2013-02-12 16:08:59 +0000 |
---|---|---|
committer | Alex Merry <alex.merry@cs.ox.ac.uk> | 2013-02-12 16:21:47 +0000 |
commit | 0a7223674204a6e8ee311e226b2b5ddef88803a3 (patch) | |
tree | 0c93ec903531c5b2eee065ca36e621ecd782610a /tikzit/src/common/util.m | |
parent | 904fa7d389b98a3ce7735f2979652be43f28ee2a (diff) |
Make sure edge bounds include decorations
Fixes rendering of newly-drawn edges in GTK+ version.
Diffstat (limited to 'tikzit/src/common/util.m')
-rw-r--r-- | tikzit/src/common/util.m | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tikzit/src/common/util.m b/tikzit/src/common/util.m index 762516f..2d40cbd 100644 --- a/tikzit/src/common/util.m +++ b/tikzit/src/common/util.m @@ -25,6 +25,24 @@ static BOOL fuzzyCompare(float f1, float f2) { return (ABS(f1 - f2) <= 0.00001f * MIN(ABS(f1), ABS(f2))); } +NSRect NSRectWithPoint(NSRect rect, NSPoint p) { + CGFloat minX = NSMinX(rect); + CGFloat maxX = NSMaxX(rect); + CGFloat minY = NSMinY(rect); + CGFloat maxY = NSMaxY(rect); + if (p.x < minX) { + minX = p.x; + } else if (p.x > maxX) { + maxX = p.x; + } + if (p.y < minY) { + minY = p.y; + } else if (p.y > maxY) { + maxY = p.y; + } + return NSMakeRect(minX, minY, maxX - minX, maxY - minY); +} + NSRect NSRectAroundPointsWithPadding(NSPoint p1, NSPoint p2, float padding) { return NSMakeRect(MIN(p1.x,p2.x)-padding, MIN(p1.y,p2.y)-padding, |