Created
June 5, 2009 21:49
-
-
Save tolmasky/124533 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//this is the view i use to show the selection: | |
_toolbarSelection = [[CPImageView alloc] initWithFrame:CGRectMake(0.0, 0.0, 50.0, 57.0)]; | |
[_toolbarSelection setImage:MediaWindowControllerToolbarSelectionImage]; | |
[_toolbarSelection setAutoresizingMask:CPViewMinXMargin | CPViewMaxXMargin]; | |
// Here comes the hack: | |
[myWindow._toolbarView addSubview:_toolbarSelection]; | |
// Upon clicking on the button, we do this to position it: | |
var selectionFrame = [_toolbarSelection frame], | |
toolbarView = [[[self window] toolbar] _toolbarView], | |
subviews = [toolbarView subviews], | |
index = 0, | |
count = [subviews count]; | |
for (; index < count; ++index) | |
{ | |
var toolbarItemView = subviews[index]; | |
if ([toolbarItemView tag] === aTag) | |
break; | |
} | |
var frame = [toolbarItemView convertRect:[toolbarItemView bounds] toView:[self window]._toolbarView]; | |
[_toolbarSelection setFrameOrigin:CGPointMake(CGRectGetMinX(frame) + (CGRectGetWidth(frame) - CGRectGetWidth(selectionFrame)) / 2.0, 28.0)]; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment