Back to index

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

#include <FilterExpanderLabel.h>

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

List of all members.

Public Types

typedef std::list
< Introspectable * > 
IntrospectableList

Public Member Functions

 FilterExpanderLabel (std::string const &label, NUX_FILE_LINE_PROTO)
virtual ~FilterExpanderLabel ()
void SetRightHandView (nux::View *view)
void SetLabel (std::string const &label)
void SetContents (nux::Layout *layout)
virtual void SetFilter (Filter::Ptr const &filter)=0
virtual std::string GetFilterType ()=0
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

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 (FilterExpanderLabel, nux::View)
void BuildLayout ()
void DoExpandChange (bool change)
bool ShouldBeHighlighted ()

Private Attributes

nux::LinearLayout * layout_
nux::LinearLayout * top_bar_layout_
nux::View * expander_view_
nux::LinearLayout * expander_layout_
nux::View * right_hand_contents_
nux::StaticCairoTextcairo_label_
std::string raw_label_
std::string label_
nux::VLayout * arrow_layout_
nux::SpaceLayout * arrow_top_space_
nux::SpaceLayout * arrow_bottom_space_
IconTextureexpand_icon_
HSeparatorseparator_
nux::SpaceLayout * space_
nux::ObjectPtr< nux::Layout > contents_
std::unique_ptr
< nux::AbstractPaintLayer > 
highlight_layer_

Detailed Description

Definition at line 52 of file FilterExpanderLabel.h.


Member Typedef Documentation

Definition at line 34 of file Introspectable.h.


Constructor & Destructor Documentation

unity::dash::FilterExpanderLabel::FilterExpanderLabel ( std::string const &  label,
NUX_FILE_LINE_PROTO   
)

Definition at line 83 of file FilterExpanderLabel.cpp.

  : nux::View(NUX_FILE_LINE_PARAM)
  , expanded(true)
  , draw_separator(false)
  , layout_(nullptr)
  , top_bar_layout_(nullptr)
  , expander_view_(nullptr)
  , expander_layout_(nullptr)
  , right_hand_contents_(nullptr)
  , cairo_label_(nullptr)
  , raw_label_(label)
  , label_("label")
  , separator_(nullptr)
{
  expanded.changed.connect(sigc::mem_fun(this, &FilterExpanderLabel::DoExpandChange));
  BuildLayout();
  SetAcceptKeyNavFocusOnMouseDown(false);

  separator_ = new HSeparator;
  separator_->SinkReference();

  dash::Style& style = dash::Style::Instance();
  int space_height = style.GetSpaceBetweenFilterWidgets() - style.GetFilterHighlightPadding();

  space_ = new nux::SpaceLayout(space_height, space_height, space_height, space_height);
  space_->SinkReference();

  draw_separator.changed.connect([&](bool value)
  {
    if (value and !separator_->IsChildOf(layout_))
    {
      layout_->AddLayout(space_, 0);
      layout_->AddView(separator_, 0);
    }
    else if (!value and separator_->IsChildOf(layout_))
    {
      layout_->RemoveChildObject(space_);
      layout_->RemoveChildObject(separator_);
    }
    QueueDraw();
  });
}

Here is the call graph for this function:

Definition at line 126 of file FilterExpanderLabel.cpp.

{
  if (space_)
    space_->UnReference();

  if (separator_)
    separator_->UnReference();
}

Member Function Documentation

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]

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:

Definition at line 162 of file FilterExpanderLabel.cpp.

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

  layout_ = new nux::VLayout(NUX_TRACKER_LOCATION);
  layout_->SetLeftAndRightPadding(style.GetFilterBarLeftPadding(), style.GetFilterBarRightPadding());

  top_bar_layout_ = new nux::HLayout(NUX_TRACKER_LOCATION);
  top_bar_layout_->SetTopAndBottomPadding(style.GetFilterHighlightPadding());

  expander_layout_ = new nux::HLayout(NUX_TRACKER_LOCATION);
  expander_layout_->SetSpaceBetweenChildren(EXPANDER_LAYOUT_SPACE_BETWEEN_CHILDREN);

  expander_view_ = new ExpanderView(NUX_TRACKER_LOCATION);
  expander_view_->SetLayout(expander_layout_);
  top_bar_layout_->AddView(expander_view_, 0);

  cairo_label_ = new nux::StaticCairoText(label_.c_str(), NUX_TRACKER_LOCATION);
  cairo_label_->SetFont(FONT_EXPANDER_LABEL);
  cairo_label_->SetTextColor(nux::color::White);
  cairo_label_->SetAcceptKeyboardEvent(false);

  nux::BaseTexture* arrow;
  arrow = dash::Style::Instance().GetGroupUnexpandIcon();
  expand_icon_ = new IconTexture(arrow,
                                 arrow->GetWidth(),
                                 arrow->GetHeight());
  expand_icon_->SetOpacity(EXPAND_DEFAULT_ICON_OPACITY);
  expand_icon_->SetMinimumSize(arrow->GetWidth(), arrow->GetHeight());
  expand_icon_->SetVisible(true);
  arrow_layout_  = new nux::VLayout();
  arrow_top_space_ = new nux::SpaceLayout(2, 2, 11, 11);
  arrow_bottom_space_ = new nux::SpaceLayout(2, 2, 9, 9);
  arrow_layout_->AddView(arrow_top_space_, 0, nux::MINOR_POSITION_CENTER);
  arrow_layout_->AddView(expand_icon_, 0, nux::MINOR_POSITION_CENTER);
  arrow_layout_->AddView(arrow_bottom_space_, 0, nux::MINOR_POSITION_CENTER);

  expander_layout_->AddView(cairo_label_, 1, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL);
  expander_layout_->AddView(arrow_layout_, 0, nux::MINOR_POSITION_CENTER);
  top_bar_layout_->AddSpace(1, 1);

  layout_->AddLayout(top_bar_layout_, 0, nux::MINOR_POSITION_LEFT);
  layout_->SetVerticalInternalMargin(0);

  SetLayout(layout_);

  // Lambda functions
  auto mouse_expand = [&](int x, int y, unsigned long b, unsigned long k)
  {
    expanded = !expanded;
  };

  auto key_redraw = [&](nux::Area*, bool, nux::KeyNavDirection)
  {
    QueueDraw();
  };

  auto key_expand = [&](nux::Area*)
  {
    expanded = !expanded;
  };

  // Signals
  expander_view_->mouse_click.connect(mouse_expand);
  expander_view_->key_nav_focus_change.connect(key_redraw);
  expander_view_->key_nav_focus_activate.connect(key_expand);
  cairo_label_->mouse_click.connect(mouse_expand);
  expand_icon_->mouse_click.connect(mouse_expand);
  key_nav_focus_change.connect([&](nux::Area* area, bool has_focus, nux::KeyNavDirection direction)
  {
    if(has_focus)
      nux::GetWindowCompositor().SetKeyFocusArea(expander_view_);
  });

  QueueRelayout();
  NeedRedraw();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void unity::dash::FilterExpanderLabel::DoExpandChange ( bool  change) [private]

Definition at line 240 of file FilterExpanderLabel.cpp.

{
  dash::Style& style = dash::Style::Instance();
  if (expanded)
    expand_icon_->SetTexture(style.GetGroupUnexpandIcon());
  else
    expand_icon_->SetTexture(style.GetGroupExpandIcon());

  if (change and contents_ and !contents_->IsChildOf(layout_))
  {
    layout_->AddLayout(contents_.GetPointer(), 1, nux::MINOR_POSITION_LEFT, nux::MINOR_SIZE_FULL, 100.0f, nux::LayoutPosition(1));
  }
  else if (!change and contents_ and contents_->IsChildOf(layout_))
  {
    layout_->RemoveChildObject(contents_.GetPointer());
  }

  layout_->ComputeContentSize();
  QueueDraw();
}

Here is the call graph for this function:

Here is the caller graph for this function:

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

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]

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:

virtual std::string unity::dash::FilterExpanderLabel::GetFilterType ( ) [pure virtual]
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]

Implements unity::debug::Introspectable.

Definition at line 313 of file FilterExpanderLabel.cpp.

{
  return "FilterExpanderLabel";
}
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 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)

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:

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

Implemented in unity::dash::FilterGenre, unity::dash::FilterRatingsWidget, and unity::dash::FilterMultiRange.

Here is the caller graph for this function:

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

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:

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:

Definition at line 261 of file FilterExpanderLabel.cpp.

{
  return ((expander_view_ && expander_view_->HasKeyFocus()));
}

Here is the caller graph for this function:


Member Data Documentation

Definition at line 93 of file FilterExpanderLabel.h.

Definition at line 91 of file FilterExpanderLabel.h.

Definition at line 92 of file FilterExpanderLabel.h.

Definition at line 88 of file FilterExpanderLabel.h.

nux::ObjectPtr<nux::Layout> unity::dash::FilterExpanderLabel::contents_ [private]

Definition at line 98 of file FilterExpanderLabel.h.

Definition at line 67 of file FilterExpanderLabel.h.

Definition at line 94 of file FilterExpanderLabel.h.

Definition at line 66 of file FilterExpanderLabel.h.

Definition at line 86 of file FilterExpanderLabel.h.

Definition at line 85 of file FilterExpanderLabel.h.

std::unique_ptr<nux::AbstractPaintLayer> unity::dash::FilterExpanderLabel::highlight_layer_ [private]

Definition at line 99 of file FilterExpanderLabel.h.

Definition at line 90 of file FilterExpanderLabel.h.

nux::LinearLayout* unity::dash::FilterExpanderLabel::layout_ [private]

Reimplemented in unity::dash::FilterMultiRange.

Definition at line 83 of file FilterExpanderLabel.h.

Definition at line 89 of file FilterExpanderLabel.h.

Definition at line 87 of file FilterExpanderLabel.h.

Definition at line 95 of file FilterExpanderLabel.h.

nux::SpaceLayout* unity::dash::FilterExpanderLabel::space_ [private]

Definition at line 96 of file FilterExpanderLabel.h.

Definition at line 84 of file FilterExpanderLabel.h.


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