Commit 992fa8fe authored by estade's avatar estade Committed by Commit bot

Remove pre-MD code from SystemTrayBubble.

Delete TrayPopupItemContainer class, which was only used for adding a
hover effect that we don't want/use in MD.

BUG=687802

Review-Url: https://codereview.chromium.org/2758433002
Cr-Commit-Position: refs/heads/master@{#457462}
parent ed9e4bf5
......@@ -413,8 +413,6 @@ component("ash") {
"common/system/tray/tray_popup_header_button.cc",
"common/system/tray/tray_popup_header_button.h",
"common/system/tray/tray_popup_ink_drop_style.h",
"common/system/tray/tray_popup_item_container.cc",
"common/system/tray/tray_popup_item_container.h",
"common/system/tray/tray_popup_item_style.cc",
"common/system/tray/tray_popup_item_style.h",
"common/system/tray/tray_popup_utils.cc",
......
......@@ -11,7 +11,6 @@
#include "ash/common/system/tray/actionable_view.h"
#include "ash/common/system/tray/system_tray_item.h"
#include "ash/common/system/tray/tray_constants.h"
#include "ash/common/system/tray/tray_popup_item_container.h"
#include "ash/common/system/tray/tray_popup_utils.h"
#include "ash/common/system/tray/tri_view.h"
#include "ash/common/wm_shell.h"
......
......@@ -7,13 +7,11 @@
#include <utility>
#include <vector>
#include "ash/common/material_design/material_design_controller.h"
#include "ash/common/system/tray/system_tray.h"
#include "ash/common/system/tray/system_tray_delegate.h"
#include "ash/common/system/tray/system_tray_item.h"
#include "ash/common/system/tray/tray_bubble_wrapper.h"
#include "ash/common/system/tray/tray_constants.h"
#include "ash/common/system/tray/tray_popup_item_container.h"
#include "ash/common/wm_shell.h"
#include "base/metrics/histogram_macros.h"
#include "base/threading/thread_task_runner_handle.h"
......@@ -295,12 +293,10 @@ void SystemTrayBubble::RecordVisibleRowMetrics() {
}
void SystemTrayBubble::UpdateBottomPadding() {
if (bubble_type_ == BUBBLE_TYPE_DEFAULT &&
MaterialDesignController::IsSystemTrayMenuMaterial()) {
if (bubble_type_ == BUBBLE_TYPE_DEFAULT)
bubble_view_->SetBottomPadding(kDefaultViewBottomPadding);
} else {
else
bubble_view_->SetBottomPadding(0);
}
}
void SystemTrayBubble::CreateItemViews(LoginStatus login_status) {
......@@ -313,9 +309,7 @@ void SystemTrayBubble::CreateItemViews(LoginStatus login_status) {
login_status = LoginStatus::LOCKED;
}
std::vector<TrayPopupItemContainer*> item_containers;
views::View* focus_view = nullptr;
const bool is_default_bubble = bubble_type_ == BUBBLE_TYPE_DEFAULT;
for (size_t i = 0; i < items_.size(); ++i) {
views::View* item_view = nullptr;
switch (bubble_type_) {
......@@ -329,27 +323,8 @@ void SystemTrayBubble::CreateItemViews(LoginStatus login_status) {
break;
}
if (item_view) {
TrayPopupItemContainer* tray_popup_item_container =
new TrayPopupItemContainer(
item_view,
is_default_bubble &&
!MaterialDesignController::IsSystemTrayMenuMaterial());
bubble_view_->AddChildView(tray_popup_item_container);
item_containers.push_back(tray_popup_item_container);
tray_item_view_map_[items_[i]->uma_type()] = tray_popup_item_container;
}
}
if (!MaterialDesignController::IsSystemTrayMenuMaterial()) {
// For default view, draw bottom border for each item, except the last
// 2 items, which are the bottom header row and the one just above it.
if (is_default_bubble) {
const int last_item_with_border =
static_cast<int>(item_containers.size()) - 2;
for (int i = 0; i < last_item_with_border; ++i) {
item_containers.at(i)->SetBorder(
views::CreateSolidSidedBorder(0, 0, 1, 0, kBorderLightColor));
}
bubble_view_->AddChildView(item_view);
tray_item_view_map_[items_[i]->uma_type()] = item_view;
}
}
......
......@@ -14,7 +14,6 @@
#include "ash/common/system/tray/system_tray_bubble.h"
#include "ash/common/system/tray/system_tray_item.h"
#include "ash/common/system/tray/tray_constants.h"
#include "ash/common/system/tray/tray_popup_item_container.h"
#include "ash/common/system/web_notification/web_notification_tray.h"
#include "ash/common/wm_shell.h"
#include "ash/common/wm_window.h"
......
// Copyright (c) 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ash/common/system/tray/tray_popup_item_container.h"
#include "ash/common/system/tray/tray_constants.h"
#include "ui/gfx/canvas.h"
#include "ui/views/layout/box_layout.h"
namespace ash {
TrayPopupItemContainer::TrayPopupItemContainer(views::View* view,
bool change_background)
: active_(false), change_background_(change_background) {
set_notify_enter_exit_on_child(true);
views::BoxLayout* layout =
new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0);
layout->SetDefaultFlex(1);
SetLayoutManager(layout);
if (view->layer()) {
SetPaintToLayer();
layer()->SetFillsBoundsOpaquely(view->layer()->fills_bounds_opaquely());
}
AddChildView(view);
SetVisible(view->visible());
}
TrayPopupItemContainer::~TrayPopupItemContainer() {}
void TrayPopupItemContainer::SetActive(bool active) {
if (!change_background_ || active_ == active)
return;
active_ = active;
SchedulePaint();
}
void TrayPopupItemContainer::ChildVisibilityChanged(View* child) {
if (visible() == child->visible())
return;
SetVisible(child->visible());
PreferredSizeChanged();
}
void TrayPopupItemContainer::ChildPreferredSizeChanged(View* child) {
PreferredSizeChanged();
}
void TrayPopupItemContainer::OnMouseEntered(const ui::MouseEvent& event) {
SetActive(true);
}
void TrayPopupItemContainer::OnMouseExited(const ui::MouseEvent& event) {
SetActive(false);
}
void TrayPopupItemContainer::OnGestureEvent(ui::GestureEvent* event) {
if (event->type() == ui::ET_GESTURE_TAP_DOWN) {
SetActive(true);
} else if (event->type() == ui::ET_GESTURE_TAP_CANCEL ||
event->type() == ui::ET_GESTURE_TAP) {
SetActive(false);
}
}
void TrayPopupItemContainer::OnPaintBackground(gfx::Canvas* canvas) {
if (child_count() == 0)
return;
views::View* view = child_at(0);
if (!view->background()) {
canvas->FillRect(gfx::Rect(size()),
(active_) ? kHoverBackgroundColor : kBackgroundColor);
}
}
} // namespace ash
// Copyright (c) 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ASH_COMMON_SYSTEM_TRAY_TRAY_POPUP_ITEM_CONTAINER_H_
#define ASH_COMMON_SYSTEM_TRAY_TRAY_POPUP_ITEM_CONTAINER_H_
#include "base/macros.h"
#include "ui/views/view.h"
namespace ash {
// A view which can optionally change the background color when a mouse is
// hovering or a user is interacting via touch.
class TrayPopupItemContainer : public views::View {
public:
TrayPopupItemContainer(views::View* view, bool change_background);
~TrayPopupItemContainer() override;
bool active() { return active_; }
private:
// Sets whether the active background is to be used, and triggers a paint.
void SetActive(bool active);
// views::View:
void ChildVisibilityChanged(views::View* child) override;
void ChildPreferredSizeChanged(views::View* child) override;
void OnMouseEntered(const ui::MouseEvent& event) override;
void OnMouseExited(const ui::MouseEvent& event) override;
void OnGestureEvent(ui::GestureEvent* event) override;
void OnPaintBackground(gfx::Canvas* canvas) override;
// True if either a mouse is hovering over this view, or if a user has touched
// down.
bool active_;
// True if mouse hover and touch feedback can alter the background color of
// the container.
bool change_background_;
DISALLOW_COPY_AND_ASSIGN(TrayPopupItemContainer);
};
} // namespace ash
#endif // ASH_COMMON_SYSTEM_TRAY_TRAY_POPUP_ITEM_CONTAINER_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment