| OLD | NEW |
| 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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 private: | 99 private: |
| 100 void UpdateMinimizedHomeBounds() { | 100 void UpdateMinimizedHomeBounds() { |
| 101 gfx::Rect minimized_bounds = minimized_layer_->parent()->bounds(); | 101 gfx::Rect minimized_bounds = minimized_layer_->parent()->bounds(); |
| 102 minimized_bounds.set_y( | 102 minimized_bounds.set_y( |
| 103 minimized_bounds.bottom() - kHomeCardMinimizedHeight); | 103 minimized_bounds.bottom() - kHomeCardMinimizedHeight); |
| 104 minimized_bounds.set_height(kHomeCardMinimizedHeight); | 104 minimized_bounds.set_height(kHomeCardMinimizedHeight); |
| 105 minimized_layer_->SetBounds(minimized_bounds); | 105 minimized_layer_->SetBounds(minimized_bounds); |
| 106 } | 106 } |
| 107 | 107 |
| 108 // aura::LayoutManager: | 108 // aura::LayoutManager: |
| 109 virtual void OnWindowResized() OVERRIDE { | 109 virtual void OnWindowResized() override { |
| 110 Layout(false, gfx::Tween::LINEAR); | 110 Layout(false, gfx::Tween::LINEAR); |
| 111 UpdateMinimizedHomeBounds(); | 111 UpdateMinimizedHomeBounds(); |
| 112 } | 112 } |
| 113 virtual void OnWindowAddedToLayout(aura::Window* child) OVERRIDE { | 113 virtual void OnWindowAddedToLayout(aura::Window* child) override { |
| 114 if (!home_card_) { | 114 if (!home_card_) { |
| 115 home_card_ = child; | 115 home_card_ = child; |
| 116 Layout(false, gfx::Tween::LINEAR); | 116 Layout(false, gfx::Tween::LINEAR); |
| 117 } | 117 } |
| 118 } | 118 } |
| 119 virtual void OnWillRemoveWindowFromLayout(aura::Window* child) OVERRIDE { | 119 virtual void OnWillRemoveWindowFromLayout(aura::Window* child) override { |
| 120 if (home_card_ == child) | 120 if (home_card_ == child) |
| 121 home_card_ = NULL; | 121 home_card_ = NULL; |
| 122 } | 122 } |
| 123 virtual void OnWindowRemovedFromLayout(aura::Window* child) OVERRIDE { | 123 virtual void OnWindowRemovedFromLayout(aura::Window* child) override { |
| 124 } | 124 } |
| 125 virtual void OnChildWindowVisibilityChanged(aura::Window* child, | 125 virtual void OnChildWindowVisibilityChanged(aura::Window* child, |
| 126 bool visible) OVERRIDE { | 126 bool visible) override { |
| 127 if (home_card_ == child) | 127 if (home_card_ == child) |
| 128 Layout(false, gfx::Tween::LINEAR); | 128 Layout(false, gfx::Tween::LINEAR); |
| 129 } | 129 } |
| 130 virtual void SetChildBounds(aura::Window* child, | 130 virtual void SetChildBounds(aura::Window* child, |
| 131 const gfx::Rect& requested_bounds) OVERRIDE { | 131 const gfx::Rect& requested_bounds) override { |
| 132 SetChildBoundsDirect(child, requested_bounds); | 132 SetChildBoundsDirect(child, requested_bounds); |
| 133 } | 133 } |
| 134 | 134 |
| 135 aura::Window* home_card_; | 135 aura::Window* home_card_; |
| 136 ui::Layer* minimized_layer_; | 136 ui::Layer* minimized_layer_; |
| 137 | 137 |
| 138 DISALLOW_COPY_AND_ASSIGN(HomeCardLayoutManager); | 138 DISALLOW_COPY_AND_ASSIGN(HomeCardLayoutManager); |
| 139 }; | 139 }; |
| 140 | 140 |
| 141 // The container view of home card contents of each state. | 141 // The container view of home card contents of each state. |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 | 176 |
| 177 main_view_->SetLayoutStateWithAnimation( | 177 main_view_->SetLayoutStateWithAnimation( |
| 178 (state == HomeCard::VISIBLE_CENTERED) ? 1.0f : 0.0f, tween_type); | 178 (state == HomeCard::VISIBLE_CENTERED) ? 1.0f : 0.0f, tween_type); |
| 179 } | 179 } |
| 180 | 180 |
| 181 void ClearGesture() { | 181 void ClearGesture() { |
| 182 gesture_manager_.reset(); | 182 gesture_manager_.reset(); |
| 183 } | 183 } |
| 184 | 184 |
| 185 // views::View: | 185 // views::View: |
| 186 virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE { | 186 virtual void OnGestureEvent(ui::GestureEvent* event) override { |
| 187 if (!gesture_manager_ && | 187 if (!gesture_manager_ && |
| 188 event->type() == ui::ET_GESTURE_SCROLL_BEGIN) { | 188 event->type() == ui::ET_GESTURE_SCROLL_BEGIN) { |
| 189 gesture_manager_.reset(new HomeCardGestureManager( | 189 gesture_manager_.reset(new HomeCardGestureManager( |
| 190 gesture_delegate_, | 190 gesture_delegate_, |
| 191 GetWidget()->GetNativeWindow()->GetRootWindow()->bounds())); | 191 GetWidget()->GetNativeWindow()->GetRootWindow()->bounds())); |
| 192 } | 192 } |
| 193 | 193 |
| 194 if (gesture_manager_) | 194 if (gesture_manager_) |
| 195 gesture_manager_->ProcessGestureEvent(event); | 195 gesture_manager_->ProcessGestureEvent(event); |
| 196 } | 196 } |
| 197 virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE { | 197 virtual bool OnMousePressed(const ui::MouseEvent& event) override { |
| 198 if (HomeCard::Get()->GetState() == HomeCard::VISIBLE_MINIMIZED && | 198 if (HomeCard::Get()->GetState() == HomeCard::VISIBLE_MINIMIZED && |
| 199 event.IsLeftMouseButton() && event.GetClickCount() == 1) { | 199 event.IsLeftMouseButton() && event.GetClickCount() == 1) { |
| 200 athena::WindowManager::Get()->ToggleOverview(); | 200 athena::WindowManager::Get()->ToggleOverview(); |
| 201 return true; | 201 return true; |
| 202 } | 202 } |
| 203 return false; | 203 return false; |
| 204 } | 204 } |
| 205 | 205 |
| 206 private: | 206 private: |
| 207 void UpdateShadow(bool should_show) { | 207 void UpdateShadow(bool should_show) { |
| 208 wm::SetShadowType( | 208 wm::SetShadowType( |
| 209 GetWidget()->GetNativeWindow(), | 209 GetWidget()->GetNativeWindow(), |
| 210 should_show ? wm::SHADOW_TYPE_RECTANGULAR : wm::SHADOW_TYPE_NONE); | 210 should_show ? wm::SHADOW_TYPE_RECTANGULAR : wm::SHADOW_TYPE_NONE); |
| 211 } | 211 } |
| 212 | 212 |
| 213 // views::WidgetDelegate: | 213 // views::WidgetDelegate: |
| 214 virtual views::View* GetContentsView() OVERRIDE { | 214 virtual views::View* GetContentsView() override { |
| 215 return this; | 215 return this; |
| 216 } | 216 } |
| 217 | 217 |
| 218 AthenaStartPageView* main_view_; | 218 AthenaStartPageView* main_view_; |
| 219 scoped_ptr<HomeCardGestureManager> gesture_manager_; | 219 scoped_ptr<HomeCardGestureManager> gesture_manager_; |
| 220 HomeCardGestureManager::Delegate* gesture_delegate_; | 220 HomeCardGestureManager::Delegate* gesture_delegate_; |
| 221 | 221 |
| 222 DISALLOW_COPY_AND_ASSIGN(HomeCardView); | 222 DISALLOW_COPY_AND_ASSIGN(HomeCardView); |
| 223 }; | 223 }; |
| 224 | 224 |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 450 instance = NULL; | 450 instance = NULL; |
| 451 } | 451 } |
| 452 | 452 |
| 453 // static | 453 // static |
| 454 HomeCard* HomeCard::Get() { | 454 HomeCard* HomeCard::Get() { |
| 455 DCHECK(instance); | 455 DCHECK(instance); |
| 456 return instance; | 456 return instance; |
| 457 } | 457 } |
| 458 | 458 |
| 459 } // namespace athena | 459 } // namespace athena |
| OLD | NEW |