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

Side by Side Diff: ios/clean/chrome/browser/ui/tab_grid/tab_grid_view_controller.mm

Issue 2810603002: [ios clean] Adds ToolsMenu to TabGrid (Closed)
Patch Set: Created 3 years, 8 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "ios/clean/chrome/browser/ui/tab_grid/tab_grid_view_controller.h" 5 #import "ios/clean/chrome/browser/ui/tab_grid/tab_grid_view_controller.h"
6 6
7 #include "base/mac/foundation_util.h" 7 #include "base/mac/foundation_util.h"
8 #import "ios/chrome/browser/ui/tab_switcher/tab_switcher_panel_overlay_view.h" 8 #import "ios/chrome/browser/ui/tab_switcher/tab_switcher_panel_overlay_view.h"
9 #import "ios/clean/chrome/browser/ui/actions/settings_actions.h" 9 #import "ios/clean/chrome/browser/ui/actions/settings_actions.h"
10 #import "ios/clean/chrome/browser/ui/actions/tab_grid_actions.h" 10 #import "ios/clean/chrome/browser/ui/actions/tab_grid_actions.h"
11 #import "ios/clean/chrome/browser/ui/commands/settings_commands.h" 11 #import "ios/clean/chrome/browser/ui/commands/settings_commands.h"
12 #import "ios/clean/chrome/browser/ui/commands/tab_grid_commands.h" 12 #import "ios/clean/chrome/browser/ui/commands/tab_grid_commands.h"
13 #import "ios/clean/chrome/browser/ui/commands/tools_menu_commands.h"
13 #import "ios/clean/chrome/browser/ui/tab_collection/tab_collection_data_source.h " 14 #import "ios/clean/chrome/browser/ui/tab_collection/tab_collection_data_source.h "
14 #import "ios/clean/chrome/browser/ui/tab_collection/tab_collection_tab_cell.h" 15 #import "ios/clean/chrome/browser/ui/tab_collection/tab_collection_tab_cell.h"
15 #import "ios/clean/chrome/browser/ui/tab_grid/mdc_floating_button+cr_tab_grid.h" 16 #import "ios/clean/chrome/browser/ui/tab_grid/mdc_floating_button+cr_tab_grid.h"
16 #import "ios/clean/chrome/browser/ui/tab_grid/tab_grid_collection_view_layout.h" 17 #import "ios/clean/chrome/browser/ui/tab_grid/tab_grid_collection_view_layout.h"
17 #import "ios/clean/chrome/browser/ui/tab_grid/tab_grid_toolbar.h" 18 #import "ios/clean/chrome/browser/ui/tab_grid/tab_grid_toolbar.h"
18 19
19 #if !defined(__has_feature) || !__has_feature(objc_arc) 20 #if !defined(__has_feature) || !__has_feature(objc_arc)
20 #error "This file requires ARC support." 21 #error "This file requires ARC support."
21 #endif 22 #endif
22 23
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 self.tabs.contentInset = 84 self.tabs.contentInset =
84 UIEdgeInsetsMake(CGRectGetMaxY(self.toolbar.frame), 0, 0, 0); 85 UIEdgeInsetsMake(CGRectGetMaxY(self.toolbar.frame), 0, 0, 0);
85 } 86 }
86 87
87 #pragma mark - SettingsActions 88 #pragma mark - SettingsActions
88 89
89 - (void)showSettings:(id)sender { 90 - (void)showSettings:(id)sender {
90 [self.dispatcher showSettings]; 91 [self.dispatcher showSettings];
91 } 92 }
92 93
94 #pragma mark - ToolsMenuActions
95
96 - (void)showToolsMenu:(id)sender {
97 [self.dispatcher showToolsMenu];
98 }
99
93 #pragma mark - TabGridActions 100 #pragma mark - TabGridActions
94 101
95 - (void)showTabGrid:(id)sender { 102 - (void)showTabGrid:(id)sender {
96 [self.dispatcher showTabGrid]; 103 [self.dispatcher showTabGrid];
97 } 104 }
98 105
99 - (void)createNewTab:(id)sender { 106 - (void)createNewTab:(id)sender {
100 [self.dispatcher createAndShowNewTabInTabGrid]; 107 [self.dispatcher createAndShowNewTabInTabGrid];
101 } 108 }
102 109
103 #pragma mark - ZoomTransitionDelegate methods 110 #pragma mark - ZoomTransitionDelegate methods
104 111
105 - (CGRect)rectForZoomWithKey:(NSObject*)key inView:(UIView*)view { 112 - (CGRect)rectForZoomWithKey:(NSObject*)key inView:(UIView*)view {
113 if (!key) {
edchin 2017/04/10 05:50:57 This logic requires some comments. It's not intuit
sczs 2017/04/11 18:47:59 Done.
114 if ([self.toolbar conformsToProtocol:@protocol(ZoomTransitionDelegate)]) {
edchin 2017/04/10 05:50:57 Is it necessary to check conformance and reinterpr
marq (ping after 24h) 2017/04/10 11:36:39 It shouldn't be.
sczs 2017/04/11 18:47:59 Removed this check.
115 return [reinterpret_cast<id<ZoomTransitionDelegate>>(self.toolbar)
116 rectForZoomWithKey:key
117 inView:view];
118 }
119 return CGRectNull;
120 }
121
106 NSIndexPath* cellPath = base::mac::ObjCCastStrict<NSIndexPath>(key); 122 NSIndexPath* cellPath = base::mac::ObjCCastStrict<NSIndexPath>(key);
107 if (!key)
108 return CGRectNull;
109 UICollectionViewCell* cell = [self.tabs cellForItemAtIndexPath:cellPath]; 123 UICollectionViewCell* cell = [self.tabs cellForItemAtIndexPath:cellPath];
110 return [view convertRect:cell.bounds fromView:cell]; 124 return [view convertRect:cell.bounds fromView:cell];
111 } 125 }
112 126
127 #pragma mark - MenuPresentationDelegate
128
129 - (CGRect)frameForMenuPresentation:(UIPresentationController*)presentation {
edchin 2017/04/10 05:50:57 If this code exists in multiple places, maybe we s
sczs 2017/04/11 18:47:59 Definitely, I think thats out of the scope of this
130 CGSize menuSize = presentation.presentedView.frame.size;
131 CGRect menuRect;
132 menuRect.size = menuSize;
133
134 CGRect menuOriginRect = [self rectForZoomWithKey:nil inView:self.view];
135 if (CGRectIsNull(menuOriginRect)) {
136 menuRect.origin = CGPointMake(50, 50);
edchin 2017/04/10 05:50:57 Magic numbers?
sczs 2017/04/11 18:47:59 Agree, this is Mark original code. Once we move to
137 return menuRect;
138 }
139 // Calculate which corner of the menu the origin rect is in. This is
140 // determined by comparing frames, and thus is RTL-independent.
141 if (CGRectGetMinX(menuOriginRect) - CGRectGetMinX(self.view.bounds) <
142 CGRectGetMaxX(self.view.bounds) - CGRectGetMaxX(menuOriginRect)) {
143 // Origin rect is closer to the left edge of |self.view| than to the right.
144 menuRect.origin.x = CGRectGetMinX(menuOriginRect);
145 } else {
146 // Origin rect is closer to the right edge of |self.view| than to the left.
147 menuRect.origin.x = CGRectGetMaxX(menuOriginRect) - menuSize.width;
148 }
149
150 if (CGRectGetMinY(menuOriginRect) - CGRectGetMinY(self.view.bounds) <
151 CGRectGetMaxY(self.view.bounds) - CGRectGetMaxY(menuOriginRect)) {
152 // Origin rect is closer to the top edge of |self.view| than to the bottom.
153 menuRect.origin.y = CGRectGetMinY(menuOriginRect);
154 } else {
155 // Origin rect is closer to the bottom edge of |self.view| than to the top.
156 menuRect.origin.y = CGRectGetMaxY(menuOriginRect) - menuSize.height;
157 }
158
159 return menuRect;
160 }
161
113 #pragma mark - TabGridConsumer methods 162 #pragma mark - TabGridConsumer methods
114 163
115 - (void)addNoTabsOverlay { 164 - (void)addNoTabsOverlay {
116 // PLACEHOLDER: The new tab grid will have a completely different zero tab 165 // PLACEHOLDER: The new tab grid will have a completely different zero tab
117 // overlay from the tab switcher. Also, the overlay will be above the recent 166 // overlay from the tab switcher. Also, the overlay will be above the recent
118 // tabs section. 167 // tabs section.
119 TabSwitcherPanelOverlayView* overlayView = 168 TabSwitcherPanelOverlayView* overlayView =
120 [[TabSwitcherPanelOverlayView alloc] initWithFrame:self.tabs.bounds 169 [[TabSwitcherPanelOverlayView alloc] initWithFrame:self.tabs.bounds
121 browserState:nil]; 170 browserState:nil];
122 overlayView.overlayType = 171 overlayView.overlayType =
123 TabSwitcherPanelOverlayType::OVERLAY_PANEL_USER_NO_OPEN_TABS; 172 TabSwitcherPanelOverlayType::OVERLAY_PANEL_USER_NO_OPEN_TABS;
124 overlayView.autoresizingMask = 173 overlayView.autoresizingMask =
125 UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; 174 UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
126 [self.tabs addSubview:overlayView]; 175 [self.tabs addSubview:overlayView];
127 self.noTabsOverlay = overlayView; 176 self.noTabsOverlay = overlayView;
128 } 177 }
129 178
130 - (void)removeNoTabsOverlay { 179 - (void)removeNoTabsOverlay {
131 [self.noTabsOverlay removeFromSuperview]; 180 [self.noTabsOverlay removeFromSuperview];
132 } 181 }
133 182
134 @end 183 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698