Merge lp:~mandel/unity/action-link-selected into lp:unity

Proposed by Manuel de la Peña
Status: Merged
Approved by: Nick Dedekind
Approved revision: no longer in the source branch.
Merged at revision: 3057
Proposed branch: lp:~mandel/unity/action-link-selected
Merge into: lp:unity
Diff against target: 77 lines (+14/-8)
3 files modified
dash/previews/ActionLink.cpp (+3/-3)
dash/previews/ActionLink.h (+1/-1)
tests/test_action_link.cpp (+10/-4)
To merge this branch: bzr merge lp:~mandel/unity/action-link-selected
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Needs Fixing
Marco Trevisan (Treviño) Approve
Review via email: mp+144335@code.launchpad.net

Commit message

Ensure that the ActionLink is highlighted when selected via keyboard navigation.

Description of the change

Ensure that the ActionLink is highlighted when selected via keyboard navigation.

To post a comment you must log in.
Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

Looks very good, thanks!

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'dash/previews/ActionLink.cpp'
2--- dash/previews/ActionLink.cpp 2012-12-14 12:14:34 +0000
3+++ dash/previews/ActionLink.cpp 2013-01-22 16:09:20 +0000
4@@ -131,9 +131,9 @@
5 QueueDraw();
6 }
7
8-int ActionLink::GetLinkAlpha(nux::ButtonVisualState state)
9+int ActionLink::GetLinkAlpha(nux::ButtonVisualState state, bool keyboardFocus)
10 {
11- if (state == nux::ButtonVisualState::VISUAL_STATE_PRELIGHT)
12+ if (keyboardFocus || state == nux::ButtonVisualState::VISUAL_STATE_PRELIGHT)
13 return LINK_HIGHLIGHTED_ALPHA_VALUE;
14 else
15 return LINK_NORMAL_ALPHA_VALUE;
16@@ -153,7 +153,7 @@
17 unsigned int alpha = 0, src = 0, dest = 0;
18
19 // set the alpha of the text according to its state
20- static_text_->SetTextAlpha(GetLinkAlpha(GetVisualState()));
21+ static_text_->SetTextAlpha(GetLinkAlpha(GetVisualState(), HasKeyboardFocus()));
22
23 GfxContext.GetRenderStates().GetBlend(alpha, src, dest);
24 GfxContext.GetRenderStates().SetBlend(true, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
25
26=== modified file 'dash/previews/ActionLink.h'
27--- dash/previews/ActionLink.h 2012-12-14 12:14:34 +0000
28+++ dash/previews/ActionLink.h 2013-01-22 16:09:20 +0000
29@@ -59,7 +59,7 @@
30 protected:
31 nux::ObjectPtr<StaticCairoText> static_text_;
32
33- int GetLinkAlpha(nux::ButtonVisualState state);
34+ int GetLinkAlpha(nux::ButtonVisualState state, bool keyboardFocus);
35
36 void Draw(nux::GraphicsEngine& GfxContext, bool force_draw);
37 void DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw) {}
38
39=== modified file 'tests/test_action_link.cpp'
40--- tests/test_action_link.cpp 2012-12-14 12:14:34 +0000
41+++ tests/test_action_link.cpp 2013-01-22 16:09:20 +0000
42@@ -161,25 +161,31 @@
43 TEST_F(TestActionLink, LinkAlphaOnPressed)
44 {
45 ButtonVisualState state = ButtonVisualState::VISUAL_STATE_PRESSED;
46- EXPECT_EQ(4, action_link->GetLinkAlpha(state));
47+ EXPECT_EQ(4, action_link->GetLinkAlpha(state, false));
48 }
49
50 TEST_F(TestActionLink, LinkAlphaOnNormal)
51 {
52 ButtonVisualState state = ButtonVisualState::VISUAL_STATE_NORMAL;
53- EXPECT_EQ(4, action_link->GetLinkAlpha(state));
54+ EXPECT_EQ(4, action_link->GetLinkAlpha(state, false));
55+}
56+
57+TEST_F(TestActionLink, LinkAlphaOnNormalButKeyboardFocused)
58+{
59+ ButtonVisualState state = ButtonVisualState::VISUAL_STATE_NORMAL;
60+ EXPECT_EQ(1, action_link->GetLinkAlpha(state, true));
61 }
62
63 TEST_F(TestActionLink, LinkAlphaOnPrelight)
64 {
65 ButtonVisualState state = ButtonVisualState::VISUAL_STATE_PRELIGHT;
66- EXPECT_EQ(1, action_link->GetLinkAlpha(state));
67+ EXPECT_EQ(1, action_link->GetLinkAlpha(state, false));
68 }
69
70 TEST_F(TestActionLink, LinkAlphaOnDisabled)
71 {
72 ButtonVisualState state = ButtonVisualState::VISUAL_STATE_DISABLED;
73- EXPECT_EQ(4, action_link->GetLinkAlpha(state));
74+ EXPECT_EQ(4, action_link->GetLinkAlpha(state, false));
75 }
76
77 }