| OLD | NEW | 
|    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 "ui/wm/core/shadow.h" |    5 #include "ui/wm/core/shadow.h" | 
|    6  |    6  | 
|    7 #include "grit/ui_resources.h" |    7 #include "grit/ui_resources.h" | 
|    8 #include "ui/base/resource/resource_bundle.h" |    8 #include "ui/base/resource/resource_bundle.h" | 
|    9 #include "ui/compositor/scoped_layer_animation_settings.h" |    9 #include "ui/compositor/scoped_layer_animation_settings.h" | 
|   10 #include "ui/wm/core/image_grid.h" |   10 #include "ui/wm/core/image_grid.h" | 
|   11  |   11  | 
|   12 namespace { |   12 namespace { | 
|   13  |   13  | 
|   14 // Shadow opacity for different styles. |   14 // Shadow opacity for different styles. | 
|   15 const float kActiveShadowOpacity = 1.0f; |   15 const float kActiveShadowOpacity = 1.0f; | 
|   16 const float kInactiveShadowOpacity = 0.2f; |   16 const float kInactiveShadowOpacity = 0.2f; | 
|   17 const float kSmallShadowOpacity = 1.0f; |   17 const float kSmallShadowOpacity = 1.0f; | 
|   18  |   18  | 
|   19 // Interior inset for different styles. |   19 // Interior inset for different styles. | 
|   20 const int kActiveInteriorInset = 0; |   20 const int kActiveInteriorInset = 0; | 
|   21 const int kInactiveInteriorInset = 0; |   21 const int kInactiveInteriorInset = 0; | 
|   22 const int kSmallInteriorInset = 5; |   22 const int kSmallInteriorInset = 5; | 
|   23  |   23  | 
|   24 // Duration for opacity animation in milliseconds. |   24 // Duration for opacity animation in milliseconds. | 
|   25 const int kShadowAnimationDurationMs = 100; |   25 const int kShadowAnimationDurationMs = 100; | 
|   26  |   26  | 
|   27 float GetOpacityForStyle(views::corewm::Shadow::Style style) { |   27 float GetOpacityForStyle(wm::Shadow::Style style) { | 
|   28   switch (style) { |   28   switch (style) { | 
|   29     case views::corewm::Shadow::STYLE_ACTIVE: |   29     case wm::Shadow::STYLE_ACTIVE: | 
|   30       return kActiveShadowOpacity; |   30       return kActiveShadowOpacity; | 
|   31     case views::corewm::Shadow::STYLE_INACTIVE: |   31     case wm::Shadow::STYLE_INACTIVE: | 
|   32       return kInactiveShadowOpacity; |   32       return kInactiveShadowOpacity; | 
|   33     case views::corewm::Shadow::STYLE_SMALL: |   33     case wm::Shadow::STYLE_SMALL: | 
|   34       return kSmallShadowOpacity; |   34       return kSmallShadowOpacity; | 
|   35   } |   35   } | 
|   36   return 1.0f; |   36   return 1.0f; | 
|   37 } |   37 } | 
|   38  |   38  | 
|   39 int GetInteriorInsetForStyle(views::corewm::Shadow::Style style) { |   39 int GetInteriorInsetForStyle(wm::Shadow::Style style) { | 
|   40   switch (style) { |   40   switch (style) { | 
|   41     case views::corewm::Shadow::STYLE_ACTIVE: |   41     case wm::Shadow::STYLE_ACTIVE: | 
|   42       return kActiveInteriorInset; |   42       return kActiveInteriorInset; | 
|   43     case views::corewm::Shadow::STYLE_INACTIVE: |   43     case wm::Shadow::STYLE_INACTIVE: | 
|   44       return kInactiveInteriorInset; |   44       return kInactiveInteriorInset; | 
|   45     case views::corewm::Shadow::STYLE_SMALL: |   45     case wm::Shadow::STYLE_SMALL: | 
|   46       return kSmallInteriorInset; |   46       return kSmallInteriorInset; | 
|   47   } |   47   } | 
|   48   return 0; |   48   return 0; | 
|   49 } |   49 } | 
|   50  |   50  | 
|   51 }  // namespace |   51 }  // namespace | 
|   52  |   52  | 
|   53 namespace views { |   53 namespace wm { | 
|   54 namespace corewm { |  | 
|   55  |   54  | 
|   56 Shadow::Shadow() : style_(STYLE_ACTIVE), interior_inset_(0) { |   55 Shadow::Shadow() : style_(STYLE_ACTIVE), interior_inset_(0) { | 
|   57 } |   56 } | 
|   58  |   57  | 
|   59 Shadow::~Shadow() { |   58 Shadow::~Shadow() { | 
|   60 } |   59 } | 
|   61  |   60  | 
|   62 void Shadow::Init(Style style) { |   61 void Shadow::Init(Style style) { | 
|   63   style_ = style; |   62   style_ = style; | 
|   64   image_grid_.reset(new ImageGrid); |   63   image_grid_.reset(new ImageGrid); | 
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  184   UpdateImageGridBounds(); |  183   UpdateImageGridBounds(); | 
|  185 } |  184 } | 
|  186  |  185  | 
|  187 void Shadow::UpdateImageGridBounds() { |  186 void Shadow::UpdateImageGridBounds() { | 
|  188   // Update bounds based on content bounds and image sizes. |  187   // Update bounds based on content bounds and image sizes. | 
|  189   gfx::Rect image_grid_bounds = content_bounds_; |  188   gfx::Rect image_grid_bounds = content_bounds_; | 
|  190   image_grid_bounds.Inset(interior_inset_, interior_inset_); |  189   image_grid_bounds.Inset(interior_inset_, interior_inset_); | 
|  191   image_grid_->SetContentBounds(image_grid_bounds); |  190   image_grid_->SetContentBounds(image_grid_bounds); | 
|  192 } |  191 } | 
|  193  |  192  | 
|  194 }  // namespace corewm |  193 }  // namespace wm | 
|  195 }  // namespace views |  | 
| OLD | NEW |