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

Side by Side Diff: ash/wm/shelf_layout_manager.h

Issue 9764008: Makes the launcher auto-hide for maximized windows. This turned out to (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add null checks and cleanup Created 8 years, 9 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
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 #ifndef ASH_WM_SHELF_LAYOUT_MANAGER_H_ 5 #ifndef ASH_WM_SHELF_LAYOUT_MANAGER_H_
6 #define ASH_WM_SHELF_LAYOUT_MANAGER_H_ 6 #define ASH_WM_SHELF_LAYOUT_MANAGER_H_
7 #pragma once 7 #pragma once
8 8
9 #include "ash/ash_export.h"
10 #include "ash/launcher/launcher.h"
9 #include "base/basictypes.h" 11 #include "base/basictypes.h"
10 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
11 #include "ui/aura/layout_manager.h" 13 #include "ui/aura/layout_manager.h"
12 #include "ash/ash_export.h"
13 #include "ui/gfx/compositor/layer_animation_observer.h"
14 #include "ui/gfx/insets.h" 14 #include "ui/gfx/insets.h"
15 #include "ui/gfx/rect.h" 15 #include "ui/gfx/rect.h"
16 16
17 namespace aura { 17 namespace aura {
18 class RootWindow; 18 class RootWindow;
19 } 19 }
20 20
21 namespace views { 21 namespace views {
22 class Widget; 22 class Widget;
23 } 23 }
24 24
25 namespace ash { 25 namespace ash {
26 namespace internal { 26 namespace internal {
27 27
28 // ShelfLayoutManager is the layout manager responsible for the launcher and 28 // ShelfLayoutManager is the layout manager responsible for the launcher and
29 // status widgets. The launcher is given the total available width and told the 29 // status widgets. The launcher is given the total available width and told the
30 // width of the status area. This allows the launcher to draw the background and 30 // width of the status area. This allows the launcher to draw the background and
31 // layout to the status area. 31 // layout to the status area.
32 // To respond to bounds changes in the status area StatusAreaLayoutManager works 32 // To respond to bounds changes in the status area StatusAreaLayoutManager works
33 // closely with ShelfLayoutManager. 33 // closely with ShelfLayoutManager.
34 class ASH_EXPORT ShelfLayoutManager : public aura::LayoutManager, 34 class ASH_EXPORT ShelfLayoutManager : public aura::LayoutManager {
35 public ui::ImplicitAnimationObserver {
36 public: 35 public:
36 enum VisibilityState {
37 // Completely visible.
38 VISIBLE,
39
40 // A couple of pixels are reserved at the bottom for the shelf.
41 AUTO_HIDE,
42
43 // Nothing is shown. Used for fullscreen windows.
44 HIDDEN,
45 };
46
47 enum AutoHideState {
48 AUTO_HIDE_SHOWN,
49 AUTO_HIDE_HIDDEN,
50 };
51
37 // We reserve a small area at the bottom of the workspace area to ensure that 52 // We reserve a small area at the bottom of the workspace area to ensure that
38 // the bottom-of-window resize handle can be hit. 53 // the bottom-of-window resize handle can be hit.
39 // TODO(jamescook): Some day we may want the workspace area to be an even 54 // TODO(jamescook): Some day we may want the workspace area to be an even
40 // multiple of the size of the grid (currently 8 pixels), which will require 55 // multiple of the size of the grid (currently 8 pixels), which will require
41 // removing this and finding a way for hover and click events to pass through 56 // removing this and finding a way for hover and click events to pass through
42 // the invisible parts of the launcher. 57 // the invisible parts of the launcher.
43 static const int kWorkspaceAreaBottomInset; 58 static const int kWorkspaceAreaBottomInset;
44 59
45 ShelfLayoutManager(views::Widget* launcher, views::Widget* status); 60 explicit ShelfLayoutManager(views::Widget* status);
46 virtual ~ShelfLayoutManager(); 61 virtual ~ShelfLayoutManager();
47 62
63 // Returns the bounds the specified window should be when maximized.
64 gfx::Rect GetMaximizedWindowBounds(aura::Window* window) const;
65 gfx::Rect GetUnmaximizedWorkAreaBounds(aura::Window* window) const;
66
48 bool in_layout() const { return in_layout_; } 67 bool in_layout() const { return in_layout_; }
49 68
50 // Stops any animations and sets the bounds of the launcher and status 69 // Stops any animations and sets the bounds of the launcher and status
51 // widgets. 70 // widgets.
52 void LayoutShelf(); 71 void LayoutShelf();
53 72
54 // Sets the visibility of the shelf to |visible|. 73 // Sets the visibility of the shelf to |state|.
55 void SetVisible(bool visible); 74 void SetState(VisibilityState visibility_state,
56 bool visible() const { return visible_; } 75 AutoHideState auto_hide_state);
76 VisibilityState visibility_state() const { return state_.visibility_state; }
77 AutoHideState auto_hide_state() const { return state_.auto_hide_state; }
57 78
58 views::Widget* launcher() { return launcher_; } 79 // Sets whether any windows overlap the shelf. If a window overlaps the shelf
80 // the shelf renders slightly differently.
81 void SetWindowOverlapsShelf(bool value);
82
83 void SetLauncher(Launcher* launcher);
84 views::Widget* launcher() { return launcher_ ? launcher_->widget() : NULL; }
85 const views::Widget* launcher() const {
86 return launcher_ ? launcher_->widget() : NULL;
87 }
59 views::Widget* status() { return status_; } 88 views::Widget* status() { return status_; }
60 89
61 // See description above field. 90 // See description above field.
62 int max_height() const { return max_height_; } 91 int shelf_height() const { return shelf_height_; }
63 92
64 // Overridden from aura::LayoutManager: 93 // Overridden from aura::LayoutManager:
65 virtual void OnWindowResized() OVERRIDE; 94 virtual void OnWindowResized() OVERRIDE;
66 virtual void OnWindowAddedToLayout(aura::Window* child) OVERRIDE; 95 virtual void OnWindowAddedToLayout(aura::Window* child) OVERRIDE;
67 virtual void OnWillRemoveWindowFromLayout(aura::Window* child) OVERRIDE; 96 virtual void OnWillRemoveWindowFromLayout(aura::Window* child) OVERRIDE;
68 virtual void OnChildWindowVisibilityChanged(aura::Window* child, 97 virtual void OnChildWindowVisibilityChanged(aura::Window* child,
69 bool visible) OVERRIDE; 98 bool visible) OVERRIDE;
70 virtual void SetChildBounds(aura::Window* child, 99 virtual void SetChildBounds(aura::Window* child,
71 const gfx::Rect& requested_bounds) OVERRIDE; 100 const gfx::Rect& requested_bounds) OVERRIDE;
72 101
73 private: 102 private:
74 struct TargetBounds { 103 struct TargetBounds {
104 TargetBounds() : opacity(0.0f) {}
105
106 float opacity;
75 gfx::Rect launcher_bounds; 107 gfx::Rect launcher_bounds;
76 gfx::Rect status_bounds; 108 gfx::Rect status_bounds;
77 gfx::Insets work_area_insets; 109 gfx::Insets work_area_insets;
78 }; 110 };
79 111
112 struct State {
113 State() : visibility_state(VISIBLE), auto_hide_state(AUTO_HIDE_HIDDEN) {}
114
115 // Returns true if the two states are considered equal. As
116 // |auto_hide_state| only matters if |visibility_state| is |AUTO_HIDE|,
117 // Equals() ignores the |auto_hide_state| as appropriate.
118 bool Equals(const State& other) const {
119 return other.visibility_state == visibility_state &&
120 (visibility_state != AUTO_HIDE ||
121 other.auto_hide_state == auto_hide_state);
122 }
123
124 VisibilityState visibility_state;
125 AutoHideState auto_hide_state;
126 };
127
80 // Stops any animations. 128 // Stops any animations.
81 void StopAnimating(); 129 void StopAnimating();
82 130
83 // Calculates the target bounds assuming visibility of |visible|. 131 // Calculates the target bounds assuming visibility of |visible|.
84 void CalculateTargetBounds(bool visible, 132 void CalculateTargetBounds(const State& state,
85 TargetBounds* target_bounds); 133 TargetBounds* target_bounds) const;
86 134
87 // Implementation of ImplicitAnimationObserver 135 // Returns whether the shelf should draw a background.
88 virtual void OnImplicitAnimationsCompleted() OVERRIDE; 136 bool GetShelfRendersBackground() const;
89 137
90 // True when inside LayoutShelf method. Used to prevent calling LayoutShelf 138 // True when inside LayoutShelf method. Used to prevent calling LayoutShelf
91 // again from SetChildBounds(). 139 // again from SetChildBounds().
92 bool in_layout_; 140 bool in_layout_;
93 141
94 // Current visibility. When the visibility changes this field is reset once 142 // Current state.
95 // the animation completes. 143 State state_;
96 bool visible_;
97 144
98 // Max height needed. 145 // Height of the shelf (max of launcher and status).
99 int max_height_; 146 int shelf_height_;
100 147
101 views::Widget* launcher_; 148 Launcher* launcher_;
102 views::Widget* status_; 149 views::Widget* status_;
103 150
151 // Do any windows overlap the shelf? This is maintained by WorkspaceManager.
152 bool window_overlaps_shelf_;
153
104 aura::RootWindow* root_window_; 154 aura::RootWindow* root_window_;
105 155
106 DISALLOW_COPY_AND_ASSIGN(ShelfLayoutManager); 156 DISALLOW_COPY_AND_ASSIGN(ShelfLayoutManager);
107 }; 157 };
108 158
109 } // namespace internal 159 } // namespace internal
110 } // namespace ash 160 } // namespace ash
111 161
112 #endif // ASH_WM_SHELF_LAYOUT_MANAGER_H_ 162 #endif // ASH_WM_SHELF_LAYOUT_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698