| Index: ui/views/controls/link.cc
|
| diff --git a/ui/views/controls/link.cc b/ui/views/controls/link.cc
|
| index d116aa35db5f74e8039bae56162a6b42fe34ee0a..c5d2bcd7e55101b7d3237c89ea8473197dd3f75a 100644
|
| --- a/ui/views/controls/link.cc
|
| +++ b/ui/views/controls/link.cc
|
| @@ -94,6 +94,16 @@ void Link::OnMouseCaptureLost() {
|
| SetPressed(false);
|
| }
|
|
|
| +void Link::OnMouseEntered(const ui::MouseEvent& event) {
|
| + mouseIsInside_ = true;
|
| + RecalculateFont();
|
| +}
|
| +
|
| +void Link::OnMouseExited(const ui::MouseEvent& event) {
|
| + mouseIsInside_ = false;
|
| + RecalculateFont();
|
| +}
|
| +
|
| bool Link::OnKeyPressed(const ui::KeyEvent& event) {
|
| bool activate = ((event.key_code() == ui::VKEY_SPACE) ||
|
| (event.key_code() == ui::VKEY_RETURN));
|
| @@ -156,6 +166,11 @@ void Link::SetPressedColor(SkColor color) {
|
| Label::SetEnabledColor(requested_pressed_color_);
|
| }
|
|
|
| +void Link::SetUnderlineOnHover(bool underlineOnHover) {
|
| + underlineOnHover_ = underlineOnHover;
|
| + RecalculateFont();
|
| +}
|
| +
|
| void Link::Init() {
|
| static bool initialized = false;
|
| static SkColor kDefaultEnabledColor;
|
| @@ -178,6 +193,8 @@ void Link::Init() {
|
|
|
| listener_ = NULL;
|
| pressed_ = false;
|
| + underlineOnHover_ = false;
|
| + mouseIsInside_ = false;
|
| SetEnabledColor(kDefaultEnabledColor);
|
| SetDisabledColor(kDefaultDisabledColor);
|
| SetPressedColor(kDefaultPressedColor);
|
| @@ -196,8 +213,15 @@ void Link::SetPressed(bool pressed) {
|
| }
|
|
|
| void Link::RecalculateFont() {
|
| - // The font should be underlined iff the link is enabled.
|
| - if (enabled() == !(font().GetStyle() & gfx::Font::UNDERLINED)) {
|
| + if (underlineOnHover_) {
|
| + // For underline on hover, the font should be underlined iff the link is
|
| + // enabled and the mouse is hovering over it.
|
| + Label::SetFont(font().DeriveFont(0, enabled() && mouseIsInside_ ?
|
| + (font().GetStyle() | gfx::Font::UNDERLINED) :
|
| + (font().GetStyle() & ~gfx::Font::UNDERLINED)));
|
| + } else if (enabled() == !(font().GetStyle() & gfx::Font::UNDERLINED)) {
|
| + // For constant underlining, the font should be underlined iff the link is
|
| + // enabled.
|
| Label::SetFont(font().DeriveFont(0, enabled() ?
|
| (font().GetStyle() | gfx::Font::UNDERLINED) :
|
| (font().GetStyle() & ~gfx::Font::UNDERLINED)));
|
|
|