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 "ash/system/tray/tray_details_view.h" | 5 #include "ash/system/tray/tray_details_view.h" |
6 | 6 |
7 #include "ash/ash_view_ids.h" | 7 #include "ash/ash_view_ids.h" |
8 #include "ash/strings/grit/ash_strings.h" | 8 #include "ash/strings/grit/ash_strings.h" |
| 9 #include "ash/system/tray/hover_highlight_view.h" |
9 #include "ash/system/tray/system_menu_button.h" | 10 #include "ash/system/tray/system_menu_button.h" |
10 #include "ash/system/tray/system_tray.h" | 11 #include "ash/system/tray/system_tray.h" |
11 #include "ash/system/tray/system_tray_item.h" | 12 #include "ash/system/tray/system_tray_item.h" |
12 #include "ash/system/tray/tray_constants.h" | 13 #include "ash/system/tray/tray_constants.h" |
13 #include "ash/system/tray/tray_popup_item_style.h" | 14 #include "ash/system/tray/tray_popup_item_style.h" |
14 #include "ash/system/tray/tray_popup_utils.h" | 15 #include "ash/system/tray/tray_popup_utils.h" |
15 #include "ash/system/tray/tri_view.h" | 16 #include "ash/system/tray/tri_view.h" |
16 #include "base/containers/adapters.h" | 17 #include "base/containers/adapters.h" |
17 #include "base/memory/ptr_util.h" | 18 #include "base/memory/ptr_util.h" |
18 #include "third_party/skia/include/core/SkDrawLooper.h" | 19 #include "third_party/skia/include/core/SkDrawLooper.h" |
| 20 #include "ui/base/l10n/l10n_util.h" |
19 #include "ui/base/resource/resource_bundle.h" | 21 #include "ui/base/resource/resource_bundle.h" |
20 #include "ui/compositor/paint_context.h" | 22 #include "ui/compositor/paint_context.h" |
21 #include "ui/compositor/paint_recorder.h" | 23 #include "ui/compositor/paint_recorder.h" |
22 #include "ui/gfx/canvas.h" | 24 #include "ui/gfx/canvas.h" |
| 25 #include "ui/gfx/image/image_skia.h" |
| 26 #include "ui/gfx/paint_vector_icon.h" |
23 #include "ui/gfx/skia_paint_util.h" | 27 #include "ui/gfx/skia_paint_util.h" |
| 28 #include "ui/gfx/vector_icon_types.h" |
24 #include "ui/views/background.h" | 29 #include "ui/views/background.h" |
25 #include "ui/views/border.h" | 30 #include "ui/views/border.h" |
| 31 #include "ui/views/controls/image_view.h" |
26 #include "ui/views/controls/label.h" | 32 #include "ui/views/controls/label.h" |
27 #include "ui/views/controls/progress_bar.h" | 33 #include "ui/views/controls/progress_bar.h" |
28 #include "ui/views/controls/scroll_view.h" | 34 #include "ui/views/controls/scroll_view.h" |
29 #include "ui/views/controls/separator.h" | 35 #include "ui/views/controls/separator.h" |
30 #include "ui/views/layout/box_layout.h" | 36 #include "ui/views/layout/box_layout.h" |
31 #include "ui/views/view_targeter.h" | 37 #include "ui/views/view_targeter.h" |
32 #include "ui/views/view_targeter_delegate.h" | 38 #include "ui/views/view_targeter_delegate.h" |
33 | 39 |
34 namespace ash { | 40 namespace ash { |
35 namespace { | 41 namespace { |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 // TODO(varkha): Make the sticky rows work with EnableViewPortLayer(). | 302 // TODO(varkha): Make the sticky rows work with EnableViewPortLayer(). |
297 scroller_->SetPaintToLayer(); | 303 scroller_->SetPaintToLayer(); |
298 scroller_->set_background( | 304 scroller_->set_background( |
299 views::Background::CreateSolidBackground(kBackgroundColor)); | 305 views::Background::CreateSolidBackground(kBackgroundColor)); |
300 scroller_->layer()->SetMasksToBounds(true); | 306 scroller_->layer()->SetMasksToBounds(true); |
301 | 307 |
302 AddChildView(scroller_); | 308 AddChildView(scroller_); |
303 box_layout_->SetFlexForView(scroller_, 1); | 309 box_layout_->SetFlexForView(scroller_, 1); |
304 } | 310 } |
305 | 311 |
| 312 HoverHighlightView* TrayDetailsView::AddScrollListItem( |
| 313 const gfx::VectorIcon& icon, |
| 314 const base::string16& text) { |
| 315 HoverHighlightView* item = new HoverHighlightView(this); |
| 316 if (icon.is_empty()) |
| 317 item->AddLabelRow(text); |
| 318 else |
| 319 item->AddIconAndLabel(gfx::CreateVectorIcon(icon, kMenuIconColor), text); |
| 320 scroll_content_->AddChildView(item); |
| 321 return item; |
| 322 } |
| 323 |
| 324 HoverHighlightView* TrayDetailsView::AddScrollListCheckableItem( |
| 325 const gfx::VectorIcon& icon, |
| 326 const base::string16& text, |
| 327 bool checked) { |
| 328 HoverHighlightView* item = AddScrollListItem(icon, text); |
| 329 TrayPopupUtils::InitializeAsCheckableRow(item, checked); |
| 330 return item; |
| 331 } |
| 332 |
| 333 HoverHighlightView* TrayDetailsView::AddScrollListCheckableItem( |
| 334 const base::string16& text, |
| 335 bool checked) { |
| 336 return AddScrollListCheckableItem(gfx::kNoneIcon, text, checked); |
| 337 } |
| 338 |
| 339 TriView* TrayDetailsView::AddScrollListSubHeader(const gfx::VectorIcon& icon, |
| 340 int text_id) { |
| 341 TriView* header = TrayPopupUtils::CreateSubHeaderRowView(!icon.is_empty()); |
| 342 TrayPopupUtils::ConfigureAsStickyHeader(header); |
| 343 |
| 344 views::Label* label = TrayPopupUtils::CreateDefaultLabel(); |
| 345 label->SetText(l10n_util::GetStringUTF16(text_id)); |
| 346 TrayPopupItemStyle style(TrayPopupItemStyle::FontStyle::SUB_HEADER); |
| 347 style.SetupLabel(label); |
| 348 header->AddView(TriView::Container::CENTER, label); |
| 349 |
| 350 if (!icon.is_empty()) { |
| 351 views::ImageView* image_view = TrayPopupUtils::CreateMainImageView(); |
| 352 image_view->SetImage(gfx::CreateVectorIcon( |
| 353 icon, GetNativeTheme()->GetSystemColor( |
| 354 ui::NativeTheme::kColorId_ProminentButtonColor))); |
| 355 header->AddView(TriView::Container::START, image_view); |
| 356 } |
| 357 |
| 358 scroll_content_->AddChildView(header); |
| 359 return header; |
| 360 } |
| 361 |
| 362 TriView* TrayDetailsView::AddScrollListSubHeader(int text_id) { |
| 363 return AddScrollListSubHeader(gfx::kNoneIcon, text_id); |
| 364 } |
| 365 |
306 void TrayDetailsView::Reset() { | 366 void TrayDetailsView::Reset() { |
307 RemoveAllChildViews(true); | 367 RemoveAllChildViews(true); |
308 scroller_ = nullptr; | 368 scroller_ = nullptr; |
309 scroll_content_ = nullptr; | 369 scroll_content_ = nullptr; |
310 progress_bar_ = nullptr; | 370 progress_bar_ = nullptr; |
311 back_button_ = nullptr; | 371 back_button_ = nullptr; |
312 tri_view_ = nullptr; | 372 tri_view_ = nullptr; |
313 } | 373 } |
314 | 374 |
315 void TrayDetailsView::ShowProgress(double value, bool visible) { | 375 void TrayDetailsView::ShowProgress(double value, bool visible) { |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
391 if (bounds().IsEmpty()) | 451 if (bounds().IsEmpty()) |
392 return views::View::GetHeightForWidth(width); | 452 return views::View::GetHeightForWidth(width); |
393 | 453 |
394 // The height of the bubble that contains this detailed view is set to | 454 // The height of the bubble that contains this detailed view is set to |
395 // the preferred height of the default view, and that determines the | 455 // the preferred height of the default view, and that determines the |
396 // initial height of |this|. Always request to stay the same height. | 456 // initial height of |this|. Always request to stay the same height. |
397 return height(); | 457 return height(); |
398 } | 458 } |
399 | 459 |
400 } // namespace ash | 460 } // namespace ash |
OLD | NEW |