| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/views/bookmark_bar_view.h" | 5 #include "chrome/browser/views/bookmark_bar_view.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "base/base_drag_source.h" | 9 #include "base/base_drag_source.h" |
| 10 #include "chrome/app/theme/theme_resources.h" | 10 #include "chrome/app/theme/theme_resources.h" |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 static void PaintAnimation(views::View* view, | 252 static void PaintAnimation(views::View* view, |
| 253 ChromeCanvas* canvas, | 253 ChromeCanvas* canvas, |
| 254 double animation_value) { | 254 double animation_value) { |
| 255 // Since we can't change the alpha of the button (it contains un-alphable | 255 // Since we can't change the alpha of the button (it contains un-alphable |
| 256 // text), we paint the bar background over the front of the button. As the | 256 // text), we paint the bar background over the front of the button. As the |
| 257 // bar background is a gradient, we have to paint the gradient at the | 257 // bar background is a gradient, we have to paint the gradient at the |
| 258 // size of the parent (hence all the margin math below). We can't use | 258 // size of the parent (hence all the margin math below). We can't use |
| 259 // the parent's actual bounds because they differ from what is painted. | 259 // the parent's actual bounds because they differ from what is painted. |
| 260 SkPaint paint; | 260 SkPaint paint; |
| 261 paint.setAlpha(static_cast<int>((1.0 - animation_value) * 255)); | 261 paint.setAlpha(static_cast<int>((1.0 - animation_value) * 255)); |
| 262 paint.setShader(gfx::CreateGradientShader(0, | 262 paint.setShader(skia::CreateGradientShader(0, |
| 263 view->height() + kTopMargin + kBottomMargin, | 263 view->height() + kTopMargin + kBottomMargin, |
| 264 kTopBorderColor, | 264 kTopBorderColor, |
| 265 kBackgroundColor))->safeUnref(); | 265 kBackgroundColor))->safeUnref(); |
| 266 canvas->FillRectInt(0, -kTopMargin, view->width(), | 266 canvas->FillRectInt(0, -kTopMargin, view->width(), |
| 267 view->height() + kTopMargin + kBottomMargin, paint); | 267 view->height() + kTopMargin + kBottomMargin, paint); |
| 268 } | 268 } |
| 269 | 269 |
| 270 private: | 270 private: |
| 271 const GURL& url_; | 271 const GURL& url_; |
| 272 Profile* profile_; | 272 Profile* profile_; |
| (...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 600 | 600 |
| 601 // TODO(sky/glen): this is temporary, need to decide on what this should | 601 // TODO(sky/glen): this is temporary, need to decide on what this should |
| 602 // look like. | 602 // look like. |
| 603 class ButtonSeparatorView : public views::View { | 603 class ButtonSeparatorView : public views::View { |
| 604 public: | 604 public: |
| 605 ButtonSeparatorView() {} | 605 ButtonSeparatorView() {} |
| 606 virtual ~ButtonSeparatorView() {} | 606 virtual ~ButtonSeparatorView() {} |
| 607 | 607 |
| 608 virtual void Paint(ChromeCanvas* canvas) { | 608 virtual void Paint(ChromeCanvas* canvas) { |
| 609 SkPaint paint; | 609 SkPaint paint; |
| 610 paint.setShader(gfx::CreateGradientShader(0, | 610 paint.setShader(skia::CreateGradientShader(0, |
| 611 height() / 2, | 611 height() / 2, |
| 612 kTopBorderColor, | 612 kTopBorderColor, |
| 613 kSeparatorColor))->safeUnref(); | 613 kSeparatorColor))->safeUnref(); |
| 614 SkRect rc = {SkIntToScalar(kSeparatorStartX), SkIntToScalar(0), | 614 SkRect rc = {SkIntToScalar(kSeparatorStartX), SkIntToScalar(0), |
| 615 SkIntToScalar(1), SkIntToScalar(height() / 2) }; | 615 SkIntToScalar(1), SkIntToScalar(height() / 2) }; |
| 616 canvas->drawRect(rc, paint); | 616 canvas->drawRect(rc, paint); |
| 617 | 617 |
| 618 SkPaint paint_down; | 618 SkPaint paint_down; |
| 619 paint_down.setShader(gfx::CreateGradientShader(height() / 2, | 619 paint_down.setShader(skia::CreateGradientShader(height() / 2, |
| 620 height(), | 620 height(), |
| 621 kSeparatorColor, | 621 kSeparatorColor, |
| 622 kBackgroundColor))->safeUnref(); | 622 kBackgroundColor))->safeUnref(); |
| 623 SkRect rc_down = { | 623 SkRect rc_down = { |
| 624 SkIntToScalar(kSeparatorStartX), SkIntToScalar(height() / 2), | 624 SkIntToScalar(kSeparatorStartX), SkIntToScalar(height() / 2), |
| 625 SkIntToScalar(1), SkIntToScalar(height() - 1) }; | 625 SkIntToScalar(1), SkIntToScalar(height() - 1) }; |
| 626 canvas->drawRect(rc_down, paint_down); | 626 canvas->drawRect(rc_down, paint_down); |
| 627 } | 627 } |
| 628 | 628 |
| 629 virtual gfx::Size GetPreferredSize() { | 629 virtual gfx::Size GetPreferredSize() { |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 901 SkDoubleToScalar(v_padding - 0.5), | 901 SkDoubleToScalar(v_padding - 0.5), |
| 902 SkDoubleToScalar(width() - h_padding - 0.5), | 902 SkDoubleToScalar(width() - h_padding - 0.5), |
| 903 SkDoubleToScalar(height() - v_padding - 0.5)); | 903 SkDoubleToScalar(height() - v_padding - 0.5)); |
| 904 | 904 |
| 905 double roundness = static_cast<double> | 905 double roundness = static_cast<double> |
| 906 (kNewtabBarRoundness) * current_state; | 906 (kNewtabBarRoundness) * current_state; |
| 907 | 907 |
| 908 // Draw our background. | 908 // Draw our background. |
| 909 SkPaint paint; | 909 SkPaint paint; |
| 910 paint.setAntiAlias(true); | 910 paint.setAntiAlias(true); |
| 911 paint.setShader(gfx::CreateGradientShader(0, | 911 paint.setShader(skia::CreateGradientShader(0, |
| 912 height(), | 912 height(), |
| 913 kTopBorderColor, | 913 kTopBorderColor, |
| 914 kBackgroundColor))->safeUnref(); | 914 kBackgroundColor))->safeUnref(); |
| 915 | 915 |
| 916 canvas->drawRoundRect(rect, | 916 canvas->drawRoundRect(rect, |
| 917 SkDoubleToScalar(roundness), | 917 SkDoubleToScalar(roundness), |
| 918 SkDoubleToScalar(roundness), paint); | 918 SkDoubleToScalar(roundness), paint); |
| 919 | 919 |
| 920 // Draw border | 920 // Draw border |
| 921 SkPaint border_paint; | 921 SkPaint border_paint; |
| 922 border_paint.setColor(kNewtabBorderColor); | 922 border_paint.setColor(kNewtabBorderColor); |
| 923 border_paint.setStyle(SkPaint::kStroke_Style); | 923 border_paint.setStyle(SkPaint::kStroke_Style); |
| 924 border_paint.setAntiAlias(true); | 924 border_paint.setAntiAlias(true); |
| 925 | 925 |
| 926 canvas->drawRoundRect(rect, | 926 canvas->drawRoundRect(rect, |
| 927 SkDoubleToScalar(roundness), | 927 SkDoubleToScalar(roundness), |
| 928 SkDoubleToScalar(roundness), border_paint); | 928 SkDoubleToScalar(roundness), border_paint); |
| 929 } else { | 929 } else { |
| 930 SkPaint paint; | 930 SkPaint paint; |
| 931 paint.setShader(gfx::CreateGradientShader(0, | 931 paint.setShader(skia::CreateGradientShader(0, |
| 932 height(), | 932 height(), |
| 933 kTopBorderColor, | 933 kTopBorderColor, |
| 934 kBackgroundColor))->safeUnref(); | 934 kBackgroundColor))->safeUnref(); |
| 935 canvas->FillRectInt(0, 0, width(), height(), paint); | 935 canvas->FillRectInt(0, 0, width(), height(), paint); |
| 936 | 936 |
| 937 canvas->FillRectInt(kTopBorderColor, 0, 0, width(), 1); | 937 canvas->FillRectInt(kTopBorderColor, 0, 0, width(), 1); |
| 938 canvas->FillRectInt(kBottomBorderColor, 0, height() - 1, width(), 1); | 938 canvas->FillRectInt(kBottomBorderColor, 0, height() - 1, width(), 1); |
| 939 } | 939 } |
| 940 } | 940 } |
| 941 | 941 |
| 942 void BookmarkBarView::PaintChildren(ChromeCanvas* canvas) { | 942 void BookmarkBarView::PaintChildren(ChromeCanvas* canvas) { |
| 943 View::PaintChildren(canvas); | 943 View::PaintChildren(canvas); |
| 944 | 944 |
| (...skipping 900 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1845 } | 1845 } |
| 1846 | 1846 |
| 1847 void BookmarkBarView::StopThrobbing(bool immediate) { | 1847 void BookmarkBarView::StopThrobbing(bool immediate) { |
| 1848 if (!throbbing_view_) | 1848 if (!throbbing_view_) |
| 1849 return; | 1849 return; |
| 1850 | 1850 |
| 1851 // If not immediate, cycle through 2 more complete cycles. | 1851 // If not immediate, cycle through 2 more complete cycles. |
| 1852 throbbing_view_->StartThrobbing(immediate ? 0 : 4); | 1852 throbbing_view_->StartThrobbing(immediate ? 0 : 4); |
| 1853 throbbing_view_ = NULL; | 1853 throbbing_view_ = NULL; |
| 1854 } | 1854 } |
| OLD | NEW |