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

Side by Side Diff: ui/message_center/views/message_view.cc

Issue 14198004: Scrolls to the notification when focus moves to its buttons. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 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 | ui/message_center/views/notification_view.h » ('j') | 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ui/message_center/views/message_view.h" 5 #include "ui/message_center/views/message_view.h"
6 6
7 #include "grit/ui_resources.h" 7 #include "grit/ui_resources.h"
8 #include "grit/ui_strings.h" 8 #include "grit/ui_strings.h"
9 #include "ui/base/l10n/l10n_util.h" 9 #include "ui/base/l10n/l10n_util.h"
10 #include "ui/base/models/simple_menu_model.h" 10 #include "ui/base/models/simple_menu_model.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 // will also allow for buttons whose touch areas extend beyond their clickable 47 // will also allow for buttons whose touch areas extend beyond their clickable
48 // area (<http://crbug.com/168856>). 48 // area (<http://crbug.com/168856>).
49 class ControlButton : public views::ImageButton { 49 class ControlButton : public views::ImageButton {
50 public: 50 public:
51 ControlButton(views::ButtonListener* listener); 51 ControlButton(views::ButtonListener* listener);
52 virtual ~ControlButton(); 52 virtual ~ControlButton();
53 53
54 // Overridden from views::ImageButton: 54 // Overridden from views::ImageButton:
55 virtual gfx::Size GetPreferredSize() OVERRIDE; 55 virtual gfx::Size GetPreferredSize() OVERRIDE;
56 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; 56 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE;
57 virtual void OnFocus() OVERRIDE;
57 58
58 // The SetPadding() method also sets the button's image alignment (positive 59 // The SetPadding() method also sets the button's image alignment (positive
59 // values yield left/top alignments, negative values yield right/bottom ones, 60 // values yield left/top alignments, negative values yield right/bottom ones,
60 // and zero values center/middle ones). ImageButton::SetImageAlignment() calls 61 // and zero values center/middle ones). ImageButton::SetImageAlignment() calls
61 // will not affect ControlButton image alignments. 62 // will not affect ControlButton image alignments.
62 void SetPadding(int horizontal_padding, int vertical_padding); 63 void SetPadding(int horizontal_padding, int vertical_padding);
63 64
64 void SetNormalImage(int resource_id); 65 void SetNormalImage(int resource_id);
65 void SetHoveredImage(int resource_id); 66 void SetHoveredImage(int resource_id);
66 void SetPressedImage(int resource_id); 67 void SetPressedImage(int resource_id);
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 gfx::Point position = ComputePaddedImagePaintPosition(image); 123 gfx::Point position = ComputePaddedImagePaintPosition(image);
123 if (!background_image_.isNull()) 124 if (!background_image_.isNull())
124 canvas->DrawImageInt(background_image_, position.x(), position.y()); 125 canvas->DrawImageInt(background_image_, position.x(), position.y());
125 canvas->DrawImageInt(image, position.x(), position.y()); 126 canvas->DrawImageInt(image, position.x(), position.y());
126 if (!overlay_image_.isNull()) 127 if (!overlay_image_.isNull())
127 canvas->DrawImageInt(overlay_image_, position.x(), position.y()); 128 canvas->DrawImageInt(overlay_image_, position.x(), position.y());
128 } 129 }
129 OnPaintFocusBorder(canvas); 130 OnPaintFocusBorder(canvas);
130 } 131 }
131 132
133 void ControlButton::OnFocus() {
134 ScrollRectToVisible(GetLocalBounds());
135 }
136
132 gfx::Point ControlButton::ComputePaddedImagePaintPosition( 137 gfx::Point ControlButton::ComputePaddedImagePaintPosition(
133 const gfx::ImageSkia& image) { 138 const gfx::ImageSkia& image) {
134 gfx::Vector2d offset; 139 gfx::Vector2d offset;
135 gfx::Rect bounds = GetContentsBounds(); 140 gfx::Rect bounds = GetContentsBounds();
136 bounds.Inset(padding_); 141 bounds.Inset(padding_);
137 142
138 if (padding_.left() == 0 && padding_.right() == 0) 143 if (padding_.left() == 0 && padding_.right() == 0)
139 offset.set_x((bounds.width() - image.width()) / 2); // Center align. 144 offset.set_x((bounds.width() - image.width()) / 2); // Center align.
140 else if (padding_.right() > 0) 145 else if (padding_.right() > 0)
141 offset.set_x(bounds.width() - image.width()); // Right align. 146 offset.set_x(bounds.width() - image.width()); // Right align.
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 gfx::Rect(screen_location, gfx::Size()), 382 gfx::Rect(screen_location, gfx::Size()),
378 views::MenuItemView::TOPRIGHT, 383 views::MenuItemView::TOPRIGHT,
379 views::MenuRunner::HAS_MNEMONICS)); 384 views::MenuRunner::HAS_MNEMONICS));
380 } 385 }
381 386
382 void MessageView::OnSlideOut() { 387 void MessageView::OnSlideOut() {
383 observer_->OnRemoveNotification(notification_id_, true); // By user. 388 observer_->OnRemoveNotification(notification_id_, true); // By user.
384 } 389 }
385 390
386 } // namespace message_center 391 } // namespace message_center
OLDNEW
« no previous file with comments | « no previous file | ui/message_center/views/notification_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698