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

Unified Diff: ash/shelf/shelf_widget.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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/shelf/shelf_widget.h ('k') | ash/system/tray/tray_background_view.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/shelf/shelf_widget.cc
diff --git a/ash/shelf/shelf_widget.cc b/ash/shelf/shelf_widget.cc
index 8dc737ab542a732fc0d6b0bb960921e0854449a8..a4de02568014d0cd8d18e6c3232d2b82513d661b 100644
--- a/ash/shelf/shelf_widget.cc
+++ b/ash/shelf/shelf_widget.cc
@@ -46,7 +46,6 @@ const int kDimAlpha = 128;
// The time to dim and un-dim.
const int kTimeToDimMs = 3000; // Slow in dimming.
const int kTimeToUnDimMs = 200; // Fast in activating.
-const int kTimeToSwitchBackgroundMs = 1000;
// Class used to slightly dim shelf items when maximized and visible.
class DimmerView : public views::View,
@@ -145,7 +144,7 @@ DimmerView::DimmerView(ash::ShelfWidget* shelf_widget,
// Make sure it is undimmed at the beginning and then fire off the dimming
// animation.
background_animator_.SetPaintsBackground(false,
- ash::internal::BackgroundAnimator::CHANGE_IMMEDIATE);
+ ash::BACKGROUND_CHANGE_IMMEDIATE);
SetHovered(false);
}
@@ -161,8 +160,7 @@ void DimmerView::SetHovered(bool hovered) {
background_animator_.SetDuration(hovered ? kTimeToUnDimMs : kTimeToDimMs);
background_animator_.SetPaintsBackground(!hovered,
disable_dimming_animations_for_test_ ?
- ash::internal::BackgroundAnimator::CHANGE_IMMEDIATE :
- ash::internal::BackgroundAnimator::CHANGE_ANIMATE);
+ ash::BACKGROUND_CHANGE_IMMEDIATE : ash::BACKGROUND_CHANGE_ANIMATE);
}
void DimmerView::ForceUndimming(bool force) {
@@ -391,22 +389,55 @@ void ShelfWidget::DelegateView::OnPaintBackground(gfx::Canvas* canvas) {
SkBitmapOperations::ROTATION_90_CW,
SkBitmapOperations::ROTATION_270_CW,
SkBitmapOperations::ROTATION_180_CW));
-
- gfx::Rect black_rect =
- shelf_->shelf_layout_manager()->SelectValueForShelfAlignment(
- gfx::Rect(0, height() - kNumBlackPixels, width(), kNumBlackPixels),
- gfx::Rect(0, 0, kNumBlackPixels, height()),
- gfx::Rect(width() - kNumBlackPixels, 0, kNumBlackPixels, height()),
- gfx::Rect(0, 0, width(), kNumBlackPixels));
-
+ const gfx::Rect dock_bounds(shelf_->shelf_layout_manager()->dock_bounds());
SkPaint paint;
paint.setAlpha(alpha_);
canvas->DrawImageInt(
launcher_background,
0, 0, launcher_background.width(), launcher_background.height(),
- 0, 0, width(), height(),
+ (SHELF_ALIGNMENT_BOTTOM == shelf_->GetAlignment() &&
+ dock_bounds.x() == 0 && dock_bounds.width() > 0) ?
+ dock_bounds.width() : 0, 0,
+ SHELF_ALIGNMENT_BOTTOM == shelf_->GetAlignment() ?
+ width() - dock_bounds.width() : width(), height(),
false,
paint);
+ if (SHELF_ALIGNMENT_BOTTOM == shelf_->GetAlignment() &&
+ dock_bounds.width() > 0) {
+ // The part of the shelf background that is in the corner below the docked
+ // windows close to the work area is an arched gradient that blends
+ // vertically oriented docked background and horizontal shelf.
+ gfx::ImageSkia launcher_corner =
+ *rb.GetImageSkiaNamed(IDR_AURA_LAUNCHER_CORNER);
+ if (dock_bounds.x() == 0) {
+ launcher_corner = gfx::ImageSkiaOperations::CreateRotatedImage(
+ launcher_corner, SkBitmapOperations::ROTATION_90_CW);
+ }
+ canvas->DrawImageInt(
+ launcher_corner,
+ 0, 0, launcher_corner.width(), launcher_corner.height(),
+ dock_bounds.x() > 0 ? dock_bounds.x() : dock_bounds.width() - height(),
+ 0,
+ height(), height(),
+ false,
+ paint);
+ // The part of the shelf background that is just below the docked windows
+ // is drawn using the last (lowest) 1-pixel tall strip of the image asset.
+ // This avoids showing the border 3D shadow between the shelf and the dock.
+ canvas->DrawImageInt(
+ launcher_background,
+ 0, launcher_background.height() - 1, launcher_background.width(), 1,
+ dock_bounds.x() > 0 ? dock_bounds.x() + height() : 0, 0,
+ dock_bounds.width() - height(), height(),
+ false,
+ paint);
+ }
+ gfx::Rect black_rect =
+ shelf_->shelf_layout_manager()->SelectValueForShelfAlignment(
+ gfx::Rect(0, height() - kNumBlackPixels, width(), kNumBlackPixels),
+ gfx::Rect(0, 0, kNumBlackPixels, height()),
+ gfx::Rect(width() - kNumBlackPixels, 0, kNumBlackPixels, height()),
+ gfx::Rect(0, 0, width(), kNumBlackPixels));
canvas->FillRect(black_rect, SK_ColorBLACK);
}
@@ -521,12 +552,12 @@ ShelfWidget::~ShelfWidget() {
void ShelfWidget::SetPaintsBackground(
ShelfBackgroundType background_type,
- internal::BackgroundAnimator::ChangeType change_type) {
+ BackgroundAnimatorChangeType change_type) {
ui::Layer* opaque_background = delegate_view_->opaque_background();
float target_opacity =
(background_type == SHELF_BACKGROUND_MAXIMIZED) ? 1.0f : 0.0f;
scoped_ptr<ui::ScopedLayerAnimationSettings> opaque_background_animation;
- if (change_type != internal::BackgroundAnimator::CHANGE_IMMEDIATE) {
+ if (change_type != BACKGROUND_CHANGE_IMMEDIATE) {
opaque_background_animation.reset(new ui::ScopedLayerAnimationSettings(
opaque_background->GetAnimator()));
opaque_background_animation->SetTransitionDuration(
@@ -536,9 +567,11 @@ void ShelfWidget::SetPaintsBackground(
// TODO(mukai): use ui::Layer on both opaque_background and normal background
// retire background_animator_ at all. It would be simpler.
+ // See also DockedBackgroundWidget::SetPaintsBackground.
background_animator_.SetPaintsBackground(
background_type != SHELF_BACKGROUND_DEFAULT,
change_type);
+ delegate_view_->SchedulePaint();
}
ShelfBackgroundType ShelfWidget::GetBackgroundType() const {
« no previous file with comments | « ash/shelf/shelf_widget.h ('k') | ash/system/tray/tray_background_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698