indragiek / INAppStoreWindow

NSWindow subclass with a highly customizable title bar and traffic lights
BSD 2-Clause "Simplified" License
1.06k stars 160 forks source link

Using INAppStoreWindow in conjunction with customView class #28

Closed andheiberg closed 12 years ago

andheiberg commented 12 years ago

I'm running into a bug when using the INAppStoreWindow class in conjunction with a custom class I wrote for all my views. I have tried to eliminate any bugs in my class by cutting out any code but the part that sets the views background color.

This is alle the custom code in my class:

- (void)drawRect:(NSRect)dirtyRect {
        [[NSColor redColor] set];
   NSRectFill([self bounds]);
}

The problem

The problem/bug happens when the INAppStoreWindow s being resized while containing a view that autoresizes with the window. As you can see in this picture there's a graphic flaw.

Graphic flaw

I've found the problem to be the code on line 179 in INAppStoreWindow.m.

[nc addObserver:self selector:@selector(_layoutTrafficLightsAndContent) name:NSWindowDidResizeNotification object:self];
[nc addObserver:self selector:@selector(_layoutTrafficLightsAndContent) name:NSWindowDidMoveNotification object:self]; 

The solution?

I simply cannot solve this bug by my own (I'm an epic newbiee). Could you please tell me how you have come around this problem?

Thanks a million for your great work.

kgn commented 12 years ago

Hmm perhaps we need to setNeedsDisplay on the contentView after setting the frame at line 397.

andheiberg commented 12 years ago

That fixed it! Thanks a lot.

kgn commented 12 years ago

Ah sweet, would you mind submitting a pull request of your updated code?

andheiberg commented 12 years ago

I'm not exactly a Github ninja :) I just started exploring Github so I'm not capable of doing that yet. I tried to first add my changes, then committing and finally pushing to original master. However I get an error "The requested URL returned error: 403 while accessing https://github.com/indragiek/INAppStoreWindow.git/info/refs" and I don't know what to do from here on. I haven't forked the repo (I simply cloned it), do I need to do this in order to commit?

kgn commented 12 years ago

Yeah the problem is you tried to push back to the main project repo, which you don't have write access to. You would need to fork the repo, commit and push your changes to your fork, then submit a pull request. This is a simple update so I will take care of it later tonight. If you're feeling daring you can try forking/submitting, definitely worth knowing how it works :)

kgn commented 12 years ago

I made a sample app and wasn't able to reproduce the graphical issues you were seeing, but I still added setNeedsDisplay after setting the frame.

andheiberg commented 12 years ago

Did you try to resize the window from one side of the screen to the other in one fast movement (this makes the flaw very obvious)?

I have now successfully created a pull request with a little change that sets the left margin of the traffic lights.

kgn commented 12 years ago

Hmm I still can't get it to happen, oh well.