Back to index

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

#include <FilterMultiRangeButton.h>

Collaboration diagram for unity::dash::FilterMultiRangeButton:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 FilterMultiRangeButton (std::string const &label, NUX_FILE_LINE_PROTO)
 FilterMultiRangeButton (NUX_FILE_LINE_PROTO)
 ~FilterMultiRangeButton ()
void SetFilter (FilterOption::Ptr const &filter)
FilterOption::Ptr GetFilter ()
void SetVisualSide (MultiRangeSide side)
void SetHasArrow (MultiRangeArrow arrow)

Protected Member Functions

virtual long ComputeContentSize ()
virtual void Draw (nux::GraphicsEngine &GfxContext, bool force_draw)

Private Types

typedef std::unique_ptr
< nux::CairoWrapper > 
NuxCairoPtr
typedef std::pair
< MultiRangeArrow,
MultiRangeSide
MapKey

Private Member Functions

void InitTheme ()
void Init ()
void RedrawTheme (nux::Geometry const &geom, cairo_t *cr, nux::ButtonVisualState faked_state, MultiRangeArrow faked_arrow, MultiRangeSide faked_side)
void RedrawFocusOverlay (nux::Geometry const &geom, cairo_t *cr, MultiRangeArrow faked_arrow, MultiRangeSide faked_side)
void OnActivated (nux::Area *area)
void OnActiveChanged (bool value)

Private Attributes

FilterOption::Ptr filter_
std::map< MapKey, NuxCairoPtractive_
std::map< MapKey, NuxCairoPtrfocus_
std::map< MapKey, NuxCairoPtrnormal_
std::map< MapKey, NuxCairoPtrprelight_
nux::Geometry cached_geometry_
MultiRangeArrow has_arrow_
MultiRangeSide side_

Detailed Description

Definition at line 53 of file FilterMultiRangeButton.h.


Member Typedef Documentation

Definition at line 91 of file FilterMultiRangeButton.h.

typedef std::unique_ptr<nux::CairoWrapper> unity::dash::FilterMultiRangeButton::NuxCairoPtr [private]

Definition at line 90 of file FilterMultiRangeButton.h.


Constructor & Destructor Documentation

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

Definition at line 49 of file FilterMultiRangeButton.cpp.

{
}

Member Function Documentation

Definition at line 104 of file FilterMultiRangeButton.cpp.

{
  long ret = nux::ToggleButton::ComputeContentSize();
  nux::Geometry const& geo = GetGeometry();
  if (cached_geometry_ != geo)
  {
    cached_geometry_ = geo;

    std::vector<MultiRangeSide> sides = {MultiRangeSide::LEFT, MultiRangeSide::RIGHT, MultiRangeSide::CENTER};
    std::vector<MultiRangeArrow> arrows = {MultiRangeArrow::LEFT, MultiRangeArrow::RIGHT, MultiRangeArrow::BOTH, MultiRangeArrow::NONE};

    for (auto arrow : arrows)
    {
      for (auto side : sides)
      {
        prelight_[MapKey(arrow, side)]->Invalidate(geo);
        active_[MapKey(arrow, side)]->Invalidate(geo);
        normal_[MapKey(arrow, side)]->Invalidate(geo);
        focus_[MapKey(arrow, side)]->Invalidate(geo);
      }
    }
  }

  return ret;
}
void unity::dash::FilterMultiRangeButton::Draw ( nux::GraphicsEngine &  GfxContext,
bool  force_draw 
) [protected, virtual]

Definition at line 216 of file FilterMultiRangeButton.cpp.

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

  gPainter.PaintBackground(GfxContext, geo);
  // set up our texture mode
  nux::TexCoordXForm texxform;
  texxform.SetWrap(nux::TEXWRAP_REPEAT, nux::TEXWRAP_REPEAT);
  texxform.SetTexCoordType(nux::TexCoordXForm::OFFSET_COORD);

  // clear what is behind us
  unsigned int alpha = 0, src = 0, dest = 0;
  GfxContext.GetRenderStates().GetBlend(alpha, src, dest);
  GfxContext.GetRenderStates().SetBlend(true, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);

  nux::Color col = nux::color::Black;
  col.alpha = 0;
  GfxContext.QRP_Color(geo.x,
                       geo.y,
                       geo.width,
                       geo.height,
                       col);

  nux::BaseTexture* texture = normal_[MapKey(has_arrow_, side_)]->GetTexture();
  if (GetVisualState() == nux::ButtonVisualState::VISUAL_STATE_PRELIGHT)
  {
    texture = prelight_[MapKey(has_arrow_, side_)]->GetTexture();
  }

  if (Active())
  {
    texture = active_[MapKey(has_arrow_, side_)]->GetTexture();
  }

  if (HasKeyFocus())
  {
    GfxContext.QRP_1Tex(geo.x,
                        geo.y,
                        geo.width,
                        geo.height,
                        focus_[MapKey(has_arrow_, side_)]->GetTexture()->GetDeviceTexture(),
                        texxform,
                        nux::color::White);
  }

  GfxContext.QRP_1Tex(geo.x,
                      geo.y,
                      geo.width,
                      geo.height,
                      texture->GetDeviceTexture(),
                      texxform,
                      nux::Color(1.0f, 1.0f, 1.0f, 1.0f));
  GfxContext.GetRenderStates().SetBlend(alpha, src, dest);
}

Definition at line 81 of file FilterMultiRangeButton.cpp.

{
  return filter_;
}

Definition at line 53 of file FilterMultiRangeButton.cpp.

{
  InitTheme();
  SetAcceptKeyNavFocusOnMouseDown(false);
  SetAcceptKeyNavFocusOnMouseEnter(true);

  state_change.connect(sigc::mem_fun(this, &FilterMultiRangeButton::OnActivated));
  key_nav_focus_change.connect([&](nux::Area*, bool, nux::KeyNavDirection) { QueueDraw(); });
  key_nav_focus_activate.connect([&](nux::Area* area) { Active() ? Deactivate() : Activate(); });
}

Here is the call graph for this function:

Definition at line 130 of file FilterMultiRangeButton.cpp.

{
  if (!active_[MapKey(MultiRangeArrow::LEFT, MultiRangeSide::LEFT)])
  {
    nux::Geometry const& geo = GetGeometry();

    std::vector<MultiRangeSide> sides = {MultiRangeSide::LEFT, MultiRangeSide::RIGHT, MultiRangeSide::CENTER};
    std::vector<MultiRangeArrow> arrows = {MultiRangeArrow::LEFT, MultiRangeArrow::RIGHT, MultiRangeArrow::BOTH, MultiRangeArrow::NONE};

    for (auto arrow : arrows)
    {
      for (auto side : sides)
      {
        active_[MapKey(arrow, side)].reset(new nux::CairoWrapper(geo, sigc::bind(sigc::mem_fun(this, &FilterMultiRangeButton::RedrawTheme), nux::ButtonVisualState::VISUAL_STATE_PRESSED, arrow, side)));
        normal_[MapKey(arrow, side)].reset(new nux::CairoWrapper(geo, sigc::bind(sigc::mem_fun(this, &FilterMultiRangeButton::RedrawTheme), nux::ButtonVisualState::VISUAL_STATE_NORMAL, arrow, side)));
        prelight_[MapKey(arrow, side)].reset(new nux::CairoWrapper(geo, sigc::bind(sigc::mem_fun(this, &FilterMultiRangeButton::RedrawTheme), nux::ButtonVisualState::VISUAL_STATE_PRELIGHT, arrow, side)));
        focus_[MapKey(arrow, side)].reset(new nux::CairoWrapper(geo, sigc::bind(sigc::mem_fun(this, &FilterMultiRangeButton::RedrawFocusOverlay), arrow, side)));
      }
    }
  }

  SetMinimumHeight(dash::Style::Instance().GetFilterButtonHeight() + 3);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void unity::dash::FilterMultiRangeButton::OnActivated ( nux::Area *  area) [private]

Definition at line 64 of file FilterMultiRangeButton.cpp.

{
  if (filter_)
    filter_->active = Active();
}

Here is the caller graph for this function:

Definition at line 70 of file FilterMultiRangeButton.cpp.

{
  NeedRedraw();
}
void unity::dash::FilterMultiRangeButton::RedrawFocusOverlay ( nux::Geometry const &  geom,
cairo_t *  cr,
MultiRangeArrow  faked_arrow,
MultiRangeSide  faked_side 
) [private]

Definition at line 189 of file FilterMultiRangeButton.cpp.

{
  Arrow arrow;
  if (faked_arrow == MultiRangeArrow::NONE)
    arrow = Arrow::NONE;
  else if (faked_arrow == MultiRangeArrow::LEFT)
    arrow = Arrow::LEFT;
  else if (faked_arrow == MultiRangeArrow::BOTH)
    arrow = Arrow::BOTH;
  else
    arrow = Arrow::RIGHT;

  Segment segment;
  if (faked_side == MultiRangeSide::LEFT)
    segment = Segment::LEFT;
  else if (faked_side == MultiRangeSide::CENTER)
    segment = Segment::MIDDLE;
  else
    segment = Segment::RIGHT;

  Style::Instance().MultiRangeFocusOverlay(cr, arrow, segment);
  QueueDraw();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void unity::dash::FilterMultiRangeButton::RedrawTheme ( nux::Geometry const &  geom,
cairo_t *  cr,
nux::ButtonVisualState  faked_state,
MultiRangeArrow  faked_arrow,
MultiRangeSide  faked_side 
) [private]

Definition at line 154 of file FilterMultiRangeButton.cpp.

{
  std::string name("10");

  if (filter_)
  {
    name = filter_->name;
  }

  Arrow arrow;
  if (faked_arrow == MultiRangeArrow::NONE)
    arrow = Arrow::NONE;
  else if (faked_arrow == MultiRangeArrow::LEFT)
    arrow = Arrow::LEFT;
  else if (faked_arrow == MultiRangeArrow::BOTH)
    arrow = Arrow::BOTH;
  else
    arrow = Arrow::RIGHT;

  Segment segment;
  if (faked_side == MultiRangeSide::LEFT)
    segment = Segment::LEFT;
  else if (faked_side == MultiRangeSide::CENTER)
    segment = Segment::MIDDLE;
  else
    segment = Segment::RIGHT;

  Style::Instance().MultiRangeSegment(cr, faked_state, name, arrow, segment);
  NeedRedraw();
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 75 of file FilterMultiRangeButton.cpp.

{
  filter_ = filter;
  SetActive(filter_->active);
}

Here is the caller graph for this function:

Definition at line 95 of file FilterMultiRangeButton.cpp.

{
  if (has_arrow_ == value)
    return;
  has_arrow_ = value;

  QueueDraw();
}

Definition at line 86 of file FilterMultiRangeButton.cpp.

{
  if (side_ == side)
    return;
  side_ = side;

  QueueDraw();
}

Member Data Documentation

Definition at line 93 of file FilterMultiRangeButton.h.

Definition at line 98 of file FilterMultiRangeButton.h.

Definition at line 88 of file FilterMultiRangeButton.h.

Definition at line 94 of file FilterMultiRangeButton.h.

Definition at line 99 of file FilterMultiRangeButton.h.

Definition at line 95 of file FilterMultiRangeButton.h.

Definition at line 96 of file FilterMultiRangeButton.h.

Definition at line 100 of file FilterMultiRangeButton.h.


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