Back to index

unity  6.0.0
Public Types | Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Private Attributes
unity::MT::GrabHandleGroup Class Reference

#include <unity-mt-grab-handle-group.h>

Inheritance diagram for unity::MT::GrabHandleGroup:
Inheritance graph
[legend]
Collaboration diagram for unity::MT::GrabHandleGroup:
Collaboration graph
[legend]

List of all members.

Public Types

typedef boost::shared_ptr
< GrabHandleGroup
Ptr

Public Member Functions

 ~GrabHandleGroup ()
void relayout (const nux::Geometry &, bool)
void restack ()
bool visible ()
bool animate (unsigned int)
bool needsAnimate ()
int opacity ()
void hide ()
void show (unsigned int handles=~0)
void raiseHandle (const boost::shared_ptr< const unity::MT::GrabHandle > &)
std::vector< TextureLayoutlayout (unsigned int handles)
void forEachHandle (const std::function< void(const unity::MT::GrabHandle::Ptr &)> &)
void requestMovement (int x, int y, unsigned int direction, unsigned int button)

Static Public Member Functions

static GrabHandleGroup::Ptr create (GrabHandleWindow *owner, std::vector< TextureSize > &textures)

Private Types

enum  State { FADE_IN = 1, FADE_OUT, NONE }

Private Member Functions

 GrabHandleGroup (GrabHandleWindow *owner, std::vector< TextureSize > &textures)

Private Attributes

State mState
int mOpacity
bool mMoreAnimate
std::vector
< unity::MT::GrabHandle::Ptr
mHandles
GrabHandleWindowmOwner

Detailed Description

Definition at line 39 of file unity-mt-grab-handle-group.h.


Member Typedef Documentation

Definition at line 45 of file unity-mt-grab-handle-group.h.


Member Enumeration Documentation

Enumerator:
FADE_IN 
FADE_OUT 
NONE 

Definition at line 77 of file unity-mt-grab-handle-group.h.

  {
    FADE_IN = 1,
    FADE_OUT,
    NONE
  };

Constructor & Destructor Documentation

Definition at line 159 of file unity-mt-grab-handle-group.cpp.

{
  for (unity::MT::GrabHandle::Ptr & handle : mHandles)
    handle->damage (nux::Geometry (handle->x (),
                                   handle->y (),
                                   handle->width (),
                                   handle->height ()));
}
unity::MT::GrabHandleGroup::GrabHandleGroup ( GrabHandleWindow owner,
std::vector< TextureSize > &  textures 
) [private]

Definition at line 136 of file unity-mt-grab-handle-group.cpp.

                                                                                       :
  mState(State::NONE),
  mOpacity(0.0f),
  mMoreAnimate(false),
  mOwner(owner)
{
}

Member Function Documentation

bool unity::MT::GrabHandleGroup::animate ( unsigned int  msec)

Definition at line 49 of file unity-mt-grab-handle-group.cpp.

{
  mMoreAnimate = false;

  switch (mState)
  {
    case State::FADE_IN:

      mOpacity += ((float) msec / (float) unity::MT::FADE_MSEC) * std::numeric_limits <unsigned short>::max ();

      if (mOpacity >= std::numeric_limits <unsigned short>::max ())
      {
        mOpacity = std::numeric_limits <unsigned short>::max ();
        mState = State::NONE;
      }
      break;
    case State::FADE_OUT:
      mOpacity -= ((float) msec / (float) unity::MT::FADE_MSEC) * std::numeric_limits <unsigned short>::max ();

      if (mOpacity <= 0)
      {
        mOpacity = 0;
        mState = State::NONE;
      }
      break;
    default:
      break;
  }

  mMoreAnimate = mState != State::NONE;

  return mMoreAnimate;
}

Definition at line 146 of file unity-mt-grab-handle-group.cpp.

{
    unity::MT::GrabHandleGroup::Ptr p = unity::MT::GrabHandleGroup::Ptr (new unity::MT::GrabHandleGroup (owner, textures));
    for (unsigned int i = 0; i < NUM_HANDLES; i++)
      p->mHandles.push_back(unity::MT::GrabHandle::create (textures.at(i).first,
                                                           textures.at(i).second.width,
                                                           textures.at(i).second.height,
                                                           p,
                                                           handlesMask.find (i)->second));
    return p;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void unity::MT::GrabHandleGroup::forEachHandle ( const std::function< void(const unity::MT::GrabHandle::Ptr &)> &  f)

Definition at line 190 of file unity-mt-grab-handle-group.cpp.

{
  for (unity::MT::GrabHandle::Ptr &h : mHandles)
    f (h);
}

Definition at line 34 of file unity-mt-grab-handle-group.cpp.

{
  for(const unity::MT::GrabHandle::Ptr & handle : mHandles)
    handle->hide();

  mState = State::FADE_OUT;
}
std::vector< unity::MT::TextureLayout > unity::MT::GrabHandleGroup::layout ( unsigned int  handles)

Definition at line 178 of file unity-mt-grab-handle-group.cpp.

{
  std::vector <unity::MT::TextureLayout> layout;

  for(const unity::MT::GrabHandle::Ptr & handle : mHandles)
    if (handle->id () & handles)
      layout.push_back (handle->layout ());

  return layout;
}

Definition at line 96 of file unity-mt-grab-handle-group.cpp.

{
  return mMoreAnimate;
}

Definition at line 84 of file unity-mt-grab-handle-group.cpp.

{
  return mOpacity;
}
void unity::MT::GrabHandleGroup::raiseHandle ( const boost::shared_ptr< const unity::MT::GrabHandle > &  h)

Definition at line 43 of file unity-mt-grab-handle-group.cpp.

void unity::MT::GrabHandleGroup::relayout ( const nux::Geometry &  rect,
bool  hard 
)

Definition at line 102 of file unity-mt-grab-handle-group.cpp.

{
  /* Each grab handle at each vertex, eg:
   *
   * 1 - topleft
   * 2 - top
   * 3 - topright
   * 4 - right
   * 5 - bottom-right
   * 6 - bottom
   * 7 - bottom-left
   * 8 - left
   */

  const float pos[9][2] =
  {
    {0.0f, 0.0f}, {0.5f, 0.0f}, {1.0f, 0.0f},
    {1.0f, 0.5f}, {1.0f, 1.0f},
    {0.5f, 1.0f}, {0.0f, 1.0f}, {0.0f, 0.5f},
    {0.5f, 0.5f} /* middle */
  };

  for (unsigned int i = 0; i < NUM_HANDLES; i++)
  {
    unity::MT::GrabHandle::Ptr & handle = mHandles.at(i);

    handle->reposition (rect.x + rect.width * pos[i][0] -
                        handle->width () / 2,
                        rect.y + rect.height * pos[i][1] -
                        handle->height () / 2,
                        unity::MT::PositionSet | (hard ? unity::MT::PositionLock : 0));
  }
}
void unity::MT::GrabHandleGroup::requestMovement ( int  x,
int  y,
unsigned int  direction,
unsigned int  button 
)

Definition at line 169 of file unity-mt-grab-handle-group.cpp.

{
  mOwner->requestMovement (x, y, direction, button);
}
void unity::MT::GrabHandleGroup::show ( unsigned int  handles = ~0)

Definition at line 24 of file unity-mt-grab-handle-group.cpp.

{
  for(const unity::MT::GrabHandle::Ptr & handle : mHandles)
    if (handles & handle->id ())
      handle->show();

  mState = State::FADE_IN;
}

Definition at line 90 of file unity-mt-grab-handle-group.cpp.

{
  return mOpacity > 0.0f;
}

Here is the caller graph for this function:


Member Data Documentation

Definition at line 88 of file unity-mt-grab-handle-group.h.

Definition at line 87 of file unity-mt-grab-handle-group.h.

Definition at line 85 of file unity-mt-grab-handle-group.h.

Definition at line 89 of file unity-mt-grab-handle-group.h.

Definition at line 84 of file unity-mt-grab-handle-group.h.


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