Commit bd3cb0be authored by andresantoso's avatar andresantoso Committed by Commit bot

Mac: Make more views adopts ThemedWindowDrawing

Follow up to https://codereview.chromium.org/900613003/.
Make NewTabButton and TabStripBackgroundView adopt ThemedWindowDrawing.

BUG=455955,453996

Review URL: https://codereview.chromium.org/904503003

Cr-Commit-Position: refs/heads/master@{#315061}
parent 26b16811
......@@ -7,12 +7,14 @@
#import <Cocoa/Cocoa.h>
#import "chrome/browser/ui/cocoa/themed_window.h"
// Overrides hit-test behavior to only accept clicks inside the image of the
// button, not just inside the bounding box. This could be abstracted to general
// use, but no other buttons are so irregularly shaped with respect to their
// bounding box.
@interface NewTabButton : NSButton
@interface NewTabButton : NSButton<ThemedWindowDrawing>
// Returns YES if the given point is over the button. |point| is in the
// superview's coordinate system.
......
......@@ -55,4 +55,14 @@
return nil;
}
// ThemedWindowDrawing implementation.
- (void)windowDidChangeTheme {
[self setNeedsDisplay:YES];
}
- (void)windowDidChangeActive {
[self setNeedsDisplay:YES];
}
@end
......@@ -7,11 +7,13 @@
#import <Cocoa/Cocoa.h>
#import "chrome/browser/ui/cocoa/themed_window.h"
// A view that draws the theme image in the top area of the window (behind the
// tab strip area). It should be arranged so that its z-order is below its
// overlapping sibling views (window controls, tab strip view, profile button
// and fullscreen button).
@interface TabStripBackgroundView : NSView
@interface TabStripBackgroundView : NSView<ThemedWindowDrawing>
@end
#endif // CHROME_BROWSER_UI_COCOA_TABS_TAB_STRIP_BACKGROUND_VIEW_H_
......@@ -40,33 +40,13 @@
}
}
- (void)viewWillMoveToWindow:(NSWindow*)window {
if ([self window]) {
[[NSNotificationCenter defaultCenter]
removeObserver:self
name:NSWindowDidBecomeMainNotification
object:[self window]];
[[NSNotificationCenter defaultCenter]
removeObserver:self
name:NSWindowDidResignMainNotification
object:[self window]];
}
if (window) {
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(windowFocusDidChange:)
name:NSWindowDidBecomeMainNotification
object:window];
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(windowFocusDidChange:)
name:NSWindowDidResignMainNotification
object:window];
}
// ThemedWindowDrawing implementation.
- (void)windowDidChangeTheme {
[self setNeedsDisplay:YES];
}
- (void)windowFocusDidChange:(NSNotification*)notification {
// The theme image may depend on the window's active state.
- (void)windowDidChangeActive {
[self setNeedsDisplay:YES];
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment