summaryrefslogtreecommitdiff
path: root/hud
diff options
authorAndrea Azzarone <azzaronea@gmail.com>2012-06-27 23:32:48 +0200
committerAndrea Azzarone <azzaronea@gmail.com>2012-06-27 23:32:48 +0200
commit9e84dac1cdf8e869283ab9c0e3b5ce87d65aed04 (patch)
treec741f4b939bb470a80dc1b3bffa1cebd836ab2a1 /hud
parent023832f96aa3f2f7b0e51f234168751ee344f3df (diff)
Fix bug 932531.
(bzr r2447.1.1)
Diffstat (limited to 'hud')
-rw-r--r--hud/HudButton.cpp15
-rw-r--r--hud/HudButton.h10
-rw-r--r--hud/HudView.cpp5
3 files changed, 28 insertions, 2 deletions
diff --git a/hud/HudButton.cpp b/hud/HudButton.cpp
index 3a36b045c..12d701d8b 100644
--- a/hud/HudButton.cpp
+++ b/hud/HudButton.cpp
@@ -52,10 +52,13 @@ namespace unity
namespace hud
{
+NUX_IMPLEMENT_OBJECT_TYPE(HudButton);
+
HudButton::HudButton(NUX_FILE_LINE_DECL)
: nux::Button(NUX_FILE_LINE_PARAM)
, is_rounded(false)
, is_focused_(false)
+ , skip_draw_(true)
{
hlayout_ = new nux::HLayout(NUX_TRACKER_LOCATION);
hlayout_->SetLeftAndRightPadding(hlayout_left_padding, -1);
@@ -130,6 +133,9 @@ long HudButton::ComputeContentSize()
void HudButton::Draw(nux::GraphicsEngine& GfxContext, bool force_draw)
{
+ if (skip_draw_)
+ return;
+
nux::Geometry const& geo = GetGeometry();
GfxContext.PushClippingRectangle(geo);
gPainter.PaintBackground(GfxContext, geo);
@@ -177,6 +183,9 @@ void HudButton::Draw(nux::GraphicsEngine& GfxContext, bool force_draw)
void HudButton::DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw)
{
+ if (skip_draw_)
+ return;
+
if (IsFullRedraw())
{
GfxContext.PushClippingRectangle(GetGeometry());
@@ -207,6 +216,12 @@ Query::Ptr HudButton::GetQuery()
return query_;
}
+void HudButton::SetSkipDraw(bool skip_draw)
+{
+ skip_draw_ = skip_draw;
+}
+
+
// Introspectable
std::string HudButton::GetName() const
{
diff --git a/hud/HudButton.h b/hud/HudButton.h
index 555f5ab38..9ccf43d14 100644
--- a/hud/HudButton.h
+++ b/hud/HudButton.h
@@ -38,8 +38,8 @@ namespace hud
class HudButton : public nux::Button, public unity::debug::Introspectable
{
- typedef nux::ObjectPtr<nux::BaseTexture> BaseTexturePtr;
- typedef std::unique_ptr<nux::CairoWrapper> NuxCairoPtr;
+ NUX_DECLARE_OBJECT_TYPE(HudButton, nux::Button);
+
public:
typedef nux::ObjectPtr<HudButton> Ptr;
@@ -48,6 +48,8 @@ public:
void SetQuery(Query::Ptr query);
std::shared_ptr<Query> GetQuery();
+ void SetSkipDraw(bool skip_draw);
+
nux::Property<std::string> label;
nux::Property<bool> is_rounded;
nux::Property<bool> fake_focused;
@@ -65,9 +67,13 @@ protected:
void RedrawTheme(nux::Geometry const& geom, cairo_t* cr, nux::ButtonVisualState faked_state);
private:
+ typedef std::unique_ptr<nux::CairoWrapper> NuxCairoPtr;
+
Query::Ptr query_;
nux::Geometry cached_geometry_;
+
bool is_focused_;
+ bool skip_draw_;
NuxCairoPtr prelight_;
NuxCairoPtr active_;
diff --git a/hud/HudView.cpp b/hud/HudView.cpp
index 150492452..725648a62 100644
--- a/hud/HudView.cpp
+++ b/hud/HudView.cpp
@@ -151,6 +151,11 @@ void View::ProcessGrowShrink()
current_height_ = new_height;
}
+ for (auto button : buttons_)
+ {
+ button->SetSkipDraw((button->GetAbsoluteY() + button->GetBaseHeight()) > (GetAbsoluteY() + current_height_));
+ }
+
QueueDraw();
if (diff > grow_anim_length + pause_before_grow_length)