~unity-team/unity/trunk

« back to all changes in this revision

Viewing changes to dash/previews/PreviewContainer.cpp

  • Committer: Daniel van Vugt
  • Date: 2012-09-13 10:56:42 UTC
  • mfrom: (2684 unity)
  • mto: This revision was merged to the branch mainline in revision 2698.
  • Revision ID: daniel.van.vugt@canonical.com-20120913105642-9on2ald55h54j1zn
Merge latest lp:unity and fix conflicts

Show diffs side-by-side

added added

removed removed

Lines of Context:
62
62
  PreviewContent(PreviewContainer*const parent)
63
63
  : parent_(parent)
64
64
  , progress_(0.0)
 
65
  , curve_progress_(0.0)
65
66
  , animating_(false)
66
67
  , waiting_preview_(false)
67
68
  , rotation_(0.0)
69
70
  , nav_complete_(0)
70
71
  , relative_nav_index_(0)
71
72
  {
 
73
    OnGeometryChanged.connect([&](nux::Area*, nux::Geometry& geo)
 
74
    {
 
75
      // Need to update the preview geometries when updating the container geo.
 
76
      UpdateAnimationProgress(progress_, curve_progress_);
 
77
    });
72
78
    Style& style = previews::Style::Instance();
73
79
 
74
80
    spin_= style.GetSearchSpinIcon(256);
98
104
 
99
105
    if (preview)
100
106
    {
 
107
      // the parents layout will not change based on the previews.
 
108
      preview->SetReconfigureParentLayoutOnGeometryChange(false);
 
109
      
101
110
      AddChild(preview.GetPointer());
102
111
      AddView(preview.GetPointer());
103
112
      preview->SetVisible(false);
123
132
  void UpdateAnimationProgress(float progress, float curve_progress)
124
133
  {
125
134
    progress_ = progress;
 
135
    curve_progress_ = curve_progress;
126
136
 
127
137
    if (!animating_)
128
138
    {
171
181
 
172
182
    if (progress >= 1.0)
173
183
    {
174
 
      animating_ = false;
175
 
      if (current_preview_)
176
 
      {
177
 
        RemoveChild(current_preview_.GetPointer());
178
 
        RemoveChildObject(current_preview_.GetPointer());
179
 
        current_preview_.Release();
180
 
      }
181
 
      if (swipe_.preview)
182
 
      {
183
 
        if (swipe_.direction == Navigation::RIGHT)
184
 
          relative_nav_index_++;
185
 
        else if (swipe_.direction == Navigation::LEFT)
186
 
          relative_nav_index_--;
187
 
 
188
 
        current_preview_ = swipe_.preview;
189
 
        swipe_.preview.Release();
 
184
      // if we were animating, we need to remove the old preview, and replace it with the new.
 
185
      if (animating_)
 
186
      {
 
187
        animating_ = false;
190
188
        if (current_preview_)
191
 
          current_preview_->OnNavigateInComplete();
192
 
      }
193
 
 
194
 
      // another swipe?
195
 
      if (!push_preview_.empty())
196
 
      {
197
 
        progress_ = 0;
198
 
        continue_navigation.emit();
199
 
      }
200
 
      else
201
 
      {
202
 
        end_navigation.emit();
 
189
        {
 
190
          RemoveChild(current_preview_.GetPointer());
 
191
          RemoveChildObject(current_preview_.GetPointer());
 
192
          current_preview_.Release();
 
193
        }
 
194
        if (swipe_.preview)
 
195
        {
 
196
          if (swipe_.direction == Navigation::RIGHT)
 
197
            relative_nav_index_++;
 
198
          else if (swipe_.direction == Navigation::LEFT)
 
199
            relative_nav_index_--;
 
200
 
 
201
          current_preview_ = swipe_.preview;
 
202
          swipe_.preview.Release();
 
203
          if (current_preview_)
 
204
            current_preview_->OnNavigateInComplete();
 
205
        } 
 
206
 
 
207
        // another swipe?
 
208
        if (!push_preview_.empty())
 
209
        {
 
210
          progress_ = 0;
 
211
          continue_navigation.emit();
 
212
        }
 
213
        else
 
214
        {
 
215
          end_navigation.emit();
 
216
        }
203
217
      }
204
218
 
205
219
      // set the geometry to the whole layout.
206
 
      if (current_preview_ && current_preview_->GetGeometry() != geometry)
 
220
      if (current_preview_)
207
221
      {
208
222
        current_preview_->SetGeometry(geometry);
209
223
      }
332
346
  PreviewSwipe swipe_;
333
347
 
334
348
  float progress_;
 
349
  float curve_progress_;
335
350
  bool animating_;
336
351
  // wait animation
337
352
  glib::Source::UniquePtr preview_wait_timer_;