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

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

Issue 149741: Allow the tiling of theme background images on the NTP.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 5 months 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/views/bookmark_bar_view.h ('k') | no next file » | 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 "app/gfx/canvas.h" 9 #include "app/gfx/canvas.h"
10 #include "app/gfx/text_elider.h" 10 #include "app/gfx/text_elider.h"
(...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after
555 } 555 }
556 556
557 void BookmarkBarView::Paint(gfx::Canvas* canvas) { 557 void BookmarkBarView::Paint(gfx::Canvas* canvas) {
558 if (IsDetachedStyle()) { 558 if (IsDetachedStyle()) {
559 // Draw the background to match the new tab page. 559 // Draw the background to match the new tab page.
560 ThemeProvider* tp = GetThemeProvider(); 560 ThemeProvider* tp = GetThemeProvider();
561 canvas->FillRectInt( 561 canvas->FillRectInt(
562 tp->GetColor(BrowserThemeProvider::COLOR_NTP_BACKGROUND), 562 tp->GetColor(BrowserThemeProvider::COLOR_NTP_BACKGROUND),
563 0, 0, width(), height()); 563 0, 0, width(), height());
564 564
565 int alignment; 565 if (tp->HasCustomImage(IDR_THEME_NTP_BACKGROUND)) {
566 if (tp->GetDisplayProperty(BrowserThemeProvider::NTP_BACKGROUND_ALIGNMENT, 566 int tiling = BrowserThemeProvider::NO_REPEAT;
567 &alignment)) { 567 tp->GetDisplayProperty(BrowserThemeProvider::NTP_BACKGROUND_TILING,
568 if (alignment & BrowserThemeProvider::ALIGN_TOP) { 568 &tiling);
569 SkBitmap* ntp_background = tp->GetBitmapNamed(IDR_THEME_NTP_BACKGROUND); 569 int alignment;
570 if (tp->GetDisplayProperty(BrowserThemeProvider::NTP_BACKGROUND_ALIGNMENT,
571 &alignment)) {
572 SkBitmap* ntp_background = tp->GetBitmapNamed(
573 IDR_THEME_NTP_BACKGROUND);
570 574
571 if (alignment & BrowserThemeProvider::ALIGN_LEFT) { 575 if (alignment & BrowserThemeProvider::ALIGN_TOP) {
572 canvas->DrawBitmapInt(*ntp_background, 0, 0); 576 PaintThemeBackgroundTopAligned(
573 } else if (alignment & BrowserThemeProvider::ALIGN_RIGHT) { 577 canvas, ntp_background, tiling, alignment);
574 canvas->DrawBitmapInt(*ntp_background, width() -
575 ntp_background->width(), 0);
576 } else { 578 } else {
577 canvas->DrawBitmapInt(*ntp_background, width() / 2- 579 PaintThemeBackgroundBottomAligned(
578 ntp_background->width() / 2, 0); 580 canvas, ntp_background, tiling, alignment);
579 } 581 }
580 } 582 }
581 } 583 }
582 584
583 // Draw the 'bottom' of the toolbar above our bubble. 585 // Draw the 'bottom' of the toolbar above our bubble.
584 canvas->FillRectInt(ResourceBundle::toolbar_separator_color, 586 canvas->FillRectInt(ResourceBundle::toolbar_separator_color,
585 0, 0, width(), 1); 587 0, 0, width(), 1);
586 588
587 SkRect rect; 589 SkRect rect;
588 590
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
628 630
629 canvas->TileImageInt(*GetThemeProvider()-> 631 canvas->TileImageInt(*GetThemeProvider()->
630 GetBitmapNamed(IDR_THEME_TOOLBAR), 632 GetBitmapNamed(IDR_THEME_TOOLBAR),
631 GetParent()->GetBounds(views::View::APPLY_MIRRORING_TRANSFORMATION).x() 633 GetParent()->GetBounds(views::View::APPLY_MIRRORING_TRANSFORMATION).x()
632 + bounds.x(), bounds.y(), 0, 0, width(), height()); 634 + bounds.x(), bounds.y(), 0, 0, width(), height());
633 canvas->FillRectInt(ResourceBundle::toolbar_separator_color, 635 canvas->FillRectInt(ResourceBundle::toolbar_separator_color,
634 0, height() - 1, width(), 1); 636 0, height() - 1, width(), 1);
635 } 637 }
636 } 638 }
637 639
640 void BookmarkBarView::PaintThemeBackgroundTopAligned(gfx::Canvas* canvas,
641 SkBitmap* ntp_background, int tiling, int alignment) {
642
643 if (alignment & BrowserThemeProvider::ALIGN_LEFT) {
644 if (tiling == BrowserThemeProvider::REPEAT)
645 canvas->TileImageInt(*ntp_background, 0, 0, width(), height());
646 else if (tiling == BrowserThemeProvider::REPEAT_X)
647 canvas->TileImageInt(*ntp_background, 0, 0, width(),
648 ntp_background->height());
649 else
650 canvas->TileImageInt(*ntp_background, 0, 0,
651 ntp_background->width(), ntp_background->height());
652
653 } else if (alignment & BrowserThemeProvider::ALIGN_RIGHT) {
654 int x_pos = width() % ntp_background->width() - ntp_background->width();
655 if (tiling == BrowserThemeProvider::REPEAT)
656 canvas->TileImageInt(*ntp_background, x_pos, 0,
657 width() + ntp_background->width(), height());
658 else if (tiling == BrowserThemeProvider::REPEAT_X)
659 canvas->TileImageInt(*ntp_background, x_pos,
660 0, width() + ntp_background->width(), ntp_background->height());
661 else
662 canvas->TileImageInt(*ntp_background, width() - ntp_background->width(),
663 0, ntp_background->width(), ntp_background->height());
664
665 } else { // ALIGN == CENTER
666 int x_pos = width() > ntp_background->width() ?
667 ((width() / 2 - ntp_background->width() / 2) %
668 ntp_background->width()) - ntp_background->width() :
669 width() / 2 - ntp_background->width() / 2;
670 if (tiling == BrowserThemeProvider::REPEAT)
671 canvas->TileImageInt(*ntp_background, x_pos, 0,
672 width() + ntp_background->width(), height());
673 else if (tiling == BrowserThemeProvider::REPEAT_X)
674 canvas->TileImageInt(*ntp_background, x_pos, 0,
675 width() + ntp_background->width(),
676 ntp_background->height());
677 else
678 canvas->TileImageInt(*ntp_background,
679 width() / 2 - ntp_background->width() / 2,
680 0, ntp_background->width(), ntp_background->height());
681 }
682 }
683
684 void BookmarkBarView::PaintThemeBackgroundBottomAligned(gfx::Canvas* canvas,
685 SkBitmap* ntp_background, int tiling, int alignment) {
686 int browser_height = GetParent()->GetBounds(
687 views::View::APPLY_MIRRORING_TRANSFORMATION).height();
688 int border_width = 5;
689 int y_pos = ((tiling == BrowserThemeProvider::REPEAT_X) ||
690 (tiling == BrowserThemeProvider::NO_REPEAT)) ?
691 browser_height - ntp_background->height() - height() - border_width :
692 browser_height % ntp_background->height() - height() - border_width -
693 ntp_background->height();
694
695 if (alignment & BrowserThemeProvider::ALIGN_LEFT) {
696 if (tiling == BrowserThemeProvider::REPEAT)
697 canvas->TileImageInt(*ntp_background, 0, y_pos, width(),
698 2 * height() + ntp_background->height() + 5);
699 else if (tiling == BrowserThemeProvider::REPEAT_X)
700 canvas->TileImageInt(*ntp_background, 0, y_pos, width(),
701 ntp_background->height());
702 else if (tiling == BrowserThemeProvider::REPEAT_Y)
703 canvas->TileImageInt(*ntp_background, 0, y_pos,
704 ntp_background->width(),
705 2 * height() + ntp_background->height() + 5);
706 else
707 canvas->TileImageInt(*ntp_background, 0, y_pos, ntp_background->width(),
708 ntp_background->height());
709
710 } else if (alignment & BrowserThemeProvider::ALIGN_RIGHT) {
711 int x_pos = width() % ntp_background->width() - ntp_background->width();
712 if (tiling == BrowserThemeProvider::REPEAT)
713 canvas->TileImageInt(*ntp_background, x_pos, y_pos,
714 width() + ntp_background->width(),
715 2 * height() + ntp_background->height() + 5);
716 else if (tiling == BrowserThemeProvider::REPEAT_X)
717 canvas->TileImageInt(*ntp_background, x_pos, y_pos,
718 width() + ntp_background->width(), ntp_background->height());
719 else if (tiling == BrowserThemeProvider::REPEAT_Y)
720 canvas->TileImageInt(*ntp_background, width() - ntp_background->width(),
721 y_pos, ntp_background->width(),
722 2 * height() + ntp_background->height() + 5);
723 else
724 canvas->TileImageInt(*ntp_background, width() - ntp_background->width(),
725 y_pos, ntp_background->width(), ntp_background->height());
726
727 } else { // ALIGN == CENTER
728 int x_pos = width() > ntp_background->width() ?
729 ((width() / 2 - ntp_background->width() / 2) %
730 ntp_background->width()) - ntp_background->width() :
731 width() / 2 - ntp_background->width() / 2;
732 if (tiling == BrowserThemeProvider::REPEAT)
733 canvas->TileImageInt(*ntp_background, x_pos, y_pos,
734 width() + ntp_background->width(),
735 2 * height() + ntp_background->height() + 5);
736 else if (tiling == BrowserThemeProvider::REPEAT_X)
737 canvas->TileImageInt(*ntp_background, x_pos, y_pos,
738 width() + ntp_background->width(), ntp_background->height());
739 else if (tiling == BrowserThemeProvider::REPEAT_Y)
740 canvas->TileImageInt(*ntp_background,
741 width() / 2 - ntp_background->width() / 2,
742 y_pos, ntp_background->width(),
743 2 * height() + ntp_background->height() + 5);
744 else
745 canvas->TileImageInt(*ntp_background,
746 width() / 2 - ntp_background->width() / 2,
747 y_pos, ntp_background->width(), ntp_background->height());
748 }
749 }
750
638 void BookmarkBarView::PaintChildren(gfx::Canvas* canvas) { 751 void BookmarkBarView::PaintChildren(gfx::Canvas* canvas) {
639 View::PaintChildren(canvas); 752 View::PaintChildren(canvas);
640 753
641 if (drop_info_.get() && drop_info_->valid && 754 if (drop_info_.get() && drop_info_->valid &&
642 drop_info_->drag_operation != 0 && drop_info_->drop_index != -1 && 755 drop_info_->drag_operation != 0 && drop_info_->drop_index != -1 &&
643 !drop_info_->is_over_overflow && !drop_info_->drop_on) { 756 !drop_info_->is_over_overflow && !drop_info_->drop_on) {
644 int index = drop_info_->drop_index; 757 int index = drop_info_->drop_index;
645 DCHECK(index <= GetBookmarkButtonCount()); 758 DCHECK(index <= GetBookmarkButtonCount());
646 int x = 0; 759 int x = 0;
647 int y = 0; 760 int y = 0;
(...skipping 928 matching lines...) Expand 10 before | Expand all | Expand 10 after
1576 } 1689 }
1577 1690
1578 void BookmarkBarView::StopThrobbing(bool immediate) { 1691 void BookmarkBarView::StopThrobbing(bool immediate) {
1579 if (!throbbing_view_) 1692 if (!throbbing_view_)
1580 return; 1693 return;
1581 1694
1582 // If not immediate, cycle through 2 more complete cycles. 1695 // If not immediate, cycle through 2 more complete cycles.
1583 throbbing_view_->StartThrobbing(immediate ? 0 : 4); 1696 throbbing_view_->StartThrobbing(immediate ? 0 : 4);
1584 throbbing_view_ = NULL; 1697 throbbing_view_ = NULL;
1585 } 1698 }
OLDNEW
« no previous file with comments | « chrome/browser/views/bookmark_bar_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698