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

Side by Side Diff: chrome/browser/views/bookmark_bar_view.cc

Issue 12842: Move convolver, image_operations, and skia_utils from base/gfx to skia/ext.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 12 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/importer/importer.cc ('k') | chrome/browser/views/bookmark_manager_view.cc » ('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) 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 "base/gfx/skia_utils.h"
11 #include "chrome/app/theme/theme_resources.h" 10 #include "chrome/app/theme/theme_resources.h"
12 #include "chrome/browser/bookmarks/bookmark_context_menu.h" 11 #include "chrome/browser/bookmarks/bookmark_context_menu.h"
13 #include "chrome/browser/bookmarks/bookmark_utils.h" 12 #include "chrome/browser/bookmarks/bookmark_utils.h"
14 #include "chrome/browser/browser.h" 13 #include "chrome/browser/browser.h"
15 #include "chrome/browser/browser_list.h" 14 #include "chrome/browser/browser_list.h"
16 #include "chrome/browser/browser_process.h" 15 #include "chrome/browser/browser_process.h"
17 #include "chrome/browser/browser_window.h" 16 #include "chrome/browser/browser_window.h"
18 #include "chrome/browser/drag_utils.h" 17 #include "chrome/browser/drag_utils.h"
19 #include "chrome/browser/download/download_util.h" 18 #include "chrome/browser/download/download_util.h"
20 #include "chrome/browser/history/history.h" 19 #include "chrome/browser/history/history.h"
(...skipping 17 matching lines...) Expand all
38 #include "chrome/common/pref_service.h" 37 #include "chrome/common/pref_service.h"
39 #include "chrome/common/resource_bundle.h" 38 #include "chrome/common/resource_bundle.h"
40 #include "chrome/common/win_util.h" 39 #include "chrome/common/win_util.h"
41 #include "chrome/views/chrome_menu.h" 40 #include "chrome/views/chrome_menu.h"
42 #include "chrome/views/menu_button.h" 41 #include "chrome/views/menu_button.h"
43 #include "chrome/views/tooltip_manager.h" 42 #include "chrome/views/tooltip_manager.h"
44 #include "chrome/views/view_constants.h" 43 #include "chrome/views/view_constants.h"
45 #include "chrome/views/widget.h" 44 #include "chrome/views/widget.h"
46 #include "chrome/views/window.h" 45 #include "chrome/views/window.h"
47 #include "generated_resources.h" 46 #include "generated_resources.h"
47 #include "skia/ext/skia_utils.h"
48 48
49 using views::BaseButton; 49 using views::BaseButton;
50 using views::DropTargetEvent; 50 using views::DropTargetEvent;
51 using views::MenuButton; 51 using views::MenuButton;
52 using views::MenuItemView; 52 using views::MenuItemView;
53 using views::View; 53 using views::View;
54 54
55 // Margins around the content. 55 // Margins around the content.
56 static const int kTopMargin = 2; 56 static const int kTopMargin = 2;
57 static const int kBottomMargin = 3; 57 static const int kBottomMargin = 3;
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 static void PaintAnimation(views::View* view, 248 static void PaintAnimation(views::View* view,
249 ChromeCanvas* canvas, 249 ChromeCanvas* canvas,
250 double animation_value) { 250 double animation_value) {
251 // Since we can't change the alpha of the button (it contains un-alphable 251 // Since we can't change the alpha of the button (it contains un-alphable
252 // text), we paint the bar background over the front of the button. As the 252 // text), we paint the bar background over the front of the button. As the
253 // bar background is a gradient, we have to paint the gradient at the 253 // bar background is a gradient, we have to paint the gradient at the
254 // size of the parent (hence all the margin math below). We can't use 254 // size of the parent (hence all the margin math below). We can't use
255 // the parent's actual bounds because they differ from what is painted. 255 // the parent's actual bounds because they differ from what is painted.
256 SkPaint paint; 256 SkPaint paint;
257 paint.setAlpha(static_cast<int>((1.0 - animation_value) * 255)); 257 paint.setAlpha(static_cast<int>((1.0 - animation_value) * 255));
258 paint.setShader(gfx::CreateGradientShader(0, 258 paint.setShader(skia::CreateGradientShader(0,
259 view->height() + kTopMargin + kBottomMargin, 259 view->height() + kTopMargin + kBottomMargin,
260 kTopBorderColor, 260 kTopBorderColor,
261 kBackgroundColor))->safeUnref(); 261 kBackgroundColor))->safeUnref();
262 canvas->FillRectInt(0, -kTopMargin, view->width(), 262 canvas->FillRectInt(0, -kTopMargin, view->width(),
263 view->height() + kTopMargin + kBottomMargin, paint); 263 view->height() + kTopMargin + kBottomMargin, paint);
264 } 264 }
265 265
266 private: 266 private:
267 const GURL& url_; 267 const GURL& url_;
268 Profile* profile_; 268 Profile* profile_;
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
596 596
597 // TODO(sky/glen): this is temporary, need to decide on what this should 597 // TODO(sky/glen): this is temporary, need to decide on what this should
598 // look like. 598 // look like.
599 class ButtonSeparatorView : public views::View { 599 class ButtonSeparatorView : public views::View {
600 public: 600 public:
601 ButtonSeparatorView() {} 601 ButtonSeparatorView() {}
602 virtual ~ButtonSeparatorView() {} 602 virtual ~ButtonSeparatorView() {}
603 603
604 virtual void Paint(ChromeCanvas* canvas) { 604 virtual void Paint(ChromeCanvas* canvas) {
605 SkPaint paint; 605 SkPaint paint;
606 paint.setShader(gfx::CreateGradientShader(0, 606 paint.setShader(skia::CreateGradientShader(0,
607 height() / 2, 607 height() / 2,
608 kTopBorderColor, 608 kTopBorderColor,
609 kSeparatorColor))->safeUnref(); 609 kSeparatorColor))->safeUnref();
610 SkRect rc = {SkIntToScalar(kSeparatorStartX), SkIntToScalar(0), 610 SkRect rc = {SkIntToScalar(kSeparatorStartX), SkIntToScalar(0),
611 SkIntToScalar(1), SkIntToScalar(height() / 2) }; 611 SkIntToScalar(1), SkIntToScalar(height() / 2) };
612 canvas->drawRect(rc, paint); 612 canvas->drawRect(rc, paint);
613 613
614 SkPaint paint_down; 614 SkPaint paint_down;
615 paint_down.setShader(gfx::CreateGradientShader(height() / 2, 615 paint_down.setShader(skia::CreateGradientShader(height() / 2,
616 height(), 616 height(),
617 kSeparatorColor, 617 kSeparatorColor,
618 kBackgroundColor))->safeUnref(); 618 kBackgroundColor))->safeUnref();
619 SkRect rc_down = { 619 SkRect rc_down = {
620 SkIntToScalar(kSeparatorStartX), SkIntToScalar(height() / 2), 620 SkIntToScalar(kSeparatorStartX), SkIntToScalar(height() / 2),
621 SkIntToScalar(1), SkIntToScalar(height() - 1) }; 621 SkIntToScalar(1), SkIntToScalar(height() - 1) };
622 canvas->drawRect(rc_down, paint_down); 622 canvas->drawRect(rc_down, paint_down);
623 } 623 }
624 624
625 virtual gfx::Size GetPreferredSize() { 625 virtual gfx::Size GetPreferredSize() {
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
897 SkDoubleToScalar(v_padding - 0.5), 897 SkDoubleToScalar(v_padding - 0.5),
898 SkDoubleToScalar(width() - h_padding - 0.5), 898 SkDoubleToScalar(width() - h_padding - 0.5),
899 SkDoubleToScalar(height() - v_padding - 0.5)); 899 SkDoubleToScalar(height() - v_padding - 0.5));
900 900
901 double roundness = static_cast<double> 901 double roundness = static_cast<double>
902 (kNewtabBarRoundness) * current_state; 902 (kNewtabBarRoundness) * current_state;
903 903
904 // Draw our background. 904 // Draw our background.
905 SkPaint paint; 905 SkPaint paint;
906 paint.setAntiAlias(true); 906 paint.setAntiAlias(true);
907 paint.setShader(gfx::CreateGradientShader(0, 907 paint.setShader(skia::CreateGradientShader(0,
908 height(), 908 height(),
909 kTopBorderColor, 909 kTopBorderColor,
910 kBackgroundColor))->safeUnref(); 910 kBackgroundColor))->safeUnref();
911 911
912 canvas->drawRoundRect(rect, 912 canvas->drawRoundRect(rect,
913 SkDoubleToScalar(roundness), 913 SkDoubleToScalar(roundness),
914 SkDoubleToScalar(roundness), paint); 914 SkDoubleToScalar(roundness), paint);
915 915
916 // Draw border 916 // Draw border
917 SkPaint border_paint; 917 SkPaint border_paint;
918 border_paint.setColor(kNewtabBorderColor); 918 border_paint.setColor(kNewtabBorderColor);
919 border_paint.setStyle(SkPaint::kStroke_Style); 919 border_paint.setStyle(SkPaint::kStroke_Style);
920 border_paint.setAntiAlias(true); 920 border_paint.setAntiAlias(true);
921 921
922 canvas->drawRoundRect(rect, 922 canvas->drawRoundRect(rect,
923 SkDoubleToScalar(roundness), 923 SkDoubleToScalar(roundness),
924 SkDoubleToScalar(roundness), border_paint); 924 SkDoubleToScalar(roundness), border_paint);
925 } else { 925 } else {
926 SkPaint paint; 926 SkPaint paint;
927 paint.setShader(gfx::CreateGradientShader(0, 927 paint.setShader(skia::CreateGradientShader(0,
928 height(), 928 height(),
929 kTopBorderColor, 929 kTopBorderColor,
930 kBackgroundColor))->safeUnref(); 930 kBackgroundColor))->safeUnref();
931 canvas->FillRectInt(0, 0, width(), height(), paint); 931 canvas->FillRectInt(0, 0, width(), height(), paint);
932 932
933 canvas->FillRectInt(kTopBorderColor, 0, 0, width(), 1); 933 canvas->FillRectInt(kTopBorderColor, 0, 0, width(), 1);
934 canvas->FillRectInt(kBottomBorderColor, 0, height() - 1, width(), 1); 934 canvas->FillRectInt(kBottomBorderColor, 0, height() - 1, width(), 1);
935 } 935 }
936 } 936 }
937 937
938 void BookmarkBarView::PaintChildren(ChromeCanvas* canvas) { 938 void BookmarkBarView::PaintChildren(ChromeCanvas* canvas) {
939 View::PaintChildren(canvas); 939 View::PaintChildren(canvas);
940 940
(...skipping 896 matching lines...) Expand 10 before | Expand all | Expand 10 after
1837 } 1837 }
1838 1838
1839 void BookmarkBarView::StopThrobbing(bool immediate) { 1839 void BookmarkBarView::StopThrobbing(bool immediate) {
1840 if (!throbbing_view_) 1840 if (!throbbing_view_)
1841 return; 1841 return;
1842 1842
1843 // If not immediate, cycle through 2 more complete cycles. 1843 // If not immediate, cycle through 2 more complete cycles.
1844 throbbing_view_->StartThrobbing(immediate ? 0 : 4); 1844 throbbing_view_->StartThrobbing(immediate ? 0 : 4);
1845 throbbing_view_ = NULL; 1845 throbbing_view_ = NULL;
1846 } 1846 }
OLDNEW
« no previous file with comments | « chrome/browser/importer/importer.cc ('k') | chrome/browser/views/bookmark_manager_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698