Skip to content

Commit

Permalink
Show UnifiedSystemTray button and hide old one.
Browse files Browse the repository at this point in the history
As described in the design doc, old SystemTray class is going to be replaced by
UnifiedSystemTray class. Model variables of SystemTrayItems will be decoupled
into SystemTrayModel, and tray icons will be implemented in UnifiedSystemTray by
obseving the models.

This is the initial CL to replace the old SystemTray button by new
UnifiedSystemTray button. Old SystemTray still has unrelated logic e.g.
notification generation, so at this point we still instantiate SystemTray and
just set the visibility to false. When we finish refactoring to move all
unrelated logic to outside SystemTray, we can stop instantiating it.

Screenshot: http://screen/jVCtkJgKCXa
Design doc: go/cros-qs-restyling

TEST=manual
BUG=836134

Change-Id: I89e708ad239fb93aee5993fd10ace7fdeaab6673
Reviewed-on: https://chromium-review.googlesource.com/1025495
Commit-Queue: Tetsui Ohkubo <tetsui@chromium.org>
Reviewed-by: Steven Bennetts <stevenjb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#556378}
  • Loading branch information
Tetsui Ohkubo authored and Commit Bot committed May 7, 2018
1 parent d490170 commit 2d429e0
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 9 deletions.
2 changes: 2 additions & 0 deletions ash/system/status_area_widget.cc
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@ void StatusAreaWidget::SetSystemTrayVisibility(bool visible) {
TrayBackgroundView* StatusAreaWidget::GetSystemTrayAnchor() const {
if (overview_button_tray_->visible())
return overview_button_tray_.get();
if (unified_system_tray_)
return unified_system_tray_.get();
return system_tray_.get();
}

Expand Down
8 changes: 8 additions & 0 deletions ash/system/tray/system_tray.cc
Original file line number Diff line number Diff line change
Expand Up @@ -658,6 +658,14 @@ views::TrayBubbleView* SystemTray::GetBubbleView() {
: nullptr;
}

void SystemTray::SetVisible(bool visible) {
// TODO(tetsui): Port logic in SystemTrayItems that is unrelated to SystemTray
// UI, and stop instantiating SystemTray instead of hiding it when
// UnifiedSystemTray is enabled.
TrayBackgroundView::SetVisible(!features::IsSystemTrayUnifiedEnabled() &&
visible);
}

void SystemTray::BubbleViewDestroyed() {
if (system_bubble_) {
system_bubble_->bubble()->BubbleViewDestroyed();
Expand Down
1 change: 1 addition & 0 deletions ash/system/tray/system_tray.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ class ASH_EXPORT SystemTray : public TrayBackgroundView,
void CloseBubble() override;
void ShowBubble(bool show_by_click) override;
views::TrayBubbleView* GetBubbleView() override;
void SetVisible(bool visible) override;

// views::TrayBubbleView::Delegate:
void BubbleViewDestroyed() override;
Expand Down
20 changes: 11 additions & 9 deletions ash/system/unified/unified_system_tray.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@

#include "ash/system/unified/unified_system_tray.h"

#include "ash/shell.h"
#include "ash/system/date/date_view.h"
#include "ash/system/model/system_tray_model.h"
#include "ash/system/status_area_widget.h"
#include "ash/system/tray/system_tray.h"
#include "ash/system/tray/tray_container.h"
#include "ash/system/unified/unified_system_tray_bubble.h"
#include "ash/system/unified/unified_system_tray_model.h"
#include "ash/system/web_notification/ash_popup_alignment_delegate.h"
Expand Down Expand Up @@ -96,11 +100,11 @@ UnifiedSystemTray::UnifiedSystemTray(Shelf* shelf)
: TrayBackgroundView(shelf),
ui_delegate_(std::make_unique<UiDelegate>(this)),
model_(std::make_unique<UnifiedSystemTrayModel>()) {
// On the first step, features in the status area button are still provided by
// TrayViews in SystemTray.
// TODO(tetsui): Remove SystemTray from StatusAreaWidget and provide these
// features from UnifiedSystemTray.
SetVisible(false);
tray_container()->AddChildView(
new tray::TimeView(tray::TimeView::ClockLayout::HORIZONTAL_CLOCK,
Shell::Get()->system_tray_model()->clock()));
SetInkDropMode(InkDropMode::ON);
SetVisible(true);
}

UnifiedSystemTray::~UnifiedSystemTray() = default;
Expand Down Expand Up @@ -140,14 +144,12 @@ void UnifiedSystemTray::ClickedOutsideBubble() {}

void UnifiedSystemTray::ShowBubbleInternal(bool show_by_click) {
bubble_ = std::make_unique<UnifiedSystemTrayBubble>(this, show_by_click);
// TODO(tetsui): Call its own SetIsActive. See the comment in the ctor.
shelf()->GetStatusAreaWidget()->system_tray()->SetIsActive(true);
SetIsActive(true);
}

void UnifiedSystemTray::HideBubbleInternal() {
bubble_.reset();
// TODO(tetsui): Call its own SetIsActive. See the comment in the ctor.
shelf()->GetStatusAreaWidget()->system_tray()->SetIsActive(false);
SetIsActive(false);
}

} // namespace ash

0 comments on commit 2d429e0

Please sign in to comment.