Back to index

unity  6.0.0
Public Types | Public Member Functions | Public Attributes | Protected Member Functions | Private Member Functions | Private Attributes
unity::switcher::SwitcherView Class Reference

#include <SwitcherView.h>

Inheritance diagram for unity::switcher::SwitcherView:
Inheritance graph
[legend]
Collaboration diagram for unity::switcher::SwitcherView:
Collaboration graph
[legend]

List of all members.

Public Types

typedef nux::ObjectPtr
< SwitcherView
Ptr
typedef std::list
< Introspectable * > 
IntrospectableList

Public Member Functions

 SwitcherView ()
ui::LayoutWindowList ExternalTargets ()
void SetModel (SwitcherModel::Ptr model)
SwitcherModel::Ptr GetModel ()
void SetupBackground (bool enabled=true)
GVariant * Introspect ()
void AddChild (Introspectable *child)
void RemoveChild (Introspectable *child)
virtual IntrospectableList GetIntrospectableChildren ()
guint64 GetIntrospectionId () const

Public Attributes

nux::Property< bool > render_boxes
nux::Property< int > border_size
nux::Property< int > flat_spacing
nux::Property< int > icon_size
nux::Property< int > minimum_spacing
nux::Property< int > tile_size
nux::Property< int > vertical_size
nux::Property< int > text_size
nux::Property< int > animation_length
nux::Property< int > monitor
nux::Property< double > spread_size
nux::Property< nux::Color > background_color
nux::Property
< UnityWindowStyle::Ptr
style

Protected Member Functions

std::string GetName () const
void AddProperties (GVariantBuilder *builder)
void PreDraw (nux::GraphicsEngine &GfxContext, bool force_draw)
void DrawOverlay (nux::GraphicsEngine &GfxContext, bool force_draw, nux::Geometry clip)
nux::Geometry GetBackgroundGeometry ()
ui::RenderArg InterpolateRenderArgs (ui::RenderArg const &start, ui::RenderArg const &end, float progress)
nux::Geometry InterpolateBackground (nux::Geometry const &start, nux::Geometry const &end, float progress)
std::list< ui::RenderArgRenderArgsFlat (nux::Geometry &background_geo, int selection, timespec const &current)
ui::RenderArg CreateBaseArgForIcon (launcher::AbstractLauncherIcon::Ptr icon)
void Draw (nux::GraphicsEngine &GfxContext, bool force_draw)
void DrawContent (nux::GraphicsEngine &GfxContext, bool force_draw)
virtual void PostDraw (nux::GraphicsEngine &GfxContext, bool force_draw)
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 (SwitcherView, ui::UnityWindowView)
void OnSelectionChanged (launcher::AbstractLauncherIcon::Ptr selection)
void OnDetailSelectionChanged (bool detail)
void OnDetailSelectionIndexChanged (unsigned int index)
void OnIconSizeChanged (int size)
void OnTileSizeChanged (int size)
nux::Geometry UpdateRenderTargets (nux::Point const &center, timespec const &current)
void OffsetRenderTargets (int x, int y)
nux::Size SpreadSize ()
void GetFlatIconPositions (int n_flat_icons, int size, int selection, int &first_flat, int &last_flat, int &half_fold_left, int &half_fold_right)
void SaveLast ()

Private Attributes

ui::LayoutSystem::Ptr layout_system_
ui::AbstractIconRenderer::Ptr icon_renderer_
SwitcherModel::Ptr model_
bool target_sizes_set_
nux::ObjectPtr< nux::BaseTexture > rounding_texture_
nux::ObjectPtr
< nux::StaticCairoText
text_view_
std::list< ui::RenderArglast_args_
std::list< ui::RenderArgsaved_args_
nux::Geometry last_background_
nux::Geometry saved_background_
ui::LayoutWindowList render_targets_
timespec current_
timespec save_time_
bool animation_draw_
glib::Source::UniquePtr redraw_idle_

Detailed Description

Definition at line 45 of file SwitcherView.h.


Member Typedef Documentation

Definition at line 34 of file Introspectable.h.

Definition at line 49 of file SwitcherView.h.


Constructor & Destructor Documentation

Definition at line 43 of file SwitcherView.cpp.

  : UnityWindowView()
  , target_sizes_set_(false)
{
  icon_renderer_ = AbstractIconRenderer::Ptr(new IconRenderer());
  icon_renderer_->pip_style = OVER_TILE;

  layout_system_ = LayoutSystem::Ptr (new LayoutSystem ());
  border_size = 50;
  flat_spacing = 10;
  icon_size = 128;
  minimum_spacing = 10;
  tile_size = 150;
  vertical_size = tile_size + 80;
  text_size = 15;
  animation_length = 250;
  monitor = -1;
  spread_size = 3.5f;
  render_boxes = false;

  animation_draw_ = false;

  save_time_.tv_sec = 0;
  save_time_.tv_nsec = 0;

  render_targets_.clear ();

  rounding_texture_.Adopt(nux::CreateTexture2DFromFile(PKGDATADIR"/switcher_round_rect.png", -1, true));

  text_view_ = new nux::StaticCairoText("Testing");
  text_view_->SetMaximumWidth ((int) (tile_size * spread_size));
  text_view_->SetLines(1);
  text_view_->SetTextColor(nux::color::White);
  text_view_->SetFont("Ubuntu Bold 10");

  icon_size.changed.connect (sigc::mem_fun (this, &SwitcherView::OnIconSizeChanged));
  tile_size.changed.connect (sigc::mem_fun (this, &SwitcherView::OnTileSizeChanged));
}

Here is the call graph for this function:


Member Function Documentation

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::switcher::SwitcherView::AddProperties ( GVariantBuilder *  builder) [protected, virtual]

Reimplemented from unity::ui::UnityWindowView.

Definition at line 87 of file SwitcherView.cpp.

{
  unity::variant::BuilderWrapper(builder)
  .add("render-boxes", render_boxes)
  .add("border-size", border_size)
  .add("flat-spacing", flat_spacing)
  .add("icon-size", icon_size)
  .add("minimum-spacing", minimum_spacing)
  .add("tile-size", tile_size)
  .add("vertical-size", vertical_size)
  .add("text-size", text_size)
  .add("animation-length", animation_length)
  .add("spread-size", (float)spread_size)
  .add("label", text_view_->GetText());
}

Here is the call graph for this function:

Definition at line 189 of file SwitcherView.cpp.

{
  RenderArg arg;
  arg.icon = icon.GetPointer();
  arg.alpha = 0.95f;

  // tells the renderer to render arrows by number
  arg.running_on_viewport = true;

  arg.window_indicators = icon->WindowsForMonitor(monitor).size();
  if (arg.window_indicators > 1)
    arg.running_arrow = true;
  else
    arg.window_indicators = 0;

  if (icon == model_->Selection())
  {
    arg.keyboard_nav_hl = true;
    arg.backlight_intensity = 1.0f;
  }
  else
  {
    arg.backlight_intensity = 0.7f;
  }

  return arg;
}

Here is the caller graph for this function:

void unity::ui::UnityWindowView::Draw ( nux::GraphicsEngine &  GfxContext,
bool  force_draw 
) [protected, inherited]

Definition at line 46 of file UnityWindowView.cpp.

{
  // fixme???
}
void unity::ui::UnityWindowView::DrawContent ( nux::GraphicsEngine &  GfxContext,
bool  force_draw 
) [protected, inherited]

Definition at line 51 of file UnityWindowView.cpp.

{
  PreDraw(GfxContext, force_draw);

  nux::Geometry base = GetGeometry();
  GfxContext.PushClippingRectangle(base);

  // clear region
  gPainter.PaintBackground(GfxContext, base);

  nux::Geometry background_geo(GetBackgroundGeometry());
  int internal_offset = style()->GetInternalOffset();

  nux::Geometry internal_clip(background_geo.x + internal_offset,
                              background_geo.y + internal_offset,
                              background_geo.width - internal_offset * 2,
                              background_geo.height - internal_offset * 2);
  GfxContext.PushClippingRectangle(internal_clip);

  nux::Geometry const& geo_absolute = GetAbsoluteGeometry();
  nux::Geometry blur_geo(geo_absolute.x, geo_absolute.y, base.width, base.height);

  if (BackgroundEffectHelper::blur_type != BLUR_NONE)
  {
    bg_texture_ = bg_helper_.GetBlurRegion(blur_geo);
  }
  else
  {
    bg_texture_ = bg_helper_.GetRegion(blur_geo);
  }

  if (bg_texture_.IsValid())
  {
    nux::TexCoordXForm texxform_blur_bg;
    texxform_blur_bg.flip_v_coord = true;
    texxform_blur_bg.SetTexCoordType(nux::TexCoordXForm::OFFSET_COORD);
    texxform_blur_bg.uoffset = ((float) base.x) / geo_absolute.width;
    texxform_blur_bg.voffset = ((float) base.y) / geo_absolute.height;

    nux::ROPConfig rop;
    rop.Blend = false;
    rop.SrcBlend = GL_ONE;
    rop.DstBlend = GL_ONE_MINUS_SRC_ALPHA;

#ifndef NUX_OPENGLES_20
    if (GfxContext.UsingGLSLCodePath())
      gPainter.PushDrawCompositionLayer(GfxContext, base,
                                        bg_texture_,
                                        texxform_blur_bg,
                                        nux::color::White,
                                        background_color, nux::LAYER_BLEND_MODE_OVERLAY,
                                        true, rop);
    else
      gPainter.PushDrawTextureLayer(GfxContext, base,
                                    bg_texture_,
                                    texxform_blur_bg,
                                    nux::color::White,
                                    true,
                                    rop);
#else
      gPainter.PushDrawCompositionLayer(GfxContext, base,
                                        bg_texture_,
                                        texxform_blur_bg,
                                        nux::color::White,
                                        background_color, nux::LAYER_BLEND_MODE_OVERLAY,
                                        true, rop);
#endif
  }

  nux::ROPConfig rop;
  rop.Blend = true;

#ifndef NUX_OPENGLES_20
  if (GfxContext.UsingGLSLCodePath() == false)
  {
    rop.SrcBlend = GL_ONE;
    rop.DstBlend = GL_ONE_MINUS_SRC_ALPHA;
    gPainter.PushDrawColorLayer (GfxContext, internal_clip, background_color, false, rop);
  }
#endif

  // Make round corners
  rop.Blend = true;
  rop.SrcBlend = GL_ZERO;
  rop.DstBlend = GL_SRC_ALPHA;
  gPainter.PaintShapeCornerROP(GfxContext,
                               internal_clip,
                               nux::color::White,
                               nux::eSHAPE_CORNER_ROUND5,
                               nux::eCornerTopLeft | nux::eCornerTopRight |
                               nux::eCornerBottomLeft | nux::eCornerBottomRight,
                               true,
                               rop);

  DrawOverlay(GfxContext, force_draw, internal_clip);

  GfxContext.PopClippingRectangle();
  GfxContext.PopClippingRectangle();

  DrawBackground(GfxContext, background_geo);

  PostDraw(GfxContext, force_draw);
}

Here is the call graph for this function:

void unity::switcher::SwitcherView::DrawOverlay ( nux::GraphicsEngine &  GfxContext,
bool  force_draw,
nux::Geometry  clip 
) [protected, virtual]

Implements unity::ui::UnityWindowView.

Definition at line 555 of file SwitcherView.cpp.

{
  nux::Geometry base = GetGeometry();

  GfxContext.GetRenderStates().SetPremultipliedBlend(nux::SRC_OVER);
  std::list<RenderArg>::iterator it;
  for (it = last_args_.begin(); it != last_args_.end(); ++it)
  {
    if (model_->Selection() == it->icon)
    {
      int view_width = text_view_->GetBaseWidth();
      int start_x = it->render_center.x - view_width / 2;

      internal_clip.Expand (-10, -10);
      if (start_x < internal_clip.x)
        start_x = internal_clip.x;
      else if (start_x + view_width > internal_clip.x + internal_clip.width)
        start_x = (internal_clip.x + internal_clip.width) - view_width;

      text_view_->SetBaseX(start_x);
    }
    if (it->y_rotation < 0)
      icon_renderer_->RenderIcon(GfxContext, *it, base, base);
  }

  std::list<RenderArg>::reverse_iterator rit;
  for (rit = last_args_.rbegin(); rit != last_args_.rend(); ++rit)
  {
    if (rit->y_rotation >= 0)
      icon_renderer_->RenderIcon(GfxContext, *rit, base, base);
  }

  if (render_boxes)
  {
    float val = 0.1f;
    for (LayoutWindow::Ptr layout : ExternalTargets())
    {
      gPainter.Paint2DQuadColor(GfxContext, layout->result, nux::Color(val, val, val ,val));
      val += 0.1f;

      if (val > 1)
        val = 0.1f;
    }

    for (rit = last_args_.rbegin(); rit != last_args_.rend(); ++rit)
    {
      nux::Geometry tmp (rit->render_center.x - 1, rit->render_center.y - 1, 2, 2);
      gPainter.Paint2DQuadColor(GfxContext, tmp, nux::color::Red);
    }
  }

  // render orange box that will encirlce active item(s)
  for (LayoutWindow::Ptr window : ExternalTargets())
  {
    nux::Geometry const& geo_absolute = GetAbsoluteGeometry();
    if (window->alpha >= 1.0f)
    {
      nux::Geometry orange_box = window->result;
      orange_box.Expand(5, 5);
      orange_box.x -= geo_absolute.x;
      orange_box.y -= geo_absolute.y;

      gPainter.PaintTextureShape(GfxContext, orange_box, rounding_texture_.GetPointer(), 6, 6, 6, 6, false);
    }
  }

  text_view_->SetBaseY(last_background_.y + last_background_.height - 45);
  text_view_->Draw(GfxContext, force_draw);

  int ms_since_change = TimeUtil::TimeDelta(&current_, &save_time_);

  if (ms_since_change < animation_length && !redraw_idle_)
  {
    redraw_idle_.reset(new glib::Idle([&] () {
      QueueDraw();
      animation_draw_ = true;
      redraw_idle_.reset();
      return false;
    }, glib::Source::Priority::DEFAULT));
  }

  animation_draw_ = false;
}

Here is the call graph for this function:

Definition at line 105 of file SwitcherView.cpp.

{
  LayoutWindowList result = render_targets_;
  return result;
}

Here is the caller graph for this function:

nux::Geometry unity::switcher::SwitcherView::GetBackgroundGeometry ( ) [protected, virtual]

Implements unity::ui::UnityWindowView.

Definition at line 550 of file SwitcherView.cpp.

{
  return last_background_;
}
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:

void unity::switcher::SwitcherView::GetFlatIconPositions ( int  n_flat_icons,
int  size,
int  selection,
int &  first_flat,
int &  last_flat,
int &  half_fold_left,
int &  half_fold_right 
) [private]

Definition at line 308 of file SwitcherView.cpp.

{
  half_fold_left = -1;
  half_fold_right = -1;

  if (n_flat_icons == 0)
  {
    first_flat = selection + 1;
    last_flat = selection;
  }
  else if (n_flat_icons == 1)
  {
    if (selection == 0)
    {
      // selection is first item
      first_flat = 0;
      last_flat = n_flat_icons;
    }
    else if (selection >= size - 2)
    {
      // selection is in ending area where all icons at end should flatten
      first_flat = size - n_flat_icons - 1;
      last_flat = size - 1;
    }
    else
    {
      first_flat = selection;
      last_flat = selection;

      half_fold_left = first_flat - 1;
      half_fold_right = last_flat + 1;
    }
  }
  else
  {
    if (selection == 0)
    {
      // selection is first item
      first_flat = 0;
      last_flat = n_flat_icons;
    }
    else if (selection >= 1 && selection <= n_flat_icons - 1)
    {
      // selection is in "beginning" area before flat section starts moving
      // first item should half fold still
      first_flat = 1;
      last_flat = n_flat_icons;

      half_fold_left = 0;
      half_fold_right = last_flat + 1;
    }
    else if (selection >= size - 2)
    {
      // selection is in ending area where all icons at end should flatten
      first_flat = size - n_flat_icons - 1;
      last_flat = size - 1;
    }
    else
    {
      first_flat = selection - n_flat_icons + 2;
      last_flat = selection + 1;

      half_fold_left = first_flat - 1;
      half_fold_right = last_flat + 1;
    }
  }
}

Here is the caller graph for this function:

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:

Definition at line 184 of file SwitcherView.cpp.

{
  return model_;
}

Here is the caller graph for this function:

std::string unity::switcher::SwitcherView::GetName ( ) const [protected, virtual]

Reimplemented from unity::ui::UnityWindowView.

Definition at line 82 of file SwitcherView.cpp.

{
  return "SwitcherView";
}
nux::Geometry unity::switcher::SwitcherView::InterpolateBackground ( nux::Geometry const &  start,
nux::Geometry const &  end,
float  progress 
) [protected]

Definition at line 237 of file SwitcherView.cpp.

{
  progress = -pow(progress - 1.0f, 2) + 1;

  nux::Geometry result;

  result.x = start.x + (end.x - start.x) * progress;
  result.y = start.y + (end.y - start.y) * progress;
  result.width = start.width + (end.width - start.width) * progress;
  result.height = start.height + (end.height - start.height) * progress;

  return result;
}

Here is the caller graph for this function:

RenderArg unity::switcher::SwitcherView::InterpolateRenderArgs ( ui::RenderArg const &  start,
ui::RenderArg const &  end,
float  progress 
) [protected]

Definition at line 217 of file SwitcherView.cpp.

{
  // easing
  progress = -pow(progress - 1.0f, 2) + 1;

  RenderArg result = end;

  result.x_rotation = start.x_rotation + (end.x_rotation - start.x_rotation) * progress;
  result.y_rotation = start.y_rotation + (end.y_rotation - start.y_rotation) * progress;
  result.z_rotation = start.z_rotation + (end.z_rotation - start.z_rotation) * progress;

  result.render_center.x = start.render_center.x + (end.render_center.x - start.render_center.x) * progress;
  result.render_center.y = start.render_center.y + (end.render_center.y - start.render_center.y) * progress;
  result.render_center.z = start.render_center.z + (end.render_center.z - start.render_center.z) * progress;

  result.logical_center = result.render_center;

  return result;
}

Here is the caller graph for this function:

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:

void unity::switcher::SwitcherView::OffsetRenderTargets ( int  x,
int  y 
) [private]

Definition at line 285 of file SwitcherView.cpp.

{
  for (LayoutWindow::Ptr target : render_targets_)
  {
    target->result.x += x;
    target->result.y += y;
  }
}

Here is the caller graph for this function:

Definition at line 160 of file SwitcherView.cpp.

{

  if (detail)
  {
    Window detail_window = model_->DetailSelectionWindow();
    text_view_->SetText(model_->Selection()->NameForWindow(detail_window));
  }
  else
  {
    text_view_->SetText(model_->Selection()->tooltip_text());
  }
  SaveLast ();
  QueueDraw ();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void unity::switcher::SwitcherView::OnDetailSelectionIndexChanged ( unsigned int  index) [private]

Definition at line 150 of file SwitcherView.cpp.

{
  if (model_->detail_selection)
  {
    Window detail_window = model_->DetailSelectionWindow();
    text_view_->SetText(model_->Selection()->NameForWindow(detail_window));
  }
  QueueDraw ();
}

Here is the caller graph for this function:

Definition at line 132 of file SwitcherView.cpp.

{
  icon_renderer_->SetTargetSize(tile_size, icon_size, 10);
}

Here is the caller graph for this function:

Definition at line 176 of file SwitcherView.cpp.

{
  if (selection)
    text_view_->SetText(selection->tooltip_text());
  SaveLast ();
  QueueDraw();
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 137 of file SwitcherView.cpp.

{
  icon_renderer_->SetTargetSize(tile_size, icon_size, 10);
  vertical_size = tile_size + 80;
}

Here is the caller graph for this function:

virtual void unity::ui::UnityWindowView::PostDraw ( nux::GraphicsEngine &  GfxContext,
bool  force_draw 
) [inline, protected, virtual, inherited]

Definition at line 54 of file UnityWindowView.h.

{};

Here is the caller graph for this function:

void unity::switcher::SwitcherView::PreDraw ( nux::GraphicsEngine &  GfxContext,
bool  force_draw 
) [protected, virtual]

Reimplemented from unity::ui::UnityWindowView.

Definition at line 533 of file SwitcherView.cpp.

{
  clock_gettime(CLOCK_MONOTONIC, &current_);

  if (!target_sizes_set_)
  {
    icon_renderer_->SetTargetSize(tile_size, icon_size, 10);
    target_sizes_set_ = true;
  }

  nux::Geometry background_geo;
  last_args_ = RenderArgsFlat(background_geo, model_->SelectionIndex(), current_);
  last_background_ = background_geo;

  icon_renderer_->PreprocessIcons(last_args_, GetGeometry());
}

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:

std::list< RenderArg > unity::switcher::SwitcherView::RenderArgsFlat ( nux::Geometry &  background_geo,
int  selection,
timespec const &  current 
) [protected]

Definition at line 382 of file SwitcherView.cpp.

{
  std::list<RenderArg> results;
  nux::Geometry base = GetGeometry();

  render_targets_.clear ();

  bool detail_selection = model_->detail_selection;

  background_geo.y = base.y + base.height / 2 - (vertical_size / 2);
  background_geo.height = vertical_size + text_size;


  if (model_)
  {

    int size = model_->Size();
    int padded_tile_size = tile_size + flat_spacing * 2;
    int max_width = base.width - border_size * 2;

    nux::Geometry spread_bounds;
    int spread_padded_width = 0;
    if (detail_selection)
    {
      spread_bounds = UpdateRenderTargets (nux::Point (0, 0), current);
      // remove extra space consumed by spread
      spread_padded_width = spread_bounds.width + 100;
      max_width -= spread_padded_width - tile_size;

      int expansion = MAX (0, spread_bounds.height - icon_size);
      background_geo.y -= expansion / 2;
      background_geo.height += expansion;
    }

    int flat_width = size * padded_tile_size;

    int n_flat_icons = CLAMP((max_width - size * minimum_spacing) / padded_tile_size - 1, 0, size);

    int overflow = flat_width - max_width;
    float x = 0;
    if (overflow < 0)
    {
      background_geo.x = base.x - overflow / 2;
      background_geo.width = base.width + overflow;

      x -= overflow / 2;
      overflow = 0;
    }
    else
    {
      background_geo.x = base.x;
      background_geo.width = base.width;
    }

    int non_flat_icons = std::max (1.0f, (float)size - n_flat_icons - 1);
    float partial_overflow = (float) overflow / (float)non_flat_icons;
    float partial_overflow_scalar = (float)(padded_tile_size - partial_overflow) / (float)(padded_tile_size);

    int first_flat, last_flat;
    int half_fold_left;
    int half_fold_right;

    GetFlatIconPositions (n_flat_icons, size, selection, first_flat, last_flat, half_fold_left, half_fold_right);

    SwitcherModel::iterator it;
    int i = 0;
    int y = base.y + base.height / 2;
    x += border_size;
    for (it = model_->begin(); it != model_->end(); ++it)
    {
      RenderArg arg = CreateBaseArgForIcon(*it);

      float scalar = partial_overflow_scalar;

      bool should_flat = false;

      if (i >= first_flat && i <= last_flat)
      {
        scalar = 1.0f;
        should_flat = true;
      }
      else if (i == half_fold_left || i == half_fold_right)
      {
        scalar += (1.0f - scalar) * 0.5f;
      }

      int half_size = tile_size / 2;
      if (i == selection && detail_selection)
      {
        half_size = spread_padded_width / 2;
        scalar = 1.0f;
      }

      x += (half_size + flat_spacing) * scalar;

      if (should_flat)
        arg.render_center = nux::Point3((int) x, y, 0);
      else
        arg.render_center = nux::Point3(x, y, 0);

      x += (half_size + flat_spacing) * scalar;

      arg.y_rotation = (1.0f - MIN (1.0f, scalar));

      if (!should_flat && overflow > 0 && i != selection)
      {
        if (i > last_flat)
        {
          arg.render_center.x -= 20;
        }
        else
        {
          arg.render_center.x += 20;
          arg.y_rotation = -arg.y_rotation;
        }
      }

      arg.render_center.z = abs(80.0f * arg.y_rotation);
      arg.logical_center = arg.render_center;

      if (i == selection && detail_selection)
      {
        arg.skip = true;
        OffsetRenderTargets (arg.render_center.x, arg.render_center.y);
      }

      results.push_back(arg);
      ++i;
    }

    int ms_since_change = TimeUtil::TimeDelta(&current, &save_time_);
    if (saved_args_.size () == results.size () && ms_since_change < animation_length)
    {
      float progress = (float) ms_since_change / (float) animation_length();

      std::list<RenderArg> end = results;
      results.clear();

      std::list<RenderArg>::iterator start_it, end_it;
      for (start_it = saved_args_.begin(), end_it = end.begin(); start_it != saved_args_.end(); ++start_it, ++end_it)
      {
        results.push_back(InterpolateRenderArgs(*start_it, *end_it, progress));
      }

      background_geo = InterpolateBackground (saved_background_, background_geo, progress);
    }
  }

  return results;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 143 of file SwitcherView.cpp.

{
  saved_args_ = last_args_;
  saved_background_ = last_background_;
  clock_gettime(CLOCK_MONOTONIC, &save_time_);
}

Here is the caller graph for this function:

Definition at line 111 of file SwitcherView.cpp.

{
  model_ = model;
  model->selection_changed.connect(sigc::mem_fun(this, &SwitcherView::OnSelectionChanged));
  model->detail_selection.changed.connect (sigc::mem_fun (this, &SwitcherView::OnDetailSelectionChanged));
  model->detail_selection_index.changed.connect (sigc::mem_fun (this, &SwitcherView::OnDetailSelectionIndexChanged));

  if (!model->Selection())
    return;

  if (model->detail_selection)
  {
    Window detail_window = model->DetailSelectionWindow();
    text_view_->SetText(model->Selection()->NameForWindow(detail_window));
  }
  else
  {
    text_view_->SetText(model->Selection()->tooltip_text());
  }
}

Here is the call graph for this function:

void unity::ui::UnityWindowView::SetupBackground ( bool  enabled = true) [inherited]

Definition at line 41 of file UnityWindowView.cpp.

{
  bg_helper_.enabled = enabled;
}

Definition at line 294 of file SwitcherView.cpp.

{
  nux::Geometry base = GetGeometry();
  nux::Size result (base.width - border_size * 2, base.height - border_size * 2);

  int width_padding = std::max(model_->Size() - 1, 0) * minimum_spacing + tile_size;
  int height_padding = text_size;

  result.width -= width_padding;
  result.height -= height_padding;

  return result;
}

Here is the caller graph for this function:

nux::Geometry unity::switcher::SwitcherView::UpdateRenderTargets ( nux::Point const &  center,
timespec const &  current 
) [private]

Definition at line 251 of file SwitcherView.cpp.

{
  std::vector<Window> xids = model_->DetailXids ();

  int ms_since_change = TimeUtil::TimeDelta(&current, &save_time_);
  float progress = MIN (1.0f, (float) ms_since_change / (float) animation_length());

  for (Window window : xids)
  {
    LayoutWindow::Ptr layout_window (new LayoutWindow (window));

    if (window == model_->DetailSelectionWindow ())
      layout_window->alpha = 1.0f * progress;
    else
      layout_window->alpha = 0.9f * progress;

    render_targets_.push_back (layout_window);
  }

  nux::Geometry max_bounds;

  nux::Geometry absolute = GetAbsoluteGeometry ();
  nux::Size spread_size = SpreadSize();
  max_bounds.x = absolute.x + center.x - spread_size.width / 2;
  max_bounds.y = absolute.y + center.y - spread_size.height / 2;
  max_bounds.width = spread_size.width;
  max_bounds.height = spread_size.height;

  nux::Geometry final_bounds;
  layout_system_->LayoutWindows (render_targets_, max_bounds, final_bounds);

  return final_bounds;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 127 of file SwitcherView.h.

Definition at line 66 of file SwitcherView.h.

nux::Property<nux::Color> unity::ui::UnityWindowView::background_color [inherited]

Definition at line 40 of file UnityWindowView.h.

Definition at line 59 of file SwitcherView.h.

Definition at line 124 of file SwitcherView.h.

Definition at line 60 of file SwitcherView.h.

Definition at line 109 of file SwitcherView.h.

Definition at line 61 of file SwitcherView.h.

Definition at line 116 of file SwitcherView.h.

Definition at line 119 of file SwitcherView.h.

Definition at line 108 of file SwitcherView.h.

Definition at line 62 of file SwitcherView.h.

Definition at line 110 of file SwitcherView.h.

Definition at line 67 of file SwitcherView.h.

Definition at line 129 of file SwitcherView.h.

Definition at line 58 of file SwitcherView.h.

Definition at line 122 of file SwitcherView.h.

nux::ObjectPtr<nux::BaseTexture> unity::switcher::SwitcherView::rounding_texture_ [private]

Definition at line 113 of file SwitcherView.h.

Definition at line 125 of file SwitcherView.h.

Definition at line 117 of file SwitcherView.h.

Definition at line 120 of file SwitcherView.h.

Definition at line 68 of file SwitcherView.h.

Definition at line 41 of file UnityWindowView.h.

Definition at line 111 of file SwitcherView.h.

Definition at line 65 of file SwitcherView.h.

Definition at line 114 of file SwitcherView.h.

Definition at line 63 of file SwitcherView.h.

Definition at line 64 of file SwitcherView.h.


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