Back to index

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

#include <FilterBasicButton.h>

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

List of all members.

Public Member Functions

 FilterBasicButton (nux::TextureArea *image, NUX_FILE_LINE_PROTO)
 FilterBasicButton (std::string const &label, NUX_FILE_LINE_PROTO)
 FilterBasicButton (std::string const &label, nux::TextureArea *image, NUX_FILE_LINE_PROTO)
 FilterBasicButton (NUX_FILE_LINE_PROTO)
virtual ~FilterBasicButton ()

Protected Types

typedef std::unique_ptr
< nux::CairoWrapper > 
NuxCairoPtr

Protected Member Functions

virtual long ComputeContentSize ()
virtual void Draw (nux::GraphicsEngine &GfxContext, bool force_draw)
void Init ()
void InitTheme ()
void RedrawTheme (nux::Geometry const &geom, cairo_t *cr, nux::ButtonVisualState faked_state)
void RedrawFocusOverlay (nux::Geometry const &geom, cairo_t *cr)

Protected Attributes

NuxCairoPtr prelight_
NuxCairoPtr active_
NuxCairoPtr normal_
NuxCairoPtr focus_
nux::Geometry cached_geometry_

Private Attributes

std::string label_

Detailed Description

Definition at line 34 of file FilterBasicButton.h.


Member Typedef Documentation

typedef std::unique_ptr<nux::CairoWrapper> unity::dash::FilterBasicButton::NuxCairoPtr [protected]

Definition at line 52 of file FilterBasicButton.h.


Constructor & Destructor Documentation

unity::dash::FilterBasicButton::FilterBasicButton ( nux::TextureArea *  image,
NUX_FILE_LINE_PROTO   
)
unity::dash::FilterBasicButton::FilterBasicButton ( std::string const &  label,
NUX_FILE_LINE_PROTO   
)
unity::dash::FilterBasicButton::FilterBasicButton ( std::string const &  label,
nux::TextureArea *  image,
NUX_FILE_LINE_PROTO   
)

Definition at line 62 of file FilterBasicButton.cpp.

{
}

Member Function Documentation

Definition at line 111 of file FilterBasicButton.cpp.

{
  long ret = nux::Button::ComputeContentSize();

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

  if (cached_geometry_ != geo)
  {
    prelight_->Invalidate(geo);
    active_->Invalidate(geo);
    normal_->Invalidate(geo);
    focus_->Invalidate(geo);

    cached_geometry_ = geo;
  }

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

Definition at line 130 of file FilterBasicButton.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_->GetTexture();
  if (Active())
    texture = active_->GetTexture();
  else if (GetVisualState() == nux::ButtonVisualState::VISUAL_STATE_PRELIGHT)
    texture = prelight_->GetTexture();
  else if (GetVisualState() == nux::ButtonVisualState::VISUAL_STATE_PRESSED)
    texture = active_->GetTexture();

  GfxContext.QRP_1Tex(geo.x,
                      geo.y,
                      geo.width,
                      geo.height,
                      texture->GetDeviceTexture(),
                      texxform,
                      nux::Color(1.0f, 1.0f, 1.0f, 1.0f));

  if (HasKeyboardFocus())
  {
    GfxContext.QRP_1Tex(geo.x,
                        geo.y,
                        geo.width,
                        geo.height,
                        focus_->GetTexture()->GetDeviceTexture(),
                        texxform,
                        nux::Color(1.0f, 1.0f, 1.0f, 1.0f));
  }

  GfxContext.GetRenderStates().SetBlend(alpha, src, dest);
}

Definition at line 66 of file FilterBasicButton.cpp.

{

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

  key_nav_focus_change.connect([&] (nux::Area*, bool, nux::KeyNavDirection)
  {
    QueueDraw();
  });

  key_nav_focus_activate.connect([&](nux::Area*)
  {
    if (GetInputEventSensitivity())
      Active() ? Deactivate() : Activate();
  });
}

Here is the call graph for this function:

Definition at line 85 of file FilterBasicButton.cpp.

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

    prelight_.reset(new nux::CairoWrapper(geo, sigc::bind(sigc::mem_fun(this, &FilterBasicButton::RedrawTheme), nux::ButtonVisualState::VISUAL_STATE_PRELIGHT)));
    active_.reset(new nux::CairoWrapper(geo, sigc::bind(sigc::mem_fun(this, &FilterBasicButton::RedrawTheme), nux::ButtonVisualState::VISUAL_STATE_PRESSED)));
    normal_.reset(new nux::CairoWrapper(geo, sigc::bind(sigc::mem_fun(this, &FilterBasicButton::RedrawTheme), nux::ButtonVisualState::VISUAL_STATE_NORMAL)));
    focus_.reset(new nux::CairoWrapper(geo, sigc::mem_fun(this, &FilterBasicButton::RedrawFocusOverlay)));
  }

  SetMinimumHeight(kMinButtonHeight);
  SetMinimumWidth(kMinButtonWidth);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void unity::dash::FilterBasicButton::RedrawFocusOverlay ( nux::Geometry const &  geom,
cairo_t *  cr 
) [protected]

Definition at line 106 of file FilterBasicButton.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void unity::dash::FilterBasicButton::RedrawTheme ( nux::Geometry const &  geom,
cairo_t *  cr,
nux::ButtonVisualState  faked_state 
) [protected]

Definition at line 101 of file FilterBasicButton.cpp.

{
  Style::Instance().Button(cr, faked_state, label_, -1, Alignment::CENTER, true);
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 55 of file FilterBasicButton.h.

Definition at line 59 of file FilterBasicButton.h.

Definition at line 57 of file FilterBasicButton.h.

Definition at line 62 of file FilterBasicButton.h.

Definition at line 56 of file FilterBasicButton.h.

Definition at line 54 of file FilterBasicButton.h.


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