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

Side by Side Diff: chrome/browser/ui/cocoa/omnibox/omnibox_popup_cell.mm

Issue 1099403005: [AiS] changing mac omnibox suggestions form NSMatrix to NSTableView (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review changes Created 5 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/ui/cocoa/omnibox/omnibox_popup_cell.h" 5 #import "chrome/browser/ui/cocoa/omnibox/omnibox_popup_cell.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 9
10 #include "base/i18n/rtl.h" 10 #include "base/i18n/rtl.h"
11 #include "base/mac/scoped_nsobject.h" 11 #include "base/mac/scoped_nsobject.h"
12 #include "base/strings/string_number_conversions.h" 12 #include "base/strings/string_number_conversions.h"
13 #include "base/strings/string_util.h" 13 #include "base/strings/string_util.h"
14 #include "base/strings/sys_string_conversions.h" 14 #include "base/strings/sys_string_conversions.h"
15 #include "base/strings/utf_string_conversions.h" 15 #include "base/strings/utf_string_conversions.h"
16 #include "chrome/browser/ui/cocoa/omnibox/omnibox_popup_view_mac.h" 16 #include "chrome/browser/ui/cocoa/omnibox/omnibox_popup_view_mac.h"
17 #include "chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.h" 17 #include "chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.h"
18 #include "chrome/browser/ui/omnibox/omnibox_popup_model.h" 18 #include "chrome/browser/ui/omnibox/omnibox_popup_model.h"
19 #include "chrome/grit/generated_resources.h" 19 #include "chrome/grit/generated_resources.h"
20 #include "components/omnibox/suggestion_answer.h" 20 #include "components/omnibox/suggestion_answer.h"
21 #include "ui/base/l10n/l10n_util.h" 21 #include "ui/base/l10n/l10n_util.h"
22 #include "ui/gfx/font.h" 22 #include "ui/gfx/font.h"
23 23
24 namespace { 24 namespace {
25 25
26 // How much to adjust the cell sizing up from the default determined
27 // by the font.
28 const CGFloat kCellHeightAdjust = 6.0;
29
26 // How far to offset image column from the left. 30 // How far to offset image column from the left.
27 const CGFloat kImageXOffset = 5.0; 31 const CGFloat kImageXOffset = 5.0;
28 32
29 // How far to offset the text column from the left. 33 // How far to offset the text column from the left.
30 const CGFloat kTextStartOffset = 28.0; 34 const CGFloat kTextStartOffset = 28.0;
31 35
32 // Rounding radius of selection and hover background on popup items. 36 // Rounding radius of selection and hover background on popup items.
33 const CGFloat kCellRoundingRadius = 2.0; 37 const CGFloat kCellRoundingRadius = 2.0;
34 38
35 // Flips the given |rect| in context of the given |frame|. 39 // Flips the given |rect| in context of the given |frame|.
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 description_.reset([CreateClassifiedAttributedString( 202 description_.reset([CreateClassifiedAttributedString(
199 answerString, DimTextColor(), match_.description_class) retain]); 203 answerString, DimTextColor(), match_.description_class) retain]);
200 } else if (match_.description.empty()) { 204 } else if (match_.description.empty()) {
201 description_.reset(); 205 description_.reset();
202 } else { 206 } else {
203 description_.reset([CreateClassifiedAttributedString( 207 description_.reset([CreateClassifiedAttributedString(
204 match_.description, DimTextColor(), match_.description_class) retain]); 208 match_.description, DimTextColor(), match_.description_class) retain]);
205 } 209 }
206 } 210 }
207 211
212 - (id)copyWithZone:(NSZone*)zone {
213 OmniboxPopupCell* copy = [super copyWithZone:zone];
214 copy->match_ = match_;
215 copy->separator_.reset([separator_ copy]);
216 copy->description_.reset([description_ copy]);
217 copy->prefix_.reset([prefix_ copy]);
218 copy->maxMatchContentsWidth_ = maxMatchContentsWidth_;
219 copy->contentsOffset_ = contentsOffset_;
220 return copy;
221 }
222
223 - (NSRect)drawingRectForBounds:(NSRect)theRect {
224 // Enlarge the cell size.
shrike 2015/04/27 18:30:10 Do you mean decrease the cell size?
dschuyler 2015/05/01 21:50:53 Done.
225 theRect.size.height -= kCellHeightAdjust;
226 return theRect;
227 }
228
208 - (void)setMaxMatchContentsWidth:(CGFloat)maxMatchContentsWidth { 229 - (void)setMaxMatchContentsWidth:(CGFloat)maxMatchContentsWidth {
209 maxMatchContentsWidth_ = maxMatchContentsWidth; 230 maxMatchContentsWidth_ = maxMatchContentsWidth;
210 } 231 }
211 232
212 - (void)setContentsOffset:(CGFloat)contentsOffset { 233 - (void)setContentsOffset:(CGFloat)contentsOffset {
213 contentsOffset_ = contentsOffset; 234 contentsOffset_ = contentsOffset;
214 } 235 }
215 236
216 // The default NSButtonCell drawing leaves the image flush left and 237 // The default NSButtonCell drawing leaves the image flush left and
217 // the title next to the image. This spaces things out to line up 238 // the title next to the image. This spaces things out to line up
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 } 448 }
428 glyphOffset -= minOffset; 449 glyphOffset -= minOffset;
429 if (glyphWidth == 0) 450 if (glyphWidth == 0)
430 glyphWidth = inputWidth - glyphOffset; 451 glyphWidth = inputWidth - glyphOffset;
431 if (isContentsRTL) 452 if (isContentsRTL)
432 glyphOffset += glyphWidth; 453 glyphOffset += glyphWidth;
433 return isRTL ? (inputWidth - glyphOffset) : glyphOffset; 454 return isRTL ? (inputWidth - glyphOffset) : glyphOffset;
434 } 455 }
435 456
436 @end 457 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698