Menu

#2843 Set background and opacity of Tk-Cocoa textured windows

closed-accepted
5
2011-01-05
2010-09-28
No

The attached patch allows you to set the background and opacity of textured ("metal") windows with Tk-Cocoa using the tk::unsupported::MacWindowStyle command. The current configuration of metal/textured windows does not integrate well with Tk widgets because the non-opacity of the window's background color causes the color to flicker through or "flash" severely during redraws of Tk widgets; it also does not allow Tk widgets to blend in seamlessly with the background because it is a gradient. This patch allows one to set the textured background to opaque, to set it to a standard NSColor, and then set the Tk widget to a corresponding hex color; this reduces the "flash" and allows the Tk widgets to blend in.

Here is an example:

toplevel .f
tk::unsupported::MacWindowStyle style .f document {metal light opacity closeBox collapseBox resizable standardDocument }

pack [label .f.f -bg #ababab -text "This is a textured window\nwith opacity and a gray background\nsimilar to other Mac applications"] -fill both -expand yes

The patch updates both tkOSXWm.c and the README file, with documentation.

Discussion

  • Kevin Walzer

    Kevin Walzer - 2010-09-28

    Looks like the [setOpaque call:YES] in the tkOSXWm.c is patch superseded by the isOpaque call in tkOSXWindowEvent.c--on further consideration and testing I don't think the opacity of the window is actually being set, because the "flicker" is still present. I'll have to do some further testing and perhaps add tkOSXWindowEvent.c to the patch as well.

     
  • Kevin Walzer

    Kevin Walzer - 2010-09-28

    Revised patch also modifies tkOSXWindowEvent.c to check for opacity flag and for the [w isOpaque] method to return YES if set, otherwise fall back to default behavior. Testing with a more complicated script than the sample above confirms that "flicker" is eliminated.

     
  • Kevin Walzer

    Kevin Walzer - 2010-10-12
     
  • Kevin Walzer

    Kevin Walzer - 2010-10-12

    Uploaded revised patch: looks like earlier upload didn't go through.

     
  • Kevin Walzer

    Kevin Walzer - 2011-01-05
    • status: open --> closed-accepted
     
  • Kevin Walzer

    Kevin Walzer - 2011-01-05

    Fixed and committed patch.