Chromium Code Reviews| 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/common/system/tray/tray_details_view.h" | 5 #include "ash/common/system/tray/tray_details_view.h" |
|
tdanderson
2016/11/09 18:35:18
nit: since this will impact all detailed views, pl
| |
| 6 | 6 |
| 7 #include "ash/common/ash_view_ids.h" | 7 #include "ash/common/ash_view_ids.h" |
| 8 #include "ash/common/material_design/material_design_controller.h" | 8 #include "ash/common/material_design/material_design_controller.h" |
| 9 #include "ash/common/system/tray/fixed_sized_scroll_view.h" | 9 #include "ash/common/system/tray/fixed_sized_scroll_view.h" |
| 10 #include "ash/common/system/tray/system_tray.h" | 10 #include "ash/common/system/tray/system_tray.h" |
| 11 #include "ash/common/system/tray/system_tray_item.h" | 11 #include "ash/common/system/tray/system_tray_item.h" |
| 12 #include "ash/common/system/tray/tray_constants.h" | 12 #include "ash/common/system/tray/tray_constants.h" |
| 13 #include "base/containers/adapters.h" | 13 #include "base/containers/adapters.h" |
| 14 #include "third_party/skia/include/core/SkDrawLooper.h" | 14 #include "third_party/skia/include/core/SkDrawLooper.h" |
| 15 #include "ui/compositor/paint_context.h" | 15 #include "ui/compositor/paint_context.h" |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 36 // the children as sticky header rows. The sticky header rows are not scrolled | 36 // the children as sticky header rows. The sticky header rows are not scrolled |
| 37 // above the top of the visible viewport until the next one "pushes" it up and | 37 // above the top of the visible viewport until the next one "pushes" it up and |
| 38 // are painted above other children. To indicate that a child is a sticky header | 38 // are painted above other children. To indicate that a child is a sticky header |
| 39 // row use set_id(VIEW_ID_STICKY_HEADER). | 39 // row use set_id(VIEW_ID_STICKY_HEADER). |
| 40 class ScrollContentsView : public views::View, | 40 class ScrollContentsView : public views::View, |
| 41 public views::ViewTargeterDelegate { | 41 public views::ViewTargeterDelegate { |
| 42 public: | 42 public: |
| 43 ScrollContentsView() { | 43 ScrollContentsView() { |
| 44 SetEventTargeter(base::MakeUnique<views::ViewTargeter>(this)); | 44 SetEventTargeter(base::MakeUnique<views::ViewTargeter>(this)); |
| 45 SetLayoutManager( | 45 SetLayoutManager( |
| 46 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 1)); | 46 new views::BoxLayout(views::BoxLayout::kVertical, 0, |
| 47 UseMd() ? kContentsVerticalSpacingMd : 0, | |
| 48 UseMd() ? 0 : kContentsBetweenChildSpacingNonMd)); | |
| 47 } | 49 } |
| 48 ~ScrollContentsView() override {} | 50 ~ScrollContentsView() override {} |
| 49 | 51 |
| 50 protected: | 52 protected: |
| 51 // views::View: | 53 // views::View: |
| 52 void OnBoundsChanged(const gfx::Rect& previous_bounds) override { | 54 void OnBoundsChanged(const gfx::Rect& previous_bounds) override { |
| 53 PositionHeaderRows(); | 55 PositionHeaderRows(); |
| 54 } | 56 } |
| 55 | 57 |
| 56 void PaintChildren(const ui::PaintContext& context) override { | 58 void PaintChildren(const ui::PaintContext& context) override { |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 99 return ViewTargeterDelegate::TargetForRect(view, local_to_header); | 101 return ViewTargeterDelegate::TargetForRect(view, local_to_header); |
| 100 } | 102 } |
| 101 return ViewTargeterDelegate::TargetForRect(root, rect); | 103 return ViewTargeterDelegate::TargetForRect(root, rect); |
| 102 } | 104 } |
| 103 | 105 |
| 104 private: | 106 private: |
| 105 const int kSeparatorThickness = 1; | 107 const int kSeparatorThickness = 1; |
| 106 const SkColor kSeparatorColor = SkColorSetA(SK_ColorBLACK, 0x1F); | 108 const SkColor kSeparatorColor = SkColorSetA(SK_ColorBLACK, 0x1F); |
| 107 const int kShadowOffsetY = 2; | 109 const int kShadowOffsetY = 2; |
| 108 const int kShadowBlur = 2; | 110 const int kShadowBlur = 2; |
| 111 const int kContentsVerticalSpacingMd = 4; | |
| 112 // TODO(fukino): Remove this constant once we stop maintaining pre-MD design. | |
| 113 // crbug.com/614453. | |
| 114 const int kContentsBetweenChildSpacingNonMd = 1; | |
| 109 | 115 |
| 110 // A structure that keeps the original offset of each header between the | 116 // A structure that keeps the original offset of each header between the |
| 111 // calls to Layout() to allow keeping track of which view should be sticky. | 117 // calls to Layout() to allow keeping track of which view should be sticky. |
| 112 struct Header { | 118 struct Header { |
| 113 explicit Header(views::View* view) | 119 explicit Header(views::View* view) |
| 114 : view(view), natural_offset(view->y()) {} | 120 : view(view), natural_offset(view->y()) {} |
| 115 | 121 |
| 116 // A header View that can be decorated as sticky. | 122 // A header View that can be decorated as sticky. |
| 117 views::View* view; | 123 views::View* view; |
| 118 | 124 |
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 456 if (index < child_count() - 1 && child_at(index + 1) != title_row_) | 462 if (index < child_count() - 1 && child_at(index + 1) != title_row_) |
| 457 scroll_border_->set_visible(true); | 463 scroll_border_->set_visible(true); |
| 458 else | 464 else |
| 459 scroll_border_->set_visible(false); | 465 scroll_border_->set_visible(false); |
| 460 } | 466 } |
| 461 | 467 |
| 462 views::View::OnPaintBorder(canvas); | 468 views::View::OnPaintBorder(canvas); |
| 463 } | 469 } |
| 464 | 470 |
| 465 } // namespace ash | 471 } // namespace ash |
| OLD | NEW |