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

Side by Side Diff: ash/system/tray/system_tray.cc

Issue 1998933002: Update shelf spacing in Chrome OS according to the MD specs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments & Refactor border around item implementation Created 4 years, 6 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 unified diff | Download patch
OLDNEW
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/system/tray/system_tray.h" 5 #include "ash/system/tray/system_tray.h"
6 6
7 #include "ash/ash_switches.h" 7 #include "ash/ash_switches.h"
8 #include "ash/material_design/material_design_controller.h"
8 #include "ash/metrics/user_metrics_recorder.h" 9 #include "ash/metrics/user_metrics_recorder.h"
9 #include "ash/shelf/shelf_layout_manager.h" 10 #include "ash/shelf/shelf_layout_manager.h"
10 #include "ash/shelf/shelf_util.h" 11 #include "ash/shelf/shelf_util.h"
11 #include "ash/shell.h" 12 #include "ash/shell.h"
12 #include "ash/shell_window_ids.h" 13 #include "ash/shell_window_ids.h"
13 #include "ash/system/audio/tray_audio.h" 14 #include "ash/system/audio/tray_audio.h"
14 #include "ash/system/cast/tray_cast.h" 15 #include "ash/system/cast/tray_cast.h"
15 #include "ash/system/date/tray_date.h" 16 #include "ash/system/date/tray_date.h"
16 #include "ash/system/status_area_widget.h" 17 #include "ash/system/status_area_widget.h"
17 #include "ash/system/tray/system_tray_delegate.h" 18 #include "ash/system/tray/system_tray_delegate.h"
(...skipping 681 matching lines...) Expand 10 before | Expand all | Expand 10 after
699 views::View* SystemTray::GetTrayItemViewForTest(SystemTrayItem* item) { 700 views::View* SystemTray::GetTrayItemViewForTest(SystemTrayItem* item) {
700 std::map<SystemTrayItem*, views::View*>::iterator it = 701 std::map<SystemTrayItem*, views::View*>::iterator it =
701 tray_item_map_.find(item); 702 tray_item_map_.find(item);
702 return it == tray_item_map_.end() ? NULL : it->second; 703 return it == tray_item_map_.end() ? NULL : it->second;
703 } 704 }
704 705
705 TrayCast* SystemTray::GetTrayCastForTesting() const { return tray_cast_; } 706 TrayCast* SystemTray::GetTrayCastForTesting() const { return tray_cast_; }
706 707
707 TrayDate* SystemTray::GetTrayDateForTesting() const { return tray_date_; } 708 TrayDate* SystemTray::GetTrayDateForTesting() const { return tray_date_; }
708 709
710 void SystemTray::GetHitRegionInsets(gfx::Insets& insets) {
711 if (ash::MaterialDesignController::IsShelfMaterial()) {
712 int top_edge, left_edge, bottom_edge, right_edge;
713 if (wm::IsHorizontalAlignment(shelf_alignment())) {
714 top_edge = (GetShelfLayoutConstant(SHELF_SIZE) - kShelfItemHeight) / 2;
715 left_edge = 0;
716 bottom_edge = (GetShelfLayoutConstant(SHELF_SIZE) - kShelfItemHeight) / 2;
717 right_edge = GetTrayConstant(PADDING_FROM_EDGE_OF_SHELF);
718 } else { // SHELF_ALIGNMENT_LEFT || SHELF_ALIGNMENT_RIGHT
719 top_edge = 0;
720 left_edge = (GetShelfLayoutConstant(SHELF_SIZE) - kShelfItemHeight) / 2;
721 bottom_edge = GetTrayConstant(PADDING_FROM_EDGE_OF_SHELF);
722 right_edge = (GetShelfLayoutConstant(SHELF_SIZE) - kShelfItemHeight) / 2;
723 }
724 insets.Set(top_edge, left_edge, bottom_edge, right_edge);
725 } else {
726 TrayBackgroundView::GetHitRegionInsets(insets);
727 }
728 }
729
709 bool SystemTray::PerformAction(const ui::Event& event) { 730 bool SystemTray::PerformAction(const ui::Event& event) {
710 // If we're already showing the default view, hide it; otherwise, show it 731 // If we're already showing the default view, hide it; otherwise, show it
711 // (and hide any popup that's currently shown). 732 // (and hide any popup that's currently shown).
712 if (HasSystemBubbleType(SystemTrayBubble::BUBBLE_TYPE_DEFAULT)) { 733 if (HasSystemBubbleType(SystemTrayBubble::BUBBLE_TYPE_DEFAULT)) {
713 system_bubble_->bubble()->Close(); 734 system_bubble_->bubble()->Close();
714 } else { 735 } else {
715 int arrow_offset = TrayBubbleView::InitParams::kArrowDefaultOffset; 736 int arrow_offset = TrayBubbleView::InitParams::kArrowDefaultOffset;
716 if (event.IsMouseEvent() || event.type() == ui::ET_GESTURE_TAP) { 737 if (event.IsMouseEvent() || event.type() == ui::ET_GESTURE_TAP) {
717 const ui::LocatedEvent& located_event = 738 const ui::LocatedEvent& located_event =
718 static_cast<const ui::LocatedEvent&>(event); 739 static_cast<const ui::LocatedEvent&>(event);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
756 .work_area() 777 .work_area()
757 .height(); 778 .height();
758 if (work_area_height > 0) { 779 if (work_area_height > 0) {
759 UMA_HISTOGRAM_CUSTOM_COUNTS( 780 UMA_HISTOGRAM_CUSTOM_COUNTS(
760 "Ash.SystemMenu.PercentageOfWorkAreaHeightCoveredByMenu", 781 "Ash.SystemMenu.PercentageOfWorkAreaHeightCoveredByMenu",
761 100 * bubble_view->height() / work_area_height, 1, 300, 100); 782 100 * bubble_view->height() / work_area_height, 1, 300, 100);
762 } 783 }
763 } 784 }
764 785
765 } // namespace ash 786 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698