Back to index

unity  6.0.0
Public Types | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes
unity::SearchBarSpinner Class Reference

#include <SearchBarSpinner.h>

Inheritance diagram for unity::SearchBarSpinner:
Inheritance graph
[legend]
Collaboration diagram for unity::SearchBarSpinner:
Collaboration graph
[legend]

List of all members.

Public Types

typedef std::list
< Introspectable * > 
IntrospectableList

Public Member Functions

 SearchBarSpinner ()
void Draw (nux::GraphicsEngine &GfxContext, bool force_draw)
void DrawContent (nux::GraphicsEngine &GfxContext, bool force_draw)
void SetState (SpinnerState state)
GVariant * Introspect ()
void AddChild (Introspectable *child)
void RemoveChild (Introspectable *child)
virtual IntrospectableList GetIntrospectableChildren ()
guint64 GetIntrospectionId () const

Protected Member Functions

std::string GetName () const
void AddProperties (GVariantBuilder *builder)
virtual bool AcceptKeyNavFocus ()
virtual std::string GetChildsName () const
 Please don't override this unless you really need to. The only valid reason is if you have a property that simply must be called 'Children'.

Private Member Functions

 NUX_DECLARE_OBJECT_TYPE (SearchBarSpinner, nux::View)
bool OnFrameTimeout ()

Private Attributes

SpinnerState _state
nux::BaseTexture * _magnify
nux::BaseTexture * _circle
nux::BaseTexture * _close
nux::BaseTexture * _spin
glib::Source::UniquePtr _spinner_timeout
glib::Source::UniquePtr _frame_timeout
nux::Matrix4 _2d_rotate
float _rotation

Detailed Description

Definition at line 41 of file SearchBarSpinner.h.


Member Typedef Documentation

Definition at line 34 of file Introspectable.h.


Constructor & Destructor Documentation

Definition at line 32 of file SearchBarSpinner.cpp.

  : nux::View(NUX_TRACKER_LOCATION),
    _state(STATE_READY),
    _rotation(0.0f)
{
  dash::Style& style = dash::Style::Instance();

  _magnify = style.GetSearchMagnifyIcon();
  _circle = style.GetSearchCircleIcon();
  _close = style.GetSearchCloseIcon();
  _spin = style.GetSearchSpinIcon();

  _2d_rotate.Identity();
  _2d_rotate.Rotate_z(0.0);
}

Here is the call graph for this function:


Member Function Documentation

bool unity::SearchBarSpinner::AcceptKeyNavFocus ( ) [protected, virtual]

Definition at line 192 of file SearchBarSpinner.cpp.

{
  return false;
}

Definition at line 78 of file Introspectable.cpp.

{
  _children.push_back(child);
  child->_parents.push_back(this);
}

Here is the caller graph for this function:

void unity::SearchBarSpinner::AddProperties ( GVariantBuilder *  builder) [protected, virtual]

Implements unity::debug::Introspectable.

Definition at line 177 of file SearchBarSpinner.cpp.

{
  nux::Geometry geo = GetGeometry();

  variant::BuilderWrapper(builder)
    .add("x", geo.x)
    .add("y", geo.y)
    .add("width", geo.width)
    .add("height", geo.height);
}

Here is the call graph for this function:

void unity::SearchBarSpinner::Draw ( nux::GraphicsEngine &  GfxContext,
bool  force_draw 
)

Definition at line 49 of file SearchBarSpinner.cpp.

{
  nux::Geometry const& geo = GetGeometry();
  nux::TexCoordXForm texxform;

  GfxContext.PushClippingRectangle(geo);

  nux::GetPainter().PaintBackground(GfxContext, geo);

  texxform.SetTexCoordType(nux::TexCoordXForm::OFFSET_COORD);
  texxform.SetWrap(nux::TEXWRAP_REPEAT, nux::TEXWRAP_REPEAT);
  texxform.min_filter = nux::TEXFILTER_LINEAR;
  texxform.mag_filter = nux::TEXFILTER_LINEAR;

  if (_state == STATE_READY)
  {
    GfxContext.QRP_1Tex(geo.x + ((geo.width - _magnify->GetWidth()) / 2),
                        geo.y + ((geo.height - _magnify->GetHeight()) / 2),
                        _magnify->GetWidth(),
                        _magnify->GetHeight(),
                        _magnify->GetDeviceTexture(),
                        texxform,
                        nux::color::White);
  }
  else if (_state == STATE_SEARCHING)
  {
    nux::Geometry spin_geo(geo.x + ((geo.width - _spin->GetWidth()) / 2),
                           geo.y + ((geo.height - _spin->GetHeight()) / 2),
                           _spin->GetWidth(),
                           _spin->GetHeight());
    // Geometry (== Rect) uses integers which were rounded above,
    // hence an extra 0.5 offset for odd sizes is needed
    // because pure floating point is not being used.
    int spin_offset_w = !(geo.width % 2) ? 0 : 1;
    int spin_offset_h = !(geo.height % 2) ? 0 : 1;

    GfxContext.PushModelViewMatrix(nux::Matrix4::TRANSLATE(-spin_geo.x - (spin_geo.width + spin_offset_w) / 2.0f,
                                                           -spin_geo.y - (spin_geo.height + spin_offset_h) / 2.0f, 0));
    GfxContext.PushModelViewMatrix(_2d_rotate);
    GfxContext.PushModelViewMatrix(nux::Matrix4::TRANSLATE(spin_geo.x + (spin_geo.width + spin_offset_w) / 2.0f,
                                                           spin_geo.y + (spin_geo.height + spin_offset_h) / 2.0f, 0));

    GfxContext.QRP_1Tex(spin_geo.x,
                        spin_geo.y,
                        spin_geo.width,
                        spin_geo.height,
                        _spin->GetDeviceTexture(),
                        texxform,
                        nux::color::White);

    GfxContext.PopModelViewMatrix();
    GfxContext.PopModelViewMatrix();
    GfxContext.PopModelViewMatrix();
  }
  else
  {
    GfxContext.QRP_1Tex(geo.x + ((geo.width - _circle->GetWidth()) / 2),
                        geo.y + ((geo.height - _circle->GetHeight()) / 2),
                        _circle->GetWidth(),
                        _circle->GetHeight(),
                        _circle->GetDeviceTexture(),
                        texxform,
                        nux::color::White);

    GfxContext.QRP_1Tex(geo.x + ((geo.width - _close->GetWidth()) / 2),
                        geo.y + ((geo.height - _close->GetHeight()) / 2),
                        _close->GetWidth(),
                        _close->GetHeight(),
                        _close->GetDeviceTexture(),
                        texxform,
                        nux::color::White);
  }
  GfxContext.PopClippingRectangle();

  if (_state == STATE_SEARCHING && !_frame_timeout)
  {
    _frame_timeout.reset(new glib::Timeout(22, sigc::mem_fun(this, &SearchBarSpinner::OnFrameTimeout)));
  }
}

Here is the call graph for this function:

void unity::SearchBarSpinner::DrawContent ( nux::GraphicsEngine &  GfxContext,
bool  force_draw 
)

Definition at line 130 of file SearchBarSpinner.cpp.

{
}
std::string unity::debug::Introspectable::GetChildsName ( ) const [protected, virtual, inherited]

Please don't override this unless you really need to. The only valid reason is if you have a property that simply must be called 'Children'.

Definition at line 92 of file Introspectable.cpp.

{
  return "Children";
}

Here is the caller graph for this function:

Introspectable::IntrospectableList unity::debug::Introspectable::GetIntrospectableChildren ( ) [virtual, inherited]

Reimplemented in unity::hud::View, unity::launcher::LauncherModel, unity::QuicklistView, and unity::dash::ResultView.

Definition at line 41 of file Introspectable.cpp.

{
  return _children;
}

Here is the caller graph for this function:

guint64 unity::debug::Introspectable::GetIntrospectionId ( ) const [inherited]

Definition at line 97 of file Introspectable.cpp.

{
  return _id;
}

Here is the caller graph for this function:

std::string unity::SearchBarSpinner::GetName ( ) const [protected, virtual]

Implements unity::debug::Introspectable.

Definition at line 172 of file SearchBarSpinner.cpp.

{
  return "SearchBarSpinner";
}
GVariant * unity::debug::Introspectable::Introspect ( ) [inherited]

Definition at line 47 of file Introspectable.cpp.

{
  GVariantBuilder  builder;
  GVariantBuilder  child_builder;
  gint             n_children = 0;

  g_variant_builder_init(&builder, G_VARIANT_TYPE("a{sv}"));
  g_variant_builder_add(&builder, "{sv}", "id", g_variant_new_uint64(_id));

  AddProperties(&builder);

  g_variant_builder_init(&child_builder, G_VARIANT_TYPE("as"));

  auto children = GetIntrospectableChildren();
  for (auto it = children.begin(); it != children.end(); it++)
  {
    if ((*it)->GetName() != "")
    {
      g_variant_builder_add(&child_builder, "s", (*it)->GetName().c_str());
      n_children++;
    }
  }

  GVariant* child_results = g_variant_builder_end(&child_builder);

  if (n_children > 0)
    g_variant_builder_add(&builder, "{sv}", GetChildsName().c_str(), child_results);
  return g_variant_builder_end(&builder);
}

Here is the call graph for this function:

Definition at line 135 of file SearchBarSpinner.cpp.

{
  _rotation += 0.1f;

  if (_rotation >= 360.0f)
    _rotation = 0.0f;

  _2d_rotate.Rotate_z(_rotation);
  QueueDraw();

  _frame_timeout.reset();
  return false;
}

Here is the caller graph for this function:

Definition at line 85 of file Introspectable.cpp.

{
  _children.remove(child);
  child->_parents.remove(this);
}

Here is the caller graph for this function:

Definition at line 150 of file SearchBarSpinner.cpp.

{
  if (_state == state)
    return;

  _state = state;
  _spinner_timeout.reset();
  _2d_rotate.Rotate_z(0.0f);
  _rotation = 0.0f;

  if (_state == STATE_SEARCHING)
  {
    _spinner_timeout.reset(new glib::TimeoutSeconds(5, [&] {
      _state = STATE_READY;
      return false;
    }));
  }

  QueueDraw();
}

Member Data Documentation

nux::Matrix4 unity::SearchBarSpinner::_2d_rotate [private]

Definition at line 73 of file SearchBarSpinner.h.

nux::BaseTexture* unity::SearchBarSpinner::_circle [private]

Definition at line 66 of file SearchBarSpinner.h.

nux::BaseTexture* unity::SearchBarSpinner::_close [private]

Definition at line 67 of file SearchBarSpinner.h.

Definition at line 71 of file SearchBarSpinner.h.

nux::BaseTexture* unity::SearchBarSpinner::_magnify [private]

Definition at line 65 of file SearchBarSpinner.h.

Definition at line 74 of file SearchBarSpinner.h.

nux::BaseTexture* unity::SearchBarSpinner::_spin [private]

Definition at line 68 of file SearchBarSpinner.h.

Definition at line 70 of file SearchBarSpinner.h.

Definition at line 63 of file SearchBarSpinner.h.


The documentation for this class was generated from the following files: