Merge lp:~azzar1/unity/fix-932531 into lp:unity

Proposed by Andrea Azzarone
Status: Merged
Approved by: Marco Trevisan (Treviño)
Approved revision: no longer in the source branch.
Merged at revision: 2459
Proposed branch: lp:~azzar1/unity/fix-932531
Merge into: lp:unity
Diff against target: 104 lines (+28/-2)
3 files modified
hud/HudButton.cpp (+15/-0)
hud/HudButton.h (+8/-2)
hud/HudView.cpp (+5/-0)
To merge this branch: bzr merge lp:~azzar1/unity/fix-932531
Reviewer Review Type Date Requested Status
Marco Trevisan (Treviño) Approve
Brandon Schaefer (community) Approve
jenkins (community) continuous-integration Approve
Review via email: mp+112447@code.launchpad.net

Commit message

Fix hud expand animation.

Description of the change

== Problem ==
HUD Draws improperly while searching for results.

== Fix ==
We don't draw the buttons unless they fit in the currently available area. We do it using a flag.

== Test ==
Visual change. Not applicable.

To post a comment you must log in.
Revision history for this message
jenkins (martin-mrazik+qa) wrote :

PASSED: Continuous integration, rev:2448
http://s-jenkins:8080/job/unity-ci/35/

review: Approve (continuous-integration)
Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

Looks good to me!

review: Approve
Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

+1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'hud/HudButton.cpp'
2--- hud/HudButton.cpp 2012-06-27 12:51:27 +0000
3+++ hud/HudButton.cpp 2012-06-27 21:42:19 +0000
4@@ -52,10 +52,13 @@
5 namespace hud
6 {
7
8+NUX_IMPLEMENT_OBJECT_TYPE(HudButton);
9+
10 HudButton::HudButton(NUX_FILE_LINE_DECL)
11 : nux::Button(NUX_FILE_LINE_PARAM)
12 , is_rounded(false)
13 , is_focused_(false)
14+ , skip_draw_(true)
15 {
16 hlayout_ = new nux::HLayout(NUX_TRACKER_LOCATION);
17 hlayout_->SetLeftAndRightPadding(hlayout_left_padding, -1);
18@@ -130,6 +133,9 @@
19
20 void HudButton::Draw(nux::GraphicsEngine& GfxContext, bool force_draw)
21 {
22+ if (skip_draw_)
23+ return;
24+
25 nux::Geometry const& geo = GetGeometry();
26 GfxContext.PushClippingRectangle(geo);
27 gPainter.PaintBackground(GfxContext, geo);
28@@ -177,6 +183,9 @@
29
30 void HudButton::DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw)
31 {
32+ if (skip_draw_)
33+ return;
34+
35 if (IsFullRedraw())
36 {
37 GfxContext.PushClippingRectangle(GetGeometry());
38@@ -207,6 +216,12 @@
39 return query_;
40 }
41
42+void HudButton::SetSkipDraw(bool skip_draw)
43+{
44+ skip_draw_ = skip_draw;
45+}
46+
47+
48 // Introspectable
49 std::string HudButton::GetName() const
50 {
51
52=== modified file 'hud/HudButton.h'
53--- hud/HudButton.h 2012-05-30 14:33:07 +0000
54+++ hud/HudButton.h 2012-06-27 21:42:19 +0000
55@@ -38,8 +38,8 @@
56
57 class HudButton : public nux::Button, public unity::debug::Introspectable
58 {
59- typedef nux::ObjectPtr<nux::BaseTexture> BaseTexturePtr;
60- typedef std::unique_ptr<nux::CairoWrapper> NuxCairoPtr;
61+ NUX_DECLARE_OBJECT_TYPE(HudButton, nux::Button);
62+
63 public:
64 typedef nux::ObjectPtr<HudButton> Ptr;
65
66@@ -48,6 +48,8 @@
67 void SetQuery(Query::Ptr query);
68 std::shared_ptr<Query> GetQuery();
69
70+ void SetSkipDraw(bool skip_draw);
71+
72 nux::Property<std::string> label;
73 nux::Property<bool> is_rounded;
74 nux::Property<bool> fake_focused;
75@@ -65,9 +67,13 @@
76 void RedrawTheme(nux::Geometry const& geom, cairo_t* cr, nux::ButtonVisualState faked_state);
77
78 private:
79+ typedef std::unique_ptr<nux::CairoWrapper> NuxCairoPtr;
80+
81 Query::Ptr query_;
82 nux::Geometry cached_geometry_;
83+
84 bool is_focused_;
85+ bool skip_draw_;
86
87 NuxCairoPtr prelight_;
88 NuxCairoPtr active_;
89
90=== modified file 'hud/HudView.cpp'
91--- hud/HudView.cpp 2012-06-27 12:51:27 +0000
92+++ hud/HudView.cpp 2012-06-27 21:42:19 +0000
93@@ -151,6 +151,11 @@
94 current_height_ = new_height;
95 }
96
97+ for (auto button : buttons_)
98+ {
99+ button->SetSkipDraw((button->GetAbsoluteY() + button->GetBaseHeight()) > (GetAbsoluteY() + current_height_));
100+ }
101+
102 QueueDraw();
103
104 if (diff > grow_anim_length + pause_before_grow_length)