Back to index

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

#include <PanelIndicatorEntryView.h>

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

List of all members.

Public Types

enum  IndicatorEntryType { INDICATOR, MENU, OTHER }
typedef std::list
< Introspectable * > 
IntrospectableList

Public Member Functions

 PanelIndicatorEntryView (indicator::Entry::Ptr const &proxy, int padding=5, IndicatorEntryType type=INDICATOR)
virtual ~PanelIndicatorEntryView ()
IndicatorEntryType GetType () const
std::string GetEntryID () const
int GetEntryPriority () const
virtual std::string GetLabel () const
virtual bool IsLabelVisible () const
virtual bool IsLabelSensitive () const
virtual bool IsIconVisible () const
virtual bool IsIconSensitive () const
virtual void Activate (int button=1)
virtual void Unactivate ()
virtual void GetGeometryForSync (indicator::EntryLocationMap &locations)
bool GetShowNow () const
bool IsSensitive () const
bool IsActive () const
bool IsVisible ()
void SetDisabled (bool disabled)
bool IsDisabled ()
void SetOpacity (double alpha)
double GetOpacity ()
void SetFocusedState (bool focused)
bool IsFocused () const
void OverlayShown ()
void OverlayHidden ()
GVariant * Introspect ()
void AddChild (Introspectable *child)
void RemoveChild (Introspectable *child)
virtual IntrospectableList GetIntrospectableChildren ()
guint64 GetIntrospectionId () const

Public Attributes

sigc::signal< void,
PanelIndicatorEntryView
*, bool > 
active_changed
sigc::signal< void,
PanelIndicatorEntryView * > 
refreshed

Protected Member Functions

std::string GetName () const
void AddProperties (GVariantBuilder *builder)
virtual void Draw (nux::GraphicsEngine &GfxContext, bool force_draw)
virtual void DrawEntryPrelight (cairo_t *cr, unsigned int w, unsigned int h)
virtual void DrawEntryContent (cairo_t *cr, unsigned int width, unsigned int height, glib::Object< GdkPixbuf > const &pixbuf, glib::Object< PangoLayout > const &layout)
void Refresh ()
void SetActiveState (bool active, int button)
virtual void ShowMenu (int button=1)
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

indicator::Entry::Ptr proxy_
unsigned int spacing_
unsigned int left_padding_
unsigned int right_padding_

Private Member Functions

void OnMouseDown (int x, int y, long button_flags, long key_flags)
void OnMouseUp (int x, int y, long button_flags, long key_flags)
void OnMouseWheel (int x, int y, int delta, unsigned long mouse_state, unsigned long key_state)
void OnActiveChanged (bool is_active)
glib::Object< GdkPixbuf > MakePixbuf ()

Private Attributes

IndicatorEntryType type_
nux::ObjectPtr< nux::BaseTexture > entry_texture_
nux::Geometry cached_geo_
double opacity_
bool draw_active_
bool overlay_showing_
bool disabled_
bool focused_

Detailed Description

Definition at line 40 of file PanelIndicatorEntryView.h.


Member Typedef Documentation

Definition at line 34 of file Introspectable.h.


Member Enumeration Documentation

Enumerator:
INDICATOR 
MENU 
OTHER 

Definition at line 43 of file PanelIndicatorEntryView.h.


Constructor & Destructor Documentation

Definition at line 52 of file PanelIndicatorEntryView.cpp.

  : TextureArea(NUX_TRACKER_LOCATION)
  , proxy_(proxy)
  , spacing_(DEFAULT_SPACING)
  , left_padding_(padding < 0 ? 0 : padding)
  , right_padding_(left_padding_)
  , type_(type)
  , entry_texture_(nullptr)
  , opacity_(1.0f)
  , draw_active_(false)
  , overlay_showing_(false)
  , disabled_(false)
  , focused_(true)
{
  proxy_->active_changed.connect(sigc::mem_fun(this, &PanelIndicatorEntryView::OnActiveChanged));
  proxy_->updated.connect(sigc::mem_fun(this, &PanelIndicatorEntryView::Refresh));

  InputArea::mouse_down.connect(sigc::mem_fun(this, &PanelIndicatorEntryView::OnMouseDown));
  InputArea::mouse_up.connect(sigc::mem_fun(this, &PanelIndicatorEntryView::OnMouseUp));

  InputArea::SetAcceptMouseWheelEvent(true);

  if (type_ != MENU)
    InputArea::mouse_wheel.connect(sigc::mem_fun(this, &PanelIndicatorEntryView::OnMouseWheel));

  panel::Style::Instance().changed.connect(sigc::mem_fun(this, &PanelIndicatorEntryView::Refresh));

  Refresh();
}

Here is the call graph for this function:

Definition at line 83 of file PanelIndicatorEntryView.cpp.

{
  // Nothing to do...
}

Member Function Documentation

void unity::PanelIndicatorEntryView::Activate ( int  button = 1) [virtual]

Definition at line 163 of file PanelIndicatorEntryView.cpp.

{
  SetActiveState(true, button);
}

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:

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

Implements unity::debug::Introspectable.

Definition at line 641 of file PanelIndicatorEntryView.cpp.

{
  std::string type_name;

  switch (GetType())
  {
    case INDICATOR:
      type_name = "indicator";
      break;
    case MENU:
      type_name = "menu";
      break;
    default:
      type_name = "other";
  }

  variant::BuilderWrapper(builder)
  .add(GetAbsoluteGeometry())
  .add("entry_id", GetEntryID())
  .add("name_hint", proxy_->name_hint())
  .add("type", type_name)
  .add("priority", proxy_->priority())
  .add("label", GetLabel())
  .add("label_sensitive", IsLabelSensitive())
  .add("label_visible", IsLabelVisible())
  .add("icon_sensitive", IsIconSensitive())
  .add("icon_visible", IsIconVisible())
  .add("visible", IsVisible() && GetOpacity() != 0.0f)
  .add("opacity", GetOpacity())
  .add("active", proxy_->active())
  .add("menu_x", proxy_->geometry().x)
  .add("menu_y", proxy_->geometry().y)
  .add("menu_width", proxy_->geometry().width)
  .add("menu_height", proxy_->geometry().height)
  .add("focused", IsFocused());
}

Here is the call graph for this function:

void unity::PanelIndicatorEntryView::Draw ( nux::GraphicsEngine &  GfxContext,
bool  force_draw 
) [protected, virtual]

Definition at line 521 of file PanelIndicatorEntryView.cpp.

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

  if (cached_geo_ != geo)
  {
    Refresh();
    cached_geo_ = geo;
  }

  if (entry_texture_ && opacity_ > 0.0f)
  {
    /* "Clear" out the background */
    nux::ROPConfig rop;
    rop.Blend = true;
    rop.SrcBlend = GL_ONE;
    rop.DstBlend = GL_ONE_MINUS_SRC_ALPHA;

    nux::ColorLayer layer(nux::color::Transparent, true, rop);
    nux::GetPainter().PushDrawLayer(GfxContext, geo, &layer);

    nux::TexCoordXForm texxform;
    GfxContext.QRP_1Tex(geo.x, geo.y, geo.width, geo.height,
                        entry_texture_->GetDeviceTexture(), texxform,
                        nux::color::White * opacity_);
  }

  GfxContext.PopClippingRectangle();
}

Here is the call graph for this function:

void unity::PanelIndicatorEntryView::DrawEntryContent ( cairo_t *  cr,
unsigned int  width,
unsigned int  height,
glib::Object< GdkPixbuf > const &  pixbuf,
glib::Object< PangoLayout > const &  layout 
) [protected, virtual]

Definition at line 251 of file PanelIndicatorEntryView.cpp.

{
  int x = left_padding_;

  if (IsActive())
    DrawEntryPrelight(cr, width, height);

  if (pixbuf && IsIconVisible())
  {
    GtkStyleContext* style_context = panel::Style::Instance().GetStyleContext();
    unsigned int icon_width = gdk_pixbuf_get_width(pixbuf);

    gtk_style_context_save(style_context);

    GtkWidgetPath* widget_path = gtk_widget_path_new();
    gint pos = gtk_widget_path_append_type(widget_path, GTK_TYPE_MENU_BAR);
    pos = gtk_widget_path_append_type(widget_path, GTK_TYPE_MENU_ITEM);
    gtk_widget_path_iter_set_name(widget_path, pos, "UnityPanelWidget");

    gtk_style_context_set_path(style_context, widget_path);
    gtk_style_context_add_class(style_context, GTK_STYLE_CLASS_MENUBAR);
    gtk_style_context_add_class(style_context, GTK_STYLE_CLASS_MENUITEM);

    if (!IsFocused())
    {
      gtk_style_context_set_state(style_context, GTK_STATE_FLAG_BACKDROP);
    }
    else if (IsActive())
    {
      gtk_style_context_set_state(style_context, GTK_STATE_FLAG_PRELIGHT);
    }

    int y = (int)((height - gdk_pixbuf_get_height(pixbuf)) / 2);
    if (overlay_showing_ && !IsActive())
    {
      /* Most of the images we get are straight pixbufs (annoyingly), so when
       * the Overlay opens, we use the pixbuf as a mask to punch out an icon from
       * a white square. It works surprisingly well for most symbolic-type
       * icon themes/icons.
       */
      cairo_save(cr);

      cairo_push_group(cr);
      gdk_cairo_set_source_pixbuf(cr, pixbuf, x, y);
      cairo_paint_with_alpha(cr, (IsIconSensitive() && IsFocused()) ? 1.0 : 0.5);

      cairo_pattern_t* pat = cairo_pop_group(cr);

      cairo_set_source_rgba(cr, 1.0f, 1.0f, 1.0f, 1.0f);
      cairo_rectangle(cr, x, y, width, height);
      cairo_mask(cr, pat);

      cairo_pattern_destroy(pat);
      cairo_restore(cr);
    }
    else
    {
      cairo_push_group(cr);
      gtk_render_icon(style_context, cr, pixbuf, x, y);
      cairo_pop_group_to_source(cr);
      cairo_paint_with_alpha(cr, (IsIconSensitive() && IsFocused()) ? 1.0 : 0.5);
    }

    gtk_widget_path_free(widget_path);

    gtk_style_context_restore(style_context);

    x += icon_width + spacing_;
  }

  if (layout)
  {
    PangoRectangle log_rect;
    pango_layout_get_extents(layout, nullptr, &log_rect);
    unsigned int text_height = log_rect.height / PANGO_SCALE;
    unsigned int text_width = log_rect.width / PANGO_SCALE;

    pango_cairo_update_layout(cr, layout);

    GtkStyleContext* style_context = panel::Style::Instance().GetStyleContext();

    gtk_style_context_save(style_context);

    GtkWidgetPath* widget_path = gtk_widget_path_new();
    gint pos = gtk_widget_path_append_type(widget_path, GTK_TYPE_MENU_BAR);
    pos = gtk_widget_path_append_type(widget_path, GTK_TYPE_MENU_ITEM);
    gtk_widget_path_iter_set_name(widget_path, pos, "UnityPanelWidget");

    gtk_style_context_set_path(style_context, widget_path);
    gtk_style_context_add_class(style_context, GTK_STYLE_CLASS_MENUBAR);
    gtk_style_context_add_class(style_context, GTK_STYLE_CLASS_MENUITEM);

    if (!IsFocused())
    {
      gtk_style_context_set_state(style_context, GTK_STATE_FLAG_BACKDROP);
    }
    else if (IsActive())
    {
      gtk_style_context_set_state(style_context, GTK_STATE_FLAG_PRELIGHT);
    }

    int y = (height - text_height) / 2;


    unsigned int text_space = GetMaximumWidth() - x - right_padding_;

    if (text_width > text_space)
    {
      cairo_pattern_t* linpat;
      int out_pixels = text_width - text_space;
      const int fading_pixels = 15;

      int fading_width = out_pixels < fading_pixels ? out_pixels : fading_pixels;

      cairo_push_group(cr);
      if (overlay_showing_)
      {
        cairo_move_to(cr, x, y);
        cairo_set_source_rgb(cr, 1.0f, 1.0f, 1.0f);
        pango_cairo_show_layout(cr, layout);
      }
      else
      {
        gtk_render_layout(style_context, cr, x, y, layout);
      }
      cairo_pop_group_to_source(cr);

      int right_margin = width - right_padding_;
      linpat = cairo_pattern_create_linear(right_margin - fading_width, y, right_margin, y);
      cairo_pattern_add_color_stop_rgba(linpat, 0, 0, 0, 0, 1);
      cairo_pattern_add_color_stop_rgba(linpat, 1, 0, 0, 0, 0);
      cairo_mask(cr, linpat);
      cairo_pattern_destroy(linpat);
    }
    else
    {
      if (overlay_showing_)
      {
        cairo_move_to(cr, x, y);
        cairo_set_source_rgb(cr, 1.0f, 1.0f, 1.0f);
        pango_cairo_show_layout(cr, layout);
      }
      else
      {
        gtk_render_layout(style_context, cr, x, y, layout);
      }
    }

    gtk_widget_path_free(widget_path);
    gtk_style_context_restore(style_context);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void unity::PanelIndicatorEntryView::DrawEntryPrelight ( cairo_t *  cr,
unsigned int  w,
unsigned int  h 
) [protected, virtual]

Definition at line 227 of file PanelIndicatorEntryView.cpp.

{
  GtkStyleContext* style_context = panel::Style::Instance().GetStyleContext();

  gtk_style_context_save(style_context);

  GtkWidgetPath* widget_path = gtk_widget_path_new();
  gtk_widget_path_append_type(widget_path, GTK_TYPE_MENU_BAR);
  gtk_widget_path_append_type(widget_path, GTK_TYPE_MENU_ITEM);
  gtk_widget_path_iter_set_name(widget_path, -1 , "UnityPanelWidget");

  gtk_style_context_set_path(style_context, widget_path);
  gtk_style_context_add_class(style_context, GTK_STYLE_CLASS_MENUBAR);
  gtk_style_context_add_class(style_context, GTK_STYLE_CLASS_MENUITEM);
  gtk_style_context_set_state(style_context, GTK_STATE_FLAG_PRELIGHT);

  gtk_render_background(style_context, cr, 0, 0, width, height);
  gtk_render_frame(style_context, cr, 0, 0, width, height);

  gtk_widget_path_free(widget_path);

  gtk_style_context_restore(style_context);
}

Here is the call graph for this function:

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:

Definition at line 715 of file PanelIndicatorEntryView.cpp.

{
  if (proxy_.get())
  {
    return proxy_->id();
  }

  return "";
}

Here is the caller graph for this function:

Definition at line 725 of file PanelIndicatorEntryView.cpp.

{
  if (proxy_.get())
  {
    return proxy_->priority();
  }
  return -1;
}

Here is the caller graph for this function:

Definition at line 683 of file PanelIndicatorEntryView.cpp.

{
  if (!IsVisible())
    return;

  locations[GetEntryID()] = GetAbsoluteGeometry();
}

Here is the call 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::PanelIndicatorEntryView::GetLabel ( ) const [virtual]

Definition at line 586 of file PanelIndicatorEntryView.cpp.

{
  if (proxy_.get())
  {
    return proxy_->label();
  }

  return "";
}

Here is the caller graph for this function:

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

Implements unity::debug::Introspectable.

Definition at line 636 of file PanelIndicatorEntryView.cpp.

{
  return "IndicatorEntry";
}

Definition at line 576 of file PanelIndicatorEntryView.cpp.

{
  return opacity_;
}

Here is the caller graph for this function:

Definition at line 678 of file PanelIndicatorEntryView.cpp.

{
  return proxy_.get() ? proxy_->show_now() : false;
}

Definition at line 581 of file PanelIndicatorEntryView.cpp.

{
  return type_;
}

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:

Definition at line 710 of file PanelIndicatorEntryView.cpp.

{
  return draw_active_;
}

Here is the caller graph for this function:

Definition at line 739 of file PanelIndicatorEntryView.cpp.

{
  return (disabled_ || !proxy_.get() || !IsSensitive());
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 753 of file PanelIndicatorEntryView.cpp.

{
  return focused_;
}

Here is the caller graph for this function:

Definition at line 626 of file PanelIndicatorEntryView.cpp.

{
  if (proxy_.get())
  {
    return proxy_->image_sensitive();
  }

  return false;
}

Here is the caller graph for this function:

Definition at line 616 of file PanelIndicatorEntryView.cpp.

{
  if (proxy_.get())
  {
    return proxy_->image_visible();
  }

  return false;
}

Here is the caller graph for this function:

Definition at line 606 of file PanelIndicatorEntryView.cpp.

{
  if (proxy_.get())
  {
    return proxy_->label_sensitive();
  }

  return false;
}

Here is the caller graph for this function:

Definition at line 596 of file PanelIndicatorEntryView.cpp.

{
  if (proxy_.get())
  {
    return proxy_->label_visible();
  }

  return false;
}

Here is the caller graph for this function:

Definition at line 691 of file PanelIndicatorEntryView.cpp.

{
  if (proxy_.get())
  {
    return IsIconSensitive() || IsLabelSensitive();
  }
  return false;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 700 of file PanelIndicatorEntryView.cpp.

{
  if (proxy_.get())
  {
    return TextureArea::IsVisible() && proxy_->visible();
  }

  return TextureArea::IsVisible();
}

Here is the caller graph for this function:

Definition at line 185 of file PanelIndicatorEntryView.cpp.

{
  glib::Object<GdkPixbuf> pixbuf;
  GtkIconTheme* theme = gtk_icon_theme_get_default();
  int image_type = proxy_->image_type();

  if (image_type == GTK_IMAGE_PIXBUF)
  {
    gsize len = 0;
    guchar* decoded = g_base64_decode(proxy_->image_data().c_str(), &len);

    glib::Object<GInputStream> stream(g_memory_input_stream_new_from_data(decoded,
                                                                          len,
                                                                          nullptr));

    pixbuf = gdk_pixbuf_new_from_stream(stream, nullptr, nullptr);

    g_free(decoded);
    g_input_stream_close(stream, nullptr, nullptr);
  }
  else if (image_type == GTK_IMAGE_STOCK ||
           image_type == GTK_IMAGE_ICON_NAME)
  {
    pixbuf = gtk_icon_theme_load_icon(theme, proxy_->image_data().c_str(), 22,
                                      (GtkIconLookupFlags)0, nullptr);
  }
  else if (image_type == GTK_IMAGE_GICON)
  {
    glib::Object<GIcon> icon(g_icon_new_for_string(proxy_->image_data().c_str(), nullptr));

    GtkIconInfo* info = gtk_icon_theme_lookup_by_gicon(theme, icon, 22,
                                                       (GtkIconLookupFlags)0);
    if (info)
    {
      pixbuf = gtk_icon_info_load_icon(info, nullptr);
      gtk_icon_info_free(info);
    }
  }

  return pixbuf;
}

Here is the caller graph for this function:

void unity::PanelIndicatorEntryView::OnActiveChanged ( bool  is_active) [private]

Definition at line 88 of file PanelIndicatorEntryView.cpp.

{
  active_changed.emit(this, is_active);

  if (draw_active_ && !is_active)
  {
    draw_active_ = false;
    Refresh();
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void unity::PanelIndicatorEntryView::OnMouseDown ( int  x,
int  y,
long  button_flags,
long  key_flags 
) [private]

Definition at line 112 of file PanelIndicatorEntryView.cpp.

{
  if (proxy_->active() || IsDisabled())
    return;

  if (((IsLabelVisible() && IsLabelSensitive()) ||
       (IsIconVisible() && IsIconSensitive())))
  {
    int button = nux::GetEventButton(button_flags);

    if (button == 2 && type_ == INDICATOR)
      SetOpacity(0.75f);
    else
      ShowMenu(button);
  }

  Refresh();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void unity::PanelIndicatorEntryView::OnMouseUp ( int  x,
int  y,
long  button_flags,
long  key_flags 
) [private]

Definition at line 131 of file PanelIndicatorEntryView.cpp.

{
  if (proxy_->active() || IsDisabled())
    return;

  int button = nux::GetEventButton(button_flags);

  nux::Geometry geo = GetAbsoluteGeometry();
  int px = geo.x + x;
  int py = geo.y + y;

  if (((IsLabelVisible() && IsLabelSensitive()) ||
       (IsIconVisible() && IsIconSensitive())) &&
      button == 2 && type_ == INDICATOR)
  {
    if (geo.IsPointInside(px, py))
      proxy_->SecondaryActivate(time(nullptr));

    SetOpacity(1.0f);
  }

  Refresh();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void unity::PanelIndicatorEntryView::OnMouseWheel ( int  x,
int  y,
int  delta,
unsigned long  mouse_state,
unsigned long  key_state 
) [private]

Definition at line 155 of file PanelIndicatorEntryView.cpp.

{
  if (!IsDisabled())
    proxy_->Scroll(delta);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 558 of file PanelIndicatorEntryView.cpp.

{
  overlay_showing_ = false;
  Refresh();
}

Here is the call graph for this function:

Definition at line 552 of file PanelIndicatorEntryView.cpp.

{
  overlay_showing_ = true;
  Refresh();
}

Here is the call graph for this function:

Definition at line 408 of file PanelIndicatorEntryView.cpp.

{
  if (!proxy_->visible())
  {
    SetVisible(false);
    // This will destroy the object texture. No need to manually delete the pointer
    entry_texture_ = nullptr;
    SetColor(nux::color::Transparent);

    QueueDraw();
    refreshed.emit(this);

    return;
  }

  glib::Object<PangoLayout> layout;
  cairo_t* cr;

  std::string label = GetLabel();
  glib::Object<GdkPixbuf> const& pixbuf = MakePixbuf();

  unsigned int width = 0;
  unsigned int icon_width = 0;
  unsigned int height = panel::Style::Instance().panel_height;
  unsigned int text_width = 0;

  // First lets figure out our size
  if (pixbuf && IsIconVisible())
  {
    width = gdk_pixbuf_get_width(pixbuf);
    icon_width = width;
  }

  if (!label.empty() && IsLabelVisible())
  {
    using namespace panel;
    PangoContext* cxt;
    PangoAttrList* attrs = nullptr;
    PangoRectangle log_rect;
    GdkScreen* screen = gdk_screen_get_default();
    PangoFontDescription* desc = nullptr;
    PanelItem panel_item = (type_ == MENU) ? PanelItem::MENU : PanelItem::INDICATOR;

    Style& panel_style = Style::Instance();
    std::string const& font_description = panel_style.GetFontDescription(panel_item);
    int dpi = panel_style.GetTextDPI();

    if (proxy_->show_now())
    {
      if (!pango_parse_markup(label.c_str(), -1, '_', &attrs, nullptr, nullptr, nullptr))
      {
        g_debug("pango_parse_markup failed");
      }
    }

    desc = pango_font_description_from_string(font_description.c_str());
    pango_font_description_set_weight(desc, PANGO_WEIGHT_NORMAL);

    nux::CairoGraphics cairo_graphics(CAIRO_FORMAT_ARGB32, 1, 1);
    cr = cairo_graphics.GetContext();

    layout = pango_cairo_create_layout(cr);
    if (attrs)
    {
      pango_layout_set_attributes(layout, attrs);
      pango_attr_list_unref(attrs);
    }

    pango_layout_set_font_description(layout, desc);

    boost::erase_all(label, "_");
    pango_layout_set_text(layout, label.c_str(), -1);

    cxt = pango_layout_get_context(layout);
    pango_cairo_context_set_font_options(cxt, gdk_screen_get_font_options(screen));
    pango_cairo_context_set_resolution(cxt, dpi / static_cast<float>(PANGO_SCALE));
    pango_layout_context_changed(layout);

    pango_layout_get_extents(layout, nullptr, &log_rect);
    text_width = log_rect.width / PANGO_SCALE;

    if (icon_width)
      width += spacing_;
    width += text_width;

    pango_font_description_free(desc);
    cairo_destroy(cr);
  }

  if (width)
    width += left_padding_ + right_padding_;

  width = std::min<int>(width, GetMaximumWidth());
  SetMinimumWidth(width);

  nux::CairoGraphics cg(CAIRO_FORMAT_ARGB32, width, height);
  cr = cg.GetContext();
  cairo_set_line_width(cr, 1);
  cairo_set_operator(cr, CAIRO_OPERATOR_CLEAR);
  cairo_paint(cr);

  cairo_set_operator(cr, CAIRO_OPERATOR_OVER);
  DrawEntryContent(cr, width, height, pixbuf, layout);

  entry_texture_ = texture_ptr_from_cairo_graphics(cg);
  SetTexture(entry_texture_.GetPointer());
  cairo_destroy(cr);

  SetVisible(true);
  refreshed.emit(this);
  QueueDraw();
}

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::PanelIndicatorEntryView::SetActiveState ( bool  active,
int  button 
) [protected]

Definition at line 173 of file PanelIndicatorEntryView.cpp.

{
  if (draw_active_ != active)
  {
    draw_active_ = active;
    Refresh();

    if (active)
      ShowMenu(button);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 734 of file PanelIndicatorEntryView.cpp.

{
  disabled_ = disabled;
}

Definition at line 744 of file PanelIndicatorEntryView.cpp.

{
  if (focused_ != focused)
  {
    focused_ = focused;
    Refresh();
  }
}

Here is the call graph for this function:

Definition at line 564 of file PanelIndicatorEntryView.cpp.

{
  opacity = CLAMP(opacity, 0.0f, 1.0f);

  if (opacity_ != opacity)
  {
    opacity_ = opacity;
    SetInputEventSensitivity(opacity_ != 0.0f);
    QueueDraw();
  }
}

Here is the caller graph for this function:

void unity::PanelIndicatorEntryView::ShowMenu ( int  button = 1) [protected, virtual]

Definition at line 99 of file PanelIndicatorEntryView.cpp.

{
  auto wm = WindowManager::Default();

  if (!wm->IsExpoActive() && !wm->IsScaleActive())
  {
    proxy_->ShowMenu(GetAbsoluteX(),
                     GetAbsoluteY() + panel::Style::Instance().panel_height,
                     button,
                     time(nullptr));
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 168 of file PanelIndicatorEntryView.cpp.

{
  SetActiveState(false, 0);
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 87 of file PanelIndicatorEntryView.h.

Definition at line 119 of file PanelIndicatorEntryView.h.

Definition at line 123 of file PanelIndicatorEntryView.h.

Definition at line 121 of file PanelIndicatorEntryView.h.

nux::ObjectPtr<nux::BaseTexture> unity::PanelIndicatorEntryView::entry_texture_ [private]

Definition at line 118 of file PanelIndicatorEntryView.h.

Definition at line 124 of file PanelIndicatorEntryView.h.

Definition at line 106 of file PanelIndicatorEntryView.h.

Definition at line 120 of file PanelIndicatorEntryView.h.

Definition at line 122 of file PanelIndicatorEntryView.h.

Definition at line 104 of file PanelIndicatorEntryView.h.

Definition at line 88 of file PanelIndicatorEntryView.h.

Definition at line 107 of file PanelIndicatorEntryView.h.

unsigned int unity::PanelIndicatorEntryView::spacing_ [protected]

Definition at line 105 of file PanelIndicatorEntryView.h.

Definition at line 117 of file PanelIndicatorEntryView.h.


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