Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2290)

Unified Diff: ash/common/system/tray/tray_details_view.cc

Issue 2289223002: Make TrayDetailsView a ViewClickListener and ButtonListener (Closed)
Patch Set: comments addressed Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/common/system/tray/tray_details_view.h ('k') | ash/common/system/tray/tray_details_view_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/common/system/tray/tray_details_view.cc
diff --git a/ash/common/system/tray/tray_details_view.cc b/ash/common/system/tray/tray_details_view.cc
index 5a1df684450836f5dd4a6e838dc62240014eeb22..10324404c3e243ae42d4bcb9edc6e3edc5351ca1 100644
--- a/ash/common/system/tray/tray_details_view.cc
+++ b/ash/common/system/tray/tray_details_view.cc
@@ -4,6 +4,7 @@
#include "ash/common/system/tray/tray_details_view.h"
+#include "ash/common/material_design/material_design_controller.h"
#include "ash/common/system/tray/fixed_sized_scroll_view.h"
#include "ash/common/system/tray/system_tray.h"
#include "ash/common/system/tray/system_tray_item.h"
@@ -61,22 +62,39 @@ class ScrollBorder : public views::Border {
TrayDetailsView::TrayDetailsView(SystemTrayItem* owner)
: owner_(owner),
- footer_(NULL),
- scroller_(NULL),
- scroll_content_(NULL),
- scroll_border_(NULL) {
+ title_row_(nullptr),
+ scroller_(nullptr),
+ scroll_content_(nullptr),
+ scroll_border_(nullptr) {
SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0));
set_background(views::Background::CreateSolidBackground(kBackgroundColor));
}
TrayDetailsView::~TrayDetailsView() {}
-void TrayDetailsView::CreateSpecialRow(int string_id,
- ViewClickListener* listener) {
- DCHECK(!footer_);
- footer_ = new SpecialPopupRow();
- footer_->SetTextLabel(string_id, listener);
- AddChildViewAt(footer_, child_count());
+void TrayDetailsView::OnViewClicked(views::View* sender) {
+ if (sender == title_row_->content())
+ TransitionToDefaultView();
+ else
+ HandleViewClicked(sender);
+}
+
+void TrayDetailsView::ButtonPressed(views::Button* sender,
+ const ui::Event& event) {
+ // TODO(tdanderson): Handle presses for material design buttons common to all
+ // detailed views here (back and Settings). See crbug.com/642136.
+ HandleButtonPressed(sender, event);
+}
+
+void TrayDetailsView::CreateTitleRow(int string_id,
+ ViewClickListener* listener) {
varkha 2016/08/31 23:18:12 Is there a case when |listener| is not |this|? Do
tdanderson 2016/09/01 14:39:12 No, this has been removed.
+ DCHECK(!title_row_);
+ const int child_view_position =
+ MaterialDesignController::IsSystemTrayMenuMaterial() ? 0 : child_count();
+ title_row_ = new SpecialPopupRow();
+ title_row_->SetTextLabel(string_id, listener);
+ AddChildViewAt(title_row_, child_view_position);
+ CreateExtraTitleRowButtons();
}
void TrayDetailsView::CreateScrollableList() {
@@ -104,16 +122,23 @@ void TrayDetailsView::AddScrollSeparator() {
void TrayDetailsView::Reset() {
RemoveAllChildViews(true);
- footer_ = NULL;
- scroller_ = NULL;
- scroll_content_ = NULL;
+ title_row_ = nullptr;
+ scroller_ = nullptr;
+ scroll_content_ = nullptr;
}
+void TrayDetailsView::HandleViewClicked(views::View* view) {}
+
+void TrayDetailsView::HandleButtonPressed(views::Button* sender,
+ const ui::Event& event) {}
+
+void TrayDetailsView::CreateExtraTitleRowButtons() {}
+
void TrayDetailsView::TransitionToDefaultView() {
// Cache pointer to owner in this function scope. TrayDetailsView will be
// deleted after called ShowDefaultView.
SystemTrayItem* owner = owner_;
- if (footer_ && footer_->content() && footer_->content()->HasFocus())
+ if (title_row_ && title_row_->content() && title_row_->content()->HasFocus())
owner->set_restore_focus(true);
owner->system_tray()->ShowDefaultView(BUBBLE_USE_EXISTING);
owner->set_restore_focus(false);
@@ -130,7 +155,8 @@ void TrayDetailsView::Layout() {
gfx::Size size = GetPreferredSize();
// Set the scroller to fill the space above the bottom row, so that the
- // bottom row of the detailed view will always stay just above the footer.
+ // bottom row of the detailed view will always stay just above the title
+ // row.
gfx::Size scroller_size = scroll_content_->GetPreferredSize();
scroller_->set_fixed_size(
gfx::Size(width() + scroller_->GetScrollBarWidth(),
@@ -139,18 +165,18 @@ void TrayDetailsView::Layout() {
views::View::Layout();
- if (footer_) {
- // Always make sure the footer element is bottom aligned.
- gfx::Rect fbounds = footer_->bounds();
- fbounds.set_y(height() - footer_->height());
- footer_->SetBoundsRect(fbounds);
+ if (title_row_ && !MaterialDesignController::IsSystemTrayMenuMaterial()) {
+ // Always make sure the title row is bottom-aligned in non-MD.
+ gfx::Rect fbounds = title_row_->bounds();
+ fbounds.set_y(height() - title_row_->height());
+ title_row_->SetBoundsRect(fbounds);
}
}
void TrayDetailsView::OnPaintBorder(gfx::Canvas* canvas) {
if (scroll_border_) {
int index = GetIndexOf(scroller_);
- if (index < child_count() - 1 && child_at(index + 1) != footer_)
+ if (index < child_count() - 1 && child_at(index + 1) != title_row_)
scroll_border_->set_visible(true);
else
scroll_border_->set_visible(false);
« no previous file with comments | « ash/common/system/tray/tray_details_view.h ('k') | ash/common/system/tray/tray_details_view_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698