Back to index

unity  6.0.0
Public Member Functions | Public Attributes | Private Member Functions | Private Attributes
unity::launcher::LauncherDragWindow Class Reference

#include <LauncherDragWindow.h>

Collaboration diagram for unity::launcher::LauncherDragWindow:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 LauncherDragWindow (nux::ObjectPtr< nux::IOpenGLBaseTexture > icon)
 ~LauncherDragWindow ()
void DrawContent (nux::GraphicsEngine &gfxContext, bool forceDraw)
void SetAnimationTarget (int x, int y)
void StartAnimation ()
bool Animating ()

Public Attributes

sigc::signal< void > anim_completed
sigc::connection on_anim_completed

Private Member Functions

 NUX_DECLARE_OBJECT_TYPE (LauncherDragWindow, nux::BaseWindow)
bool OnAnimationTimeout ()

Private Attributes

nux::ObjectPtr
< nux::IOpenGLBaseTexture > 
_icon
nux::Point2 _animation_target
glib::Source::UniquePtr animation_timer_

Detailed Description

Definition at line 35 of file LauncherDragWindow.h.


Constructor & Destructor Documentation

unity::launcher::LauncherDragWindow::LauncherDragWindow ( nux::ObjectPtr< nux::IOpenGLBaseTexture >  icon)

Definition at line 34 of file LauncherDragWindow.cpp.

  : nux::BaseWindow("")
  , _icon(icon)
{
  SetBaseSize(_icon->GetWidth(), _icon->GetHeight());
}

Definition at line 41 of file LauncherDragWindow.cpp.

{
  if (on_anim_completed.connected())
    on_anim_completed.disconnect();
}

Member Function Documentation

Definition at line 47 of file LauncherDragWindow.cpp.

{
  return bool(animation_timer_);
}
void unity::launcher::LauncherDragWindow::DrawContent ( nux::GraphicsEngine &  gfxContext,
bool  forceDraw 
)

Definition at line 99 of file LauncherDragWindow.cpp.

{
  nux::Geometry geo = GetGeometry();
  geo.SetX(0);
  geo.SetY(0);

  GfxContext.PushClippingRectangle(geo);

  nux::TexCoordXForm texxform;
  texxform.FlipVCoord(true);

  GfxContext.QRP_1Tex(0,
                      0,
                      _icon->GetWidth(),
                      _icon->GetHeight(),
                      _icon,
                      texxform,
                      nux::color::White);

  GfxContext.PopClippingRectangle();
}

Definition at line 66 of file LauncherDragWindow.cpp.

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

  int half_size = geo.width / 2;

  int target_x = static_cast<int>(_animation_target.x) - half_size;
  int target_y = static_cast<int>(_animation_target.y) - half_size;

  int x_delta = static_cast<int>(static_cast<float>(target_x - geo.x) * .3f);
  if (std::abs(x_delta) < 5)
    x_delta = (x_delta >= 0) ? std::min(5, target_x - geo.x) : std::max(-5, target_x - geo.x);

  int y_delta = static_cast<int>(static_cast<float>(target_y - geo.y) * .3f);
  if (std::abs(y_delta) < 5)
    y_delta = (y_delta >= 0) ? std::min(5, target_y - geo.y) : std::max(-5, target_y - geo.y);

  SetBaseXY(geo.x + x_delta, geo.y + y_delta);

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

  if (new_geo.x == target_x && new_geo.y == target_y)
  {
    anim_completed.emit();
    animation_timer_.reset();

    return false;
  }

  return true;
}

Here is the caller graph for this function:

Definition at line 52 of file LauncherDragWindow.cpp.

{
  _animation_target = nux::Point2(x, y);
}

Definition at line 57 of file LauncherDragWindow.cpp.

{
  if (animation_timer_)
    return;

  animation_timer_.reset(new glib::Timeout(15));
  animation_timer_->Run(sigc::mem_fun(this, &LauncherDragWindow::OnAnimationTimeout));
}

Here is the call graph for this function:


Member Data Documentation

Definition at line 57 of file LauncherDragWindow.h.

nux::ObjectPtr<nux::IOpenGLBaseTexture> unity::launcher::LauncherDragWindow::_icon [private]

Definition at line 56 of file LauncherDragWindow.h.

Definition at line 50 of file LauncherDragWindow.h.

Definition at line 58 of file LauncherDragWindow.h.

Definition at line 51 of file LauncherDragWindow.h.


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