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

Side by Side Diff: ash/shelf/shelf_layout_manager.cc

Issue 98373006: Animating docked background in sync with shelf (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Animating docked background in sync with shelf (rebase) Created 7 years 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
« no previous file with comments | « ash/shelf/shelf_layout_manager.h ('k') | ash/shelf/shelf_layout_manager_observer.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/shelf/shelf_layout_manager.h" 5 #include "ash/shelf/shelf_layout_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <cstring> 9 #include <cstring>
10 #include <string> 10 #include <string>
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 public: 168 public:
169 explicit UpdateShelfObserver(ShelfLayoutManager* shelf) : shelf_(shelf) { 169 explicit UpdateShelfObserver(ShelfLayoutManager* shelf) : shelf_(shelf) {
170 shelf_->update_shelf_observer_ = this; 170 shelf_->update_shelf_observer_ = this;
171 } 171 }
172 172
173 void Detach() { 173 void Detach() {
174 shelf_ = NULL; 174 shelf_ = NULL;
175 } 175 }
176 176
177 virtual void OnImplicitAnimationsCompleted() OVERRIDE { 177 virtual void OnImplicitAnimationsCompleted() OVERRIDE {
178 if (shelf_) { 178 if (shelf_)
179 shelf_->UpdateShelfBackground(BackgroundAnimator::CHANGE_ANIMATE); 179 shelf_->UpdateShelfBackground(BACKGROUND_CHANGE_ANIMATE);
180 }
181 delete this; 180 delete this;
182 } 181 }
183 182
184 private: 183 private:
185 virtual ~UpdateShelfObserver() { 184 virtual ~UpdateShelfObserver() {
186 if (shelf_) 185 if (shelf_)
187 shelf_->update_shelf_observer_ = NULL; 186 shelf_->update_shelf_observer_ = NULL;
188 } 187 }
189 188
190 // Shelf we're in. NULL if deleted before we're deleted. 189 // Shelf we're in. NULL if deleted before we're deleted.
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 base::TimeDelta::FromMilliseconds(kAutoHideDelayMS), 358 base::TimeDelta::FromMilliseconds(kAutoHideDelayMS),
360 this, &ShelfLayoutManager::UpdateAutoHideStateNow); 359 this, &ShelfLayoutManager::UpdateAutoHideStateNow);
361 } 360 }
362 } else { 361 } else {
363 StopAutoHideTimer(); 362 StopAutoHideTimer();
364 } 363 }
365 } 364 }
366 365
367 void ShelfLayoutManager::SetWindowOverlapsShelf(bool value) { 366 void ShelfLayoutManager::SetWindowOverlapsShelf(bool value) {
368 window_overlaps_shelf_ = value; 367 window_overlaps_shelf_ = value;
369 UpdateShelfBackground(BackgroundAnimator::CHANGE_ANIMATE); 368 UpdateShelfBackground(BACKGROUND_CHANGE_ANIMATE);
370 } 369 }
371 370
372 void ShelfLayoutManager::AddObserver(ShelfLayoutManagerObserver* observer) { 371 void ShelfLayoutManager::AddObserver(ShelfLayoutManagerObserver* observer) {
373 observers_.AddObserver(observer); 372 observers_.AddObserver(observer);
374 } 373 }
375 374
376 void ShelfLayoutManager::RemoveObserver(ShelfLayoutManagerObserver* observer) { 375 void ShelfLayoutManager::RemoveObserver(ShelfLayoutManagerObserver* observer) {
377 observers_.RemoveObserver(observer); 376 observers_.RemoveObserver(observer);
378 } 377 }
379 378
380 //////////////////////////////////////////////////////////////////////////////// 379 ////////////////////////////////////////////////////////////////////////////////
381 // ShelfLayoutManager, Gesture dragging: 380 // ShelfLayoutManager, Gesture dragging:
382 381
383 void ShelfLayoutManager::StartGestureDrag(const ui::GestureEvent& gesture) { 382 void ShelfLayoutManager::StartGestureDrag(const ui::GestureEvent& gesture) {
384 gesture_drag_status_ = GESTURE_DRAG_IN_PROGRESS; 383 gesture_drag_status_ = GESTURE_DRAG_IN_PROGRESS;
385 gesture_drag_amount_ = 0.f; 384 gesture_drag_amount_ = 0.f;
386 gesture_drag_auto_hide_state_ = visibility_state() == SHELF_AUTO_HIDE ? 385 gesture_drag_auto_hide_state_ = visibility_state() == SHELF_AUTO_HIDE ?
387 auto_hide_state() : SHELF_AUTO_HIDE_SHOWN; 386 auto_hide_state() : SHELF_AUTO_HIDE_SHOWN;
388 UpdateShelfBackground(BackgroundAnimator::CHANGE_ANIMATE); 387 UpdateShelfBackground(BACKGROUND_CHANGE_ANIMATE);
389 } 388 }
390 389
391 ShelfLayoutManager::DragState ShelfLayoutManager::UpdateGestureDrag( 390 ShelfLayoutManager::DragState ShelfLayoutManager::UpdateGestureDrag(
392 const ui::GestureEvent& gesture) { 391 const ui::GestureEvent& gesture) {
393 bool horizontal = IsHorizontalAlignment(); 392 bool horizontal = IsHorizontalAlignment();
394 gesture_drag_amount_ += horizontal ? gesture.details().scroll_y() : 393 gesture_drag_amount_ += horizontal ? gesture.details().scroll_y() :
395 gesture.details().scroll_x(); 394 gesture.details().scroll_x();
396 LayoutShelf(); 395 LayoutShelf();
397 396
398 // Start reveling the status menu when: 397 // Start reveling the status menu when:
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
591 auto_hide_event_filter_.reset(new AutoHideEventFilter(this)); 590 auto_hide_event_filter_.reset(new AutoHideEventFilter(this));
592 } else { 591 } else {
593 auto_hide_event_filter_.reset(NULL); 592 auto_hide_event_filter_.reset(NULL);
594 } 593 }
595 594
596 StopAutoHideTimer(); 595 StopAutoHideTimer();
597 596
598 State old_state = state_; 597 State old_state = state_;
599 state_ = state; 598 state_ = state;
600 599
601 BackgroundAnimator::ChangeType change_type = 600 BackgroundAnimatorChangeType change_type = BACKGROUND_CHANGE_ANIMATE;
602 BackgroundAnimator::CHANGE_ANIMATE;
603 bool delay_background_change = false; 601 bool delay_background_change = false;
604 602
605 // Do not animate the background when: 603 // Do not animate the background when:
606 // - Going from a hidden / auto hidden shelf in fullscreen to a visible shelf 604 // - Going from a hidden / auto hidden shelf in fullscreen to a visible shelf
607 // in maximized mode. 605 // in maximized mode.
608 // - Going from an auto hidden shelf in maximized mode to a visible shelf in 606 // - Going from an auto hidden shelf in maximized mode to a visible shelf in
609 // maximized mode. 607 // maximized mode.
610 if (state.visibility_state == SHELF_VISIBLE && 608 if (state.visibility_state == SHELF_VISIBLE &&
611 state.window_state == WORKSPACE_WINDOW_STATE_MAXIMIZED && 609 state.window_state == WORKSPACE_WINDOW_STATE_MAXIMIZED &&
612 old_state.visibility_state != SHELF_VISIBLE) { 610 old_state.visibility_state != SHELF_VISIBLE) {
613 change_type = BackgroundAnimator::CHANGE_IMMEDIATE; 611 change_type = BACKGROUND_CHANGE_IMMEDIATE;
614 } else { 612 } else {
615 // Delay the animation when the shelf was hidden, and has just been made 613 // Delay the animation when the shelf was hidden, and has just been made
616 // visible (e.g. using a gesture-drag). 614 // visible (e.g. using a gesture-drag).
617 if (state.visibility_state == SHELF_VISIBLE && 615 if (state.visibility_state == SHELF_VISIBLE &&
618 old_state.visibility_state == SHELF_AUTO_HIDE && 616 old_state.visibility_state == SHELF_AUTO_HIDE &&
619 old_state.auto_hide_state == SHELF_AUTO_HIDE_HIDDEN) { 617 old_state.auto_hide_state == SHELF_AUTO_HIDE_HIDDEN) {
620 delay_background_change = true; 618 delay_background_change = true;
621 } 619 }
622 } 620 }
623 621
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
923 gfx::Rect status_x = target_bounds->shelf_bounds_in_root; 921 gfx::Rect status_x = target_bounds->shelf_bounds_in_root;
924 status_x.set_x(0); 922 status_x.set_x(0);
925 status_x.ClampToCenteredSize( 923 status_x.ClampToCenteredSize(
926 target_bounds->status_bounds_in_shelf.size()); 924 target_bounds->status_bounds_in_shelf.size());
927 target_bounds->status_bounds_in_shelf.set_x(status_x.x()); 925 target_bounds->status_bounds_in_shelf.set_x(status_x.x());
928 } 926 }
929 } 927 }
930 } 928 }
931 929
932 void ShelfLayoutManager::UpdateShelfBackground( 930 void ShelfLayoutManager::UpdateShelfBackground(
933 BackgroundAnimator::ChangeType type) { 931 BackgroundAnimatorChangeType type) {
934 shelf_->SetPaintsBackground(GetShelfBackgroundType(), type); 932 const ShelfBackgroundType background_type(GetShelfBackgroundType());
933 shelf_->SetPaintsBackground(background_type, type);
934 FOR_EACH_OBSERVER(ShelfLayoutManagerObserver, observers_,
935 OnBackgroundUpdated(background_type, type));
935 } 936 }
936 937
937 ShelfBackgroundType ShelfLayoutManager::GetShelfBackgroundType() const { 938 ShelfBackgroundType ShelfLayoutManager::GetShelfBackgroundType() const {
938 if (state_.visibility_state != SHELF_AUTO_HIDE && 939 if (state_.visibility_state != SHELF_AUTO_HIDE &&
939 state_.window_state == WORKSPACE_WINDOW_STATE_MAXIMIZED) { 940 state_.window_state == WORKSPACE_WINDOW_STATE_MAXIMIZED) {
940 return SHELF_BACKGROUND_MAXIMIZED; 941 return SHELF_BACKGROUND_MAXIMIZED;
941 } 942 }
942 943
943 if (gesture_drag_status_ == GESTURE_DRAG_IN_PROGRESS || 944 if (gesture_drag_status_ == GESTURE_DRAG_IN_PROGRESS ||
944 (!state_.is_screen_locked && window_overlaps_shelf_) || 945 (!state_.is_screen_locked && window_overlaps_shelf_) ||
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
1127 1128
1128 void ShelfLayoutManager::OnDockBoundsChanging( 1129 void ShelfLayoutManager::OnDockBoundsChanging(
1129 const gfx::Rect& dock_bounds, 1130 const gfx::Rect& dock_bounds,
1130 DockedWindowLayoutManagerObserver::Reason reason) { 1131 DockedWindowLayoutManagerObserver::Reason reason) {
1131 // Skip shelf layout in case docked notification originates from this class. 1132 // Skip shelf layout in case docked notification originates from this class.
1132 if (reason == DISPLAY_INSETS_CHANGED) 1133 if (reason == DISPLAY_INSETS_CHANGED)
1133 return; 1134 return;
1134 if (dock_bounds_ != dock_bounds) { 1135 if (dock_bounds_ != dock_bounds) {
1135 dock_bounds_ = dock_bounds; 1136 dock_bounds_ = dock_bounds;
1136 OnWindowResized(); 1137 OnWindowResized();
1138 UpdateShelfBackground(BACKGROUND_CHANGE_ANIMATE);
1137 } 1139 }
1138 } 1140 }
1139 1141
1140 void ShelfLayoutManager::OnLockStateEvent(LockStateObserver::EventType event) { 1142 void ShelfLayoutManager::OnLockStateEvent(LockStateObserver::EventType event) {
1141 if (event == EVENT_LOCK_ANIMATION_STARTED) { 1143 if (event == EVENT_LOCK_ANIMATION_STARTED) {
1142 // Hide the status area widget (using auto hide animation). 1144 // Hide the status area widget (using auto hide animation).
1143 base::AutoReset<ShelfVisibilityState> state(&state_.visibility_state, 1145 base::AutoReset<ShelfVisibilityState> state(&state_.visibility_state,
1144 SHELF_HIDDEN); 1146 SHELF_HIDDEN);
1145 TargetBounds target_bounds; 1147 TargetBounds target_bounds;
1146 CalculateTargetBounds(state_, &target_bounds); 1148 CalculateTargetBounds(state_, &target_bounds);
(...skipping 11 matching lines...) Expand all
1158 return gfx::Insets(0, distance, 0, 0); 1160 return gfx::Insets(0, distance, 0, 0);
1159 case SHELF_ALIGNMENT_TOP: 1161 case SHELF_ALIGNMENT_TOP:
1160 return gfx::Insets(0, 0, distance, 0); 1162 return gfx::Insets(0, 0, distance, 0);
1161 } 1163 }
1162 NOTREACHED(); 1164 NOTREACHED();
1163 return gfx::Insets(); 1165 return gfx::Insets();
1164 } 1166 }
1165 1167
1166 } // namespace internal 1168 } // namespace internal
1167 } // namespace ash 1169 } // namespace ash
OLDNEW
« no previous file with comments | « ash/shelf/shelf_layout_manager.h ('k') | ash/shelf/shelf_layout_manager_observer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698