Commit 028ddd65 authored by mukai@chromium.org's avatar mukai@chromium.org

Scrolls to the notification when focus moves to its buttons.

BUG=224974

Review URL: https://codereview.chromium.org/14198004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@194699 0039d316-1c4b-4281-b951-d872f2087c98
parent bf9b054c
......@@ -54,6 +54,7 @@ class ControlButton : public views::ImageButton {
// Overridden from views::ImageButton:
virtual gfx::Size GetPreferredSize() OVERRIDE;
virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE;
virtual void OnFocus() OVERRIDE;
// The SetPadding() method also sets the button's image alignment (positive
// values yield left/top alignments, negative values yield right/bottom ones,
......@@ -129,6 +130,10 @@ void ControlButton::OnPaint(gfx::Canvas* canvas) {
OnPaintFocusBorder(canvas);
}
void ControlButton::OnFocus() {
ScrollRectToVisible(GetLocalBounds());
}
gfx::Point ControlButton::ComputePaddedImagePaintPosition(
const gfx::ImageSkia& image) {
gfx::Vector2d offset;
......
......@@ -255,6 +255,7 @@ class NotificationButton : public views::CustomButton {
// Overridden from views::View:
virtual gfx::Size GetPreferredSize() OVERRIDE;
virtual int GetHeightForWidth(int width) OVERRIDE;
virtual void OnFocus() OVERRIDE;
// Overridden from views::CustomButton:
virtual void StateChanged() OVERRIDE;
......@@ -319,6 +320,10 @@ int NotificationButton::GetHeightForWidth(int width) {
return kButtonHeight;
}
void NotificationButton::OnFocus() {
ScrollRectToVisible(GetLocalBounds());
}
void NotificationButton::StateChanged() {
if (state() == STATE_HOVERED || state() == STATE_PRESSED)
set_background(MakeBackground(kHoveredButtonBackgroundColor));
......@@ -544,6 +549,12 @@ void NotificationView::Layout() {
expand_size.width(), expand_size.height());
}
void NotificationView::ScrollRectToVisible(const gfx::Rect& rect) {
// Notification want to show the whole notification when a part of it (like
// a button) gets focused.
views::View::ScrollRectToVisible(GetLocalBounds());
}
void NotificationView::ButtonPressed(views::Button* sender,
const ui::Event& event) {
// See if the button pressed was an action button.
......
......@@ -35,6 +35,7 @@ class MESSAGE_CENTER_EXPORT NotificationView : public MessageView {
virtual gfx::Size GetPreferredSize() OVERRIDE;
virtual int GetHeightForWidth(int width) OVERRIDE;
virtual void Layout() OVERRIDE;
virtual void ScrollRectToVisible(const gfx::Rect& rect) OVERRIDE;
// Overridden from MessageView:
virtual void ButtonPressed(views::Button* sender,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment