Back to index

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

#include <PanelIndicatorsView.h>

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

List of all members.

Public Types

enum  IndicatorEntryPosition { AUTO = -1, START = nux::NUX_LAYOUT_BEGIN, END = nux::NUX_LAYOUT_END }
typedef
PanelIndicatorEntryView::IndicatorEntryType 
IndicatorEntryType
typedef std::list
< Introspectable * > 
IntrospectableList

Public Member Functions

 PanelIndicatorsView ()
 ~PanelIndicatorsView ()
void AddIndicator (indicator::Indicator::Ptr const &indicator)
void RemoveIndicator (indicator::Indicator::Ptr const &indicator)
PanelIndicatorEntryViewAddEntry (indicator::Entry::Ptr const &entry, int padding=5, IndicatorEntryPosition pos=AUTO, IndicatorEntryType type=IndicatorEntryType::INDICATOR)
void RemoveEntry (std::string const &entry_id)
PanelIndicatorEntryViewActivateEntryAt (int x, int y, int button=1)
PanelIndicatorEntryViewActivateEntry (std::string const &entry_id, int button=1)
bool ActivateIfSensitive ()
virtual void OverlayShown ()
virtual void OverlayHidden ()
void SetOpacity (double opacity)
double GetOpacity ()
void SetMaximumEntriesWidth (int max_width)
void GetGeometryForSync (indicator::EntryLocationMap &locations)
GVariant * Introspect ()
void AddChild (Introspectable *child)
void RemoveChild (Introspectable *child)
virtual IntrospectableList GetIntrospectableChildren ()
guint64 GetIntrospectionId () const

Public Attributes

sigc::signal< void,
PanelIndicatorEntryView * > 
on_indicator_updated

Protected Types

typedef std::vector
< indicator::Indicator::Ptr
Indicators
typedef std::map< std::string,
PanelIndicatorEntryView * > 
Entries

Protected Member Functions

std::string GetName () const
void AddProperties (GVariantBuilder *builder)
Indicators GetIndicators ()
virtual void Draw (nux::GraphicsEngine &GfxContext, bool force_draw)
virtual void DrawContent (nux::GraphicsEngine &GfxContext, bool force_draw)
virtual void OnEntryAdded (indicator::Entry::Ptr const &entry)
virtual void OnEntryRefreshed (PanelIndicatorEntryView *view)
virtual void OnEntryRemoved (std::string const &entry_id)
virtual void AddEntryView (PanelIndicatorEntryView *view, IndicatorEntryPosition pos=AUTO)
virtual void RemoveEntryView (PanelIndicatorEntryView *view)
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

nux::HLayout * layout_
Entries entries_

Private Member Functions

 NUX_DECLARE_OBJECT_TYPE (PanelIndicatorsView, nux::View)

Private Attributes

Indicators indicators_
double opacity_
std::map
< indicator::Indicator::Ptr,
std::vector< sigc::connection > > 
indicators_connections_

Detailed Description

Definition at line 35 of file PanelIndicatorsView.h.


Member Typedef Documentation

typedef std::map<std::string, PanelIndicatorEntryView*> unity::PanelIndicatorsView::Entries [protected]

Definition at line 93 of file PanelIndicatorsView.h.

Definition at line 51 of file PanelIndicatorsView.h.

Definition at line 78 of file PanelIndicatorsView.h.

Definition at line 34 of file Introspectable.h.


Member Enumeration Documentation

Enumerator:
AUTO 
START 
END 

Definition at line 45 of file PanelIndicatorsView.h.

                              {
    AUTO = -1,
    START = nux::NUX_LAYOUT_BEGIN,
    END = nux::NUX_LAYOUT_END,
  };

Constructor & Destructor Documentation

Definition at line 43 of file PanelIndicatorsView.cpp.

: View(NUX_TRACKER_LOCATION)
, layout_(NULL)
, opacity_(1.0f)
{
  LOG_DEBUG(logger) << "Indicators View Added: ";
  layout_ = new nux::HLayout("", NUX_TRACKER_LOCATION);
  layout_->SetContentDistribution(nux::eStackRight);

  SetLayout(layout_);
}

Definition at line 55 of file PanelIndicatorsView.cpp.

{
  for (auto ind : indicators_connections_)
  {
    for (auto conn : ind.second)
      conn.disconnect();
  }
}

Member Function Documentation

PanelIndicatorEntryView * unity::PanelIndicatorsView::ActivateEntry ( std::string const &  entry_id,
int  button = 1 
)

Definition at line 152 of file PanelIndicatorsView.cpp.

{
  auto entry = entries_.find(entry_id);

  if (entry != entries_.end())
  {
    PanelIndicatorEntryView* view = entry->second;

    if (view->IsSensitive() && view->IsVisible())
      view->Activate(button);

    return view;
  }

  return nullptr;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PanelIndicatorEntryView * unity::PanelIndicatorsView::ActivateEntryAt ( int  x,
int  y,
int  button = 1 
)

Definition at line 200 of file PanelIndicatorsView.cpp.

{
  PanelIndicatorEntryView* target = nullptr;
  bool found_old_active = false;

  //
  // Change the entry active status without waiting
  // for slow inter-process communication with unity-panel-service,
  // which causes visible lag in many cases.
  //

  for (auto entry : entries_)
  {
    PanelIndicatorEntryView* view = entry.second;

    if (!target && view->IsVisible() && view->IsFocused() &&
        view->IsSensitive() &&
        view->GetAbsoluteGeometry().IsPointInside(x, y))
    {
      view->Activate(button);
      target = view;
      break;
    }
    else if (target && view->IsActive())
    {
      view->Unactivate();
      found_old_active = true;
      break;
    }
  }

  if (target && !found_old_active)
  {
    for (auto entry : entries_)
    {
      PanelIndicatorEntryView* view = entry.second;

      if (view != target && view->IsActive())
      {
        view->Unactivate();
        break;
      }
    }
  }

  return target;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 170 of file PanelIndicatorsView.cpp.

{
  std::map<int, PanelIndicatorEntryView*> sorted_entries;
  
  for (auto entry : entries_)
    sorted_entries[entry.second->GetEntryPriority()] = entry.second;
  
  for (auto entry : sorted_entries)
  {
    PanelIndicatorEntryView* view = entry.second;

    if (view->IsSensitive() && view->IsVisible() && view->IsFocused())
    {
      /* Use the 0 button, it means it's a keyboard activation */
      view->Activate(0);
      return true;
    }
  }

  return false;
}

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:

PanelIndicatorEntryView * unity::PanelIndicatorsView::AddEntry ( indicator::Entry::Ptr const &  entry,
int  padding = 5,
IndicatorEntryPosition  pos = AUTO,
IndicatorEntryType  type = IndicatorEntryType::INDICATOR 
)

Definition at line 301 of file PanelIndicatorsView.cpp.

{
  auto view = new PanelIndicatorEntryView(entry, padding, type);
  AddEntryView(view, pos);

  return view;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 257 of file PanelIndicatorsView.cpp.

{
  if (!view)
    return;

  int entry_pos = pos;

  view->SetOpacity(opacity_);
  view->refreshed.connect(sigc::mem_fun(this, &PanelIndicatorsView::OnEntryRefreshed));

  if (entry_pos == IndicatorEntryPosition::AUTO)
  {
    entry_pos = nux::NUX_LAYOUT_BEGIN;

    if (view->GetEntryPriority() > -1)
    {
      for (auto area : layout_->GetChildren())
      {
        auto en = dynamic_cast<PanelIndicatorEntryView*>(area);

        if (en)
        {
          if (en && view->GetEntryPriority() <= en->GetEntryPriority())
            break;

          entry_pos++;
        }
      }
    }
  }

  layout_->AddView(view, 0, nux::eCenter, nux::eFull, 1.0, (nux::LayoutPosition) entry_pos);

  entries_[view->GetEntryID()] = view;

  AddChild(view);
  QueueRelayout();
  QueueDraw();

  on_indicator_updated.emit(view);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Reimplemented in unity::PanelMenuView.

Definition at line 65 of file PanelIndicatorsView.cpp.

{
  LOG_DEBUG(logger) << "IndicatorAdded: " << indicator->name();
  indicators_.push_back(indicator);

  std::vector<sigc::connection> connections;

  auto entry_added_conn = indicator->on_entry_added.connect(sigc::mem_fun(this, &PanelIndicatorsView::OnEntryAdded));
  connections.push_back(entry_added_conn);

  auto entry_removed_conn = indicator->on_entry_removed.connect(sigc::mem_fun(this, &PanelIndicatorsView::OnEntryRemoved));
  connections.push_back(entry_removed_conn);

  indicators_connections_[indicator] = connections;
}

Here is the call graph for this function:

Here is the caller graph for this function:

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

Implements unity::debug::Introspectable.

Reimplemented in unity::PanelMenuView.

Definition at line 394 of file PanelIndicatorsView.cpp.

{
  variant::BuilderWrapper(builder)
  .add(GetAbsoluteGeometry())
  .add("entries", entries_.size())
  .add("opacity", opacity_);
}

Here is the call graph for this function:

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

Reimplemented in unity::PanelMenuView.

Definition at line 115 of file PanelIndicatorsView.cpp.

{
  nux::Geometry geo = GetGeometry();

  GfxContext.PushClippingRectangle(geo);
  nux::GetPainter().PaintBackground(GfxContext, geo);
  GfxContext.PopClippingRectangle();
}
void unity::PanelIndicatorsView::DrawContent ( nux::GraphicsEngine &  GfxContext,
bool  force_draw 
) [protected, virtual]

Reimplemented in unity::PanelMenuView.

Definition at line 249 of file PanelIndicatorsView.cpp.

{
  GfxContext.PushClippingRectangle(GetGeometry());
  layout_->ProcessDraw(GfxContext, force_draw);
  GfxContext.PopClippingRectangle();
}
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 193 of file PanelIndicatorsView.cpp.

{
  for (auto entry : entries_)
    entry.second->GetGeometryForSync(locations);
}

Here is the caller graph for this function:

Definition at line 109 of file PanelIndicatorsView.cpp.

{
  return indicators_;
}

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

Implements unity::debug::Introspectable.

Reimplemented in unity::PanelMenuView.

Definition at line 388 of file PanelIndicatorsView.cpp.

{
  return "Indicators";
}

Definition at line 368 of file PanelIndicatorsView.cpp.

{
  return opacity_;
}

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::PanelIndicatorsView::OnEntryAdded ( indicator::Entry::Ptr const &  entry) [protected, virtual]

Reimplemented in unity::PanelMenuView.

Definition at line 311 of file PanelIndicatorsView.cpp.

{
  AddEntry(entry);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 317 of file PanelIndicatorsView.cpp.

{
  QueueRelayout();
  QueueDraw();

  on_indicator_updated.emit(view);
}

Here is the caller graph for this function:

void unity::PanelIndicatorsView::OnEntryRemoved ( std::string const &  entry_id) [protected, virtual]

Definition at line 348 of file PanelIndicatorsView.cpp.

{
  RemoveEntry(entry_id);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Reimplemented in unity::PanelMenuView.

Definition at line 361 of file PanelIndicatorsView.cpp.

{
  for (auto entry: entries_)
    entry.second->OverlayHidden();
}

Here is the caller graph for this function:

Reimplemented in unity::PanelMenuView.

Definition at line 354 of file PanelIndicatorsView.cpp.

{
  for (auto entry: entries_)
    entry.second->OverlayShown();
}

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::PanelIndicatorsView::RemoveEntry ( std::string const &  entry_id)

Definition at line 342 of file PanelIndicatorsView.cpp.

{
  RemoveEntryView(entries_[entry_id]);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 326 of file PanelIndicatorsView.cpp.

{
  if (!view)
    return;

  std::string const& entry_id = view->GetEntryID();
  RemoveChild(view);
  on_indicator_updated.emit(view);
  entries_.erase(entry_id);
  layout_->RemoveChildObject(view);

  QueueRelayout();
  QueueDraw();
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 82 of file PanelIndicatorsView.cpp.

{
  auto connections = indicators_connections_.find(indicator);

  if (connections != indicators_connections_.end()) {
    for (auto conn : connections->second)
      conn.disconnect();

    indicators_connections_.erase(indicator);
  }

  for (auto entry : indicator->GetEntries())
    OnEntryRemoved(entry->id());

  for (auto i = indicators_.begin(); i != indicators_.end(); i++)
  {
    if (*i == indicator)
    {
      indicators_.erase(i);
      break;
    }
  }

  LOG_DEBUG(logger) << "IndicatorRemoved: " << indicator->name();
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 125 of file PanelIndicatorsView.cpp.

{
  unsigned int n_entries = 0;

  for (auto entry : entries_)
    if (entry.second->IsVisible())
      n_entries++;

  if (n_entries > 0)
  {
    for (auto entry : entries_)
    {
      if (entry.second->IsVisible() && n_entries > 0)
      {
        int max_entry_width = max_width / n_entries;

        if (entry.second->GetBaseWidth() > max_entry_width)
          entry.second->SetMaximumWidth(max_entry_width);

        max_width -= entry.second->GetBaseWidth();
        --n_entries;
      }
    }
  }
}

Here is the caller graph for this function:

void unity::PanelIndicatorsView::SetOpacity ( double  opacity)

Definition at line 374 of file PanelIndicatorsView.cpp.

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

  for (auto entry: entries_)
    entry.second->SetOpacity(opacity);

  if (opacity_ != opacity)
  {
    opacity_ = opacity;
    NeedRedraw();
  }
}

Here is the caller graph for this function:


Member Data Documentation

Definition at line 94 of file PanelIndicatorsView.h.

Definition at line 97 of file PanelIndicatorsView.h.

std::map<indicator::Indicator::Ptr, std::vector<sigc::connection> > unity::PanelIndicatorsView::indicators_connections_ [private]

Definition at line 100 of file PanelIndicatorsView.h.

nux::HLayout* unity::PanelIndicatorsView::layout_ [protected]

Definition at line 92 of file PanelIndicatorsView.h.

Definition at line 72 of file PanelIndicatorsView.h.

Definition at line 98 of file PanelIndicatorsView.h.


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