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

Side by Side Diff: ash/wm/status_area_layout_manager.cc

Issue 357063002: Snap widgets to pixel boundary on ash (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: adjust tests Created 6 years, 5 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/wm/status_area_layout_manager.h ('k') | ash/wm/system_modal_container_layout_manager.h » ('j') | 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/wm/status_area_layout_manager.h" 5 #include "ash/wm/status_area_layout_manager.h"
6 6
7 #include "ash/shelf/shelf_layout_manager.h" 7 #include "ash/shelf/shelf_layout_manager.h"
8 #include "ash/shelf/shelf_widget.h" 8 #include "ash/shelf/shelf_widget.h"
9 #include "ash/system/status_area_widget.h" 9 #include "ash/system/status_area_widget.h"
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
11 #include "ui/aura/window.h" 11 #include "ui/aura/window.h"
12 #include "ui/views/widget/widget.h" 12 #include "ui/views/widget/widget.h"
13 13
14 namespace ash { 14 namespace ash {
15 15
16 //////////////////////////////////////////////////////////////////////////////// 16 ////////////////////////////////////////////////////////////////////////////////
17 // StatusAreaLayoutManager, public: 17 // StatusAreaLayoutManager, public:
18 18
19 StatusAreaLayoutManager::StatusAreaLayoutManager(ShelfWidget* shelf) 19 StatusAreaLayoutManager::StatusAreaLayoutManager(aura::Window* container,
20 : in_layout_(false), 20 ShelfWidget* shelf)
21 shelf_(shelf) { 21 : SnapToPixelLayoutManager(container), in_layout_(false), shelf_(shelf) {
22 } 22 }
23 23
24 StatusAreaLayoutManager::~StatusAreaLayoutManager() { 24 StatusAreaLayoutManager::~StatusAreaLayoutManager() {
25 } 25 }
26 26
27 //////////////////////////////////////////////////////////////////////////////// 27 ////////////////////////////////////////////////////////////////////////////////
28 // StatusAreaLayoutManager, aura::LayoutManager implementation: 28 // StatusAreaLayoutManager, aura::LayoutManager implementation:
29 29
30 void StatusAreaLayoutManager::OnWindowResized() { 30 void StatusAreaLayoutManager::OnWindowResized() {
31 LayoutStatusArea(); 31 LayoutStatusArea();
32 } 32 }
33 33
34 void StatusAreaLayoutManager::OnWindowAddedToLayout(aura::Window* child) {
35 }
36
37 void StatusAreaLayoutManager::OnWillRemoveWindowFromLayout(
38 aura::Window* child) {
39 }
40
41 void StatusAreaLayoutManager::OnWindowRemovedFromLayout(aura::Window* child) {
42 }
43
44 void StatusAreaLayoutManager::OnChildWindowVisibilityChanged(
45 aura::Window* child, bool visible) {
46 }
47
48 void StatusAreaLayoutManager::SetChildBounds( 34 void StatusAreaLayoutManager::SetChildBounds(
49 aura::Window* child, 35 aura::Window* child,
50 const gfx::Rect& requested_bounds) { 36 const gfx::Rect& requested_bounds) {
51 // Only need to have the shelf do a layout if the child changing is the status 37 // Only need to have the shelf do a layout if the child changing is the status
52 // area and the shelf isn't in the process of doing a layout. 38 // area and the shelf isn't in the process of doing a layout.
53 if (child != shelf_->status_area_widget()->GetNativeView() || in_layout_) { 39 if (child != shelf_->status_area_widget()->GetNativeView() || in_layout_) {
54 SetChildBoundsDirect(child, requested_bounds); 40 SnapToPixelLayoutManager::SetChildBounds(child, requested_bounds);
55 return; 41 return;
56 } 42 }
57 43
58 // If the bounds match, no need to do anything. Check for target bounds to 44 // If the bounds match, no need to do anything. Check for target bounds to
59 // ensure any active animation is retargeted. 45 // ensure any active animation is retargeted.
60 if (requested_bounds == child->GetTargetBounds()) 46 if (requested_bounds == child->GetTargetBounds())
61 return; 47 return;
62 48
63 SetChildBoundsDirect(child, requested_bounds); 49 SnapToPixelLayoutManager::SetChildBounds(child, requested_bounds);
64 LayoutStatusArea(); 50 LayoutStatusArea();
65 } 51 }
66 52
67 //////////////////////////////////////////////////////////////////////////////// 53 ////////////////////////////////////////////////////////////////////////////////
68 // StatusAreaLayoutManager, private: 54 // StatusAreaLayoutManager, private:
69 55
70 void StatusAreaLayoutManager::LayoutStatusArea() { 56 void StatusAreaLayoutManager::LayoutStatusArea() {
71 // Shelf layout manager may be already doing layout. 57 // Shelf layout manager may be already doing layout.
72 if (shelf_->shelf_layout_manager()->updating_bounds()) 58 if (shelf_->shelf_layout_manager()->updating_bounds())
73 return; 59 return;
74 60
75 base::AutoReset<bool> auto_reset_in_layout(&in_layout_, true); 61 base::AutoReset<bool> auto_reset_in_layout(&in_layout_, true);
76 shelf_->shelf_layout_manager()->LayoutShelf(); 62 shelf_->shelf_layout_manager()->LayoutShelf();
77 } 63 }
78 64
79 } // namespace ash 65 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/status_area_layout_manager.h ('k') | ash/wm/system_modal_container_layout_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698