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

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

Issue 115461: Fixed StatusBubbleViews::AvoidMouse() to support the mirrored UI (RTL) mode.... (Closed) Base URL: http://src.chromium.org/svn/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 | « no previous file | 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/status_bubble_views.h" 5 #include "chrome/browser/views/status_bubble_views.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
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 553 matching lines...) Expand 10 before | Expand all | Expand 10 after
564 GetCursorPos(&tmp); 564 GetCursorPos(&tmp);
565 cursor_location = tmp; 565 cursor_location = tmp;
566 #else 566 #else
567 NOTIMPLEMENTED(); 567 NOTIMPLEMENTED();
568 #endif 568 #endif
569 569
570 // Get the position of the frame. 570 // Get the position of the frame.
571 gfx::Point top_left; 571 gfx::Point top_left;
572 views::RootView* root = frame_->GetRootView(); 572 views::RootView* root = frame_->GetRootView();
573 views::View::ConvertPointToScreen(root, &top_left); 573 views::View::ConvertPointToScreen(root, &top_left);
574 int window_width = root->GetLocalBounds(true).width(); // border included.
574 575
575 // Get the cursor position relative to the popup. 576 // Get the cursor position relative to the popup.
576 cursor_location.set_x(cursor_location.x() - (top_left.x() + position_.x())); 577 if (view_->UILayoutIsRightToLeft()) {
578 int top_right_x = top_left.x() + window_width;
579 cursor_location.set_x(top_right_x - cursor_location.x());
580 } else {
581 cursor_location.set_x(cursor_location.x() - (top_left.x() + position_.x()));
582 }
577 cursor_location.set_y(cursor_location.y() - (top_left.y() + position_.y())); 583 cursor_location.set_y(cursor_location.y() - (top_left.y() + position_.y()));
578 584
579 // If the mouse is in a position where we think it would move the 585 // If the mouse is in a position where we think it would move the
580 // status bubble, figure out where and how the bubble should be moved. 586 // status bubble, figure out where and how the bubble should be moved.
581 if (cursor_location.y() > -kMousePadding && 587 if (cursor_location.y() > -kMousePadding &&
582 cursor_location.x() < size_.width() + kMousePadding) { 588 cursor_location.x() < size_.width() + kMousePadding) {
583 int offset = kMousePadding + cursor_location.y(); 589 int offset = kMousePadding + cursor_location.y();
584 590
585 // Make the movement non-linear. 591 // Make the movement non-linear.
586 offset = offset * offset / kMousePadding; 592 offset = offset * offset / kMousePadding;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
618 NOTIMPLEMENTED(); 624 NOTIMPLEMENTED();
619 #endif 625 #endif
620 const int bubble_bottom_y = top_left.y() + position_.y() + size_.height(); 626 const int bubble_bottom_y = top_left.y() + position_.y() + size_.height();
621 627
622 if (bubble_bottom_y + offset > monitor_rect.height()) { 628 if (bubble_bottom_y + offset > monitor_rect.height()) {
623 // The offset is still too large. Move the bubble to the right and reset 629 // The offset is still too large. Move the bubble to the right and reset
624 // Y offset_ to zero. 630 // Y offset_ to zero.
625 view_->SetStyle(StatusView::STYLE_STANDARD_RIGHT); 631 view_->SetStyle(StatusView::STYLE_STANDARD_RIGHT);
626 offset_ = 0; 632 offset_ = 0;
627 633
628 int root_width = root->GetLocalBounds(true).width(); // border included.
629 // Substract border width + bubble width. 634 // Substract border width + bubble width.
630 int right_position_x = root_width - (position_.x() + size_.width()); 635 int right_position_x = window_width - (position_.x() + size_.width());
631 popup_->SetBounds(gfx::Rect(top_left.x() + right_position_x, 636 popup_->SetBounds(gfx::Rect(top_left.x() + right_position_x,
632 top_left.y() + position_.y(), 637 top_left.y() + position_.y(),
633 size_.width(), size_.height())); 638 size_.width(), size_.height()));
634 } else { 639 } else {
635 offset_ = offset; 640 offset_ = offset;
636 popup_->SetBounds(gfx::Rect(top_left.x() + position_.x(), 641 popup_->SetBounds(gfx::Rect(top_left.x() + position_.x(),
637 top_left.y() + position_.y() + offset_, 642 top_left.y() + position_.y() + offset_,
638 size_.width(), size_.height())); 643 size_.width(), size_.height()));
639 } 644 }
640 } else if (offset_ != 0 || 645 } else if (offset_ != 0 ||
(...skipping 25 matching lines...) Expand all
666 frame_->GetBounds(&frame_bounds, false); 671 frame_->GetBounds(&frame_bounds, false);
667 int mirrored_x = frame_bounds.width() - x - w; 672 int mirrored_x = frame_bounds.width() - x - w;
668 position_.SetPoint(mirrored_x, y); 673 position_.SetPoint(mirrored_x, y);
669 } else { 674 } else {
670 position_.SetPoint(x, y); 675 position_.SetPoint(x, y);
671 } 676 }
672 677
673 size_.SetSize(w, h); 678 size_.SetSize(w, h);
674 Reposition(); 679 Reposition();
675 } 680 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698