Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(523)

Side by Side Diff: chrome/browser/cocoa/tab_window_controller.mm

Issue 3181029: Mac: Show a context menu for poup window. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: Created 10 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #import "chrome/browser/cocoa/tab_window_controller.h" 5 #import "chrome/browser/cocoa/tab_window_controller.h"
6 6
7 #include "app/theme_provider.h" 7 #include "app/theme_provider.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #import "chrome/browser/cocoa/tab_strip_view.h" 9 #import "chrome/browser/cocoa/tab_strip_view.h"
10 #import "chrome/browser/cocoa/themed_window.h" 10 #import "chrome/browser/cocoa/themed_window.h"
11 11
12 @interface TabWindowController(PRIVATE) 12 @interface TabWindowController(PRIVATE)
13 - (void)setUseOverlay:(BOOL)useOverlay; 13 - (void)setUseOverlay:(BOOL)useOverlay;
14 @end 14 @end
15 15
16 @interface PopupStripView : NSView {
17 @protected
viettrungluu 2010/08/20 17:02:00 why protected and not private?
18 TabWindowController* controller_; // weak: own us.
viettrungluu 2010/08/20 17:02:00 s/own/owns/
19 }
20
21 - (void)setController:(TabWindowController*)controller;
viettrungluu 2010/08/20 17:02:00 Just declare it as a @property; in general, things
22 @end
23
24 @implementation PopupStripView
25 - (id)initWithFrame:(NSRect)frameRect {
26 if ((self = [super initWithFrame:frameRect]) != nil) {
27 controller_ = nil;
28 }
29 return self;
30 }
31
32 - (BOOL)acceptsFirstMouse:(NSEvent*)event {
33 return YES;
34 }
35
36 - (NSMenu *)menuForEvent:(NSEvent*)event {
37 if (!controller_)
38 return nil;
39 return [controller_ popupContextMenu];
40 }
41
42 - (void)setController:(TabWindowController*)controller {
43 controller_ = controller;
44 }
45 @end
46
16 @interface TabWindowOverlayWindow : NSWindow 47 @interface TabWindowOverlayWindow : NSWindow
17 @end 48 @end
18 49
19 @implementation TabWindowOverlayWindow 50 @implementation TabWindowOverlayWindow
20 51
21 - (ThemeProvider*)themeProvider { 52 - (ThemeProvider*)themeProvider {
22 if ([self parentWindow]) 53 if ([self parentWindow])
23 return [[[self parentWindow] windowController] themeProvider]; 54 return [[[self parentWindow] windowController] themeProvider];
24 return NULL; 55 return NULL;
25 } 56 }
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 NSRect contentFrame = [tabContentArea_ frame]; 99 NSRect contentFrame = [tabContentArea_ frame];
69 NSRect tabFrame = 100 NSRect tabFrame =
70 NSMakeRect(0, NSMaxY(contentFrame), 101 NSMakeRect(0, NSMaxY(contentFrame),
71 NSWidth(contentFrame), 102 NSWidth(contentFrame),
72 NSHeight([topTabStripView_ frame])); 103 NSHeight([topTabStripView_ frame]));
73 [topTabStripView_ setFrame:tabFrame]; 104 [topTabStripView_ setFrame:tabFrame];
74 NSView* contentParent = [[[self window] contentView] superview]; 105 NSView* contentParent = [[[self window] contentView] superview];
75 [contentParent addSubview:topTabStripView_]; 106 [contentParent addSubview:topTabStripView_];
76 } 107 }
77 108
109 - (void)addPopupStripToWindow {
110 NSRect contentFrame = [[[self window] contentView] frame];
viettrungluu 2010/08/20 17:02:00 Please do |NSView* contentView = [[self window] co
111 NSRect outerFrame = [[[[self window] contentView] superview] frame];
112 NSRect stripFrame =
113 NSMakeRect(0,
114 NSMaxY(contentFrame),
115 NSWidth(contentFrame),
116 NSHeight(outerFrame) - NSHeight(contentFrame));
117 [popupStripView_ setFrame:stripFrame];
118 [popupStripView_ setController:self];
119
120 NSView* contentParent = [[[self window] contentView] superview];
viettrungluu 2010/08/20 17:02:00 You can probably now do |[[contentView superview]
121 [contentParent addSubview:popupStripView_];
122 }
123
78 - (void)windowDidLoad { 124 - (void)windowDidLoad {
79 // Cache the difference in height between the window content area and the 125 // Cache the difference in height between the window content area and the
80 // tab content area. 126 // tab content area.
81 NSRect tabFrame = [tabContentArea_ frame]; 127 NSRect tabFrame = [tabContentArea_ frame];
82 NSRect contentFrame = [[[self window] contentView] frame]; 128 NSRect contentFrame = [[[self window] contentView] frame];
83 contentAreaHeightDelta_ = NSHeight(contentFrame) - NSHeight(tabFrame); 129 contentAreaHeightDelta_ = NSHeight(contentFrame) - NSHeight(tabFrame);
84 130
85 if ([self hasTabStrip]) { 131 if ([self hasTabStrip]) {
86 if ([self useVerticalTabs]) { 132 if ([self useVerticalTabs]) {
87 // No top tabstrip so remove the tabContentArea offset. 133 // No top tabstrip so remove the tabContentArea offset.
88 tabFrame.size.height = contentFrame.size.height; 134 tabFrame.size.height = contentFrame.size.height;
89 [tabContentArea_ setFrame:tabFrame]; 135 [tabContentArea_ setFrame:tabFrame];
90 [self addSideTabStripToWindow]; 136 [self addSideTabStripToWindow];
91 } else { 137 } else {
92 [self addTopTabStripToWindow]; 138 [self addTopTabStripToWindow];
93 } 139 }
94 } else { 140 } else {
95 // No top tabstrip so remove the tabContentArea offset. 141 // No top tabstrip so remove the tabContentArea offset.
96 tabFrame.size.height = contentFrame.size.height; 142 tabFrame.size.height = contentFrame.size.height;
97 [tabContentArea_ setFrame:tabFrame]; 143 [tabContentArea_ setFrame:tabFrame];
144 [self addPopupStripToWindow];
98 } 145 }
99 } 146 }
100 147
101 // Toggles from one display mode of the tab strip to another. Will automatically 148 // Toggles from one display mode of the tab strip to another. Will automatically
102 // call -layoutSubviews to reposition other content. 149 // call -layoutSubviews to reposition other content.
103 - (void)toggleTabStripDisplayMode { 150 - (void)toggleTabStripDisplayMode {
104 // Adjust the size of the tab contents to either use more or less space, 151 // Adjust the size of the tab contents to either use more or less space,
105 // depending on the direction of the toggle. This needs to be done prior to 152 // depending on the direction of the toggle. This needs to be done prior to
106 // adding back in the top tab strip as its position is based off the MaxY 153 // adding back in the top tab strip as its position is based off the MaxY
107 // of the tab content area. 154 // of the tab content area.
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 - (void)deferPerformClose { 379 - (void)deferPerformClose {
333 closeDeferred_ = YES; 380 closeDeferred_ = YES;
334 } 381 }
335 382
336 // Called when the size of the window content area has changed. Override to 383 // Called when the size of the window content area has changed. Override to
337 // position specific views. Base class implementation does nothing. 384 // position specific views. Base class implementation does nothing.
338 - (void)layoutSubviews { 385 - (void)layoutSubviews {
339 NOTIMPLEMENTED(); 386 NOTIMPLEMENTED();
340 } 387 }
341 388
389 - (NSMenu*)popupContextMenu {
390 return nil; // Doesn't show a context menu at the default.
viettrungluu 2010/08/20 17:02:00 s/at the/by/
391 }
342 @end 392 @end
OLDNEW
« chrome/browser/cocoa/tab_window_controller.h ('K') | « chrome/browser/cocoa/tab_window_controller.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698