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

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

Issue 113443: ChromeCanvas->gfx::Canvas (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 7 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') | chrome/browser/views/bookmark_bubble_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 "app/gfx/chrome_canvas.h" 9 #include "app/gfx/canvas.h"
10 #include "app/gfx/text_elider.h" 10 #include "app/gfx/text_elider.h"
11 #include "app/l10n_util.h" 11 #include "app/l10n_util.h"
12 #include "app/os_exchange_data.h" 12 #include "app/os_exchange_data.h"
13 #include "app/resource_bundle.h" 13 #include "app/resource_bundle.h"
14 #include "app/win_util.h" 14 #include "app/win_util.h"
15 #include "base/string_util.h" 15 #include "base/string_util.h"
16 #include "base/base_drag_source.h" 16 #include "base/base_drag_source.h"
17 #include "chrome/browser/bookmarks/bookmark_context_menu.h" 17 #include "chrome/browser/bookmarks/bookmark_context_menu.h"
18 #include "chrome/browser/bookmarks/bookmark_utils.h" 18 #include "chrome/browser/bookmarks/bookmark_utils.h"
19 #include "chrome/browser/browser.h" 19 #include "chrome/browser/browser.h"
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 show_animation_->Show(); 249 show_animation_->Show();
250 } 250 }
251 } 251 }
252 252
253 virtual bool IsTriggerableEvent(const views::MouseEvent& e) { 253 virtual bool IsTriggerableEvent(const views::MouseEvent& e) {
254 // This is hard coded to avoid potential notification on left mouse down, 254 // This is hard coded to avoid potential notification on left mouse down,
255 // which we want to show the menu. 255 // which we want to show the menu.
256 return e.IsMiddleMouseButton(); 256 return e.IsMiddleMouseButton();
257 } 257 }
258 258
259 virtual void Paint(ChromeCanvas *canvas) { 259 virtual void Paint(gfx::Canvas *canvas) {
260 views::MenuButton::Paint(canvas, false); 260 views::MenuButton::Paint(canvas, false);
261 } 261 }
262 262
263 private: 263 private:
264 scoped_ptr<SlideAnimation> show_animation_; 264 scoped_ptr<SlideAnimation> show_animation_;
265 265
266 DISALLOW_COPY_AND_ASSIGN(BookmarkFolderButton); 266 DISALLOW_COPY_AND_ASSIGN(BookmarkFolderButton);
267 }; 267 };
268 268
269 // DropInfo ------------------------------------------------------------------- 269 // DropInfo -------------------------------------------------------------------
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 BookmarkDragData data; 303 BookmarkDragData data;
304 }; 304 };
305 305
306 // ButtonSeparatorView -------------------------------------------------------- 306 // ButtonSeparatorView --------------------------------------------------------
307 307
308 class ButtonSeparatorView : public views::View { 308 class ButtonSeparatorView : public views::View {
309 public: 309 public:
310 ButtonSeparatorView() {} 310 ButtonSeparatorView() {}
311 virtual ~ButtonSeparatorView() {} 311 virtual ~ButtonSeparatorView() {}
312 312
313 virtual void Paint(ChromeCanvas* canvas) { 313 virtual void Paint(gfx::Canvas* canvas) {
314 SkPaint paint; 314 SkPaint paint;
315 paint.setShader(skia::CreateGradientShader(0, 315 paint.setShader(skia::CreateGradientShader(0,
316 height() / 2, 316 height() / 2,
317 kTopBorderColor, 317 kTopBorderColor,
318 kSeparatorColor))->safeUnref(); 318 kSeparatorColor))->safeUnref();
319 SkRect rc = {SkIntToScalar(kSeparatorStartX), SkIntToScalar(0), 319 SkRect rc = {SkIntToScalar(kSeparatorStartX), SkIntToScalar(0),
320 SkIntToScalar(1), SkIntToScalar(height() / 2) }; 320 SkIntToScalar(1), SkIntToScalar(height() / 2) };
321 canvas->drawRect(rc, paint); 321 canvas->drawRect(rc, paint);
322 322
323 SkPaint paint_down; 323 SkPaint paint_down;
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 View* parent, 547 View* parent,
548 View* child) { 548 View* child) {
549 if (is_add && child == this && height() > 0) { 549 if (is_add && child == this && height() > 0) {
550 // We only layout while parented. When we become parented, if our bounds 550 // We only layout while parented. When we become parented, if our bounds
551 // haven't changed, DidChangeBounds won't get invoked and we won't layout. 551 // haven't changed, DidChangeBounds won't get invoked and we won't layout.
552 // Therefore we always force a layout when added. 552 // Therefore we always force a layout when added.
553 Layout(); 553 Layout();
554 } 554 }
555 } 555 }
556 556
557 void BookmarkBarView::Paint(ChromeCanvas* 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 canvas->FillRectInt(kNewtabBackgroundColor, 0, 0, width(), height()); 560 canvas->FillRectInt(kNewtabBackgroundColor, 0, 0, width(), height());
561 561
562 // Draw the 'bottom' of the toolbar above our bubble. 562 // Draw the 'bottom' of the toolbar above our bubble.
563 canvas->FillRectInt(ResourceBundle::toolbar_separator_color, 563 canvas->FillRectInt(ResourceBundle::toolbar_separator_color,
564 0, 0, width(), 1); 564 0, 0, width(), 1);
565 565
566 SkRect rect; 566 SkRect rect;
567 567
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
609 609
610 // +1 is for toolbar outdent. 610 // +1 is for toolbar outdent.
611 canvas->TileImageInt(*GetThemeProvider()-> 611 canvas->TileImageInt(*GetThemeProvider()->
612 GetBitmapNamed(IDR_THEME_TOOLBAR), 612 GetBitmapNamed(IDR_THEME_TOOLBAR),
613 bounds.x() + 1, bounds.y(), 0, 0, width(), height()); 613 bounds.x() + 1, bounds.y(), 0, 0, width(), height());
614 canvas->FillRectInt(ResourceBundle::toolbar_separator_color, 614 canvas->FillRectInt(ResourceBundle::toolbar_separator_color,
615 0, height() - 1, width(), 1); 615 0, height() - 1, width(), 1);
616 } 616 }
617 } 617 }
618 618
619 void BookmarkBarView::PaintChildren(ChromeCanvas* canvas) { 619 void BookmarkBarView::PaintChildren(gfx::Canvas* canvas) {
620 View::PaintChildren(canvas); 620 View::PaintChildren(canvas);
621 621
622 if (drop_info_.get() && drop_info_->valid && 622 if (drop_info_.get() && drop_info_->valid &&
623 drop_info_->drag_operation != 0 && drop_info_->drop_index != -1 && 623 drop_info_->drag_operation != 0 && drop_info_->drop_index != -1 &&
624 !drop_info_->is_over_overflow && !drop_info_->drop_on) { 624 !drop_info_->is_over_overflow && !drop_info_->drop_on) {
625 int index = drop_info_->drop_index; 625 int index = drop_info_->drop_index;
626 DCHECK(index <= GetBookmarkButtonCount()); 626 DCHECK(index <= GetBookmarkButtonCount());
627 int x = 0; 627 int x = 0;
628 int y = 0; 628 int y = 0;
629 int h = height(); 629 int h = height();
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
885 MenuButton* BookmarkBarView::CreateOverflowButton() { 885 MenuButton* BookmarkBarView::CreateOverflowButton() {
886 MenuButton* button = new MenuButton(NULL, std::wstring(), this, false); 886 MenuButton* button = new MenuButton(NULL, std::wstring(), this, false);
887 button->SetIcon(*ResourceBundle::GetSharedInstance(). 887 button->SetIcon(*ResourceBundle::GetSharedInstance().
888 GetBitmapNamed(IDR_BOOKMARK_BAR_CHEVRONS)); 888 GetBitmapNamed(IDR_BOOKMARK_BAR_CHEVRONS));
889 889
890 // The overflow button's image contains an arrow and therefore it is a 890 // The overflow button's image contains an arrow and therefore it is a
891 // direction sensitive image and we need to flip it if the UI layout is 891 // direction sensitive image and we need to flip it if the UI layout is
892 // right-to-left. 892 // right-to-left.
893 // 893 //
894 // By default, menu buttons are not flipped because they generally contain 894 // By default, menu buttons are not flipped because they generally contain
895 // text and flipping the ChromeCanvas object will break text rendering. Since 895 // text and flipping the gfx::Canvas object will break text rendering. Since
896 // the overflow button does not contain text, we can safely flip it. 896 // the overflow button does not contain text, we can safely flip it.
897 button->EnableCanvasFlippingForRTLUI(true); 897 button->EnableCanvasFlippingForRTLUI(true);
898 898
899 // Make visible as necessary. 899 // Make visible as necessary.
900 button->SetVisible(false); 900 button->SetVisible(false);
901 return button; 901 return button;
902 } 902 }
903 903
904 int BookmarkBarView::GetBookmarkButtonCount() { 904 int BookmarkBarView::GetBookmarkButtonCount() {
905 // We contain at least four non-bookmark button views: recently bookmarked, 905 // We contain at least four non-bookmark button views: recently bookmarked,
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
1046 1046
1047 void BookmarkBarView::WriteDragData(View* sender, 1047 void BookmarkBarView::WriteDragData(View* sender,
1048 int press_x, 1048 int press_x,
1049 int press_y, 1049 int press_y,
1050 OSExchangeData* data) { 1050 OSExchangeData* data) {
1051 UserMetrics::RecordAction(L"BookmarkBar_DragButton", profile_); 1051 UserMetrics::RecordAction(L"BookmarkBar_DragButton", profile_);
1052 1052
1053 for (int i = 0; i < GetBookmarkButtonCount(); ++i) { 1053 for (int i = 0; i < GetBookmarkButtonCount(); ++i) {
1054 if (sender == GetBookmarkButton(i)) { 1054 if (sender == GetBookmarkButton(i)) {
1055 views::TextButton* button = GetBookmarkButton(i); 1055 views::TextButton* button = GetBookmarkButton(i);
1056 ChromeCanvas canvas(button->width(), button->height(), false); 1056 gfx::Canvas canvas(button->width(), button->height(), false);
1057 button->Paint(&canvas, true); 1057 button->Paint(&canvas, true);
1058 drag_utils::SetDragImageOnDataObject(canvas, button->width(), 1058 drag_utils::SetDragImageOnDataObject(canvas, button->width(),
1059 button->height(), press_x, 1059 button->height(), press_x,
1060 press_y, data); 1060 press_y, data);
1061 WriteDragData(model_->GetBookmarkBarNode()->GetChild(i), data); 1061 WriteDragData(model_->GetBookmarkBarNode()->GetChild(i), data);
1062 return; 1062 return;
1063 } 1063 }
1064 } 1064 }
1065 NOTREACHED(); 1065 NOTREACHED();
1066 } 1066 }
(...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after
1532 } 1532 }
1533 1533
1534 void BookmarkBarView::StopThrobbing(bool immediate) { 1534 void BookmarkBarView::StopThrobbing(bool immediate) {
1535 if (!throbbing_view_) 1535 if (!throbbing_view_)
1536 return; 1536 return;
1537 1537
1538 // If not immediate, cycle through 2 more complete cycles. 1538 // If not immediate, cycle through 2 more complete cycles.
1539 throbbing_view_->StartThrobbing(immediate ? 0 : 4); 1539 throbbing_view_->StartThrobbing(immediate ? 0 : 4);
1540 throbbing_view_ = NULL; 1540 throbbing_view_ = NULL;
1541 } 1541 }
OLDNEW
« no previous file with comments | « chrome/browser/views/bookmark_bar_view.h ('k') | chrome/browser/views/bookmark_bubble_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698