OLD | NEW |
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 <memory> | 8 #include <memory> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 22 matching lines...) Expand all Loading... |
33 #include "ui/views/controls/button/image_button.h" | 33 #include "ui/views/controls/button/image_button.h" |
34 #include "ui/views/controls/button/label_button.h" | 34 #include "ui/views/controls/button/label_button.h" |
35 #include "ui/views/controls/button/label_button_border.h" | 35 #include "ui/views/controls/button/label_button_border.h" |
36 #include "ui/views/controls/button/md_text_button.h" | 36 #include "ui/views/controls/button/md_text_button.h" |
37 #include "ui/views/controls/button/menu_button.h" | 37 #include "ui/views/controls/button/menu_button.h" |
38 #include "ui/views/controls/image_view.h" | 38 #include "ui/views/controls/image_view.h" |
39 #include "ui/views/controls/label.h" | 39 #include "ui/views/controls/label.h" |
40 #include "ui/views/controls/link.h" | 40 #include "ui/views/controls/link.h" |
41 #include "ui/views/controls/menu/menu_runner.h" | 41 #include "ui/views/controls/menu/menu_runner.h" |
42 #include "ui/views/layout/layout_constants.h" | 42 #include "ui/views/layout/layout_constants.h" |
| 43 #include "ui/views/style/platform_style.h" |
43 #include "ui/views/widget/widget.h" | 44 #include "ui/views/widget/widget.h" |
44 #include "ui/views/window/non_client_view.h" | 45 #include "ui/views/window/non_client_view.h" |
45 | 46 |
46 | 47 |
47 // Helpers -------------------------------------------------------------------- | 48 // Helpers -------------------------------------------------------------------- |
48 | 49 |
49 namespace { | 50 namespace { |
50 | 51 |
51 const int kEdgeItemPadding = views::kRelatedControlHorizontalSpacing; | 52 const int kEdgeItemPadding = views::kRelatedControlHorizontalSpacing; |
52 const int kIconToLabelSpacing = views::kRelatedControlHorizontalSpacing; | 53 const int kIconToLabelSpacing = views::kRelatedControlHorizontalSpacing; |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 false, views::Button::STATE_HOVERED, | 154 false, views::Button::STATE_HOVERED, |
154 views::Painter::CreateImageGridPainter(kHoveredImageSet)); | 155 views::Painter::CreateImageGridPainter(kHoveredImageSet)); |
155 const int kPressedImageSet[] = IMAGE_GRID(IDR_INFOBARBUTTON_PRESSED); | 156 const int kPressedImageSet[] = IMAGE_GRID(IDR_INFOBARBUTTON_PRESSED); |
156 button_border->SetPainter( | 157 button_border->SetPainter( |
157 false, views::Button::STATE_PRESSED, | 158 false, views::Button::STATE_PRESSED, |
158 views::Painter::CreateImageGridPainter(kPressedImageSet)); | 159 views::Painter::CreateImageGridPainter(kPressedImageSet)); |
159 button->SetBorder(std::move(button_border)); | 160 button->SetBorder(std::move(button_border)); |
160 button->set_animate_on_state_change(false); | 161 button->set_animate_on_state_change(false); |
161 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 162 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
162 button->SetFontList(rb.GetFontList(ui::ResourceBundle::MediumFont)); | 163 button->SetFontList(rb.GetFontList(ui::ResourceBundle::MediumFont)); |
163 button->SetFocusable(true); | 164 views::PlatformStyle::ConfigureFocus(views::PlatformStyle::CONTROL::BUTTON, |
| 165 button); |
164 button->SetTextColor(views::Button::STATE_NORMAL, GetInfobarTextColor()); | 166 button->SetTextColor(views::Button::STATE_NORMAL, GetInfobarTextColor()); |
165 button->SetTextColor(views::Button::STATE_HOVERED, GetInfobarTextColor()); | 167 button->SetTextColor(views::Button::STATE_HOVERED, GetInfobarTextColor()); |
166 return button; | 168 return button; |
167 } | 169 } |
168 | 170 |
169 views::MdTextButton* InfoBarView::CreateMdTextButton( | 171 views::MdTextButton* InfoBarView::CreateMdTextButton( |
170 views::ButtonListener* listener, | 172 views::ButtonListener* listener, |
171 const base::string16& text) { | 173 const base::string16& text) { |
172 DCHECK(ui::MaterialDesignController::IsModeMaterial()); | 174 DCHECK(ui::MaterialDesignController::IsModeMaterial()); |
173 views::MdTextButton* button = | 175 views::MdTextButton* button = |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 284 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
283 close_button_->SetImage(views::CustomButton::STATE_NORMAL, | 285 close_button_->SetImage(views::CustomButton::STATE_NORMAL, |
284 rb.GetImageNamed(IDR_CLOSE_1).ToImageSkia()); | 286 rb.GetImageNamed(IDR_CLOSE_1).ToImageSkia()); |
285 close_button_->SetImage(views::CustomButton::STATE_HOVERED, | 287 close_button_->SetImage(views::CustomButton::STATE_HOVERED, |
286 rb.GetImageNamed(IDR_CLOSE_1_H).ToImageSkia()); | 288 rb.GetImageNamed(IDR_CLOSE_1_H).ToImageSkia()); |
287 close_button_->SetImage(views::CustomButton::STATE_PRESSED, | 289 close_button_->SetImage(views::CustomButton::STATE_PRESSED, |
288 rb.GetImageNamed(IDR_CLOSE_1_P).ToImageSkia()); | 290 rb.GetImageNamed(IDR_CLOSE_1_P).ToImageSkia()); |
289 } | 291 } |
290 close_button_->SetAccessibleName( | 292 close_button_->SetAccessibleName( |
291 l10n_util::GetStringUTF16(IDS_ACCNAME_CLOSE)); | 293 l10n_util::GetStringUTF16(IDS_ACCNAME_CLOSE)); |
292 close_button_->SetFocusable(true); | 294 views::PlatformStyle::ConfigureFocus(views::PlatformStyle::CONTROL::BUTTON, |
| 295 close_button_); |
293 // Subclasses should already be done adding child views by this point (see | 296 // Subclasses should already be done adding child views by this point (see |
294 // related DCHECK in Layout()). | 297 // related DCHECK in Layout()). |
295 child_container_->AddChildView(close_button_); | 298 child_container_->AddChildView(close_button_); |
296 } | 299 } |
297 | 300 |
298 // Ensure the infobar is tall enough to display its contents. | 301 // Ensure the infobar is tall enough to display its contents. |
299 int height = ui::MaterialDesignController::IsModeMaterial() | 302 int height = ui::MaterialDesignController::IsModeMaterial() |
300 ? InfoBarContainerDelegate::kDefaultBarTargetHeightMd | 303 ? InfoBarContainerDelegate::kDefaultBarTargetHeightMd |
301 : InfoBarContainerDelegate::kDefaultBarTargetHeight; | 304 : InfoBarContainerDelegate::kDefaultBarTargetHeight; |
302 const int kMinimumVerticalPadding = 6; | 305 const int kMinimumVerticalPadding = 6; |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
436 } | 439 } |
437 | 440 |
438 bool InfoBarView::DoesIntersectRect(const View* target, | 441 bool InfoBarView::DoesIntersectRect(const View* target, |
439 const gfx::Rect& rect) const { | 442 const gfx::Rect& rect) const { |
440 DCHECK_EQ(this, target); | 443 DCHECK_EQ(this, target); |
441 // Only events that intersect the portion below the arrow are interesting. | 444 // Only events that intersect the portion below the arrow are interesting. |
442 gfx::Rect non_arrow_bounds = GetLocalBounds(); | 445 gfx::Rect non_arrow_bounds = GetLocalBounds(); |
443 non_arrow_bounds.Inset(0, arrow_height(), 0, 0); | 446 non_arrow_bounds.Inset(0, arrow_height(), 0, 0); |
444 return rect.Intersects(non_arrow_bounds); | 447 return rect.Intersects(non_arrow_bounds); |
445 } | 448 } |
OLD | NEW |