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

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

Issue 6334152: Clean up RTL methods.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 10 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/bookmark_bar_view.h" 5 #include "chrome/browser/ui/views/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 489 matching lines...) Expand 10 before | Expand all | Expand 10 after
500 y = GetBookmarkButton(0)->y(); 500 y = GetBookmarkButton(0)->y();
501 h = GetBookmarkButton(0)->height(); 501 h = GetBookmarkButton(0)->height();
502 } 502 }
503 503
504 // Since the drop indicator is painted directly onto the canvas, we must 504 // Since the drop indicator is painted directly onto the canvas, we must
505 // make sure it is painted in the right location if the locale is RTL. 505 // make sure it is painted in the right location if the locale is RTL.
506 gfx::Rect indicator_bounds(x - kDropIndicatorWidth / 2, 506 gfx::Rect indicator_bounds(x - kDropIndicatorWidth / 2,
507 y, 507 y,
508 kDropIndicatorWidth, 508 kDropIndicatorWidth,
509 h); 509 h);
510 indicator_bounds.set_x(MirroredLeftPointForRect(indicator_bounds)); 510 indicator_bounds.set_x(GetMirroredXForRect(indicator_bounds));
511 511
512 // TODO(sky/glen): make me pretty! 512 // TODO(sky/glen): make me pretty!
513 canvas->FillRectInt(kDropIndicatorColor, indicator_bounds.x(), 513 canvas->FillRectInt(kDropIndicatorColor, indicator_bounds.x(),
514 indicator_bounds.y(), indicator_bounds.width(), 514 indicator_bounds.y(), indicator_bounds.width(),
515 indicator_bounds.height()); 515 indicator_bounds.height());
516 } 516 }
517 } 517 }
518 518
519 bool BookmarkBarView::GetDropFormats( 519 bool BookmarkBarView::GetDropFormats(
520 int* formats, 520 int* formats,
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
770 return bookmark_drop_menu_ ? bookmark_drop_menu_->menu() : NULL; 770 return bookmark_drop_menu_ ? bookmark_drop_menu_->menu() : NULL;
771 } 771 }
772 772
773 const BookmarkNode* BookmarkBarView::GetNodeForButtonAt(const gfx::Point& loc, 773 const BookmarkNode* BookmarkBarView::GetNodeForButtonAt(const gfx::Point& loc,
774 int* start_index) { 774 int* start_index) {
775 *start_index = 0; 775 *start_index = 0;
776 776
777 if (loc.x() < 0 || loc.x() >= width() || loc.y() < 0 || loc.y() >= height()) 777 if (loc.x() < 0 || loc.x() >= width() || loc.y() < 0 || loc.y() >= height())
778 return NULL; 778 return NULL;
779 779
780 gfx::Point adjusted_loc(MirroredXCoordinateInsideView(loc.x()), loc.y()); 780 gfx::Point adjusted_loc(GetMirroredXInView(loc.x()), loc.y());
781 781
782 // Check the buttons first. 782 // Check the buttons first.
783 for (int i = 0; i < GetBookmarkButtonCount(); ++i) { 783 for (int i = 0; i < GetBookmarkButtonCount(); ++i) {
784 views::View* child = GetChildViewAt(i); 784 views::View* child = GetChildViewAt(i);
785 if (!child->IsVisible()) 785 if (!child->IsVisible())
786 break; 786 break;
787 if (child->bounds().Contains(adjusted_loc)) 787 if (child->bounds().Contains(adjusted_loc))
788 return model_->GetBookmarkBarNode()->GetChild(i); 788 return model_->GetBookmarkBarNode()->GetChild(i);
789 } 789 }
790 790
(...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after
1371 bool* is_over_other) { 1371 bool* is_over_other) {
1372 DCHECK(model_); 1372 DCHECK(model_);
1373 DCHECK(model_->IsLoaded()); 1373 DCHECK(model_->IsLoaded());
1374 DCHECK(data.is_valid()); 1374 DCHECK(data.is_valid());
1375 1375
1376 // The drop event uses the screen coordinates while the child Views are 1376 // The drop event uses the screen coordinates while the child Views are
1377 // always laid out from left to right (even though they are rendered from 1377 // always laid out from left to right (even though they are rendered from
1378 // right-to-left on RTL locales). Thus, in order to make sure the drop 1378 // right-to-left on RTL locales). Thus, in order to make sure the drop
1379 // coordinates calculation works, we mirror the event's X coordinate if the 1379 // coordinates calculation works, we mirror the event's X coordinate if the
1380 // locale is RTL. 1380 // locale is RTL.
1381 int mirrored_x = MirroredXCoordinateInsideView(event.x()); 1381 int mirrored_x = GetMirroredXInView(event.x());
1382 1382
1383 *index = -1; 1383 *index = -1;
1384 *drop_on = false; 1384 *drop_on = false;
1385 *is_over_other = *is_over_overflow = false; 1385 *is_over_other = *is_over_overflow = false;
1386 1386
1387 if (event.y() < other_bookmarked_button_->y() || 1387 if (event.y() < other_bookmarked_button_->y() ||
1388 event.y() >= other_bookmarked_button_->y() + 1388 event.y() >= other_bookmarked_button_->y() +
1389 other_bookmarked_button_->height()) { 1389 other_bookmarked_button_->height()) {
1390 // Mouse isn't over a button. 1390 // Mouse isn't over a button.
1391 return ui::DragDropTypes::DRAG_NONE; 1391 return ui::DragDropTypes::DRAG_NONE;
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
1739 // The tooltip is the only way we have to display text explaining the error 1739 // The tooltip is the only way we have to display text explaining the error
1740 // to the user. 1740 // to the user.
1741 sync_error_button->SetTooltipText( 1741 sync_error_button->SetTooltipText(
1742 UTF16ToWide(l10n_util::GetStringUTF16(IDS_SYNC_BOOKMARK_BAR_ERROR_DESC))); 1742 UTF16ToWide(l10n_util::GetStringUTF16(IDS_SYNC_BOOKMARK_BAR_ERROR_DESC)));
1743 sync_error_button->SetAccessibleName( 1743 sync_error_button->SetAccessibleName(
1744 l10n_util::GetStringUTF16(IDS_ACCNAME_SYNC_ERROR_BUTTON)); 1744 l10n_util::GetStringUTF16(IDS_ACCNAME_SYNC_ERROR_BUTTON));
1745 sync_error_button->SetIcon( 1745 sync_error_button->SetIcon(
1746 *ResourceBundle::GetSharedInstance().GetBitmapNamed(IDR_WARNING)); 1746 *ResourceBundle::GetSharedInstance().GetBitmapNamed(IDR_WARNING));
1747 return sync_error_button; 1747 return sync_error_button;
1748 } 1748 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698