2010-11-29 1 views
5

Cocoa 용 오픈 소스 라이브러리가 iTunes 스타일의 창을 만들 수 있습니까?iTunes 스타일의 NSWindow 서브 클래스?

sample iTunes window

내가 공간 절약과 창 제목을 필요로하지 않는다 유틸리티 형 애플리케이션을위한 좋은 찾기 : 즉 컨트롤이 수평 방향의 수직 대신에 배치되어있는 창입니다.

+11

내가 찾으 성가신 애플 디자인 가이드 라인에 대하여. 나는 그들이 그 일을 계속하지 않기를 바란다. 나쁜 예를 설정합니다. 실제로 – JeremyP

답변

8

이 빠르게 멀리 해킹 NSWindow 표시 대의원은 시작할 수 있어야합니다

//VerticalTrafficLightsWindowDelegate.h 

#import <Cocoa/Cocoa.h> 

@interface VerticalTrafficLightsWindowDelegate : NSObject <NSWindowDelegate> { 
    NSWindow *window; 
} 

@property (assign) IBOutlet NSWindow *window; 

- (void)verticalizeButtonsForWindow:(NSWindow *)aWindow; 

@end 

//VerticalTrafficLightsWindowDelegate.m 

#import "VerticalTrafficLightsWindowDelegate.h" 

@implementation VerticalTrafficLightsWindowDelegate 

@synthesize window; 

- (void)awakeFromNib { 
    [self verticalizeButtonsForWindow:window]; 
} 

- (void)windowDidResize:(NSNotification *)notification { 
    [self verticalizeButtonsForWindow:window]; 
} 

- (void)verticalizeButtonsForWindow:(NSWindow *)aWindow { 
    NSArray *contentSuperViews = [[[aWindow contentView] superview] subviews]; 

    NSView *closeButton = [contentSuperViews objectAtIndex:0]; 
    NSRect closeButtonFrame = [closeButton frame]; 

    NSView *minimizeButton = [contentSuperViews objectAtIndex:2]; 
    NSRect minimizeButtonFrame = [minimizeButton frame]; 

    NSView *zoomButton = [contentSuperViews objectAtIndex:1]; 
    NSRect zoomButtonFrame = [zoomButton frame]; 

    [minimizeButton setFrame:NSMakeRect(closeButtonFrame.origin.x, closeButtonFrame.origin.y - 20.0, minimizeButtonFrame.size.width, minimizeButtonFrame.size.height)]; 
    [zoomButton setFrame:NSMakeRect(closeButtonFrame.origin.x, closeButtonFrame.origin.y - 40.0, zoomButtonFrame.size.width, zoomButtonFrame.size.height)]; 
} 

@end 

그러나 난 그냥 JeremyP처럼 난 단지 애플이 어떤 OS X의 더 넓은

+0

, 나는 그저 바랄뿐입니다. 그 통제는 추악합니다. –

+0

이것은 효과가 있지만 상당히 추합니다. 제목 표시 줄의 크기를 늘려야 할 수도 있지만, iTunes에서 NSToolbar와 동일한 코코아를 사용하고 있다고 생각합니다. 그렇다면 작은 크기의 신호등이 필요합니다.) –

+0

iTunes와 시각적으로 일치 시키려면 통합 된 질감 창이 있어야합니다. iTunes의 윈도우 UI (UI 브라우저) 설정 방법을 살펴보면 iTunes에 툴바가 전혀 사용되지 않는다는 것을 알 수 있습니다! 그리고 이러한 트래픽 버튼은 도구 모음의 요소가 아니어야합니다. 그것들은 윈도우의 상위 기능이며 내용과 관련이 없습니다 (대 툴바 아이콘). (좋아요, 확대/축소는 내용과 관련이 있습니다 만, 요점을 얻지 않습니까?)) – Regexident

1

아마도 NSWindow, NSView를 하위 클래스로 만들고 창과 단추를 직접 그리어야합니다.

아, 사용자 지정 그림을 그리는 데 중요한 세부 사항을 잃어 버렸다는 내용을 추가하고 싶습니다. 드로잉은 주 스레드에서 수행되고 메인 스레드는 잠시 동안 주 스레드 실행을 차단하는 중요한 작업을 수행하는 데 많은 시간을 할애 할 수 있으므로 사용자는 창을 이동할 수 없으며 애니메이션 위에 단추 마우스가 작동하지 않습니다 .

물론 다른 스레드에서 마우스 청취 이벤트를 구현하지 않으면 그림을 그려서 포커스를 잠급니다 ... 내가 의미 한 바는 - 실제로 이것이 앱을 훨씬 더 좋게 만든다고 생각하지 않는 한 걱정하지 마십시오.

0

그냥 확산 않을거야 기대할 수있는 말을 가지고 @Regexident '에 기반한 수정 된 버전 새로운 MacOS를위한. 새 macOS UI에 대한보기 계층 구조가 변경되어 원래 버전이 작동하지 않습니다. 수정 된 코드는 다음과 같이 (맥 OS 10.13에서 작동)입니다 :

- (void)verticalizeButtonsForWindow:(NSWindow *)aWindow { 
    // New view hierarchy. 
    NSView *titleBarContainerView = aWindow.contentView.superview.subviews[1]; 
    titleBarContainerView.frame = NSMakeRect(titleBarContainerView.frame.origin.x, titleBarContainerView.frame.origin.y - 60.0 + titleBarContainerView.frame.size.height, titleBarContainerView.frame.size.width, 60.0); 
    NSView *titleBarView = titleBarContainerView.subviews[0]; 
    titleBarView.frame = NSMakeRect(0.0, 0.0, titleBarView.frame.size.width, 60.0); 
    NSArray *titleBarSubviews = titleBarView.subviews; 

    NSView *closeButton = [titleBarSubviews objectAtIndex:0]; 
    NSRect closeButtonFrame = [closeButton frame]; 

    NSView *minimizeButton = [titleBarSubviews objectAtIndex:2]; 
    NSRect minimizeButtonFrame = [minimizeButton frame]; 

    NSView *zoomButton = [titleBarSubviews objectAtIndex:1]; 
    NSRect zoomButtonFrame = [zoomButton frame]; 

    // Coordinate changed: add instead of minus. 
    [minimizeButton setFrame:NSMakeRect(closeButtonFrame.origin.x, closeButtonFrame.origin.y + 20.0, minimizeButtonFrame.size.width, minimizeButtonFrame.size.height)]; 
    [zoomButton setFrame:NSMakeRect(closeButtonFrame.origin.x, closeButtonFrame.origin.y + 40.0, zoomButtonFrame.size.width, zoomButtonFrame.size.height)]; 
} 

결과 스크린 샷 : enter image description here