Back to index

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

#include <FilterMultiRangeWidget.h>

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

List of all members.

Public Types

typedef std::list
< Introspectable * > 
IntrospectableList

Public Member Functions

 FilterMultiRange (NUX_FILE_LINE_PROTO)
virtual ~FilterMultiRange ()
void SetFilter (Filter::Ptr const &filter)
std::string GetFilterType ()
void SetRightHandView (nux::View *view)
void SetLabel (std::string const &label)
void SetContents (nux::Layout *layout)
GVariant * Introspect ()
void AddChild (Introspectable *child)
void RemoveChild (Introspectable *child)
virtual IntrospectableList GetIntrospectableChildren ()
guint64 GetIntrospectionId () const

Public Attributes

nux::Property< bool > expanded
nux::Property< bool > draw_separator

Protected Member Functions

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

 NUX_DECLARE_OBJECT_TYPE (FilterMultiRange, FilterExpanderLabel)
void OnAllActivated (nux::View *view)
void OnOptionAdded (dash::FilterOption::Ptr const &new_filter)
void OnOptionRemoved (dash::FilterOption::Ptr const &removed_filter)
void OnActiveChanged (bool value)

Private Attributes

nux::HLayout * layout_
FilterAllButtonall_button_
std::vector
< FilterMultiRangeButton * > 
buttons_
MultiRangeFilter::Ptr filter_

Detailed Description

Definition at line 42 of file FilterMultiRangeWidget.h.


Member Typedef Documentation

Definition at line 34 of file Introspectable.h.


Constructor & Destructor Documentation

Definition at line 40 of file FilterMultiRangeWidget.cpp.

  : FilterExpanderLabel(_("Multi-range"), NUX_FILE_LINE_PARAM)
{
  InitTheme();

  dash::Style& style = dash::Style::Instance();
  const int left_padding = 0;
  const int right_padding = 0;
  const int top_padding = style.GetSpaceBetweenFilterWidgets() - style.GetFilterHighlightPadding() - 2;
  const int bottom_padding = style.GetFilterHighlightPadding() - 1;

  all_button_ = new FilterAllButton(NUX_TRACKER_LOCATION);

  layout_ = new nux::HLayout(NUX_TRACKER_LOCATION);
  layout_->SetLeftAndRightPadding(left_padding, right_padding);
  layout_->SetTopAndBottomPadding(top_padding, bottom_padding);

  SetRightHandView(all_button_);
  SetContents(layout_);
  OnActiveChanged(false);
}

Here is the call graph for this function:

Definition at line 62 of file FilterMultiRangeWidget.cpp.

{
}

Member Function Documentation

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

Definition at line 305 of file FilterExpanderLabel.cpp.

{
  return true;
}

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

Implements unity::debug::Introspectable.

Definition at line 318 of file FilterExpanderLabel.cpp.

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

  wrapper.add("expander-has-focus", expander_view_->HasKeyFocus());
}

Here is the call graph for this function:

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

Definition at line 266 of file FilterExpanderLabel.cpp.

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

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

  if (ShouldBeHighlighted())
  {
    nux::Geometry geo(top_bar_layout_->GetGeometry());
    geo.x = base.x;
    geo.width = base.width;

    if (!highlight_layer_)
      highlight_layer_.reset(dash::Style::Instance().FocusOverlay(geo.width, geo.height));

    highlight_layer_->SetGeometry(geo);
    highlight_layer_->Renderlayer(GfxContext);
  }

  GfxContext.PopClippingRectangle();
}

Here is the call graph for this function:

void unity::dash::FilterExpanderLabel::DrawContent ( nux::GraphicsEngine &  GfxContext,
bool  force_draw 
) [protected, virtual, inherited]

Definition at line 289 of file FilterExpanderLabel.cpp.

{
  GfxContext.PushClippingRectangle(GetGeometry());

  if (ShouldBeHighlighted() && highlight_layer_ && !IsFullRedraw())
  {
    nux::GetPainter().PushLayer(GfxContext, highlight_layer_->GetGeometry(), highlight_layer_.get());
  }

  GetLayout()->ProcessDraw(GfxContext, force_draw);
  GfxContext.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:

Implements unity::dash::FilterExpanderLabel.

Definition at line 156 of file FilterMultiRangeWidget.cpp.

{
  return "FilterMultiRange";
}
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::FilterExpanderLabel::GetName ( ) const [protected, virtual, inherited]

Implements unity::debug::Introspectable.

Definition at line 313 of file FilterExpanderLabel.cpp.

{
  return "FilterExpanderLabel";
}

Definition at line 161 of file FilterMultiRangeWidget.cpp.

{
  //FIXME - build theme here - store images, cache them, fun fun fun
}

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::dash::FilterMultiRange::OnActiveChanged ( bool  value) [private]

Definition at line 83 of file FilterMultiRangeWidget.cpp.

{
  // go through all the buttons, and set the state :(
  int start = 2000;
  int end = 0;
  int index = 0;
  for (auto button : buttons_)
  {
    FilterOption::Ptr filter = button->GetFilter();
    bool tmp_active = filter->active;
    button->SetActive(tmp_active);
    if (filter != nullptr)
    {
      if (filter->active)
      {
        if (index < start)
          start = index;
        if (index > end)
          end = index;
      }
    }
    index++;
  }

  index = 0;
  for (auto button : buttons_)
  {
    if (index == start && index == end)
      button->SetHasArrow(MultiRangeArrow::BOTH);
    else if (index == start)
      button->SetHasArrow(MultiRangeArrow::LEFT);
    else if (index == end && index != 0)
      button->SetHasArrow(MultiRangeArrow::RIGHT);
    else
      button->SetHasArrow(MultiRangeArrow::NONE);

    if (index == 0)
      button->SetVisualSide(MultiRangeSide::LEFT);
    else if (index == (int)buttons_.size() - 1)
      button->SetVisualSide(MultiRangeSide::RIGHT);
    else
      button->SetVisualSide(MultiRangeSide::CENTER);

    index++;
  }
}

Here is the caller graph for this function:

void unity::dash::FilterMultiRange::OnAllActivated ( nux::View *  view) [private]

Definition at line 130 of file FilterMultiRangeWidget.cpp.

{
  FilterMultiRangeButton* button = new FilterMultiRangeButton(NUX_TRACKER_LOCATION);
  button->SetFilter(new_filter);
  layout_->AddView(button);
  buttons_.push_back(button);
  new_filter->active.changed.connect(sigc::mem_fun(this, &FilterMultiRange::OnActiveChanged));
  OnActiveChanged(false);

}

Here is the call graph for this function:

Here is the caller graph for this function:

void unity::dash::FilterMultiRange::OnOptionRemoved ( dash::FilterOption::Ptr const &  removed_filter) [private]

Definition at line 141 of file FilterMultiRangeWidget.cpp.

{
  for (auto it=buttons_.begin() ; it != buttons_.end(); it++)
  {
    if ((*it)->GetFilter() == removed_filter)
    {
      layout_->RemoveChildObject(*it);
      buttons_.erase(it);
      break;
    }
  }

  OnActiveChanged(false);
}

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::dash::FilterExpanderLabel::SetContents ( nux::Layout *  layout) [inherited]

Definition at line 152 of file FilterExpanderLabel.cpp.

{
  // Since the contents is initially unowned, we don't want to Adopt it, just assign.
  contents_ = contents;

  layout_->AddLayout(contents_.GetPointer(), 1, nux::MINOR_POSITION_LEFT, nux::MINOR_SIZE_FULL);

  QueueDraw();
}

Here is the caller graph for this function:

void unity::dash::FilterMultiRange::SetFilter ( Filter::Ptr const &  filter) [virtual]

Implements unity::dash::FilterExpanderLabel.

Definition at line 66 of file FilterMultiRangeWidget.cpp.

{
  filter_ = std::static_pointer_cast<MultiRangeFilter>(filter);

  all_button_->SetFilter(filter_);
  expanded = !filter_->collapsed();

  filter_->option_added.connect(sigc::mem_fun(this, &FilterMultiRange::OnOptionAdded));
  filter_->option_removed.connect(sigc::mem_fun(this, &FilterMultiRange::OnOptionRemoved));

  // finally - make sure we are up-todate with our filter list
  for (auto it : filter_->options())
    OnOptionAdded(it);

  SetLabel(filter_->name);
}

Here is the call graph for this function:

void unity::dash::FilterExpanderLabel::SetLabel ( std::string const &  label) [inherited]

Definition at line 135 of file FilterExpanderLabel.cpp.

{
  raw_label_ = label;

  cairo_label_->SetText(label.c_str());
}

Here is the call graph for this function:

Here is the caller graph for this function:

void unity::dash::FilterExpanderLabel::SetRightHandView ( nux::View *  view) [inherited]

Definition at line 142 of file FilterExpanderLabel.cpp.

{
  dash::Style& style = dash::Style::Instance();

  right_hand_contents_ = view;
  right_hand_contents_->SetMinimumHeight(style.GetAllButtonHeight());
  right_hand_contents_->SetMaximumHeight(style.GetAllButtonHeight());
  top_bar_layout_->AddView(right_hand_contents_, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FIX);
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 62 of file FilterMultiRangeWidget.h.

Definition at line 64 of file FilterMultiRangeWidget.h.

nux::Property<bool> unity::dash::FilterExpanderLabel::draw_separator [inherited]

Definition at line 67 of file FilterExpanderLabel.h.

nux::Property<bool> unity::dash::FilterExpanderLabel::expanded [inherited]

Definition at line 66 of file FilterExpanderLabel.h.

Definition at line 65 of file FilterMultiRangeWidget.h.

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

Reimplemented from unity::dash::FilterExpanderLabel.

Definition at line 61 of file FilterMultiRangeWidget.h.


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