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
=== modified file 'hud/HudButton.cpp'
--- hud/HudButton.cpp 2012-06-27 12:51:27 +0000
+++ hud/HudButton.cpp 2012-06-27 21:42:19 +0000
@@ -52,10 +52,13 @@
52namespace hud52namespace hud
53{53{
5454
55NUX_IMPLEMENT_OBJECT_TYPE(HudButton);
56
55HudButton::HudButton(NUX_FILE_LINE_DECL)57HudButton::HudButton(NUX_FILE_LINE_DECL)
56 : nux::Button(NUX_FILE_LINE_PARAM)58 : nux::Button(NUX_FILE_LINE_PARAM)
57 , is_rounded(false)59 , is_rounded(false)
58 , is_focused_(false)60 , is_focused_(false)
61 , skip_draw_(true)
59{62{
60 hlayout_ = new nux::HLayout(NUX_TRACKER_LOCATION);63 hlayout_ = new nux::HLayout(NUX_TRACKER_LOCATION);
61 hlayout_->SetLeftAndRightPadding(hlayout_left_padding, -1);64 hlayout_->SetLeftAndRightPadding(hlayout_left_padding, -1);
@@ -130,6 +133,9 @@
130133
131void HudButton::Draw(nux::GraphicsEngine& GfxContext, bool force_draw)134void HudButton::Draw(nux::GraphicsEngine& GfxContext, bool force_draw)
132{135{
136 if (skip_draw_)
137 return;
138
133 nux::Geometry const& geo = GetGeometry();139 nux::Geometry const& geo = GetGeometry();
134 GfxContext.PushClippingRectangle(geo);140 GfxContext.PushClippingRectangle(geo);
135 gPainter.PaintBackground(GfxContext, geo);141 gPainter.PaintBackground(GfxContext, geo);
@@ -177,6 +183,9 @@
177183
178void HudButton::DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw)184void HudButton::DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw)
179{185{
186 if (skip_draw_)
187 return;
188
180 if (IsFullRedraw())189 if (IsFullRedraw())
181 {190 {
182 GfxContext.PushClippingRectangle(GetGeometry());191 GfxContext.PushClippingRectangle(GetGeometry());
@@ -207,6 +216,12 @@
207 return query_;216 return query_;
208}217}
209218
219void HudButton::SetSkipDraw(bool skip_draw)
220{
221 skip_draw_ = skip_draw;
222}
223
224
210// Introspectable225// Introspectable
211std::string HudButton::GetName() const226std::string HudButton::GetName() const
212{227{
213228
=== modified file 'hud/HudButton.h'
--- hud/HudButton.h 2012-05-30 14:33:07 +0000
+++ hud/HudButton.h 2012-06-27 21:42:19 +0000
@@ -38,8 +38,8 @@
3838
39class HudButton : public nux::Button, public unity::debug::Introspectable 39class HudButton : public nux::Button, public unity::debug::Introspectable
40{40{
41 typedef nux::ObjectPtr<nux::BaseTexture> BaseTexturePtr;41 NUX_DECLARE_OBJECT_TYPE(HudButton, nux::Button);
42 typedef std::unique_ptr<nux::CairoWrapper> NuxCairoPtr;42
43public:43public:
44 typedef nux::ObjectPtr<HudButton> Ptr;44 typedef nux::ObjectPtr<HudButton> Ptr;
4545
@@ -48,6 +48,8 @@
48 void SetQuery(Query::Ptr query);48 void SetQuery(Query::Ptr query);
49 std::shared_ptr<Query> GetQuery();49 std::shared_ptr<Query> GetQuery();
5050
51 void SetSkipDraw(bool skip_draw);
52
51 nux::Property<std::string> label;53 nux::Property<std::string> label;
52 nux::Property<bool> is_rounded;54 nux::Property<bool> is_rounded;
53 nux::Property<bool> fake_focused;55 nux::Property<bool> fake_focused;
@@ -65,9 +67,13 @@
65 void RedrawTheme(nux::Geometry const& geom, cairo_t* cr, nux::ButtonVisualState faked_state);67 void RedrawTheme(nux::Geometry const& geom, cairo_t* cr, nux::ButtonVisualState faked_state);
6668
67private:69private:
70 typedef std::unique_ptr<nux::CairoWrapper> NuxCairoPtr;
71
68 Query::Ptr query_;72 Query::Ptr query_;
69 nux::Geometry cached_geometry_;73 nux::Geometry cached_geometry_;
74
70 bool is_focused_;75 bool is_focused_;
76 bool skip_draw_;
7177
72 NuxCairoPtr prelight_;78 NuxCairoPtr prelight_;
73 NuxCairoPtr active_;79 NuxCairoPtr active_;
7480
=== modified file 'hud/HudView.cpp'
--- hud/HudView.cpp 2012-06-27 12:51:27 +0000
+++ hud/HudView.cpp 2012-06-27 21:42:19 +0000
@@ -151,6 +151,11 @@
151 current_height_ = new_height;151 current_height_ = new_height;
152 }152 }
153153
154 for (auto button : buttons_)
155 {
156 button->SetSkipDraw((button->GetAbsoluteY() + button->GetBaseHeight()) > (GetAbsoluteY() + current_height_));
157 }
158
154 QueueDraw();159 QueueDraw();
155160
156 if (diff > grow_anim_length + pause_before_grow_length)161 if (diff > grow_anim_length + pause_before_grow_length)