Back to index

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

#include <LensBar.h>

Inheritance diagram for unity::dash::LensBar:
Inheritance graph
[legend]
Collaboration diagram for unity::dash::LensBar:
Collaboration graph
[legend]

List of all members.

Public Types

typedef std::list
< Introspectable * > 
IntrospectableList

Public Member Functions

 LensBar ()
void AddLens (Lens::Ptr &lens)
void Activate (std::string id)
void ActivateNext ()
void ActivatePrevious ()
GVariant * Introspect ()
void AddChild (Introspectable *child)
void RemoveChild (Introspectable *child)
virtual IntrospectableList GetIntrospectableChildren ()
guint64 GetIntrospectionId () const

Public Attributes

sigc::signal< void,
std::string const & > 
lens_activated

Protected Member Functions

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 Types

typedef std::vector
< LensBarIcon * > 
LensIcons
typedef std::unique_ptr
< nux::AbstractPaintLayer > 
LayerPtr

Private Member Functions

 NUX_DECLARE_OBJECT_TYPE (LensBar, nux::View)
void SetupBackground ()
void SetupLayout ()
void SetupHomeLens ()
void Draw (nux::GraphicsEngine &gfx_context, bool force_draw)
void DrawContent (nux::GraphicsEngine &gfx_context, bool force_draw)
void SetActive (LensBarIcon *icon)
bool AcceptKeyNavFocus ()
std::string GetName () const
void AddProperties (GVariantBuilder *builder)
std::string GetActiveLensId () const

Private Attributes

LensIcons icons_
nux::HLayout * layout_
LayerPtr bg_layer_

Detailed Description

Definition at line 46 of file LensBar.h.


Member Typedef Documentation

Definition at line 34 of file Introspectable.h.

typedef std::unique_ptr<nux::AbstractPaintLayer> unity::dash::LensBar::LayerPtr [private]

Definition at line 77 of file LensBar.h.

typedef std::vector<LensBarIcon*> unity::dash::LensBar::LensIcons [private]

Definition at line 49 of file LensBar.h.


Constructor & Destructor Documentation

Definition at line 40 of file LensBar.cpp.

  : nux::View(NUX_TRACKER_LOCATION)
{
  SetupBackground();
  SetupLayout();
  SetupHomeLens();
}

Here is the call graph for this function:


Member Function Documentation

Definition at line 232 of file LensBar.cpp.

{
  return false;
}
void unity::dash::LensBar::Activate ( std::string  id)

Definition at line 93 of file LensBar.cpp.

{
  for (auto icon: icons_)
  {
    if (icon->id == id)
    {
      SetActive(icon);
      break;
    }
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 175 of file LensBar.cpp.

{
  // Special case when switching from the command lens.
  if (GetActiveLensId() == "commands.lens")
  {
    SetActive(icons_[0]);
    return;
  }

  bool activate_next = false;
  for (auto it = icons_.begin();
       it < icons_.end();
       it++)
  {
    LensBarIcon *icon = *it;

    if (activate_next && icon->IsVisible())
    {
      SetActive(icon);
      return;
    }
    if (icon->active)
      activate_next = true;
  }
  SetActive(icons_[0]);

}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 203 of file LensBar.cpp.

{
  // Special case when switching from the command lens.
  if (GetActiveLensId() == "commands.lens")
  {
    SetActive(icons_.back());
    return;
  }

  bool activate_previous = false;
  for (auto it = icons_.rbegin();
       it < icons_.rend();
       ++it)
  {
    LensBarIcon *icon = *it;

    if (activate_previous && icon->IsVisible())
    {
       SetActive(icon);
       return;
    }
    if (icon->active)
      activate_previous = true;
  }
  SetActive(icons_.back());

}

Here is the call graph for this function:

Here is the caller graph for this function:

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:

Definition at line 80 of file LensBar.cpp.

{
  LensBarIcon* icon = new LensBarIcon(lens->id, lens->icon_hint);
  icon->SetVisible(lens->visible);
  lens->visible.changed.connect([icon](bool visible) { icon->SetVisible(visible); } );
  icons_.push_back(icon);
  layout_->AddView(icon, 0, nux::eCenter, nux::eFix);
  AddChild(icon);

  icon->mouse_click.connect([&, icon] (int x, int y, unsigned long button, unsigned long keyboard) { SetActive(icon); });
  icon->key_nav_focus_activate.connect([&, icon](nux::Area*){ SetActive(icon); });
}

Here is the call graph for this function:

Here is the caller graph for this function:

void unity::dash::LensBar::AddProperties ( GVariantBuilder *  builder) [private, virtual]

Implements unity::debug::Introspectable.

Definition at line 243 of file LensBar.cpp.

{
  unity::variant::BuilderWrapper wrapper(builder);

  wrapper.add("focused-lens-icon", "");

  for( auto icon : icons_)
  {
    if (icon->active)
      wrapper.add("active-lens", icon->id.Get());

    if (icon->HasKeyFocus())
      wrapper.add("focused-lens-icon", icon->id.Get());
  }
}

Here is the call graph for this function:

void unity::dash::LensBar::Draw ( nux::GraphicsEngine &  gfx_context,
bool  force_draw 
) [private]

Definition at line 105 of file LensBar.cpp.

{
  nux::Geometry const& base = GetGeometry();

  gfx_context.PushClippingRectangle(base);
  nux::GetPainter().PaintBackground(gfx_context, base);

  bg_layer_->SetGeometry(base);
  nux::GetPainter().RenderSinglePaintLayer(gfx_context, base, bg_layer_.get());

  gfx_context.PopClippingRectangle();
}
void unity::dash::LensBar::DrawContent ( nux::GraphicsEngine &  gfx_context,
bool  force_draw 
) [private]

Definition at line 118 of file LensBar.cpp.

{
  nux::Geometry const& base = GetGeometry();

  gfx_context.PushClippingRectangle(base);

  if (!IsFullRedraw())
    nux::GetPainter().PushLayer(gfx_context, bg_layer_->GetGeometry(), bg_layer_.get());

  layout_->ProcessDraw(gfx_context, force_draw);

  if (!IsFullRedraw())
    nux::GetPainter().PopBackground();

  for (auto icon: icons_)
  {
    if (icon->active)
    {
      nux::Geometry const& geo = icon->GetGeometry();
      int middle = geo.x + geo.width/2;
      int size = 5;
      // Nux doesn't draw too well the small triangles, so let's draw a
      // bigger one and clip part of them using the "-1".
      int y = base.y - 1;

      nux::GetPainter().Draw2DTriangleColor(gfx_context,
                                            middle - size, y,
                                            middle, y + size,
                                            middle + size, y,
                                            nux::color::White);

      break;

    }
  }

  gfx_context.PopClippingRectangle();
}
std::string unity::dash::LensBar::GetActiveLensId ( ) const [private]

Definition at line 259 of file LensBar.cpp.

{
  for (auto icon : icons_)
  {
    if (icon->active)
      return icon->id;
  }
  return "";
}

Here is the caller graph for this function:

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::dash::LensBar::GetName ( ) const [private, virtual]

Implements unity::debug::Introspectable.

Definition at line 238 of file LensBar.cpp.

{
  return "LensBar";
}
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:

unity::dash::LensBar::NUX_DECLARE_OBJECT_TYPE ( LensBar  ,
nux::View   
) [private]

Definition at line 85 of file Introspectable.cpp.

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

Here is the caller graph for this function:

void unity::dash::LensBar::SetActive ( LensBarIcon icon) [private]

Definition at line 157 of file LensBar.cpp.

{
  bool state_changed = false;

  for (auto icon: icons_)
  {
    bool state = icon == activated;

    if (icon->active != state)
      state_changed = true;

    icon->active = state;
  }

  if (state_changed)
    lens_activated.emit(activated->id);
}

Here is the caller graph for this function:

Definition at line 48 of file LensBar.cpp.

{
  nux::ROPConfig rop;
  rop.Blend = true;
  rop.SrcBlend = GL_ONE;
  rop.DstBlend = GL_ONE_MINUS_SRC_ALPHA;
  bg_layer_.reset(new nux::ColorLayer(nux::Color(0.0f, 0.0f, 0.0f, 0.2f), true, rop));
}

Here is the caller graph for this function:

Definition at line 67 of file LensBar.cpp.

{
  LensBarIcon* icon = new LensBarIcon("home.lens", PKGDATADIR"/lens-nav-home.svg");
  icon->SetVisible(true);
  icon->active = true;
  icons_.push_back(icon);
  layout_->AddView(icon, 0, nux::eCenter, nux::MINOR_SIZE_FULL);
  AddChild(icon);

  icon->mouse_click.connect([&, icon] (int x, int y, unsigned long button, unsigned long keyboard) { SetActive(icon); });
  icon->key_nav_focus_activate.connect([&, icon](nux::Area*){ SetActive(icon); });
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 57 of file LensBar.cpp.

{
  layout_ = new nux::HLayout(NUX_TRACKER_LOCATION);
  layout_->SetContentDistribution(nux::MAJOR_POSITION_CENTER);
  SetLayout(layout_);

  SetMinimumHeight(LENSBAR_HEIGHT);
  SetMaximumHeight(LENSBAR_HEIGHT);
}

Here is the caller graph for this function:


Member Data Documentation

Definition at line 82 of file LensBar.h.

Definition at line 79 of file LensBar.h.

nux::HLayout* unity::dash::LensBar::layout_ [private]

Definition at line 81 of file LensBar.h.

sigc::signal<void, std::string const&> unity::dash::LensBar::lens_activated

Definition at line 59 of file LensBar.h.


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