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

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

Issue 10453101: Convert most of the rest of chrome to ImageSkia (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 6 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
OLDNEW
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 <set> 9 #include <set>
10 #include <vector> 10 #include <vector>
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 static const int kRightMargin = 1; 87 static const int kRightMargin = 1;
88 88
89 // static 89 // static
90 const char BookmarkBarView::kViewClassName[] = 90 const char BookmarkBarView::kViewClassName[] =
91 "browser/ui/views/bookmarks/BookmarkBarView"; 91 "browser/ui/views/bookmarks/BookmarkBarView";
92 92
93 // Padding between buttons. 93 // Padding between buttons.
94 static const int kButtonPadding = 0; 94 static const int kButtonPadding = 0;
95 95
96 // Icon to display when one isn't found for the page. 96 // Icon to display when one isn't found for the page.
97 static SkBitmap* kDefaultFavicon = NULL; 97 static gfx::ImageSkia* kDefaultFavicon = NULL;
98 98
99 // Icon used for folders. 99 // Icon used for folders.
100 static SkBitmap* kFolderIcon = NULL; 100 static gfx::ImageSkia* kFolderIcon = NULL;
101 101
102 // Offset for where the menu is shown relative to the bottom of the 102 // Offset for where the menu is shown relative to the bottom of the
103 // BookmarkBarView. 103 // BookmarkBarView.
104 static const int kMenuOffset = 3; 104 static const int kMenuOffset = 3;
105 105
106 // Color of the drop indicator. 106 // Color of the drop indicator.
107 static const SkColor kDropIndicatorColor = SK_ColorBLACK; 107 static const SkColor kDropIndicatorColor = SK_ColorBLACK;
108 108
109 // Width of the drop indicator. 109 // Width of the drop indicator.
110 static const int kDropIndicatorWidth = 2; 110 static const int kDropIndicatorWidth = 2;
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 // BookmarkBarView ------------------------------------------------------------ 351 // BookmarkBarView ------------------------------------------------------------
352 352
353 // static 353 // static
354 const int BookmarkBarView::kMaxButtonWidth = 150; 354 const int BookmarkBarView::kMaxButtonWidth = 150;
355 const int BookmarkBarView::kNewtabHorizontalPadding = 8; 355 const int BookmarkBarView::kNewtabHorizontalPadding = 8;
356 const int BookmarkBarView::kNewtabVerticalPadding = 12; 356 const int BookmarkBarView::kNewtabVerticalPadding = 12;
357 357
358 // static 358 // static
359 bool BookmarkBarView::testing_ = false; 359 bool BookmarkBarView::testing_ = false;
360 360
361 // Returns the bitmap to use for starred folders. 361 // Returns the image to use for starred folders.
362 static const SkBitmap& GetFolderIcon() { 362 static const gfx::ImageSkia& GetFolderIcon() {
363 if (!kFolderIcon) { 363 if (!kFolderIcon) {
364 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 364 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
365 kFolderIcon = rb.GetBitmapNamed(IDR_BOOKMARK_BAR_FOLDER); 365 kFolderIcon = rb.GetImageSkiaNamed(IDR_BOOKMARK_BAR_FOLDER);
366 } 366 }
367 return *kFolderIcon; 367 return *kFolderIcon;
368 } 368 }
369 369
370 BookmarkBarView::BookmarkBarView(Browser* browser) 370 BookmarkBarView::BookmarkBarView(Browser* browser)
371 : page_navigator_(NULL), 371 : page_navigator_(NULL),
372 model_(NULL), 372 model_(NULL),
373 bookmark_menu_(NULL), 373 bookmark_menu_(NULL),
374 bookmark_drop_menu_(NULL), 374 bookmark_drop_menu_(NULL),
375 other_bookmarked_button_(NULL), 375 other_bookmarked_button_(NULL),
(...skipping 737 matching lines...) Expand 10 before | Expand all | Expand 10 after
1113 1113
1114 void BookmarkBarView::Init() { 1114 void BookmarkBarView::Init() {
1115 // Note that at this point we're not in a hierarchy so GetThemeProvider() will 1115 // Note that at this point we're not in a hierarchy so GetThemeProvider() will
1116 // return NULL. When we're inserted into a hierarchy, we'll call 1116 // return NULL. When we're inserted into a hierarchy, we'll call
1117 // UpdateColors(), which will set the appropriate colors for all the objects 1117 // UpdateColors(), which will set the appropriate colors for all the objects
1118 // added in this function. 1118 // added in this function.
1119 1119
1120 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 1120 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
1121 1121
1122 if (!kDefaultFavicon) 1122 if (!kDefaultFavicon)
1123 kDefaultFavicon = rb.GetBitmapNamed(IDR_DEFAULT_FAVICON); 1123 kDefaultFavicon = rb.GetImageSkiaNamed(IDR_DEFAULT_FAVICON);
1124 1124
1125 // Child views are traversed in the order they are added. Make sure the order 1125 // Child views are traversed in the order they are added. Make sure the order
1126 // they are added matches the visual order. 1126 // they are added matches the visual order.
1127 overflow_button_ = CreateOverflowButton(); 1127 overflow_button_ = CreateOverflowButton();
1128 AddChildView(overflow_button_); 1128 AddChildView(overflow_button_);
1129 1129
1130 other_bookmarked_button_ = CreateOtherBookmarkedButton(); 1130 other_bookmarked_button_ = CreateOtherBookmarkedButton();
1131 // We'll re-enable when the model is loaded. 1131 // We'll re-enable when the model is loaded.
1132 other_bookmarked_button_->SetEnabled(false); 1132 other_bookmarked_button_->SetEnabled(false);
1133 AddChildView(other_bookmarked_button_); 1133 AddChildView(other_bookmarked_button_);
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1188 button->set_id(VIEW_ID_OTHER_BOOKMARKS); 1188 button->set_id(VIEW_ID_OTHER_BOOKMARKS);
1189 button->SetIcon(GetFolderIcon()); 1189 button->SetIcon(GetFolderIcon());
1190 button->set_context_menu_controller(this); 1190 button->set_context_menu_controller(this);
1191 button->set_tag(kOtherFolderButtonTag); 1191 button->set_tag(kOtherFolderButtonTag);
1192 return button; 1192 return button;
1193 } 1193 }
1194 1194
1195 MenuButton* BookmarkBarView::CreateOverflowButton() { 1195 MenuButton* BookmarkBarView::CreateOverflowButton() {
1196 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 1196 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
1197 MenuButton* button = new OverFlowButton(this); 1197 MenuButton* button = new OverFlowButton(this);
1198 button->SetIcon(*rb.GetBitmapNamed(IDR_BOOKMARK_BAR_CHEVRONS)); 1198 button->SetIcon(*rb.GetImageSkiaNamed(IDR_BOOKMARK_BAR_CHEVRONS));
1199 1199
1200 // The overflow button's image contains an arrow and therefore it is a 1200 // The overflow button's image contains an arrow and therefore it is a
1201 // direction sensitive image and we need to flip it if the UI layout is 1201 // direction sensitive image and we need to flip it if the UI layout is
1202 // right-to-left. 1202 // right-to-left.
1203 // 1203 //
1204 // By default, menu buttons are not flipped because they generally contain 1204 // By default, menu buttons are not flipped because they generally contain
1205 // text and flipping the gfx::Canvas object will break text rendering. Since 1205 // text and flipping the gfx::Canvas object will break text rendering. Since
1206 // the overflow button does not contain text, we can safely flip it. 1206 // the overflow button does not contain text, we can safely flip it.
1207 button->EnableCanvasFlippingForRTLUI(true); 1207 button->EnableCanvasFlippingForRTLUI(true);
1208 1208
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after
1670 (1 - size_animation_->GetCurrentValue()))); 1670 (1 - size_animation_->GetCurrentValue())));
1671 } else { 1671 } else {
1672 prefsize.set_height( 1672 prefsize.set_height(
1673 static_cast<int>( 1673 static_cast<int>(
1674 browser_defaults::kBookmarkBarHeight * 1674 browser_defaults::kBookmarkBarHeight *
1675 size_animation_->GetCurrentValue())); 1675 size_animation_->GetCurrentValue()));
1676 } 1676 }
1677 } 1677 }
1678 return prefsize; 1678 return prefsize;
1679 } 1679 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/avatar_menu_button.cc ('k') | chrome/browser/ui/views/bookmarks/bookmark_menu_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698