| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/ui/views/infobars/infobar_container_view.h" | 5 #include "chrome/browser/ui/views/infobars/infobar_container_view.h" |
| 6 | 6 |
| 7 #include "cc/paint/paint_flags.h" | 7 #include "cc/paint/paint_flags.h" |
| 8 #include "cc/paint/paint_shader.h" | 8 #include "cc/paint/paint_shader.h" |
| 9 #include "chrome/browser/ui/infobar_container_delegate.h" | 9 #include "chrome/browser/ui/infobar_container_delegate.h" |
| 10 #include "chrome/browser/ui/view_ids.h" | 10 #include "chrome/browser/ui/view_ids.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 ContentShadow() { | 30 ContentShadow() { |
| 31 SetPaintToLayer(); | 31 SetPaintToLayer(); |
| 32 layer()->SetFillsBoundsOpaquely(false); | 32 layer()->SetFillsBoundsOpaquely(false); |
| 33 } | 33 } |
| 34 ~ContentShadow() override {} | 34 ~ContentShadow() override {} |
| 35 | 35 |
| 36 protected: | 36 protected: |
| 37 // views::View: | 37 // views::View: |
| 38 void OnPaint(gfx::Canvas* canvas) override { | 38 void OnPaint(gfx::Canvas* canvas) override { |
| 39 // The first shader (small shadow) blurs from 0 to kSmallShadowHeight. | 39 // The first shader (small shadow) blurs from 0 to kSmallShadowHeight. |
| 40 cc::PaintFlags paint; | 40 cc::PaintFlags flags; |
| 41 paint.setShader(gfx::CreateGradientShader( | 41 flags.setShader(gfx::CreateGradientShader( |
| 42 0, kSmallShadowHeight, SkColorSetA(SK_ColorBLACK, kSmallShadowAlpha), | 42 0, kSmallShadowHeight, SkColorSetA(SK_ColorBLACK, kSmallShadowAlpha), |
| 43 SkColorSetA(SK_ColorBLACK, SK_AlphaTRANSPARENT))); | 43 SkColorSetA(SK_ColorBLACK, SK_AlphaTRANSPARENT))); |
| 44 gfx::Rect small_shadow_bounds = GetLocalBounds(); | 44 gfx::Rect small_shadow_bounds = GetLocalBounds(); |
| 45 small_shadow_bounds.set_height(kSmallShadowHeight); | 45 small_shadow_bounds.set_height(kSmallShadowHeight); |
| 46 canvas->DrawRect(small_shadow_bounds, paint); | 46 canvas->DrawRect(small_shadow_bounds, flags); |
| 47 | 47 |
| 48 // The second shader (large shadow) is solid from 0 to kSmallShadowHeight | 48 // The second shader (large shadow) is solid from 0 to kSmallShadowHeight |
| 49 // (blending with the first shader) and then blurs from kSmallShadowHeight | 49 // (blending with the first shader) and then blurs from kSmallShadowHeight |
| 50 // to kLargeShadowHeight. | 50 // to kLargeShadowHeight. |
| 51 paint.setShader(gfx::CreateGradientShader( | 51 flags.setShader(gfx::CreateGradientShader( |
| 52 kSmallShadowHeight, height(), | 52 kSmallShadowHeight, height(), |
| 53 SkColorSetA(SK_ColorBLACK, kLargeShadowAlpha), | 53 SkColorSetA(SK_ColorBLACK, kLargeShadowAlpha), |
| 54 SkColorSetA(SK_ColorBLACK, SK_AlphaTRANSPARENT))); | 54 SkColorSetA(SK_ColorBLACK, SK_AlphaTRANSPARENT))); |
| 55 canvas->DrawRect(GetLocalBounds(), paint); | 55 canvas->DrawRect(GetLocalBounds(), flags); |
| 56 } | 56 } |
| 57 | 57 |
| 58 private: | 58 private: |
| 59 DISALLOW_COPY_AND_ASSIGN(ContentShadow); | 59 DISALLOW_COPY_AND_ASSIGN(ContentShadow); |
| 60 }; | 60 }; |
| 61 | 61 |
| 62 } // namespace | 62 } // namespace |
| 63 | 63 |
| 64 // static | 64 // static |
| 65 const char InfoBarContainerView::kViewClassName[] = "InfoBarContainerView"; | 65 const char InfoBarContainerView::kViewClassName[] = "InfoBarContainerView"; |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 infobars::InfoBar* infobar, | 126 infobars::InfoBar* infobar, |
| 127 size_t position) { | 127 size_t position) { |
| 128 AddChildViewAt(static_cast<InfoBarView*>(infobar), | 128 AddChildViewAt(static_cast<InfoBarView*>(infobar), |
| 129 static_cast<int>(position)); | 129 static_cast<int>(position)); |
| 130 } | 130 } |
| 131 | 131 |
| 132 void InfoBarContainerView::PlatformSpecificRemoveInfoBar( | 132 void InfoBarContainerView::PlatformSpecificRemoveInfoBar( |
| 133 infobars::InfoBar* infobar) { | 133 infobars::InfoBar* infobar) { |
| 134 RemoveChildView(static_cast<InfoBarView*>(infobar)); | 134 RemoveChildView(static_cast<InfoBarView*>(infobar)); |
| 135 } | 135 } |
| OLD | NEW |