~do-core/do/weather-applet

« back to all changes in this revision

Viewing changes to Do.Interface.Linux.Docky/src/Docky.Interface/DockArea_Rendering.cs

  • Committer: Jason Smith
  • Date: 2009-02-09 05:07:34 UTC
  • mfrom: (935.4.4 do)
  • Revision ID: jassmith@gmail.com-20090209050734-qv12e2y1jonpg7zx
Merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
42
42
                IDockPainter painter, last_painter;
43
43
                Matrix default_matrix;
44
44
                
 
45
                DateTime RenderTime { get; set; }
 
46
                
45
47
                DateTime ActiveIconChangeTime { get; set; }
46
48
 
47
49
                bool PainterOverlayVisible { get; set; }
54
56
                                if (drag_resizing && drag_start_point != Cursor)
55
57
                                        return 0;
56
58
                                
57
 
                                double zoom = Math.Min (1, (DateTime.UtcNow - enter_time).TotalMilliseconds / 
58
 
                                                        BaseAnimationTime.TotalMilliseconds);
 
59
                                double zoom = Math.Min (1, (RenderTime - enter_time).TotalMilliseconds / 
 
60
                                                         BaseAnimationTime.TotalMilliseconds);
59
61
                                if (CursorIsOverDockArea) {
60
62
                                        if (DockPreferences.AutoHide)
61
63
                                                zoom = 1;
84
86
                                        if (CursorIsOverDockArea) {
85
87
                                                return 0;
86
88
                                        } else {
87
 
                                                offset = Math.Min (1, (DateTime.UtcNow - enter_time).TotalMilliseconds / 
 
89
                                                offset = Math.Min (1, (RenderTime - enter_time).TotalMilliseconds / 
88
90
                                                                   SummonTime.TotalMilliseconds);
89
91
                                                offset = Math.Min (offset, Math.Min (1, 
90
 
                                                                                     (DateTime.UtcNow - interface_change_time)
 
92
                                                                                     (RenderTime - interface_change_time)
91
93
                                                                                     .TotalMilliseconds / SummonTime.TotalMilliseconds));
92
94
                                        }
93
95
                                        
94
96
                                        if (PainterOverlayVisible)
95
97
                                                offset = 1 - offset;
96
98
                                } else {
97
 
                                        offset = Math.Min (1, (DateTime.UtcNow - enter_time).TotalMilliseconds / 
 
99
                                        offset = Math.Min (1, (RenderTime - enter_time).TotalMilliseconds / 
98
100
                                                           SummonTime.TotalMilliseconds);
99
101
                                        if (CursorIsOverDockArea)
100
102
                                                offset = 1 - offset;
108
110
                /// </value>
109
111
                double DockIconOpacity {
110
112
                        get {
111
 
                                if (SummonTime < DateTime.UtcNow - interface_change_time) {
 
113
                                if (SummonTime < RenderTime - interface_change_time) {
112
114
                                        if (PainterOverlayVisible)
113
115
                                                return 0;
114
116
                                        return 1;
115
117
                                }
116
118
 
117
 
                                double total_time = (DateTime.UtcNow - interface_change_time).TotalMilliseconds;
 
119
                                double total_time = (RenderTime - interface_change_time).TotalMilliseconds;
118
120
                                if (PainterOverlayVisible) {
119
121
                                        return 1 - (total_time / SummonTime.TotalMilliseconds);
120
122
                                } else {
222
224
                                        return;
223
225
                        }
224
226
                        
 
227
                        AbstractDockItem dockItem = DockItems [icon];
225
228
                        PointD center;
226
229
                        double zoom;
227
230
                        IconZoomedPosition (icon, out center, out zoom);
228
231
                        
229
232
                        // This gives the actual x,y coordinates of the icon
230
 
                        PointD iconPosition = new PointD (center.X - zoom * DockItems [icon].Width / 2,
231
 
                                                          center.Y - zoom * DockItems [icon].Width / 2);
 
233
                        PointD iconPosition = new PointD (center.X - zoom * dockItem.Width / 2,
 
234
                                                          center.Y - zoom * dockItem.Width / 2);
232
235
                        
233
236
                        ClickAnimationType animationType = IconAnimation (icon);
234
237
                        
237
240
                        if (animationType == ClickAnimationType.Bounce) {
238
241
                                // bounces twice
239
242
                                double delta = Math.Abs (30 * Math.Sin 
240
 
                                                         (DockItems [icon].TimeSinceClick.TotalMilliseconds * Math.PI / 
 
243
                                                         (dockItem.TimeSinceClick.TotalMilliseconds * Math.PI / 
241
244
                                                          (BounceTime.TotalMilliseconds / 2)));
242
245
                                
243
246
                                iconPosition = iconPosition.RelativeMovePoint (delta, RelativeMove.Inward);
244
247
                        } else {
245
 
                                if (DockItems [icon] != null && DockItems [icon].NeedsAttention) {
 
248
                                if (dockItem != null && dockItem.NeedsAttention) {
246
249
                                        drawUrgency = true;
247
 
                                        if (DateTime.UtcNow - DockItems [icon].AttentionRequestStartTime < BounceTime) {
248
 
                                                double urgentMs = (DateTime.UtcNow - DockItems [icon].AttentionRequestStartTime)
 
250
                                        if (RenderTime - dockItem.AttentionRequestStartTime < BounceTime) {
 
251
                                                double urgentMs = (RenderTime - dockItem.AttentionRequestStartTime)
249
252
                                                        .TotalMilliseconds;
250
253
                                                
251
254
                                                double delta = 100 * Math.Sin (urgentMs * Math.PI / (BounceTime.TotalMilliseconds));
255
258
                        }
256
259
                        
257
260
                        int size;
258
 
                        Surface iconSurface = DockItems [icon].GetIconSurface (cr.Target, (int) (IconSize * zoom), out size);
 
261
                        Surface iconSurface = dockItem.GetIconSurface (cr.Target, (int) (IconSize * zoom), out size);
259
262
                        
260
 
                        if (DockItems [icon].ScalingType != ScalingType.None) {
 
263
                        if (dockItem.ScalingType != ScalingType.None) {
261
264
                                double scale;
262
265
                                
263
266
                                if (size == DockPreferences.FullIconSize) {
274
277
                                // we need to multiply x and y by 1 / scale to undo the scaling of the context.  We only want to zoom
275
278
                                // the icon, not move it around.
276
279
                                
277
 
                                double fadeInOpacity = Math.Min (DockItems [icon].TimeSinceAdd.TotalMilliseconds / 
 
280
                                double fadeInOpacity = Math.Min (dockItem.TimeSinceAdd.TotalMilliseconds / 
278
281
                                                                 InsertAnimationTime.TotalMilliseconds, 1);
279
282
                                cr.SetSource (iconSurface, 
280
283
                                              iconPosition.X / scale, iconPosition.Y / scale);
281
284
                                cr.PaintWithAlpha (fadeInOpacity);
282
285
                                
283
286
                                bool shade_light = GtkDragging && 
284
 
                                        DockItems [icon].IsAcceptingDrops && icon == PositionProvider.IndexAtPosition (Cursor);
 
287
                                        dockItem.IsAcceptingDrops && icon == PositionProvider.IndexAtPosition (Cursor);
285
288
                                
286
289
                                bool shade_dark = animationType == ClickAnimationType.Darken;
287
290
                                if (shade_dark || shade_light) {
291
294
                                        if (shade_light) {
292
295
                                                cr.Color = new Cairo.Color (.9, .95, 1, .5);
293
296
                                        } else {
294
 
                                                double opacity = (BounceTime - DockItems [icon].TimeSinceClick).TotalMilliseconds / 
 
297
                                                double opacity = (BounceTime - dockItem.TimeSinceClick).TotalMilliseconds / 
295
298
                                                        BounceTime.TotalMilliseconds - .7;
296
299
                                                
297
300
                                                cr.Color = new Cairo.Color (0, 0, 0, opacity);
310
313
                                if (DockPreferences.DockIsHorizontal) {
311
314
                                        // why this fails to center right... i dont know...
312
315
                                        cr.SetSource (iconSurface, 
313
 
                                                      (int) iconPosition.X, (int) center.Y - DockItems [icon].Height / 2);
 
316
                                                      (int) iconPosition.X, (int) center.Y - dockItem.Height / 2);
314
317
                                } else {
315
318
                                        cr.SetSource (iconSurface, 
316
319
                                                      (int) iconPosition.X - IconSize / 2 + 5, (int) iconPosition.Y);
318
321
                                cr.Paint ();
319
322
                        }
320
323
                        
321
 
                        if (0 < DockItems [icon].WindowCount) {
 
324
                        if (0 < dockItem.WindowCount) {
322
325
                                Gdk.Point location;
323
326
                                switch (DockPreferences.Orientation) {
324
327
                                case DockOrientation.Bottom:
335
338
                                        location = new Gdk.Point ((int) center.X, 1);
336
339
                                        break;
337
340
                                }
338
 
                                Util.DrawGlowIndicator (cr, location, drawUrgency, DockItems [icon].WindowCount);
 
341
                                Util.DrawGlowIndicator (cr, location, drawUrgency, dockItem.WindowCount);
339
342
                        }
340
343
                        
341
344
                        // we do a null check here to allow things like separator items to supply
342
345
                        // a null.  This allows us to draw nothing at all instead of rendering a
343
346
                        // blank surface (which is slow)
344
347
                        if (!PopupMenu.Visible && PositionProvider.IndexAtPosition (Cursor) == icon &&
345
 
                            CursorIsOverDockArea && DockItems [icon].GetTextSurface (cr.Target) != null && !GtkDragging) {
 
348
                            CursorIsOverDockArea && dockItem.GetTextSurface (cr.Target) != null && !GtkDragging) {
346
349
 
347
350
                                Gdk.Point textPoint;
348
351
                                if (DockPreferences.DockIsHorizontal) {
361
364
                                                textPoint = textPoint.RelativeMovePoint (DockPreferences.TextWidth, RelativeMove.Inward);
362
365
                                        textPoint = textPoint.RelativeMovePoint (10, RelativeMove.RealUp);
363
366
                                }
364
 
                                DockItems [icon].GetTextSurface (cr.Target).Show (cr, textPoint.X, textPoint.Y);
 
367
                                dockItem.GetTextSurface (cr.Target).Show (cr, textPoint.X, textPoint.Y);
365
368
                        }
366
369
                }
367
370
 
391
394
                        return (DockItems [icon].TimeSinceClick < BounceTime) ? 
392
395
                                DockItems [icon].AnimationType : ClickAnimationType.None;
393
396
                }
 
397
                
 
398
                void IconZoomedPosition (int icon, out PointD center, out double zoom)
 
399
                {
 
400
                        PositionProvider.IconZoomedPosition (icon, ZoomIn, Cursor, out center, out zoom);
 
401
                }
394
402
 
395
403
                Surface GetOverlaySurface (Context similar)
396
404
                {
414
422
                        if (!IsDrawable || window.IsRepositionHidden)
415
423
                                return ret_val;
416
424
                        
 
425
                        RenderTime = DateTime.UtcNow;
417
426
                        Context cr;
418
427
                        if (backbuffer == null) {
419
428
                                cr = Gdk.CairoHelper.Create (GdkWindow);