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 "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h" | 5 #include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
413 int y; | 413 int y; |
414 | 414 |
415 // DropData for the drop. | 415 // DropData for the drop. |
416 BookmarkNodeData data; | 416 BookmarkNodeData data; |
417 | 417 |
418 DropLocation location; | 418 DropLocation location; |
419 }; | 419 }; |
420 | 420 |
421 // ButtonSeparatorView -------------------------------------------------------- | 421 // ButtonSeparatorView -------------------------------------------------------- |
422 | 422 |
| 423 // Paints a themed gradient divider at location |x|. |height| is the full |
| 424 // height of the view you want to paint the divider into, not the height of |
| 425 // the divider. The height of the divider will become: |
| 426 // |height| - 2 * |vertical_padding|. |
| 427 // The color of the divider is a gradient starting with |top_color| at the |
| 428 // top, and changing into |middle_color| and then over to |bottom_color| as |
| 429 // you go further down. |
| 430 void PaintVerticalDivider(gfx::Canvas* canvas, |
| 431 int x, |
| 432 int height, |
| 433 int vertical_padding, |
| 434 SkColor top_color, |
| 435 SkColor middle_color, |
| 436 SkColor bottom_color) { |
| 437 // Draw the upper half of the divider. |
| 438 SkPaint paint; |
| 439 skia::RefPtr<SkShader> shader = gfx::CreateGradientShader( |
| 440 vertical_padding + 1, height / 2, top_color, middle_color); |
| 441 paint.setShader(shader.get()); |
| 442 SkRect rc = { SkIntToScalar(x), |
| 443 SkIntToScalar(vertical_padding + 1), |
| 444 SkIntToScalar(x + 1), |
| 445 SkIntToScalar(height / 2) }; |
| 446 canvas->sk_canvas()->drawRect(rc, paint); |
| 447 |
| 448 // Draw the lower half of the divider. |
| 449 SkPaint paint_down; |
| 450 shader = gfx::CreateGradientShader( |
| 451 height / 2, height - vertical_padding, middle_color, bottom_color); |
| 452 paint_down.setShader(shader.get()); |
| 453 SkRect rc_down = { SkIntToScalar(x), |
| 454 SkIntToScalar(height / 2), |
| 455 SkIntToScalar(x + 1), |
| 456 SkIntToScalar(height - vertical_padding) }; |
| 457 canvas->sk_canvas()->drawRect(rc_down, paint_down); |
| 458 } |
| 459 |
423 class BookmarkBarView::ButtonSeparatorView : public views::View { | 460 class BookmarkBarView::ButtonSeparatorView : public views::View { |
424 public: | 461 public: |
425 ButtonSeparatorView() {} | 462 ButtonSeparatorView() {} |
426 ~ButtonSeparatorView() override {} | 463 ~ButtonSeparatorView() override {} |
427 | 464 |
428 void OnPaint(gfx::Canvas* canvas) override { | 465 void OnPaint(gfx::Canvas* canvas) override { |
429 DetachableToolbarView::PaintVerticalDivider( | 466 PaintVerticalDivider( |
430 canvas, | 467 canvas, |
431 kSeparatorStartX, | 468 kSeparatorStartX, |
432 height(), | 469 height(), |
433 1, | 470 1, |
434 kEdgeDividerColor, | 471 kEdgeDividerColor, |
435 kMiddleDividerColor, | 472 kMiddleDividerColor, |
436 GetThemeProvider()->GetColor(ThemeProperties::COLOR_TOOLBAR)); | 473 GetThemeProvider()->GetColor(ThemeProperties::COLOR_TOOLBAR)); |
437 } | 474 } |
438 | 475 |
439 gfx::Size GetPreferredSize() const override { | 476 gfx::Size GetPreferredSize() const override { |
(...skipping 1520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1960 return; | 1997 return; |
1961 apps_page_shortcut_->SetVisible(visible); | 1998 apps_page_shortcut_->SetVisible(visible); |
1962 UpdateBookmarksSeparatorVisibility(); | 1999 UpdateBookmarksSeparatorVisibility(); |
1963 LayoutAndPaint(); | 2000 LayoutAndPaint(); |
1964 } | 2001 } |
1965 | 2002 |
1966 void BookmarkBarView::OnShowManagedBookmarksPrefChanged() { | 2003 void BookmarkBarView::OnShowManagedBookmarksPrefChanged() { |
1967 if (UpdateOtherAndManagedButtonsVisibility()) | 2004 if (UpdateOtherAndManagedButtonsVisibility()) |
1968 LayoutAndPaint(); | 2005 LayoutAndPaint(); |
1969 } | 2006 } |
OLD | NEW |