Back to index

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

#include <HudIcon.h>

Inheritance diagram for unity::hud::Icon:
Inheritance graph
[legend]
Collaboration diagram for unity::hud::Icon:
Collaboration graph
[legend]

List of all members.

Public Types

typedef nux::ObjectPtr< IconPtr
typedef std::list
< Introspectable * > 
IntrospectableList

Public Member Functions

 Icon ()
void SetIcon (std::string const &icon_name, unsigned int icon_size, unsigned int tile_size)
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

sigc::signal< void,
nux::BaseTexture * > 
texture_updated

Protected Member Functions

void Draw (nux::GraphicsEngine &GfxContext, bool force_draw)
std::string GetName () const
virtual bool AcceptKeyNavFocus ()
void AddProperties (GVariantBuilder *builder)
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 Attributes

nux::ObjectPtr< nux::BaseTexture > background_
nux::ObjectPtr< nux::BaseTexture > gloss_
nux::ObjectPtr< nux::BaseTexture > edge_
nux::ObjectPtr
< HudIconTextureSource
icon_texture_source_
unity::ui::IconRenderer icon_renderer_

Detailed Description

Definition at line 34 of file HudIcon.h.


Member Typedef Documentation

Definition at line 34 of file Introspectable.h.

typedef nux::ObjectPtr<Icon> unity::hud::Icon::Ptr

Definition at line 37 of file HudIcon.h.


Constructor & Destructor Documentation

Definition at line 36 of file HudIcon.cpp.

  : IconTexture("", 0, true)
{
  background_.Adopt(nux::CreateTexture2DFromFile(PKGDATADIR"/launcher_icon_back_54.png", -1, true));
  gloss_.Adopt(nux::CreateTexture2DFromFile(PKGDATADIR"/launcher_icon_shine_54.png", -1, true));
  edge_.Adopt(nux::CreateTexture2DFromFile(PKGDATADIR"/launcher_icon_edge_54.png", -1,  true));

  texture_updated.connect([&] (nux::BaseTexture* texture)
  {
    icon_texture_source_ = new HudIconTextureSource(nux::ObjectPtr<nux::BaseTexture>(texture));
    icon_texture_source_->ColorForIcon(_pixbuf_cached);
    QueueDraw();
    LOG_DEBUG(logger) << "got our texture";
  });
}

Here is the call graph for this function:


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::IconTexture::AddProperties ( GVariantBuilder *  builder) [protected, virtual, inherited]

Implements unity::debug::Introspectable.

Reimplemented in unity::dash::LensBarIcon.

Definition at line 241 of file IconTexture.cpp.

{
  unity::variant::BuilderWrapper(builder)
  .add(GetGeometry())
  .add("icon_name", _icon_name);
}

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::hud::Icon::Draw ( nux::GraphicsEngine &  GfxContext,
bool  force_draw 
) [protected]

Reimplemented from unity::IconTexture.

Definition at line 60 of file HudIcon.cpp.

{
  if (texture() == nullptr)
    return;

  unity::ui::RenderArg arg;
  arg.icon = icon_texture_source_.GetPointer();
  arg.colorify            = nux::color::White;
  arg.running_arrow       = true;
  arg.running_on_viewport = true;
  arg.render_center       = nux::Point3(GetMinimumWidth() / 2.0f, GetMinimumHeight() / 2.0f, 0.0f);
  arg.logical_center      = arg.render_center;
  arg.window_indicators   = true;
  arg.backlight_intensity = 1.0f;
  arg.alpha               = 1.0f;

  std::list<unity::ui::RenderArg> args;
  args.push_front(arg);


  auto toplevel = GetToplevel();
  icon_renderer_.PreprocessIcons(args, toplevel->GetGeometry());
  icon_renderer_.RenderIcon(GfxContext, arg, toplevel->GetGeometry(), toplevel->GetGeometry());
}

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::hud::Icon::GetName ( ) const [protected, virtual]

Reimplemented from unity::IconTexture.

Definition at line 85 of file HudIcon.cpp.

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

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::hud::Icon::SetIcon ( std::string const &  icon_name,
unsigned int  icon_size,
unsigned int  tile_size 
)

Definition at line 52 of file HudIcon.cpp.

{
  IconTexture::SetByIconName(icon_name, icon_size);
  icon_renderer_.SetTargetSize(tile_size, icon_size, 0);
  SetMinimumWidth(tile_size);
  SetMinimumHeight(tile_size + vertical_padding * 2);
}

Here is the call 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::ObjectPtr<nux::BaseTexture> unity::hud::Icon::background_ [private]

Definition at line 48 of file HudIcon.h.

nux::ObjectPtr<nux::BaseTexture> unity::hud::Icon::edge_ [private]

Definition at line 50 of file HudIcon.h.

nux::ObjectPtr<nux::BaseTexture> unity::hud::Icon::gloss_ [private]

Definition at line 49 of file HudIcon.h.

Definition at line 52 of file HudIcon.h.

Definition at line 51 of file HudIcon.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: