Is there a way to draw a red "border" around the entire screen somehow? I don't want to draw inside my application's window. And I want to be able to use other programs while this red border is shown.
I want to really signal to the user that the computer is in a special mode.
Windows need not be opaque and can be set to ignore mouse events, using this it is quite easy to do what you wish. In outline:
a) Create a NSView subclass with a drawRect: method which draws a semi-transparent (< 1 alpha value) red border inside its frame.
b) Create an NSWindow subclass. Use NSBorderlessWindowMask as the style. Set backgroundColor to clearColor, opaque to NO, level to something that suits you - say NSScreenSaverWindowLevel, ignoreMouseEvents to YES, canHide to NO, etc. Set the window size/location to (one of your) screen(s). Set its contentView to your view from (a).
You now have a "window" which is a just a outlined semi-transparent red rectangle, create one and your screen is outlined as you wish.
Related
I realized that suddenly (without me touching the corresponding code) my NSBox has a double visualization. It is as if the Box has a background color and draws its normal rounded frame inside. I added a small screenshot. The parent control is white, the NSBox is gray with the title "Inputs" (unchanged titlePosition). Under the title is the normal box, adding a 2nd shade of gray.
I did not change any of the usual suspects, especially not boxType which is still set to .primary.
I did work on the Dark Mode (Dark Aqua) but cannot see any change that would cause this behaviour. effectiveAppearance is still Aqua.
A NSBox with a boxType of .primary always draws a background. That is intended behaviour. Only if the view behind NSBox is white you may not see it. If you want a NSBox without background you must make it boxType .custom and set the background color as required.
I like the way the developers behind Vox.app have created a custom titlebar and still kept the original shadow.
If you set the styleMask = NSBorderlessWindowMask it will create another kind of shadow, and the rounded corners are gone.
And it doesn't seem to be that easy to recreate those shadows especially when you also want rounded corners.
I have taken a window shot of the app that I like. Look at the drop shadows and the title bar.
Is it possible (I assume) to do this? And if so, how?
Is it possible (I assume) to do this?
Yes, this is possible.
And if so, how?
You need to subclass the NSWindow and NSView, set the background color, use custom buttons etc.
For curvy-corners, you need to draw using bezier path. I tried reached somewhat near, however titlebar's color is not changed in this screenshot... but I hope you can do it from here:
How can I draw a slight white 'glow' around a button or label in 10.5 and later? I have seen some apps do it, but I am still confused how I should do this.
See NSShadow. You'd create and set a shadow (saving your graphics context beforehand), then draw the basic shape of your button, unset it (by restoring your graphics context), then continue drawing as usual.
In the case of a ready-made control like NSButton, you will need to subclass and override its cell drawing (and possibly make the host NSButton control itself a bit larger to accommodate the larger area needed to encompass the "glow" of the cell).
You might be able to avoid this with a label by setting its font shadow, but I don't think IB lets you do this, so you'd programmatically give the label an attributed string (via its -setAttributedString: method). The attributes would include the NSShadow (configured as desired) as the NSShadowAttributeName.
I'm creating NSOutlineView with custom cell class (extending NSTextFieldCell) which should display image-based badge (something like in Mail.app while working offline).
Is this approach appropriate? I've created NSRect with oval shape inside (with bezierPathWithRoundedRect:xRadius:yRadius: method) which is filled with color depending if window is active etc. I've prepared a image with a symbol I want to dispay (grey on transparent background) and draw it inside a rect using drawInRect:fromRect:operation:fraction: method. I'm able to choose such a NSCompositingOperation to have an image displayed properly when background is blue or grey but not on white background.
May it be related to the brightness of the image is (or is it another image-related problem) or maybe should I do something totally different?
Background: My application has a main window which contains a few smaller NSView objects, each of which contains several different controls, labels, images, etc. One of these views (and everything it contains) is disabled in response to a given flag. When the flag is set, I automatically disable and grey-out all of the controls embedded within that NSView.
Question: I would like to know how to darken the disabled NSView. The effect I am looking for would be something like drawing a 50% transparent black box on top of the disabled NSView. The background and all of the controls would still be visible, but the colors would be a darker shade. Is there a simple way to do this?
CoreAnimation in 10.5 should provide an easy way to put a translucent layer above a view. You can create a black layer in front of the view, with the opacity at 0%. When you want to darken the view, set the opacity of the black layer to 50%, and the view will be darkened smoothly.