indragiek / inappstorewindow Goto Github PK
View Code? Open in Web Editor NEWNSWindow subclass with a highly customizable title bar and traffic lights
License: BSD 2-Clause "Simplified" License
NSWindow subclass with a highly customizable title bar and traffic lights
License: BSD 2-Clause "Simplified" License
INAppStoreWindow draws the titleBarView on top of the standard title bar text. This prevents a document-based application from correctly showing the document name in the titlebar. This issue can be visualized by inserting:
NSRect titleBarViewFrame = window.titleBarView.frame;
titleBarViewFrame.origin.y -= 20.0;
window.titleBarView.frame = titleBarViewFrame;
in the -windowControllerDidLoadNib: method of Document.m in the SampleDocumentApp. The original title becomes visible when the titleBarView is moved downwards revealing the original title.
Hi,
I changed the class name of my NSWindow to INAppStoreWindow, and write a line of code in the app delegate as follows:
[windowController.window setTitleBarHeight:60];
But it doesn't work at all. Nothing was changed.
Thank you.
kai.
First- thanks for the nice Class.
I use this in my Application and i know the bug with the Trafficlights - for me no problem, but now Apple has a Problem with this:
"....During our review of your application we noticed a minor issue. While this issue has not prevented your application from being approved, we encourage you to make the necessary changes in order to maximize the user experience of your application.
The standard close/minimize/zoom widgets do not preform as expected. While the buttons do work when the user clicks on them, if the user hovers the mouse over them they do not display the proper symbols. "X, -, +"
We encourage you to resolve this issue in your next update..."
Any ideas or solutions for this problem - i see the problem is solved after i resize the Window, but i can't find a way the fix this.
I think we are ready to update the podspec, but I'd like to give the new changes a little bit of time to settle first...
I'm just looking at adding full screen mode to our app. I'm using a custom title bar drawing block to draw a dark title bar. However when exiting full screen mode, the title bar reverts to the default appearance (albeit with the traffic light buttons clipped off). It seems that drawRect is not being called.
Is this possible? Any pointers?
Hello,
First of all, thanks for this amazing class.
Would it be possible to have options to
Thanks
In the sample app the following line causes the traffic lights to not be displayed:
[self.window.titleBarView setWantsLayer:YES];
I also found this to be the case in my own app when setting the titleBarView to a custom layer-backed NSView. Not sure what is going on at this point...
Calling [NSMenu popUpContextMenu: withEvent: forView:]; crashes the application in - (NSMethodSignature *)methodSignatureForSelector:(SEL)selector of INAppStoreWindowDelegateProxy when no secondary NSWindowDelegate is defined. It also crashes if I associates a menu to a view as context menu and right-click on the view.
This is the error i get when i try to use INAppStore in my 10.7 SDK project
unrecognized selector sent to instance 0x10011e250
2011-08-02 17:15:02.167 Randomizr for Mac[1691:707] -[NSWindow setTitleBarHeight:]: unrecognized selector sent to instance 0x10011e250
In document app, if the NSDocument
becomes edited and "– Edited" label appears in title bar, the position of the traffic light buttons reset to default.
You can check this issue by sending updateChangeCount:NSChangeDiscardable
message.
When this happens, no notification is being sent. hasUnautosavedChanges
/isDocumentEdited
are not KVO observable.
I can't find the workaround to resolve this issue. The only chance to do this without going into Private API is to override updateChangeCount:
method and update titlebar's layout from this.
The other option is to re-layout title bar from within drawRect:
(since system redraws it), but this solution is ugly.
Any ideas?
I noticed that any controls added to the titleBarView doesn't get the inactive state set when the window (or app) isn't frontmost. Compare it with the Finder windows where the buttons also get a slight tint when they're in the background.
The issue can be seen here if you switch back and forth between the main window and the opened window controller: js@6f567d5
I'm not quite sure what kind of state flag (and where) NSWindow is supposed to set on its view in order for the controls to get this state?
Conditions:
When exiting full screen mode, the contentView height is incorrect - it includes the extra height of title bar. What's happening is that the value of _cachedTitleBarHeight is zero inside windowWillExitFullScreen and this is causing the contentView height to be calculated incorrectly.
_cachedTitleBarHeight is only set inside setTitleBarHeight and crucially only if its value is not the same as the current (default?) value, hence why it remains zero.
On Mac OS X 10.7.5, when you right-click on a WebView inside à INAppStoreWindow, the "forwardInvocation:" method of INAppStoreWindowDelegateProxy gets called infinitely, making the app crashes.
The drawing in the title bar gets messed up when the window is minimized, then the dock icon is clicked causing the window to be un-minify. Surprisingly clicking on the minified window in the dock does not cause this problem.
I have fixed this issue in my fork, it's a simple fix of just calling setNeedsDisplay in makeKeyAndOrderFront.
https://github.com/InScopeApps/INAppStoreWindow/commit/58293dedfd334768fdfdd79db849dc6dd6a7c092
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/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.
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];
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.
Hello,
Is there a way to support the Lion fullscreen mode?
Thanks and regards,
I don't think this method is ever getting called, but the sheet are working so we might be able to delete it?
Hi,
I just found a very weird bug about the traffic lights. After I launched the sample app, I moved my mouse to the traffic lights area, but the traffic lights were not highlighted. But after I moved my mouse to the original traffic lights area, they were highlighted! (see the picture here: http://d.pr/bk5M)
Once I resized the window manually, all the above problems were gone.
Could you take a look at this problem? Thank you!
Kai.
The App Store no longer uses this style of titlebar. The code is applicable to a lot of customization situations, so something more general would be good. Up for suggestions!
When creating a INAppStoreWindow it seems that no title is present:
// The class of the window has been set in INAppStoreWindow in Interface Builder
INAppStoreWindow *aWindow = (INAppStoreWindow*)self.window;
[aWindow setExcludedFromWindowsMenu:NO];
aWindow.titleBarHeight = 40.0;
[aWindow setMinSize:NSMakeSize(100.0, aWindow.titleBarHeight)];
[aWindow setContentBorderThickness:0.0 forEdge:NSMinYEdge]; // no bottom border
[aWindow setTitle:@"AppStore Window"];
but the app has not a title!
What am I wrong?
If using INAppStoreWindow and you add windowWillReturnUndoManager: to your window controller, you would expect it to get invoked at some point (like when opening the Edit menu). Currently it doesn't due to the delegate proxy.
It looks like this can be fixed by adding this method to INAppStoreWindowDelegateProxy
- (NSUndoManager*)windowWillReturnUndoManager:(NSWindow *)window
{
if ([_secondaryDelegate respondsToSelector:@selector(windowWillReturnUndoManager:)]) {
return [_secondaryDelegate windowWillReturnUndoManager:window];
}
return nil;
}
I'm writing a document-based application and I would like to use your NSWindow subclass as the class of the document window. Everything works flawlessly, except for one thing: when I save the document (choosing File > Save...), the dialog appears correctly, but when I dismiss it the traffic lights button are not centered anymore.
In other words, when the Save action is triggered, the traffic lights buttons are moved to the top left corner of the window. Resizing the window immediately solves the problem.
Are there any known issues with this subclass and document-based applications?
So, files can be built with ARC specifically enabled or disabled for them, in spite of the main project's settings. Also, a static library can be used to segregate ARC from non-ARC code.
Given these things, it seems pointless to have all these checks whether ARC is available. If you want INAppStoreWindow
to be able to be built for old systems on old tools, that's totally fine. People using INAppStoreWindow
in ARC projects can simply jigger the build settings for those files, or package it in a static library. Thoughts?
My INAppStoreWindow has a NSView that covers the contentArea
when trying to add subview (loaded from a nib) to that NSView I get the error above. A EXC_BAD_ACCESS
on line 284 on INAPPStoreWindow.m. This happens periodically when i try to load a view from a nib and add it to the INAppStoreWindows only view (the one that covers the content area)
This is the code i am using to load the view from the nib and add it to the nsview
//At the very top of the file
import "AllVC.h"
AllVC *vc = [[AllVC alloc] initWithNibName:@"AllVC" bundle:[NSBundle mainBundle]];
[vc.view setFrame:_view.bounds];
[_view addSubview:vc.view];
Hi,
I added these two lines after INAppStoreWindow creation in order to
[aWindow setMinSize:NSMakeSize(insideFrameSize.width, aWindow.titleBarHeight)];
[aWindow setContentBorderThickness:0.0 forEdge:NSMinYEdge];
where insideFrameSize is the desidered NSSize of the main window frame
Thanks for this nice gui!
When i start a modal sheet it starts to slide in from the titlebar's original size not the new size. is there anyway to adjust this?
It would be cool if you could create a view in IB that would be used as the toolbar view where the height of the view controlled the height of the toolbar, but could be over-written.
A window with a taller-than-standard titlebar will lose a few pixels on top each time the Twitter or Facebook NSSharingService window appears / disappears.
Sample project here:
http://supercrazyawesome.com/jump/SharingINAppStoreWindow.zip
To activate the close/miniaturize/zoom buttons, you still have to move the cursor into the original close widgets' frame.That means putting the cursor on the lower part of the close widgets won't activate the three buttons. Could this be fixed without using private API?
There is a visual issue when working with more than one window while presenting a sheet:
http://imageshack.us/f/403/issueiappw21.png/
Steps to reproduce (Sample App - 10.7.3):
Haven't looked into the code yet, there might be an easy fix.
This is the title bar i use for my window, it's height is 28: http://f.cl.ly/items/1x0U0G3i2L1K0Y321x0l/Captura%20de%20ecrã%202012-10-21,%20às%2015.39.37.png
When i try to show a sheet from the window's title bar here's what happens: http://f.cl.ly/items/2Q2E1m0j1h1B0R1c0l46/Sem%20nome.png
From the img you can see that the animation when showing the sheet is making the title bar look smaller in height when the sheet is fully displayed. The sheet is not being shown from the bottom of the title bar. How can i fix it?
The content border "chrome" (the one set with setContentBorderThickness:forEdge:
) is drawn with the default styling, I think it would be nice if the -titleBarDrawingBlock
was also also called for content borders
@indragiek I have to questions. My first is how can i use the setTitleDrawingBlock:
method to add a custom background image to the title bar like the one in the README
But I want the Title bar to be bigger like the one in this image (also in the README)
so to recap:
I want the title bar to be as tall as the one in the second image but have a custom background image like the one in the first image. How would do this?
Also how would i set the title of my window using INAppStoreWindow
please forgive me if I ask questions that have obvious answers I am a newbie to Mac App Developing but Ive been developing for iOS for atleast three years now and I'm trying to get into Mac app developing.
Thanks for all your help
P.S.
How would I add a Navigation Bar-like control to the title bar using INAppStoreWindow
like in github for mac
Thanks again for all your help!
After I comment out the following code
if (self.delegate == nil) {
[super setDelegate:_delegateProxy];
}
from - (void)_doInitialWindowSetup, it works again.
If movableByWindowBackground is set to NO and the title bar height is greater than the standard height, the window cannot be dragged by clicking on any part of the titlebar that is below where the standard title bar would have normally ended.
I'm trying to replicate the toolbar from the mac app store, however adding a nstoolbar to the titleBarView seams to be impossible. What is the correct way to accomplish this?
Maybe there is a way to get in-front of the delegate callback?
- (NSRect)window:(NSWindow *)window willPositionSheet:(NSWindow *)sheet usingRect:(NSRect)rect
I've been attempting to use CocoaPods to grab the newest version of your project, but it keeps downloading what you've tagged as 1.0. Would you mind bumping the number?
Ctrl+1, Ctrl+2, etc. shortcuts switch to the numbered Space. Normally, you can click-and-hold a window's titlebar (i.e. initiate drag) and then use the aforementioned shortcuts to move the window to the numbered Space.
Unfortunately this interaction does not work with INAppStoreWindows that have views in the titlebar spanning the entire titlebar's frame.
Support for Cocoa Autolayout would be nice. Right now, if I try to use auto layout there is a crash because it manually tries to set the frame.
Hi,
when do you plan on supporting Lion? Currently there's a lot wrong with INAppStoreWindow
Thanks so much!
It would be useful to be able to set the gradient colors for the title bar view. I know you can set a drawing block and use custom colors with that, but if all you want to do is modify the gradient you're going to have to reimplement all of the other drawing code.
In my particular case this is useful because I have Safari-like tabs underneath my title bar. The default NSWindow title bar color transitions well into the tabs, but INAppStoreWindow's is a bit too dark.
Though the gradient matches the Lion palette, the subtle "noise" added to Lion windows is not generated, so it is still a bit different than the AppStore window (or Chrome, or Twitter, or Reeder).
I have a weird issue with my NSSavePanels. The panel draws the accessoryView twice - once before it slides down and once when it's all the way down. Unfortunately, this means if there is another modal over the top (confirmation, for example) it somehow draws the view's contents OVER this next modal.
To be honest, I don't know whether it's to do with INAppStore Window, but if it's anything else it's probably an ARC / Cocoa bug!
Any help would be greatly appreciated :)
Hello, thank you for this great class!
I have used autolayout to design my nib but now I disabled it. The app keeps crashing on launch. When I use NSWindow instead of INAppStoreWindow it works perfectly fine.
I have posted this on stackoverflow with the crash report an the error: http://stackoverflow.com/questions/13610324/can-not-get-rid-of-autolayout-unable-to-install-constraint-on-view
I am sorry that I can not provide more details. I have tried to use the modified file from #77 but it still crashes.
I have tried to reproduce the bug with a fresh project but I could not.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.