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

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

Issue 7317: Change all ConvertPointTo* methods to use gfx::Point instead of CPoint.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 12 years, 2 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) 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.h" 5 #include "chrome/browser/views/status_bubble.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/scoped_ptr.h" 9 #include "base/scoped_ptr.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after
560 } 560 }
561 561
562 void StatusBubble::AvoidMouse() { 562 void StatusBubble::AvoidMouse() {
563 // Our status bubble is located in screen coordinates, so we should get 563 // Our status bubble is located in screen coordinates, so we should get
564 // those rather than attempting to reverse decode the web contents 564 // those rather than attempting to reverse decode the web contents
565 // coordinates. 565 // coordinates.
566 CPoint cursor_location; 566 CPoint cursor_location;
567 GetCursorPos(&cursor_location); 567 GetCursorPos(&cursor_location);
568 568
569 // Get the position of the frame. 569 // Get the position of the frame.
570 CPoint top_left(0, 0); 570 gfx::Point top_left;
571 ChromeViews::View::ConvertPointToScreen(frame_->GetRootView(), &top_left); 571 ChromeViews::View::ConvertPointToScreen(frame_->GetRootView(), &top_left);
572 572
573 // Get the cursor position relative to the popup. 573 // Get the cursor position relative to the popup.
574 cursor_location.x -= (top_left.x + position_.x); 574 cursor_location.x -= (top_left.x() + position_.x);
575 cursor_location.y -= (top_left.y + position_.y); 575 cursor_location.y -= (top_left.y() + position_.y);
576 576
577 // If the mouse is in a position where we think it would move the 577 // If the mouse is in a position where we think it would move the
578 // status bubble, figure out where and how the bubble should be moved. 578 // status bubble, figure out where and how the bubble should be moved.
579 if (cursor_location.y > -kMousePadding && 579 if (cursor_location.y > -kMousePadding &&
580 cursor_location.x < size_.cx + kMousePadding) { 580 cursor_location.x < size_.cx + kMousePadding) {
581 int offset = kMousePadding + cursor_location.y; 581 int offset = kMousePadding + cursor_location.y;
582 582
583 // Make the movement non-linear. 583 // Make the movement non-linear.
584 offset = offset * offset / kMousePadding; 584 offset = offset * offset / kMousePadding;
585 585
(...skipping 12 matching lines...) Expand all
598 if (offset >= size_.cy - kShadowSize * 2) { 598 if (offset >= size_.cy - kShadowSize * 2) {
599 offset = size_.cy - kShadowSize * 2; 599 offset = size_.cy - kShadowSize * 2;
600 view_->SetStyle(StatusView::STYLE_BOTTOM); 600 view_->SetStyle(StatusView::STYLE_BOTTOM);
601 } else if (offset > kBubbleCornerRadius / 2 - kShadowSize) { 601 } else if (offset > kBubbleCornerRadius / 2 - kShadowSize) {
602 view_->SetStyle(StatusView::STYLE_FLOATING); 602 view_->SetStyle(StatusView::STYLE_FLOATING);
603 } else { 603 } else {
604 view_->SetStyle(StatusView::STYLE_STANDARD); 604 view_->SetStyle(StatusView::STYLE_STANDARD);
605 } 605 }
606 606
607 offset_ = offset; 607 offset_ = offset;
608 popup_->MoveWindow(top_left.x + position_.x, 608 popup_->MoveWindow(top_left.x() + position_.x,
609 top_left.y + position_.y + offset_, 609 top_left.y() + position_.y + offset_,
610 size_.cx, 610 size_.cx,
611 size_.cy); 611 size_.cy);
612 } else if (offset_ != 0) { 612 } else if (offset_ != 0) {
613 offset_ = 0; 613 offset_ = 0;
614 view_->SetStyle(StatusView::STYLE_STANDARD); 614 view_->SetStyle(StatusView::STYLE_STANDARD);
615 popup_->MoveWindow(top_left.x + position_.x, 615 popup_->MoveWindow(top_left.x() + position_.x,
616 top_left.y + position_.y, 616 top_left.y() + position_.y,
617 size_.cx, 617 size_.cx,
618 size_.cy); 618 size_.cy);
619 } 619 }
620 } 620 }
621 621
622 void StatusBubble::Reposition() { 622 void StatusBubble::Reposition() {
623 if (popup_) { 623 if (popup_) {
624 CPoint top_left(0, 0); 624 gfx::Point top_left;
625 ChromeViews::View::ConvertPointToScreen(frame_->GetRootView(), &top_left); 625 ChromeViews::View::ConvertPointToScreen(frame_->GetRootView(), &top_left);
626 626
627 popup_->MoveWindow(top_left.x + position_.x, 627 popup_->MoveWindow(top_left.x() + position_.x,
628 top_left.y + position_.y, 628 top_left.y() + position_.y,
629 size_.cx, 629 size_.cx,
630 size_.cy); 630 size_.cy);
631 } 631 }
632 } 632 }
633 633
634 void StatusBubble::SetBounds(int x, int y, int w, int h) { 634 void StatusBubble::SetBounds(int x, int y, int w, int h) {
635 // If the UI layout is RTL, we need to mirror the position of the bubble 635 // If the UI layout is RTL, we need to mirror the position of the bubble
636 // relative to the parent. 636 // relative to the parent.
637 if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) { 637 if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) {
638 CRect frame_bounds; 638 CRect frame_bounds;
639 frame_->GetBounds(&frame_bounds, false); 639 frame_->GetBounds(&frame_bounds, false);
640 int mirrored_x = frame_bounds.Width() - x - w; 640 int mirrored_x = frame_bounds.Width() - x - w;
641 position_.SetPoint(mirrored_x, y); 641 position_.SetPoint(mirrored_x, y);
642 } else { 642 } else {
643 position_.SetPoint(x, y); 643 position_.SetPoint(x, y);
644 } 644 }
645 645
646 size_.SetSize(w, h); 646 size_.SetSize(w, h);
647 Reposition(); 647 Reposition();
648 } 648 }
649 649
OLDNEW
« no previous file with comments | « chrome/browser/views/old_frames/xp_frame.cc ('k') | chrome/browser/views/tabs/dragged_tab_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698