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

Side by Side Diff: chrome/browser/ui/views/infobars/infobar_view.cc

Issue 1817253003: [MD] Use same focus ring on BarControlButton as MdTextButton. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: update docs Created 4 years, 9 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
« no previous file with comments | « chrome/browser/ui/views/find_bar_view.cc ('k') | ui/views/controls/button/custom_button.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "chrome/browser/ui/views/infobars/infobar_view.h" 5 #include "chrome/browser/ui/views/infobars/infobar_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 227
228 // Even though other views are technically grandchildren, we'll lay them out 228 // Even though other views are technically grandchildren, we'll lay them out
229 // here on behalf of |child_container_|. 229 // here on behalf of |child_container_|.
230 int start_x = kEdgeItemPadding; 230 int start_x = kEdgeItemPadding;
231 if (icon_ != NULL) { 231 if (icon_ != NULL) {
232 icon_->SetPosition(gfx::Point(start_x, OffsetY(icon_))); 232 icon_->SetPosition(gfx::Point(start_x, OffsetY(icon_)));
233 start_x = icon_->bounds().right() + kIconToLabelSpacing; 233 start_x = icon_->bounds().right() + kIconToLabelSpacing;
234 } 234 }
235 235
236 int content_minimum_width = ContentMinimumWidth(); 236 int content_minimum_width = ContentMinimumWidth();
237 close_button_->SizeToPreferredSize();
237 close_button_->SetPosition(gfx::Point( 238 close_button_->SetPosition(gfx::Point(
238 std::max( 239 std::max(
239 start_x + content_minimum_width + 240 start_x + content_minimum_width +
240 ((content_minimum_width > 0) ? kBeforeCloseButtonSpacing : 0), 241 ((content_minimum_width > 0) ? kBeforeCloseButtonSpacing : 0),
241 width() - kEdgeItemPadding - close_button_->width()), 242 width() - kEdgeItemPadding - close_button_->width()),
242 OffsetY(close_button_))); 243 OffsetY(close_button_)));
243 244
244 // For accessibility reasons, the close button should come last. 245 // For accessibility reasons, the close button should come last.
245 DCHECK_EQ(close_button_->parent()->child_count() - 1, 246 DCHECK_EQ(close_button_->parent()->child_count() - 1,
246 close_button_->parent()->GetIndexOf(close_button_)); 247 close_button_->parent()->GetIndexOf(close_button_));
(...skipping 21 matching lines...) Expand all
268 } else { 269 } else {
269 close_button_ = new views::ImageButton(this); 270 close_button_ = new views::ImageButton(this);
270 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 271 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
271 close_button_->SetImage(views::CustomButton::STATE_NORMAL, 272 close_button_->SetImage(views::CustomButton::STATE_NORMAL,
272 rb.GetImageNamed(IDR_CLOSE_1).ToImageSkia()); 273 rb.GetImageNamed(IDR_CLOSE_1).ToImageSkia());
273 close_button_->SetImage(views::CustomButton::STATE_HOVERED, 274 close_button_->SetImage(views::CustomButton::STATE_HOVERED,
274 rb.GetImageNamed(IDR_CLOSE_1_H).ToImageSkia()); 275 rb.GetImageNamed(IDR_CLOSE_1_H).ToImageSkia());
275 close_button_->SetImage(views::CustomButton::STATE_PRESSED, 276 close_button_->SetImage(views::CustomButton::STATE_PRESSED,
276 rb.GetImageNamed(IDR_CLOSE_1_P).ToImageSkia()); 277 rb.GetImageNamed(IDR_CLOSE_1_P).ToImageSkia());
277 } 278 }
278 close_button_->SizeToPreferredSize();
279 close_button_->SetAccessibleName( 279 close_button_->SetAccessibleName(
280 l10n_util::GetStringUTF16(IDS_ACCNAME_CLOSE)); 280 l10n_util::GetStringUTF16(IDS_ACCNAME_CLOSE));
281 close_button_->SetFocusable(true); 281 close_button_->SetFocusable(true);
282 // Subclasses should already be done adding child views by this point (see 282 // Subclasses should already be done adding child views by this point (see
283 // related DCHECK in Layout()). 283 // related DCHECK in Layout()).
284 child_container_->AddChildView(close_button_); 284 child_container_->AddChildView(close_button_);
285 } 285 }
286 286
287 // Ensure the infobar is tall enough to display its contents. 287 // Ensure the infobar is tall enough to display its contents.
288 int height = ui::MaterialDesignController::IsModeMaterial() 288 int height = ui::MaterialDesignController::IsModeMaterial()
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 } 431 }
432 432
433 bool InfoBarView::DoesIntersectRect(const View* target, 433 bool InfoBarView::DoesIntersectRect(const View* target,
434 const gfx::Rect& rect) const { 434 const gfx::Rect& rect) const {
435 DCHECK_EQ(this, target); 435 DCHECK_EQ(this, target);
436 // Only events that intersect the portion below the arrow are interesting. 436 // Only events that intersect the portion below the arrow are interesting.
437 gfx::Rect non_arrow_bounds = GetLocalBounds(); 437 gfx::Rect non_arrow_bounds = GetLocalBounds();
438 non_arrow_bounds.Inset(0, arrow_height(), 0, 0); 438 non_arrow_bounds.Inset(0, arrow_height(), 0, 0);
439 return rect.Intersects(non_arrow_bounds); 439 return rect.Intersects(non_arrow_bounds);
440 } 440 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/find_bar_view.cc ('k') | ui/views/controls/button/custom_button.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698