mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-08-25 04:57:03 +00:00
New: CPThemeStateKeyWindow for CPView.
Every view in the key window now takes on the 'key window' theme state. This makes it easy to theme everything in inactive windows in more muted colours. Also, combined with the first responder theme state of the previous commit we can have visuals like "first responder but in an inactive window" for text views and such things.
This commit is contained in:
@@ -2961,6 +2961,25 @@ setBoundsOrigin:
|
||||
while (count--)
|
||||
[_subviews[count] _notifyViewDidResignFirstResponder];
|
||||
}
|
||||
|
||||
- (void)_notifyWindowDidBecomeKey
|
||||
{
|
||||
[self setThemeState:CPThemeStateKeyWindow];
|
||||
|
||||
var count = [_subviews count];
|
||||
while (count--)
|
||||
[_subviews[count] _notifyWindowDidBecomeKey];
|
||||
}
|
||||
|
||||
- (void)_notifyWindowDidResignKey
|
||||
{
|
||||
[self unsetThemeState:CPThemeStateKeyWindow];
|
||||
|
||||
var count = [_subviews count];
|
||||
while (count--)
|
||||
[_subviews[count] _notifyWindowDidResignKey];
|
||||
}
|
||||
|
||||
#pragma mark Theme Attributes
|
||||
|
||||
+ (CPString)defaultThemeClass
|
||||
|
||||
@@ -1965,6 +1965,7 @@ CPTexturedBackgroundWindowMask
|
||||
_hasBecomeKeyWindow = YES;
|
||||
|
||||
[_windowView noteKeyWindowStateChanged];
|
||||
[_contentView _notifyWindowDidBecomeKey];
|
||||
|
||||
[[CPNotificationCenter defaultCenter]
|
||||
postNotificationName:CPWindowDidBecomeKeyNotification
|
||||
@@ -2033,6 +2034,7 @@ CPTexturedBackgroundWindowMask
|
||||
CPApp._keyWindow = nil;
|
||||
|
||||
[_windowView noteKeyWindowStateChanged];
|
||||
[_contentView _notifyWindowDidResignKey];
|
||||
|
||||
[[CPNotificationCenter defaultCenter]
|
||||
postNotificationName:CPWindowDidResignKeyNotification
|
||||
|
||||
@@ -244,6 +244,7 @@
|
||||
|
||||
[self assertTrue:CGPointEqualToPoint(CGPointMake(4, 6), [subView0 convertPoint:CGPointMake(7, 11) fromView:tView0])]
|
||||
}
|
||||
|
||||
+ (CPArray)createResponderView:(/*@ref */CPView)viewOut siblingView:(/*@ref */CPView)siblingViewOut inWindow:(/*@ref */CPWindow)windowOut
|
||||
{
|
||||
var aView = [CPResponderView new],
|
||||
@@ -392,6 +393,31 @@
|
||||
[self assertFalse:[subview hasThemeState:CPThemeStateFirstResponder]];
|
||||
}
|
||||
|
||||
- (void)testWhenAndOnlyWhenWindowIsKeyEveryViewShouldHaveThemeStateKeyWindow
|
||||
{
|
||||
var aView, siblingView, aWindow;
|
||||
[CPViewTest createResponderView:@ref(aView) siblingView:@ref(siblingView) inWindow:@ref(aWindow)];
|
||||
|
||||
var subview = [CPView new];
|
||||
[aView addSubview:subview];
|
||||
|
||||
var aView2, siblingView2, aWindow2;
|
||||
[CPViewTest createResponderView:@ref(aView2) siblingView:@ref(siblingView2) inWindow:@ref(aWindow2)];
|
||||
|
||||
[aWindow makeKeyWindow];
|
||||
[self assertTrue:[aView hasThemeState:CPThemeStateKeyWindow]];
|
||||
[self assertTrue:[siblingView hasThemeState:CPThemeStateKeyWindow]];
|
||||
[self assertTrue:[subview hasThemeState:CPThemeStateKeyWindow]];
|
||||
[self assertFalse:[aView2 hasThemeState:CPThemeStateKeyWindow]];
|
||||
[self assertFalse:[siblingView2 hasThemeState:CPThemeStateKeyWindow]];
|
||||
|
||||
[aWindow2 makeKeyWindow];
|
||||
[self assertFalse:[aView hasThemeState:CPThemeStateKeyWindow]];
|
||||
[self assertFalse:[siblingView hasThemeState:CPThemeStateKeyWindow]];
|
||||
[self assertFalse:[subview hasThemeState:CPThemeStateKeyWindow]];
|
||||
[self assertTrue:[aView2 hasThemeState:CPThemeStateKeyWindow]];
|
||||
[self assertTrue:[siblingView2 hasThemeState:CPThemeStateKeyWindow]];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user