• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Partially transparent child window
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Partially transparent child window


  • Subject: Re: Partially transparent child window
  • From: Ricky Sharp <email@hidden>
  • Date: Mon, 25 Sep 2006 16:33:36 -0500


On Sep 25, 2006, at 4:16 PM, James Bucanek wrote:

I'm trying to create a child window that is partially transparent.

Some portions of the window I want to be completely transparent, letting the parent window show though, while others portions are drawn with varying degrees of transparency, from semi-transparent to fully opaque. (I'm essentialy drawing some diagrams over a set of table views, connecting cells of a table to the rows of an outline....)

I started with the code I used for a another transparent child window but suddenly realized that I was controlling the transparency of the entire window via its transparency setting (i.e. [childWindow setAlpha:0.5]).

As soon as I set the alpha of the child to 1.0, it obscures everything it overlays in the parent window. I've tried

    [childWindow setBackground:[NSColor clearColor]];
    [childWindow isOpaque:NO];

That should have worked. Here's a snippet from my "watermark" overlay window's designated initializer:


if ((self = [super initWithContentRect:theContentRect
    styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered
    defer:NO]) != nil)
    {
    [self setLevel:NSFloatingWindowLevel];
    [self setBackgroundColor:[NSColor clearColor]];
    [self setIgnoresMouseEvents:YES];
    [self setHidesOnDeactivate:YES];
    [self setReleasedWhenClosed:NO];
    [self setMovableByWindowBackground:NO];
    [self setHasShadow:NO];
    [self useOptimizedDrawing:YES];

    [self setOpaque:NO];
    [self setAlphaValue:1.0];
    }

I then add a view to that window which does the drawing I need. In this particular case, a simple image with semi-transparent "Demo" text in it.

The view you add to your window would not be opaque. For images and solid-fill rectangles that the view will render, be sure to draw with a compositing mode of NSCompositeSourceOver. If your images/colors are semi-transparent, they'll give you the effects you want.

In summary, your window will just be a container with a fixed transparency (1.0) and your view will draw with various transparencies.

___________________________________________________________
Ricky A. Sharp         mailto:email@hidden
Instant Interactive(tm)   http://www.instantinteractive.com

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Partially transparent child window
      • From: James Bucanek <email@hidden>
References: 
 >Partially transparent child window (From: James Bucanek <email@hidden>)

  • Prev by Date: Re: Accuracy of timestamping streamed data (code included - long)
  • Next by Date: Re: Accuracy of timestamping streamed data (code included - long)
  • Previous by thread: Partially transparent child window
  • Next by thread: Re: Partially transparent child window
  • Index(es):
    • Date
    • Thread