| 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" |
| 6 | 6 |
| 7 #include "ash/common/ash_view_ids.h" | 7 #include "ash/common/ash_view_ids.h" |
| 8 #include "ash/common/system/tray/system_menu_button.h" | 8 #include "ash/common/system/tray/system_menu_button.h" |
| 9 #include "ash/common/system/tray/system_tray.h" | 9 #include "ash/common/system/tray/system_tray.h" |
| 10 #include "ash/common/system/tray/system_tray_item.h" | 10 #include "ash/common/system/tray/system_tray_item.h" |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 DISALLOW_COPY_AND_ASSIGN(ScrollContentsView); | 220 DISALLOW_COPY_AND_ASSIGN(ScrollContentsView); |
| 221 }; | 221 }; |
| 222 | 222 |
| 223 // Constants for the title row. | 223 // Constants for the title row. |
| 224 const int kTitleRowVerticalPadding = 4; | 224 const int kTitleRowVerticalPadding = 4; |
| 225 const int kTitleRowProgressBarHeight = 2; | 225 const int kTitleRowProgressBarHeight = 2; |
| 226 const int kTitleRowPaddingTop = kTitleRowVerticalPadding; | 226 const int kTitleRowPaddingTop = kTitleRowVerticalPadding; |
| 227 const int kTitleRowPaddingBottom = | 227 const int kTitleRowPaddingBottom = |
| 228 kTitleRowVerticalPadding - kTitleRowProgressBarHeight; | 228 kTitleRowVerticalPadding - kTitleRowProgressBarHeight; |
| 229 | 229 |
| 230 class ScrollSeparator : public views::View { | |
| 231 public: | |
| 232 ScrollSeparator() {} | |
| 233 | |
| 234 ~ScrollSeparator() override {} | |
| 235 | |
| 236 private: | |
| 237 // views::View: | |
| 238 void OnPaint(gfx::Canvas* canvas) override { | |
| 239 canvas->FillRect(gfx::Rect(0, height() / 2, width(), 1), kBorderLightColor); | |
| 240 } | |
| 241 gfx::Size GetPreferredSize() const override { | |
| 242 return gfx::Size(1, kTrayPopupScrollSeparatorHeight); | |
| 243 } | |
| 244 | |
| 245 DISALLOW_COPY_AND_ASSIGN(ScrollSeparator); | |
| 246 }; | |
| 247 | |
| 248 } // namespace | 230 } // namespace |
| 249 | 231 |
| 250 TrayDetailsView::TrayDetailsView(SystemTrayItem* owner) | 232 TrayDetailsView::TrayDetailsView(SystemTrayItem* owner) |
| 251 : owner_(owner), | 233 : owner_(owner), |
| 252 box_layout_(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)), | 234 box_layout_(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)), |
| 253 scroller_(nullptr), | 235 scroller_(nullptr), |
| 254 scroll_content_(nullptr), | 236 scroll_content_(nullptr), |
| 255 progress_bar_(nullptr), | 237 progress_bar_(nullptr), |
| 256 tri_view_(nullptr), | 238 tri_view_(nullptr), |
| 257 back_button_(nullptr) { | 239 back_button_(nullptr) { |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 // TODO(varkha): Make the sticky rows work with EnableViewPortLayer(). | 296 // TODO(varkha): Make the sticky rows work with EnableViewPortLayer(). |
| 315 scroller_->SetPaintToLayer(); | 297 scroller_->SetPaintToLayer(); |
| 316 scroller_->set_background( | 298 scroller_->set_background( |
| 317 views::Background::CreateSolidBackground(kBackgroundColor)); | 299 views::Background::CreateSolidBackground(kBackgroundColor)); |
| 318 scroller_->layer()->SetMasksToBounds(true); | 300 scroller_->layer()->SetMasksToBounds(true); |
| 319 | 301 |
| 320 AddChildView(scroller_); | 302 AddChildView(scroller_); |
| 321 box_layout_->SetFlexForView(scroller_, 1); | 303 box_layout_->SetFlexForView(scroller_, 1); |
| 322 } | 304 } |
| 323 | 305 |
| 324 void TrayDetailsView::AddScrollSeparator() { | |
| 325 DCHECK(scroll_content_); | |
| 326 // Do not draw the separator if it is the very first item | |
| 327 // in the scrollable list. | |
| 328 if (scroll_content_->has_children()) | |
| 329 scroll_content_->AddChildView(new ScrollSeparator); | |
| 330 } | |
| 331 | |
| 332 void TrayDetailsView::Reset() { | 306 void TrayDetailsView::Reset() { |
| 333 RemoveAllChildViews(true); | 307 RemoveAllChildViews(true); |
| 334 scroller_ = nullptr; | 308 scroller_ = nullptr; |
| 335 scroll_content_ = nullptr; | 309 scroll_content_ = nullptr; |
| 336 progress_bar_ = nullptr; | 310 progress_bar_ = nullptr; |
| 337 back_button_ = nullptr; | 311 back_button_ = nullptr; |
| 338 tri_view_ = nullptr; | 312 tri_view_ = nullptr; |
| 339 } | 313 } |
| 340 | 314 |
| 341 void TrayDetailsView::ShowProgress(double value, bool visible) { | 315 void TrayDetailsView::ShowProgress(double value, bool visible) { |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 417 if (bounds().IsEmpty()) | 391 if (bounds().IsEmpty()) |
| 418 return views::View::GetHeightForWidth(width); | 392 return views::View::GetHeightForWidth(width); |
| 419 | 393 |
| 420 // The height of the bubble that contains this detailed view is set to | 394 // The height of the bubble that contains this detailed view is set to |
| 421 // the preferred height of the default view, and that determines the | 395 // the preferred height of the default view, and that determines the |
| 422 // initial height of |this|. Always request to stay the same height. | 396 // initial height of |this|. Always request to stay the same height. |
| 423 return height(); | 397 return height(); |
| 424 } | 398 } |
| 425 | 399 |
| 426 } // namespace ash | 400 } // namespace ash |
| OLD | NEW |