Back to index

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

#include <LensBarIcon.h>

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

List of all members.

Public Types

typedef std::list
< Introspectable * > 
IntrospectableList

Public Member Functions

 LensBarIcon (std::string id, std::string icon_hint)
 ~LensBarIcon ()
void SetByIconName (std::string const &icon_name, unsigned int size)
void SetByFilePath (std::string const &file_path, unsigned int size)
void GetTextureSize (int *width, int *height)
void LoadIcon ()
void SetOpacity (float opacity)
void SetTexture (nux::BaseTexture *texture)
void SetAcceptKeyNavFocus (bool accept)
nux::BaseTexture * texture ()
GVariant * Introspect ()
void AddChild (Introspectable *child)
void RemoveChild (Introspectable *child)
virtual IntrospectableList GetIntrospectableChildren ()
guint64 GetIntrospectionId () const

Public Attributes

nux::Property< std::string > id
nux::Property< bool > active
sigc::signal< void,
nux::BaseTexture * > 
texture_updated

Protected Member Functions

virtual bool AcceptKeyNavFocus ()
virtual bool DoCanFocus ()
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'.

Protected Attributes

bool _accept_key_nav_focus
glib::Object< GdkPixbuf > _pixbuf_cached

Private Types

typedef std::unique_ptr
< nux::AbstractPaintLayer > 
LayerPtr

Private Member Functions

 NUX_DECLARE_OBJECT_TYPE (LensBarIcon, IconTexture)
void Draw (nux::GraphicsEngine &gfx_context, bool force_draw)
void OnActiveChanged (bool is_active)
std::string GetName () const
void AddProperties (GVariantBuilder *builder)

Private Attributes

const float inactive_opacity_
LayerPtr focus_layer_

Detailed Description

Definition at line 36 of file LensBarIcon.h.


Member Typedef Documentation

Definition at line 34 of file Introspectable.h.

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

Definition at line 55 of file LensBarIcon.h.


Constructor & Destructor Documentation

unity::dash::LensBarIcon::LensBarIcon ( std::string  id,
std::string  icon_hint 
)

Definition at line 40 of file LensBarIcon.cpp.

  : IconTexture(icon_hint, 24)
  , id(id_)
  , active(false)
  , inactive_opacity_(0.4f)
{
  SetMinimumWidth(FOCUS_OVERLAY_WIDTH);
  SetMaximumWidth(FOCUS_OVERLAY_WIDTH);
  SetMinimumHeight(FOCUS_OVERLAY_HEIGHT);
  SetMaximumHeight(FOCUS_OVERLAY_HEIGHT);

  focus_layer_.reset(Style::Instance().FocusOverlay(FOCUS_OVERLAY_WIDTH, FOCUS_OVERLAY_HEIGHT));
  
  SetOpacity(inactive_opacity_);

  SetAcceptKeyNavFocus(true);
  SetAcceptKeyNavFocusOnMouseDown(false);
  SetAcceptKeyNavFocusOnMouseEnter(true);

  active.changed.connect(sigc::mem_fun(this, &LensBarIcon::OnActiveChanged));
  key_nav_focus_change.connect([&](nux::Area*, bool, nux::KeyNavDirection){ QueueDraw(); });
}

Here is the call graph for this function:

Definition at line 63 of file LensBarIcon.cpp.

{}

Member Function Documentation

bool unity::IconTexture::AcceptKeyNavFocus ( ) [protected, virtual, inherited]

Definition at line 257 of file IconTexture.cpp.

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::dash::LensBarIcon::AddProperties ( GVariantBuilder *  builder) [private, virtual]

Reimplemented from unity::IconTexture.

Definition at line 119 of file LensBarIcon.cpp.

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

  wrapper.add(GetAbsoluteGeometry());
  wrapper.add("name", id);
}

Here is the call graph for this function:

bool unity::IconTexture::DoCanFocus ( ) [protected, virtual, inherited]

Definition at line 230 of file IconTexture.cpp.

{
  return false;
}
void unity::dash::LensBarIcon::Draw ( nux::GraphicsEngine &  gfx_context,
bool  force_draw 
) [private]

Reimplemented from unity::IconTexture.

Definition at line 66 of file LensBarIcon.cpp.

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

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

  if (!texture())
  {
    gfx_context.PopClippingRectangle();
    return;
  }

  if (HasKeyFocus() && focus_layer_)
  {
    nux::Geometry geo(GetGeometry());
    nux::AbstractPaintLayer* layer = focus_layer_.get();

    layer->SetGeometry(geo);
    layer->Renderlayer(gfx_context);
  }

  float opacity = active ? 1.0f : inactive_opacity_;
  int width = 0, height = 0;
  GetTextureSize(&width, &height);

  nux::Color col(1.0f * opacity, 1.0f * opacity, 1.0f * opacity, opacity);
  nux::TexCoordXForm texxform;
  texxform.SetTexCoordType(nux::TexCoordXForm::OFFSET_COORD);
  texxform.SetWrap(nux::TEXWRAP_CLAMP_TO_BORDER, nux::TEXWRAP_CLAMP_TO_BORDER);

  gfx_context.QRP_1Tex(geo.x + ((geo.width - width) / 2),
                       geo.y + ((geo.height - height) / 2),
                       width,
                       height,
                       texture()->GetDeviceTexture(),
                       texxform,
                       col);

  gfx_context.PopClippingRectangle();
}

Here is the call 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::LensBarIcon::GetName ( ) const [private, virtual]

Reimplemented from unity::IconTexture.

Definition at line 114 of file LensBarIcon.cpp.

{
  return "LensBarIcon";
}
void unity::IconTexture::GetTextureSize ( int *  width,
int *  height 
) [inherited]

Definition at line 205 of file IconTexture.cpp.

{
  if (width)
    *width = _texture_size.width;
  if (height)
    *height = _texture_size.height;
}

Here is the caller graph for this function:

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:

void unity::IconTexture::LoadIcon ( ) [inherited]

Definition at line 100 of file IconTexture.cpp.

{
  LOG_DEBUG(logger) << "LoadIcon called (" << _icon_name << ") - loading: " << _loading;
  static const char* const DEFAULT_GICON = ". GThemedIcon text-x-preview";

  if (_loading || _size == 0 || _handle)
    return;

  _loading = true;

  glib::Object<GIcon> icon(g_icon_new_for_string(_icon_name.empty() ?  DEFAULT_GICON : _icon_name.c_str(), NULL));

  if (G_IS_ICON(icon.RawPtr()))
  {
    _handle = IconLoader::GetDefault().LoadFromGIconString(_icon_name.empty() ? DEFAULT_GICON : _icon_name.c_str(),
                                                           _size,
                                                           sigc::mem_fun(this, &IconTexture::IconLoaded));
  }
  else if (_icon_name.find("http://") == 0)
  {
    _handle = IconLoader::GetDefault().LoadFromURI(_icon_name,
                                                   _size, sigc::mem_fun(this, &IconTexture::IconLoaded));
  }
  else
  {
    _handle = IconLoader::GetDefault().LoadFromIconName(_icon_name,
                                                        _size,
                                                        sigc::mem_fun(this, &IconTexture::IconLoaded));
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void unity::dash::LensBarIcon::OnActiveChanged ( bool  is_active) [private]

Definition at line 108 of file LensBarIcon.cpp.

{
  QueueDraw();
}

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:

void unity::IconTexture::SetAcceptKeyNavFocus ( bool  accept) [inherited]

Definition at line 252 of file IconTexture.cpp.

{
  _accept_key_nav_focus = accept;
}

Here is the caller graph for this function:

void unity::IconTexture::SetByFilePath ( std::string const &  file_path,
unsigned int  size 
) [inherited]

Definition at line 95 of file IconTexture.cpp.

{
  SetByIconName(file_path, size);
}

Here is the call graph for this function:

void unity::IconTexture::SetByIconName ( std::string const &  icon_name,
unsigned int  size 
) [inherited]

Definition at line 77 of file IconTexture.cpp.

{
  if (_icon_name == icon_name && _size == size)
    return;

  _icon_name = icon_name;
  _size = size;

  if (_size == 0)
  {
    _texture_cached = nullptr;
    return;
  }

  LoadIcon();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void unity::IconTexture::SetOpacity ( float  opacity) [inherited]

Definition at line 213 of file IconTexture.cpp.

{
  _opacity = opacity;

  QueueDraw();
}

Here is the caller graph for this function:

void unity::IconTexture::SetTexture ( nux::BaseTexture *  texture) [inherited]

Definition at line 220 of file IconTexture.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

nux::BaseTexture * unity::IconTexture::texture ( ) [inherited]

Definition at line 225 of file IconTexture.cpp.

{
  return _texture_cached.GetPointer();
}

Here is the caller graph for this function:


Member Data Documentation

bool unity::IconTexture::_accept_key_nav_focus [protected, inherited]

Definition at line 62 of file IconTexture.h.

glib::Object<GdkPixbuf> unity::IconTexture::_pixbuf_cached [protected, inherited]

Definition at line 67 of file IconTexture.h.

nux::Property<bool> unity::dash::LensBarIcon::active

Definition at line 44 of file LensBarIcon.h.

Definition at line 58 of file LensBarIcon.h.

nux::Property<std::string> unity::dash::LensBarIcon::id

Definition at line 43 of file LensBarIcon.h.

Definition at line 57 of file LensBarIcon.h.

sigc::signal<void, nux::BaseTexture*> unity::IconTexture::texture_updated [inherited]

Definition at line 57 of file IconTexture.h.


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