Skip to content

Commit

Permalink
Fix expanding/contracting the graph window on mouseover.
Browse files Browse the repository at this point in the history
  • Loading branch information
mikepj committed May 18, 2020
1 parent 9ef696b commit 70a2ab3
Showing 2 changed files with 25 additions and 18 deletions.
5 changes: 1 addition & 4 deletions Graph Views/XRGBackgroundView.h
Original file line number Diff line number Diff line change
@@ -44,15 +44,12 @@
NSRect unminimizedRect;

NSPoint viewPointClicked;

NSTrackingRectTag trackingRect;
}

@property NSString *hostname;
@property NSArray *resizeRects;

@property NSBezierPath *outerPath;
@property NSBezierPath *innerPath;
@property NSTrackingArea *trackingArea;

@property BOOL clickedMinimized;

38 changes: 24 additions & 14 deletions Graph Views/XRGBackgroundView.m
Original file line number Diff line number Diff line change
@@ -60,29 +60,28 @@ - (void)awakeFromNib {

- (void)setFrame:(NSRect)frame {
[super setFrame:frame];

[self updatePaths];
[parentWindow.moduleManager windowChangedToSize:self.frame.size];
}

- (void)offsetDrawingOrigin:(NSSize)offset {
[self translateOriginToPoint: NSMakePoint(offset.width, offset.height)];
}

- (void)resizeSubviewsWithOldSize:(NSSize)oldBoundsSize {
[self updatePaths];
- (NSBezierPath *)outerPath {
int borderWidth = [parentWindow borderWidth];

return [NSBezierPath bezierPathWithRoundedRect:self.bounds xRadius:borderWidth yRadius:borderWidth];
}

- (void)updatePaths {
- (NSBezierPath *)innerPath {
int borderWidth = [parentWindow borderWidth];
NSRect tmpRect = [self bounds];
tmpRect.origin.x += borderWidth;
tmpRect.origin.y = tmpRect.size.height - borderWidth - [appSettings textRectHeight];
tmpRect.size.width -= borderWidth * 2;
tmpRect.size.height = [appSettings textRectHeight];

self.outerPath = [NSBezierPath bezierPathWithRoundedRect:self.bounds xRadius:borderWidth yRadius:borderWidth];
self.innerPath = [NSBezierPath bezierPathWithRoundedRect:tmpRect xRadius:borderWidth yRadius:borderWidth];

return [NSBezierPath bezierPathWithRoundedRect:tmpRect xRadius:borderWidth yRadius:borderWidth];
}

- (void)drawRect:(NSRect)rect{
@@ -97,8 +96,6 @@ - (void)drawRect:(NSRect)rect{
[self translateOriginToPoint: NSMakePoint(0, 0 - [self frame].size.width)];
isVertical = NO;
lastWidth = [self frame].size.width;

[self updatePaths];
}
if ([moduleManager graphOrientationVertical] && !isVertical) {
// first update our size:
@@ -110,8 +107,6 @@ - (void)drawRect:(NSRect)rect{
[self setBoundsRotation: 0];
[self setAutoresizesSubviews:YES];
isVertical = YES;

[self updatePaths];
}

if (!isVertical) {
@@ -132,10 +127,10 @@ - (void)drawRect:(NSRect)rect{
tmpRect.size.height = [appSettings textRectHeight];

[[appSettings borderColor] set];
[self.outerPath fill];
[[self outerPath] fill];

[[appSettings backgroundColor] set];
[self.innerPath fill];
[[self innerPath] fill];

NSRect titleRect;
if (isVertical) {
@@ -490,6 +485,21 @@ - (BOOL)performDragOperation:(id <NSDraggingInfo>)sender {
return YES;
}

- (void)updateTrackingAreas {
[super updateTrackingAreas];

if (self.trackingArea) {
[self removeTrackingArea:self.trackingArea];
self.trackingArea = nil;
}

self.trackingArea = [[NSTrackingArea alloc] initWithRect:self.bounds
options:(NSTrackingMouseEnteredAndExited | NSTrackingActiveAlways)
owner:self
userInfo:nil];
[self addTrackingArea:self.trackingArea];
}

- (void)mouseEntered:(NSEvent *)theEvent {
// NSLog(@"mouseEntered start\n");
if (self.clickedMinimized && [appSettings autoExpandGraph]) {

0 comments on commit 70a2ab3

Please sign in to comment.