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

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

Issue 10830190: Fix status area tray spacing. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ash/system/tray/tray_background_view.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/tray_background_view.h" 5 #include "ash/system/tray/tray_background_view.h"
6 6
7 #include "ash/launcher/background_animator.h" 7 #include "ash/launcher/background_animator.h"
8 #include "ash/shell.h" 8 #include "ash/shell.h"
9 #include "ash/shell_window_ids.h" 9 #include "ash/shell_window_ids.h"
10 #include "ash/system/status_area_widget.h"
11 #include "ash/system/status_area_widget_delegate.h"
10 #include "ash/system/tray/tray_constants.h" 12 #include "ash/system/tray/tray_constants.h"
11 #include "ui/aura/window.h" 13 #include "ui/aura/window.h"
12 #include "ui/gfx/canvas.h" 14 #include "ui/gfx/canvas.h"
13 #include "ui/gfx/skia_util.h" 15 #include "ui/gfx/skia_util.h"
14 #include "ui/views/background.h" 16 #include "ui/views/background.h"
15 #include "ui/views/layout/box_layout.h" 17 #include "ui/views/layout/box_layout.h"
16 18
17 namespace { 19 namespace {
18 20
19 const SkColor kTrayBackgroundAlpha = 100; 21 const SkColor kTrayBackgroundAlpha = 100;
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 this, 0, kTrayBackgroundAlpha)), 132 this, 0, kTrayBackgroundAlpha)),
131 ALLOW_THIS_IN_INITIALIZER_LIST(hover_background_animator_( 133 ALLOW_THIS_IN_INITIALIZER_LIST(hover_background_animator_(
132 this, 0, kTrayBackgroundHoverAlpha - kTrayBackgroundAlpha)) { 134 this, 0, kTrayBackgroundHoverAlpha - kTrayBackgroundAlpha)) {
133 set_notify_enter_exit_on_child(true); 135 set_notify_enter_exit_on_child(true);
134 136
135 // Initially we want to paint the background, but without the hover effect. 137 // Initially we want to paint the background, but without the hover effect.
136 SetPaintsBackground(true, internal::BackgroundAnimator::CHANGE_IMMEDIATE); 138 SetPaintsBackground(true, internal::BackgroundAnimator::CHANGE_IMMEDIATE);
137 hover_background_animator_.SetPaintsBackground(false, 139 hover_background_animator_.SetPaintsBackground(false,
138 internal::BackgroundAnimator::CHANGE_IMMEDIATE); 140 internal::BackgroundAnimator::CHANGE_IMMEDIATE);
139 141
140 SetBorder();
141
142 tray_container_ = new TrayContainer(shelf_alignment_); 142 tray_container_ = new TrayContainer(shelf_alignment_);
143 SetContents(tray_container_); 143 SetContents(tray_container_);
144 } 144 }
145 145
146 TrayBackgroundView::~TrayBackgroundView() { 146 TrayBackgroundView::~TrayBackgroundView() {
147 } 147 }
148 148
149 void TrayBackgroundView::OnMouseEntered(const views::MouseEvent& event) { 149 void TrayBackgroundView::OnMouseEntered(const views::MouseEvent& event) {
150 hover_background_animator_.SetPaintsBackground(true, 150 hover_background_animator_.SetPaintsBackground(true,
151 internal::BackgroundAnimator::CHANGE_ANIMATE); 151 internal::BackgroundAnimator::CHANGE_ANIMATE);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 hide_background_animator_.SetPaintsBackground(value, change_type); 186 hide_background_animator_.SetPaintsBackground(value, change_type);
187 } 187 }
188 188
189 void TrayBackgroundView::SetShelfAlignment(ShelfAlignment alignment) { 189 void TrayBackgroundView::SetShelfAlignment(ShelfAlignment alignment) {
190 shelf_alignment_ = alignment; 190 shelf_alignment_ = alignment;
191 SetBorder(); 191 SetBorder();
192 tray_container_->SetAlignment(alignment); 192 tray_container_->SetAlignment(alignment);
193 } 193 }
194 194
195 void TrayBackgroundView::SetBorder() { 195 void TrayBackgroundView::SetBorder() {
196 views::View* parent = status_area_widget_->status_area_widget_delegate();
197 int child_count = parent->child_count();
198 DCHECK(child_count > 0);
199 int on_edge = (this == parent->child_at(child_count-1));
196 // Change the border padding for different shelf alignment. 200 // Change the border padding for different shelf alignment.
197 if (shelf_alignment() == SHELF_ALIGNMENT_BOTTOM) { 201 if (shelf_alignment() == SHELF_ALIGNMENT_BOTTOM) {
198 set_border(views::Border::CreateEmptyBorder(0, 0, 202 set_border(views::Border::CreateEmptyBorder(
199 kPaddingFromBottomOfScreenBottomAlignment, 203 0, 0, kPaddingFromBottomOfScreenBottomAlignment,
200 kPaddingFromRightEdgeOfScreenBottomAlignment)); 204 on_edge ? kPaddingFromRightEdgeOfScreenBottomAlignment : 0));
201 } else if (shelf_alignment() == SHELF_ALIGNMENT_LEFT) { 205 } else if (shelf_alignment() == SHELF_ALIGNMENT_LEFT) {
202 set_border(views::Border::CreateEmptyBorder(0, 206 set_border(views::Border::CreateEmptyBorder(
203 kPaddingFromOuterEdgeOfLauncherVerticalAlignment, 207 0, kPaddingFromOuterEdgeOfLauncherVerticalAlignment,
204 kPaddingFromBottomOfScreenVerticalAlignment, 208 on_edge ? kPaddingFromBottomOfScreenVerticalAlignment : 0,
205 kPaddingFromInnerEdgeOfLauncherVerticalAlignment)); 209 kPaddingFromInnerEdgeOfLauncherVerticalAlignment));
206 } else { 210 } else {
207 set_border(views::Border::CreateEmptyBorder(0, 211 set_border(views::Border::CreateEmptyBorder(
208 kPaddingFromInnerEdgeOfLauncherVerticalAlignment, 212 0, kPaddingFromInnerEdgeOfLauncherVerticalAlignment,
209 kPaddingFromBottomOfScreenVerticalAlignment, 213 on_edge ? kPaddingFromBottomOfScreenVerticalAlignment : 0,
210 kPaddingFromOuterEdgeOfLauncherVerticalAlignment)); 214 kPaddingFromOuterEdgeOfLauncherVerticalAlignment));
211 } 215 }
212 } 216 }
213 217
214 } // namespace internal 218 } // namespace internal
215 } // namespace ash 219 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/tray/tray_background_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698