diff options
author | glotov@chromium.org <glotov@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-18 06:47:06 +0000 |
---|---|---|
committer | glotov@chromium.org <glotov@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-18 06:47:06 +0000 |
commit | 89a3da9808c7f1b0b5481ce1d6b1c45cdcc01040 (patch) | |
tree | 4ea1092224d48d6013554a3d161ea8fbc1542569 /chrome/browser/chromeos/volume_bubble.cc | |
parent | 975237f8f51600c93a18749120dc82bb6121e804 (diff) | |
download | chromium_src-89a3da9808c7f1b0b5481ce1d6b1c45cdcc01040.zip chromium_src-89a3da9808c7f1b0b5481ce1d6b1c45cdcc01040.tar.gz chromium_src-89a3da9808c7f1b0b5481ce1d6b1c45cdcc01040.tar.bz2 |
Set volume bubble position relative to screen size.
BUG=http://crosbug.com/4136
TEST=none
Review URL: http://codereview.chromium.org/2820013
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@50214 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/chromeos/volume_bubble.cc')
-rw-r--r-- | chrome/browser/chromeos/volume_bubble.cc | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/chrome/browser/chromeos/volume_bubble.cc b/chrome/browser/chromeos/volume_bubble.cc index 667f420..3cef827f 100644 --- a/chrome/browser/chromeos/volume_bubble.cc +++ b/chrome/browser/chromeos/volume_bubble.cc @@ -12,9 +12,16 @@ #include "views/widget/root_view.h" namespace { + const int kBubbleShowTimeoutSec = 2; const int kAnimationDurationMs = 200; -const int kVolumeBubbleX = 300, kVolumeBubbleY = 700; + +// Horizontal relative position: 0 - leftmost, 0.5 - center, 1 - rightmost. +const double kVolumeBubbleXRatio = 0.18; + +// Vertical gap from the bottom of the screen in pixels. +const int kVolumeBubbleBottomGap = 30; + } // namespace namespace chromeos { @@ -64,11 +71,19 @@ void VolumeBubble::ShowVolumeBubble(int percent) { DCHECK(view_ == NULL); view_ = new VolumeBubbleView; view_->Init(previous_percent_); + // Calculate position of the volume bubble. // TODO(glotov): Place volume bubble over the keys initiated the // volume change. This metric must be specific to the given // architecture. crosbug.com/4028 - bubble_ = InfoBubble::Show(widget, - gfx::Rect(kVolumeBubbleX, kVolumeBubbleY, 0, 0), + gfx::Rect bounds; + widget->GetBounds(&bounds, false); + const gfx::Size view_size = view_->GetPreferredSize(); + // Note that (x, y) is the point of the center of the bubble. + const int x = view_size.width() / 2 + + kVolumeBubbleXRatio * (bounds.width() - view_size.width()); + const int y = bounds.height() - view_size.height() / 2 - + kVolumeBubbleBottomGap; + bubble_ = InfoBubble::Show(widget, gfx::Rect(x, y, 0, 20), BubbleBorder::FLOAT, view_, this); } else { DCHECK(view_); |