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
=== modified file 'dash/previews/ActionLink.cpp'
--- dash/previews/ActionLink.cpp 2012-12-14 12:14:34 +0000
+++ dash/previews/ActionLink.cpp 2013-01-22 16:09:20 +0000
@@ -131,9 +131,9 @@
131 QueueDraw();131 QueueDraw();
132}132}
133133
134int ActionLink::GetLinkAlpha(nux::ButtonVisualState state)134int ActionLink::GetLinkAlpha(nux::ButtonVisualState state, bool keyboardFocus)
135{135{
136 if (state == nux::ButtonVisualState::VISUAL_STATE_PRELIGHT)136 if (keyboardFocus || state == nux::ButtonVisualState::VISUAL_STATE_PRELIGHT)
137 return LINK_HIGHLIGHTED_ALPHA_VALUE;137 return LINK_HIGHLIGHTED_ALPHA_VALUE;
138 else138 else
139 return LINK_NORMAL_ALPHA_VALUE;139 return LINK_NORMAL_ALPHA_VALUE;
@@ -153,7 +153,7 @@
153 unsigned int alpha = 0, src = 0, dest = 0;153 unsigned int alpha = 0, src = 0, dest = 0;
154154
155 // set the alpha of the text according to its state155 // set the alpha of the text according to its state
156 static_text_->SetTextAlpha(GetLinkAlpha(GetVisualState()));156 static_text_->SetTextAlpha(GetLinkAlpha(GetVisualState(), HasKeyboardFocus()));
157157
158 GfxContext.GetRenderStates().GetBlend(alpha, src, dest);158 GfxContext.GetRenderStates().GetBlend(alpha, src, dest);
159 GfxContext.GetRenderStates().SetBlend(true, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);159 GfxContext.GetRenderStates().SetBlend(true, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
160160
=== modified file 'dash/previews/ActionLink.h'
--- dash/previews/ActionLink.h 2012-12-14 12:14:34 +0000
+++ dash/previews/ActionLink.h 2013-01-22 16:09:20 +0000
@@ -59,7 +59,7 @@
59protected:59protected:
60 nux::ObjectPtr<StaticCairoText> static_text_;60 nux::ObjectPtr<StaticCairoText> static_text_;
6161
62 int GetLinkAlpha(nux::ButtonVisualState state);62 int GetLinkAlpha(nux::ButtonVisualState state, bool keyboardFocus);
6363
64 void Draw(nux::GraphicsEngine& GfxContext, bool force_draw);64 void Draw(nux::GraphicsEngine& GfxContext, bool force_draw);
65 void DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw) {}65 void DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw) {}
6666
=== modified file 'tests/test_action_link.cpp'
--- tests/test_action_link.cpp 2012-12-14 12:14:34 +0000
+++ tests/test_action_link.cpp 2013-01-22 16:09:20 +0000
@@ -161,25 +161,31 @@
161TEST_F(TestActionLink, LinkAlphaOnPressed)161TEST_F(TestActionLink, LinkAlphaOnPressed)
162{162{
163 ButtonVisualState state = ButtonVisualState::VISUAL_STATE_PRESSED;163 ButtonVisualState state = ButtonVisualState::VISUAL_STATE_PRESSED;
164 EXPECT_EQ(4, action_link->GetLinkAlpha(state));164 EXPECT_EQ(4, action_link->GetLinkAlpha(state, false));
165}165}
166166
167TEST_F(TestActionLink, LinkAlphaOnNormal)167TEST_F(TestActionLink, LinkAlphaOnNormal)
168{168{
169 ButtonVisualState state = ButtonVisualState::VISUAL_STATE_NORMAL;169 ButtonVisualState state = ButtonVisualState::VISUAL_STATE_NORMAL;
170 EXPECT_EQ(4, action_link->GetLinkAlpha(state));170 EXPECT_EQ(4, action_link->GetLinkAlpha(state, false));
171}
172
173TEST_F(TestActionLink, LinkAlphaOnNormalButKeyboardFocused)
174{
175 ButtonVisualState state = ButtonVisualState::VISUAL_STATE_NORMAL;
176 EXPECT_EQ(1, action_link->GetLinkAlpha(state, true));
171}177}
172178
173TEST_F(TestActionLink, LinkAlphaOnPrelight)179TEST_F(TestActionLink, LinkAlphaOnPrelight)
174{180{
175 ButtonVisualState state = ButtonVisualState::VISUAL_STATE_PRELIGHT;181 ButtonVisualState state = ButtonVisualState::VISUAL_STATE_PRELIGHT;
176 EXPECT_EQ(1, action_link->GetLinkAlpha(state));182 EXPECT_EQ(1, action_link->GetLinkAlpha(state, false));
177}183}
178184
179TEST_F(TestActionLink, LinkAlphaOnDisabled)185TEST_F(TestActionLink, LinkAlphaOnDisabled)
180{186{
181 ButtonVisualState state = ButtonVisualState::VISUAL_STATE_DISABLED;187 ButtonVisualState state = ButtonVisualState::VISUAL_STATE_DISABLED;
182 EXPECT_EQ(4, action_link->GetLinkAlpha(state));188 EXPECT_EQ(4, action_link->GetLinkAlpha(state, false));
183}189}
184190
185}191}