summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorglotov@google.com <glotov@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-11 16:48:50 +0000
committerglotov@google.com <glotov@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-11 16:48:50 +0000
commit899505c5a3a10ac024fc8e91dd08beda12549312 (patch)
tree895b439fc35f219a98df02fe48617372e3fac2d3 /chrome
parent804be3af5e9a45547178b46fe1c5ccf492c791fc (diff)
downloadchromium_src-899505c5a3a10ac024fc8e91dd08beda12549312.zip
chromium_src-899505c5a3a10ac024fc8e91dd08beda12549312.tar.gz
chromium_src-899505c5a3a10ac024fc8e91dd08beda12549312.tar.bz2
Show hand cursor only on small user pods and labels
BUG=chromium-os:9296 TEST=manual Review URL: http://codereview.chromium.org/5966008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@71049 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/chromeos/login/rounded_view.h4
-rw-r--r--chrome/browser/chromeos/login/screen_lock_view.h1
-rw-r--r--chrome/browser/chromeos/login/user_controller.cc2
-rw-r--r--chrome/browser/chromeos/login/user_controller.h2
-rw-r--r--chrome/browser/chromeos/login/user_view.cc11
-rw-r--r--chrome/browser/chromeos/login/user_view.h3
-rw-r--r--chrome/browser/chromeos/login/username_view.cc21
-rw-r--r--chrome/browser/chromeos/login/username_view.h13
8 files changed, 41 insertions, 16 deletions
diff --git a/chrome/browser/chromeos/login/rounded_view.h b/chrome/browser/chromeos/login/rounded_view.h
index 09877ba..bc23f80 100644
--- a/chrome/browser/chromeos/login/rounded_view.h
+++ b/chrome/browser/chromeos/login/rounded_view.h
@@ -35,9 +35,11 @@ class RoundedView: public C {
// Empty constructor.
RoundedView() {}
- // One argument constructor.
+ // Constructors.
template<typename D>
explicit RoundedView(const D &value) : C(value) {}
+ template<typename D1, typename D2>
+ explicit RoundedView(const D1 &val1, const D2 &val2) : C(val1, val2) {}
// Overrides views::View.
virtual void ProcessPaint(gfx::Canvas* canvas);
diff --git a/chrome/browser/chromeos/login/screen_lock_view.h b/chrome/browser/chromeos/login/screen_lock_view.h
index d57b30c..2e781e5 100644
--- a/chrome/browser/chromeos/login/screen_lock_view.h
+++ b/chrome/browser/chromeos/login/screen_lock_view.h
@@ -65,6 +65,7 @@ class ScreenLockView : public ThrobberHostView,
// UserView::Delegate implementation:
virtual void OnSignout();
+ virtual bool IsUserSelected() const { return true; }
protected:
// views::View implementation:
diff --git a/chrome/browser/chromeos/login/user_controller.cc b/chrome/browser/chromeos/login/user_controller.cc
index d5d14dd..09f737f 100644
--- a/chrome/browser/chromeos/login/user_controller.cc
+++ b/chrome/browser/chromeos/login/user_controller.cc
@@ -69,7 +69,7 @@ class ClickNotifyingWidget : public views::WidgetGtk {
private:
gboolean OnButtonPress(GtkWidget* widget, GdkEventButton* event) {
- if (!controller_->is_user_selected())
+ if (!controller_->IsUserSelected())
controller_->SelectUserRelative(0);
return views::WidgetGtk::OnButtonPress(widget, event);
diff --git a/chrome/browser/chromeos/login/user_controller.h b/chrome/browser/chromeos/login/user_controller.h
index 7b894f1..43da098 100644
--- a/chrome/browser/chromeos/login/user_controller.h
+++ b/chrome/browser/chromeos/login/user_controller.h
@@ -73,7 +73,6 @@ class UserController : public views::WidgetDelegate,
void UpdateUserCount(int index, int total_user_count);
int user_index() const { return user_index_; }
- bool is_user_selected() const { return is_user_selected_; }
bool is_new_user() const { return is_new_user_; }
bool is_guest() const { return is_guest_; }
@@ -125,6 +124,7 @@ class UserController : public views::WidgetDelegate,
// UserView::Delegate implementation:
virtual void OnRemoveUser();
+ virtual bool IsUserSelected() const { return is_user_selected_; }
// Selects user relative to the current user.
void SelectUserRelative(int shift);
diff --git a/chrome/browser/chromeos/login/user_view.cc b/chrome/browser/chromeos/login/user_view.cc
index 980f107..b93eaf3 100644
--- a/chrome/browser/chromeos/login/user_view.cc
+++ b/chrome/browser/chromeos/login/user_view.cc
@@ -215,7 +215,8 @@ class RemoveButton : public views::TextButton {
class PodImageView : public views::ImageView {
public:
- PodImageView() { }
+ explicit PodImageView(const UserView::Delegate* delegate)
+ : delegate_(delegate) { }
void SetImage(const SkBitmap& image, const SkBitmap& image_hot) {
image_ = image;
@@ -236,10 +237,12 @@ class PodImageView : public views::ImageView {
gfx::NativeCursor GetCursorForPoint(
views::Event::EventType event_type,
const gfx::Point& p) {
- return gfx::GetCursor(GDK_HAND2);
+ return (delegate_->IsUserSelected()) ? NULL : gfx::GetCursor(GDK_HAND2);
}
private:
+ const UserView::Delegate* delegate_;
+
SkBitmap image_;
SkBitmap image_hot_;
@@ -256,9 +259,9 @@ UserView::UserView(Delegate* delegate, bool is_login, bool need_background)
signout_view_ = new SignoutView(this);
if (need_background)
- image_view_ = new RoundedView<PodImageView>;
+ image_view_ = new RoundedView<PodImageView>(delegate);
else
- image_view_ = new PodImageView;
+ image_view_ = new PodImageView(delegate);
Init(need_background);
}
diff --git a/chrome/browser/chromeos/login/user_view.h b/chrome/browser/chromeos/login/user_view.h
index 5d4182c..893ce4e3 100644
--- a/chrome/browser/chromeos/login/user_view.h
+++ b/chrome/browser/chromeos/login/user_view.h
@@ -38,6 +38,9 @@ class UserView : public views::View,
// Notifies that user would like to remove this user from login screen.
virtual void OnRemoveUser() {}
+
+ // Returns true if current user is selected.
+ virtual bool IsUserSelected() const = 0;
};
// Creates UserView for login screen (|is_login| == true) or screen locker.
diff --git a/chrome/browser/chromeos/login/username_view.cc b/chrome/browser/chromeos/login/username_view.cc
index 5aead72..5206901 100644
--- a/chrome/browser/chromeos/login/username_view.cc
+++ b/chrome/browser/chromeos/login/username_view.cc
@@ -9,6 +9,7 @@
#include "chrome/browser/chromeos/login/rounded_view.h"
#include "gfx/canvas.h"
#include "gfx/canvas_skia.h"
+#include "gfx/gtk_util.h"
#include "gfx/rect.h"
#include "third_party/skia/include/core/SkColorShader.h"
#include "third_party/skia/include/core/SkComposeShader.h"
@@ -31,13 +32,13 @@ template<typename C>
class HalfRoundedView : public RoundedView<C> {
public:
HalfRoundedView(const std::wstring &text, bool use_small_shape)
- : RoundedView<C>(text), use_small_shape_(use_small_shape) {
+ : RoundedView<C>(text, use_small_shape) {
}
protected:
// Overrides ViewFilter.
virtual SkPath GetClipPath() const {
- if (!use_small_shape_) {
+ if (!C::use_small_shape()) {
return RoundedView<C>::GetClipPath();
} else {
SkPath path;
@@ -66,15 +67,12 @@ class HalfRoundedView : public RoundedView<C> {
this->y() + this->height());
return view_rect;
}
-
- private:
- // Whether the shape for the smaller view should be used.
- bool use_small_shape_;
};
} // namespace
-UsernameView::UsernameView(const std::wstring& username)
- : views::Label(username) {
+UsernameView::UsernameView(const std::wstring& username, bool use_small_shape)
+ : views::Label(username),
+ use_small_shape_(use_small_shape) {
}
void UsernameView::Paint(gfx::Canvas* canvas) {
@@ -94,6 +92,13 @@ UsernameView* UsernameView::CreateShapedUsernameView(
return new HalfRoundedView<UsernameView>(username, use_small_shape);
}
+gfx::NativeCursor UsernameView::GetCursorForPoint(
+ views::Event::EventType event_type,
+ const gfx::Point& p) {
+
+ return use_small_shape_ ? gfx::GetCursor(GDK_HAND2) : NULL;
+}
+
void UsernameView::PaintUsername(const gfx::Rect& bounds) {
margin_width_ = bounds.height() * kMarginRatio;
gfx::CanvasSkia canvas(bounds.width(), bounds.height(), false);
diff --git a/chrome/browser/chromeos/login/username_view.h b/chrome/browser/chromeos/login/username_view.h
index 3ea81aa..b2acd5a 100644
--- a/chrome/browser/chromeos/login/username_view.h
+++ b/chrome/browser/chromeos/login/username_view.h
@@ -35,9 +35,17 @@ class UsernameView : public views::Label {
protected:
// Constructs username view for the given |username|. Consider using
// |CreateShapedUsernameView| to match the login page style.
- explicit UsernameView(const std::wstring& username);
+ UsernameView(const std::wstring& username, bool use_small_shape);
+
+ // True indicates that this UsernameView is used for a user pod not
+ // currently selected.
+ bool use_small_shape() const { return use_small_shape_; }
private:
+ // Overriden from View.
+ gfx::NativeCursor GetCursorForPoint(
+ views::Event::EventType event_type,
+ const gfx::Point& p);
// Paints username to the bitmap with the bounds given.
void PaintUsername(const gfx::Rect& bounds);
@@ -48,6 +56,9 @@ class UsernameView : public views::Label {
// Holds margins width (depends on the height).
int margin_width_;
+ // Whether the shape for the smaller view should be used.
+ bool use_small_shape_;
+
DISALLOW_COPY_AND_ASSIGN(UsernameView);
};