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

Side by Side Diff: athena/home/home_card_impl.cc

Issue 641683003: C++11 override style change for athena (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Created 6 years, 2 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "athena/home/home_card_impl.h" 5 #include "athena/home/home_card_impl.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 #include <limits> 8 #include <limits>
9 9
10 #include "athena/env/public/athena_env.h" 10 #include "athena/env/public/athena_env.h"
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 } // namespace 64 } // namespace
65 65
66 // Makes sure the homecard is center-aligned horizontally and bottom-aligned 66 // Makes sure the homecard is center-aligned horizontally and bottom-aligned
67 // vertically. 67 // vertically.
68 class HomeCardLayoutManager : public aura::LayoutManager { 68 class HomeCardLayoutManager : public aura::LayoutManager {
69 public: 69 public:
70 HomeCardLayoutManager() 70 HomeCardLayoutManager()
71 : home_card_(NULL), 71 : home_card_(NULL),
72 minimized_layer_(NULL) {} 72 minimized_layer_(NULL) {}
73 73
74 virtual ~HomeCardLayoutManager() {} 74 ~HomeCardLayoutManager() override {}
75 75
76 void Layout(bool animate, gfx::Tween::Type tween_type) { 76 void Layout(bool animate, gfx::Tween::Type tween_type) {
77 // |home_card| could be detached from the root window (e.g. when it is being 77 // |home_card| could be detached from the root window (e.g. when it is being
78 // destroyed). 78 // destroyed).
79 if (!home_card_ || !home_card_->IsVisible() || !home_card_->GetRootWindow()) 79 if (!home_card_ || !home_card_->IsVisible() || !home_card_->GetRootWindow())
80 return; 80 return;
81 81
82 scoped_ptr<ui::ScopedLayerAnimationSettings> settings; 82 scoped_ptr<ui::ScopedLayerAnimationSettings> settings;
83 if (animate) { 83 if (animate) {
84 settings.reset(new ui::ScopedLayerAnimationSettings( 84 settings.reset(new ui::ScopedLayerAnimationSettings(
(...skipping 12 matching lines...) Expand all
97 private: 97 private:
98 void UpdateMinimizedHomeBounds() { 98 void UpdateMinimizedHomeBounds() {
99 gfx::Rect minimized_bounds = minimized_layer_->parent()->bounds(); 99 gfx::Rect minimized_bounds = minimized_layer_->parent()->bounds();
100 minimized_bounds.set_y( 100 minimized_bounds.set_y(
101 minimized_bounds.bottom() - kHomeCardMinimizedHeight); 101 minimized_bounds.bottom() - kHomeCardMinimizedHeight);
102 minimized_bounds.set_height(kHomeCardMinimizedHeight); 102 minimized_bounds.set_height(kHomeCardMinimizedHeight);
103 minimized_layer_->SetBounds(minimized_bounds); 103 minimized_layer_->SetBounds(minimized_bounds);
104 } 104 }
105 105
106 // aura::LayoutManager: 106 // aura::LayoutManager:
107 virtual void OnWindowResized() override { 107 void OnWindowResized() override {
108 Layout(false, gfx::Tween::LINEAR); 108 Layout(false, gfx::Tween::LINEAR);
109 UpdateMinimizedHomeBounds(); 109 UpdateMinimizedHomeBounds();
110 } 110 }
111 virtual void OnWindowAddedToLayout(aura::Window* child) override { 111 void OnWindowAddedToLayout(aura::Window* child) override {
112 if (!home_card_) { 112 if (!home_card_) {
113 home_card_ = child; 113 home_card_ = child;
114 Layout(false, gfx::Tween::LINEAR); 114 Layout(false, gfx::Tween::LINEAR);
115 } 115 }
116 } 116 }
117 virtual void OnWillRemoveWindowFromLayout(aura::Window* child) override { 117 void OnWillRemoveWindowFromLayout(aura::Window* child) override {
118 if (home_card_ == child) 118 if (home_card_ == child)
119 home_card_ = NULL; 119 home_card_ = NULL;
120 } 120 }
121 virtual void OnWindowRemovedFromLayout(aura::Window* child) override { 121 void OnWindowRemovedFromLayout(aura::Window* child) override {
122 } 122 }
123 virtual void OnChildWindowVisibilityChanged(aura::Window* child, 123 void OnChildWindowVisibilityChanged(aura::Window* child,
124 bool visible) override { 124 bool visible) override {
125 if (home_card_ == child) 125 if (home_card_ == child)
126 Layout(false, gfx::Tween::LINEAR); 126 Layout(false, gfx::Tween::LINEAR);
127 } 127 }
128 virtual void SetChildBounds(aura::Window* child, 128 void SetChildBounds(aura::Window* child,
129 const gfx::Rect& requested_bounds) override { 129 const gfx::Rect& requested_bounds) override {
130 SetChildBoundsDirect(child, requested_bounds); 130 SetChildBoundsDirect(child, requested_bounds);
131 } 131 }
132 132
133 aura::Window* home_card_; 133 aura::Window* home_card_;
134 ui::Layer* minimized_layer_; 134 ui::Layer* minimized_layer_;
135 135
136 DISALLOW_COPY_AND_ASSIGN(HomeCardLayoutManager); 136 DISALLOW_COPY_AND_ASSIGN(HomeCardLayoutManager);
137 }; 137 };
138 138
139 // The container view of home card contents of each state. 139 // The container view of home card contents of each state.
140 class HomeCardView : public views::WidgetDelegateView, 140 class HomeCardView : public views::WidgetDelegateView,
141 public AthenaStartPageView::Observer { 141 public AthenaStartPageView::Observer {
142 public: 142 public:
143 HomeCardView(app_list::AppListViewDelegate* view_delegate, 143 HomeCardView(app_list::AppListViewDelegate* view_delegate,
144 aura::Window* container, 144 aura::Window* container,
145 HomeCardGestureManager::Delegate* gesture_delegate) 145 HomeCardGestureManager::Delegate* gesture_delegate)
146 : gesture_delegate_(gesture_delegate) { 146 : gesture_delegate_(gesture_delegate) {
147 SetLayoutManager(new views::FillLayout()); 147 SetLayoutManager(new views::FillLayout());
148 // Ideally AppListMainView should be used here and have AthenaStartPageView 148 // Ideally AppListMainView should be used here and have AthenaStartPageView
149 // as its child view, so that custom pages and apps grid are available in 149 // as its child view, so that custom pages and apps grid are available in
150 // the home card. 150 // the home card.
151 // TODO(mukai): make it so after the detailed UI has been fixed. 151 // TODO(mukai): make it so after the detailed UI has been fixed.
152 main_view_ = new AthenaStartPageView(view_delegate); 152 main_view_ = new AthenaStartPageView(view_delegate);
153 main_view_->AddObserver(this); 153 main_view_->AddObserver(this);
154 AddChildView(main_view_); 154 AddChildView(main_view_);
155 } 155 }
156 156
157 virtual ~HomeCardView() { main_view_->RemoveObserver(this); } 157 ~HomeCardView() override { main_view_->RemoveObserver(this); }
158 158
159 void SetStateProgress(HomeCard::State from_state, 159 void SetStateProgress(HomeCard::State from_state,
160 HomeCard::State to_state, 160 HomeCard::State to_state,
161 float progress) { 161 float progress) {
162 // TODO(mukai): not clear the focus, but simply close the virtual keyboard. 162 // TODO(mukai): not clear the focus, but simply close the virtual keyboard.
163 GetFocusManager()->ClearFocus(); 163 GetFocusManager()->ClearFocus();
164 if (from_state == HomeCard::VISIBLE_CENTERED) 164 if (from_state == HomeCard::VISIBLE_CENTERED)
165 main_view_->SetLayoutState(1.0f - progress); 165 main_view_->SetLayoutState(1.0f - progress);
166 else if (to_state == HomeCard::VISIBLE_CENTERED) 166 else if (to_state == HomeCard::VISIBLE_CENTERED)
167 main_view_->SetLayoutState(progress); 167 main_view_->SetLayoutState(progress);
(...skipping 10 matching lines...) Expand all
178 178
179 main_view_->SetLayoutStateWithAnimation( 179 main_view_->SetLayoutStateWithAnimation(
180 (state == HomeCard::VISIBLE_CENTERED) ? 1.0f : 0.0f, tween_type); 180 (state == HomeCard::VISIBLE_CENTERED) ? 1.0f : 0.0f, tween_type);
181 } 181 }
182 182
183 void ClearGesture() { 183 void ClearGesture() {
184 gesture_manager_.reset(); 184 gesture_manager_.reset();
185 } 185 }
186 186
187 // views::View: 187 // views::View:
188 virtual void OnGestureEvent(ui::GestureEvent* event) override { 188 void OnGestureEvent(ui::GestureEvent* event) override {
189 if (!gesture_manager_ && 189 if (!gesture_manager_ &&
190 event->type() == ui::ET_GESTURE_SCROLL_BEGIN) { 190 event->type() == ui::ET_GESTURE_SCROLL_BEGIN) {
191 gesture_manager_.reset(new HomeCardGestureManager( 191 gesture_manager_.reset(new HomeCardGestureManager(
192 gesture_delegate_, 192 gesture_delegate_,
193 GetWidget()->GetNativeWindow()->GetRootWindow()->bounds())); 193 GetWidget()->GetNativeWindow()->GetRootWindow()->bounds()));
194 } 194 }
195 195
196 if (gesture_manager_) 196 if (gesture_manager_)
197 gesture_manager_->ProcessGestureEvent(event); 197 gesture_manager_->ProcessGestureEvent(event);
198 } 198 }
199 virtual bool OnMousePressed(const ui::MouseEvent& event) override { 199 bool OnMousePressed(const ui::MouseEvent& event) override {
200 if (HomeCard::Get()->GetState() == HomeCard::VISIBLE_MINIMIZED && 200 if (HomeCard::Get()->GetState() == HomeCard::VISIBLE_MINIMIZED &&
201 event.IsLeftMouseButton() && event.GetClickCount() == 1) { 201 event.IsLeftMouseButton() && event.GetClickCount() == 1) {
202 athena::WindowManager::Get()->EnterOverview(); 202 athena::WindowManager::Get()->EnterOverview();
203 return true; 203 return true;
204 } 204 }
205 return false; 205 return false;
206 } 206 }
207 207
208 private: 208 private:
209 void UpdateShadow(bool should_show) { 209 void UpdateShadow(bool should_show) {
210 wm::SetShadowType( 210 wm::SetShadowType(
211 GetWidget()->GetNativeWindow(), 211 GetWidget()->GetNativeWindow(),
212 should_show ? wm::SHADOW_TYPE_RECTANGULAR : wm::SHADOW_TYPE_NONE); 212 should_show ? wm::SHADOW_TYPE_RECTANGULAR : wm::SHADOW_TYPE_NONE);
213 } 213 }
214 214
215 // views::WidgetDelegate: 215 // views::WidgetDelegate:
216 virtual views::View* GetContentsView() override { 216 views::View* GetContentsView() override {
217 return this; 217 return this;
218 } 218 }
219 219
220 // AthenaStartPageView::Observer: 220 // AthenaStartPageView::Observer:
221 virtual void OnLayoutStateChanged(float new_state) override { 221 void OnLayoutStateChanged(float new_state) override {
222 if (new_state == 1.0f) 222 if (new_state == 1.0f)
223 HomeCard::Get()->SetState(HomeCard::VISIBLE_CENTERED); 223 HomeCard::Get()->SetState(HomeCard::VISIBLE_CENTERED);
224 } 224 }
225 225
226 AthenaStartPageView* main_view_; 226 AthenaStartPageView* main_view_;
227 scoped_ptr<HomeCardGestureManager> gesture_manager_; 227 scoped_ptr<HomeCardGestureManager> gesture_manager_;
228 HomeCardGestureManager::Delegate* gesture_delegate_; 228 HomeCardGestureManager::Delegate* gesture_delegate_;
229 229
230 DISALLOW_COPY_AND_ASSIGN(HomeCardView); 230 DISALLOW_COPY_AND_ASSIGN(HomeCardView);
231 }; 231 };
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 instance = NULL; 442 instance = NULL;
443 } 443 }
444 444
445 // static 445 // static
446 HomeCard* HomeCard::Get() { 446 HomeCard* HomeCard::Get() {
447 DCHECK(instance); 447 DCHECK(instance);
448 return instance; 448 return instance;
449 } 449 }
450 450
451 } // namespace athena 451 } // namespace athena
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698