| OLD | NEW |
| 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 #include "ash/common/system/toast/toast_overlay.h" | 5 #include "ash/common/system/toast/toast_overlay.h" |
| 6 | 6 |
| 7 #include "ash/common/shelf/wm_shelf.h" | 7 #include "ash/common/shelf/wm_shelf.h" |
| 8 #include "ash/common/wm_lookup.h" | 8 #include "ash/common/wm_lookup.h" |
| 9 #include "ash/common/wm_root_window_controller.h" | 9 #include "ash/common/wm_root_window_controller.h" |
| 10 #include "ash/common/wm_shell.h" | 10 #include "ash/common/wm_shell.h" |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 SetHorizontalAlignment(gfx::ALIGN_LEFT); | 79 SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 80 SetFontList(rb->GetFontList(kTextFontStyle)); | 80 SetFontList(rb->GetFontList(kTextFontStyle)); |
| 81 SetAutoColorReadabilityEnabled(false); | 81 SetAutoColorReadabilityEnabled(false); |
| 82 SetMultiLine(true); | 82 SetMultiLine(true); |
| 83 SetEnabledColor(SK_ColorWHITE); | 83 SetEnabledColor(SK_ColorWHITE); |
| 84 SetDisabledColor(SK_ColorWHITE); | 84 SetDisabledColor(SK_ColorWHITE); |
| 85 SetSubpixelRenderingEnabled(false); | 85 SetSubpixelRenderingEnabled(false); |
| 86 | 86 |
| 87 int verticalSpacing = | 87 int verticalSpacing = |
| 88 kToastVerticalSpacing - (GetPreferredSize().height() - GetBaseline()); | 88 kToastVerticalSpacing - (GetPreferredSize().height() - GetBaseline()); |
| 89 SetBorder(views::Border::CreateEmptyBorder( | 89 SetBorder(views::CreateEmptyBorder(verticalSpacing, kToastHorizontalSpacing, |
| 90 verticalSpacing, kToastHorizontalSpacing, verticalSpacing, | 90 verticalSpacing, kToastHorizontalSpacing)); |
| 91 kToastHorizontalSpacing)); | |
| 92 } | 91 } |
| 93 | 92 |
| 94 ToastOverlayLabel::~ToastOverlayLabel() {} | 93 ToastOverlayLabel::~ToastOverlayLabel() {} |
| 95 | 94 |
| 96 /////////////////////////////////////////////////////////////////////////////// | 95 /////////////////////////////////////////////////////////////////////////////// |
| 97 // ToastOverlayButton | 96 // ToastOverlayButton |
| 98 class ToastOverlayButton : public views::LabelButton { | 97 class ToastOverlayButton : public views::LabelButton { |
| 99 public: | 98 public: |
| 100 explicit ToastOverlayButton(views::ButtonListener* listener, | 99 explicit ToastOverlayButton(views::ButtonListener* listener, |
| 101 const base::string16& label); | 100 const base::string16& label); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 115 set_ink_drop_base_color(SK_ColorWHITE); | 114 set_ink_drop_base_color(SK_ColorWHITE); |
| 116 | 115 |
| 117 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); | 116 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); |
| 118 | 117 |
| 119 SetEnabledTextColors(kButtonTextColor); | 118 SetEnabledTextColors(kButtonTextColor); |
| 120 SetFontList(rb->GetFontList(kTextFontStyle)); | 119 SetFontList(rb->GetFontList(kTextFontStyle)); |
| 121 | 120 |
| 122 // Treat the space below the baseline as a margin. | 121 // Treat the space below the baseline as a margin. |
| 123 int verticalSpacing = kToastVerticalSpacing - | 122 int verticalSpacing = kToastVerticalSpacing - |
| 124 (GetPreferredSize().height() - label()->GetBaseline()); | 123 (GetPreferredSize().height() - label()->GetBaseline()); |
| 125 SetBorder(views::Border::CreateEmptyBorder( | 124 SetBorder(views::CreateEmptyBorder(verticalSpacing, kToastHorizontalSpacing, |
| 126 verticalSpacing, kToastHorizontalSpacing, verticalSpacing, | 125 verticalSpacing, kToastHorizontalSpacing)); |
| 127 kToastHorizontalSpacing)); | |
| 128 } | 126 } |
| 129 | 127 |
| 130 /////////////////////////////////////////////////////////////////////////////// | 128 /////////////////////////////////////////////////////////////////////////////// |
| 131 // ToastOverlayView | 129 // ToastOverlayView |
| 132 class ToastOverlayView : public views::View, public views::ButtonListener { | 130 class ToastOverlayView : public views::View, public views::ButtonListener { |
| 133 public: | 131 public: |
| 134 // This object is not owned by the views hiearchy or by the widget. | 132 // This object is not owned by the views hiearchy or by the widget. |
| 135 ToastOverlayView(ToastOverlay* overlay, | 133 ToastOverlayView(ToastOverlay* overlay, |
| 136 const base::string16& text, | 134 const base::string16& text, |
| 137 const base::string16& dismiss_text); | 135 const base::string16& dismiss_text); |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 | 291 |
| 294 views::Widget* ToastOverlay::widget_for_testing() { | 292 views::Widget* ToastOverlay::widget_for_testing() { |
| 295 return overlay_widget_.get(); | 293 return overlay_widget_.get(); |
| 296 } | 294 } |
| 297 | 295 |
| 298 void ToastOverlay::ClickDismissButtonForTesting(const ui::Event& event) { | 296 void ToastOverlay::ClickDismissButtonForTesting(const ui::Event& event) { |
| 299 overlay_view_->button()->NotifyClick(event); | 297 overlay_view_->button()->NotifyClick(event); |
| 300 } | 298 } |
| 301 | 299 |
| 302 } // namespace ash | 300 } // namespace ash |
| OLD | NEW |