~cszikszoy/do/docklets-toggle-vis

« 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-06-02 21:35:59 UTC
  • mfrom: (1195.1.18 do)
  • Revision ID: jason@t500-20090602213559-rhh5yaomi2kq1aif
Merge cursor tracker branch

Show diffs side-by-side

added added

removed removed

Lines of Context:
57
57
                const int UrgentIndicatorSize = 12;
58
58
                
59
59
                Dictionary<IDockPainter, Surface> painter_surfaces;
60
 
                bool next_fast_render, first_render_set, last_no_render;
 
60
                bool next_fast_render, first_render_set, last_no_render, rendering;
 
61
                double? zoom_in_buffer;
61
62
                
62
63
                Surface backbuffer, input_area_buffer, dock_icon_buffer;
63
64
                Surface indicator, urgent_indicator;
71
72
                
72
73
                PreviousRenderData RenderData { get; set; }
73
74
 
74
 
                bool PainterOverlayVisible { get; set; }
75
 
 
 
75
                //// <value>
 
76
                /// Determines if the current rendering state allows for a fast render
 
77
                /// </value>
76
78
                bool CanFastRender {
77
79
                        get {
78
80
                                bool result = next_fast_render && !RenderData.ForceFullRender && RenderData.RenderItems.Count == 0;
79
 
                                next_fast_render = RenderData.ZoomIn == 1 && ZoomIn == 1 && !drag_resizing;
 
81
                                next_fast_render = RenderData.ZoomIn == 1 && ZoomIn == 1 && !DnDTracker.DragResizing;
80
82
                                return result;
81
83
                        }
82
84
                }
83
85
                
 
86
                //// <value>
 
87
                /// Determines if the current rendering state allows for a "no" render
 
88
                /// </value>
84
89
                bool CanNoRender {
85
90
                        get {
86
91
                                bool result = DockPreferences.ZoomEnabled && 
87
92
                                            !RenderData.ForceFullRender &&
88
93
                                                RenderData.RenderItems.Count == 0 &&
89
94
                                            RenderData.ZoomIn == 0 &&
90
 
                                                !GtkDragging &&
91
 
                                                !drag_resizing &&
 
95
                                                !DnDTracker.GtkDragging &&
 
96
                                                !DnDTracker.DragResizing &&
92
97
                                                ZoomIn == 0;
93
98
                                bool tmp = last_no_render;
94
99
                                last_no_render = result;
96
101
                        }
97
102
                }
98
103
                
 
104
                //// <value>
 
105
                /// Determins if a single item only needs to be redrawn and updated (usually caused by an update request)
 
106
                /// </value>
99
107
                bool SingleItemRender {
100
108
                        get {
101
109
                                return !RenderData.ForceFullRender && 
133
141
                        }
134
142
                }
135
143
                
 
144
                //// <value>
 
145
                /// Get autohide state
 
146
                /// </value>
136
147
                bool IsHidden {
137
148
                        get {
138
149
                                bool hidden = false;
196
207
                        get {
197
208
                                double offset = 0;
198
209
                                // we never hide in these conditions
199
 
                                if (DockPreferences.AutohideType == AutohideType.None || drag_resizing || PainterOpacity == 1) {
 
210
                                if (DockPreferences.AutohideType == AutohideType.None || DnDTracker.DragResizing || PainterOpacity == 1) {
200
211
                                        if ((RenderTime - FirstRenderTime) > SummonTime)
201
212
                                                return 0;
202
213
                                        offset = 1 - Math.Min (1, (DateTime.UtcNow - FirstRenderTime).TotalMilliseconds / SummonTime.TotalMilliseconds);
231
242
                /// </value>
232
243
                double ZoomIn {
233
244
                        get {
234
 
                                if (drag_resizing && drag_start_point != Cursor)
 
245
                                if (DnDTracker.InternalDragActive)
235
246
                                        return 0;
236
247
                                
 
248
                                // we buffer this value during renders since it will be checked many times and we dont need to 
 
249
                                // recalculate it each time
 
250
                                if (zoom_in_buffer.HasValue && rendering) {
 
251
                                        return zoom_in_buffer.Value;
 
252
                                }
 
253
                                
237
254
                                double zoom = Math.Min (1, (RenderTime - enter_time).TotalMilliseconds / 
238
255
                                                         BaseAnimationTime.TotalMilliseconds);
239
256
                                if (CursorIsOverDockArea) {
247
264
                                if (PainterOverlayVisible)
248
265
                                        zoom = zoom * DockIconOpacity;
249
266
                                
 
267
                                if (rendering)
 
268
                                        zoom_in_buffer = zoom;
 
269
                                
250
270
                                return zoom;
251
271
                        }
252
272
                }
276
296
                void DrawDrock (Context cr)
277
297
                {
278
298
                        Gdk.Rectangle dockArea = GetDockArea ();
 
299
                        window.SetBackgroundBlur (dockArea);
 
300
                        
279
301
                        DockBackgroundRenderer.RenderDockBackground (cr, dockArea);
280
302
 
281
303
                        IDockPainter dpaint = (Painter == null) ? LastPainter : Painter;
390
412
                                if (index >= startItem && index <= endItem)
391
413
                                        DrawIcon (cr, index, true);
392
414
                                
393
 
                        } else if (!animationRequired && SingleItemRender) {
 
415
                        } else if (SingleItemRender && !animationRequired) {
394
416
                                // A single icon for some reason needs to be drawn again. This is more or less
395
417
                                // a special case of a fast render
396
418
                                Gdk.Rectangle renderArea = Gdk.Rectangle.Zero;
448
470
                void DrawIcon (Context cr, int icon, bool hovered)
449
471
                {
450
472
                        // Don't draw the icon we are dragging around
451
 
                        if (GtkDragging && !DragState.IsFinished) {
452
 
                                int item = DockItems.IndexOf (DragState.DragItem);
 
473
                        if (DnDTracker.GtkDragging && !DnDTracker.DragState.IsFinished) {
 
474
                                int item = DockItems.IndexOf (DnDTracker.DragState.DragItem);
453
475
                                if (item == icon && DockServices.ItemsService.ItemCanBeMoved (item))
454
476
                                        return;
455
477
                        }
456
478
                        
457
479
                        AbstractDockItem dockItem = DockItems [icon];
458
 
                        if (dockItem == null) return;
 
480
                        if (dockItem == null) return; //happens?
459
481
                        
460
482
                        PointD center;
461
483
                        double zoom;
549
571
                                              iconPosition.X / scale, iconPosition.Y / scale);
550
572
                                cr.PaintWithAlpha (fadeInOpacity);
551
573
                                
552
 
                                bool shade_light = GtkDragging && !PreviewIsDesktopFile && CursorIsOverDockArea &&
 
574
                                bool shade_light = DnDTracker.GtkDragging && !DnDTracker.PreviewIsDesktopFile && CursorIsOverDockArea &&
553
575
                                        dockItem.IsAcceptingDrops && icon == PositionProvider.IndexAtPosition (Cursor);
554
576
                                
555
577
                                bool shade_dark = animationType == ClickAnimationType.Darken;
600
622
                        // blank surface (which is slow)
601
623
                        if (!PopupMenu.Visible && hovered &&
602
624
                            CursorIsOverDockArea && dockItem.GetTextSurface (cr.Target) != null && 
603
 
                            !GtkDragging && !drag_resizing) {
 
625
                            !DnDTracker.GtkDragging && !DnDTracker.DragResizing) {
604
626
 
605
627
                                Gdk.Point textPoint;
606
 
                                Gdk.Rectangle monitor = LayoutUtils.MonitorGemonetry ();
607
628
                                Surface textSurface = dockItem.GetTextSurface (cr.Target);
608
629
                                textPoint.X = PositionProvider.IconUnzoomedPosition (icon).X - (dockItem.TextSurfaceSize.Width >> 1);
609
630
                                textPoint.X = Math.Max (0, Math.Min (Width - dockItem.TextSurfaceSize.Width, textPoint.X));
670
691
                Surface GetIndicator (Surface similar)
671
692
                {
672
693
                        if (indicator == null) {
673
 
                                Style style = Docky.Interface.DockWindow.Window.Style;
 
694
                                Style style = window.Style;
674
695
                                Gdk.Color color = style.Backgrounds [(int) StateType.Selected].SetMinimumValue (100);
675
696
 
676
697
                                indicator = similar.CreateSimilar (similar.Content, IndicatorSize * 2, IndicatorSize * 2);
776
797
                        if (!IsDrawable)
777
798
                                return false;
778
799
                        
 
800
                        rendering = true;
 
801
                        zoom_in_buffer = null;
779
802
                        RenderTime = DateTime.UtcNow;
780
803
                        Context cr;
781
804
                        if (backbuffer == null) {
813
836
                        ((IDisposable)cr.Target).Dispose ();
814
837
                        ((IDisposable)cr).Dispose ();
815
838
                        
 
839
                        rendering = false;
816
840
                        return true;
817
841
                }
818
842