예제 #1
0
		static DockySurface[] GetSlices (DockySurface model)
		{
			if (menu_slices != null)
				return menu_slices;
			
			DockySurface main = new DockySurface (TotalWidth, TotalHeight, model);
			
			using (Gdk.Pixbuf pixbuf = DockServices.Drawing.LoadIcon (DockServices.Theme.MenuSvg)) {
				Gdk.CairoHelper.SetSourcePixbuf (main.Context, pixbuf, ShadowSize, ShadowSize);
				main.Context.Paint ();
			}
			
			Gdk.Rectangle extents;
			if (ShadowSize > 0)
				using (DockySurface shadow = main.CreateMask (0, out extents)) {
					shadow.GaussianBlur (ShadowSize);
					shadow.Context.Operator = Operator.DestOut;
					for (int i = 0; i < 4; i++) {
						shadow.Context.SetSource (main.Internal);
						shadow.Context.Paint ();
					}
					
					main.Context.Operator = Operator.DestOver;
					main.Context.SetSource (shadow.Internal);
					main.Context.PaintWithAlpha (1);
					main.Context.Operator = Operator.Over;
				}
			
			int middleWidth = TotalWidth - 2 * SliceSize;
			int middleHeight = TotalHeight - 2 * SliceSize - TailHeight;
			int tailSliceSize = TailHeight + SliceSize;
			int tailSideSize = (middleWidth - TailWidth) / 2;
			
			DockySurface[] results = new DockySurface[11];
			results[(int) Slice.TopLeft] = main.CreateSlice (new Gdk.Rectangle (
					0, 
					0, 
					SliceSize, 
					SliceSize));
			
			results[(int) Slice.Top] = main.CreateSlice (new Gdk.Rectangle (
					SliceSize, 
					0, 
					middleWidth, 
					SliceSize));
			
			results[(int) Slice.TopRight] = main.CreateSlice (new Gdk.Rectangle (
					TotalWidth - SliceSize, 
					0, 
					SliceSize, 
					SliceSize));
			
			results[(int) Slice.Left] = main.CreateSlice (new Gdk.Rectangle (
					0, 
					SliceSize, 
					SliceSize, 
					middleHeight));
			
			results[(int) Slice.Center] = main.CreateSlice (new Gdk.Rectangle (
					SliceSize, 
					SliceSize, 
					middleWidth, 
					middleHeight));
			
			results[(int) Slice.Right] = main.CreateSlice (new Gdk.Rectangle (
					TotalWidth - SliceSize, 
					SliceSize, 
					SliceSize, 
					middleHeight));
			
			results[(int) Slice.BottomLeft] = main.CreateSlice (new Gdk.Rectangle (
					0, 
					TotalHeight - tailSliceSize, 
					SliceSize, 
					tailSliceSize));
			
			results[(int) Slice.TailLeft] = main.CreateSlice (new Gdk.Rectangle (
					SliceSize, 
					TotalHeight - tailSliceSize, 
					tailSideSize, 
					tailSliceSize));
			
			results[(int) Slice.Tail] = main.CreateSlice (new Gdk.Rectangle (
					SliceSize + tailSideSize,
					TotalHeight - tailSliceSize,
					TailWidth,
					tailSliceSize));
				
			results[(int) Slice.TailRight] = main.CreateSlice (new Gdk.Rectangle (
					SliceSize + middleWidth - tailSideSize,
					TotalHeight - tailSliceSize,
					tailSideSize,
					tailSliceSize));
			
			results[(int) Slice.BottomRight] = main.CreateSlice (new Gdk.Rectangle (
					SliceSize + middleWidth,
					TotalHeight - tailSliceSize,
					SliceSize,
					tailSliceSize));
			
			menu_slices = results;
			
			main.Dispose ();
			
			return menu_slices;
		}
예제 #2
0
		void DrawDock (DockySurface surface)
		{
			surface.Clear ();
			
			UpdateDrawRegionsForSurface (surface);
			
			Gdk.Rectangle dockArea, cursorArea;
			GetDockAreaOnSurface (surface, out dockArea, out cursorArea);
			
			if (Preferences.PanelMode) {
				Gdk.Rectangle panelArea = dockArea;
				if (PanelModeToggleProgress == 1) {
					if (Preferences.IsVertical) {
						panelArea.Y = -100;
						panelArea.Height = Height + 200;
					} else {
						panelArea.X = -100;
						panelArea.Width = Width + 200;
					}
				}
				DrawDockBackground (surface, panelArea);
			} else {
				DrawDockBackground (surface, dockArea);
			}
				
			double painterVisibility = PainterOpacity;
			if (painterVisibility < 1) {
			
				if (icon_buffer == null || icon_buffer.Width != surface.Width || icon_buffer.Height != surface.Height) {
					if (icon_buffer != null)
						icon_buffer.Dispose ();
					icon_buffer = new DockySurface (surface.Width, surface.Height, surface);
				}
				
				icon_buffer.Clear ();
				foreach (AbstractDockItem adi in Items)
					DrawItem (icon_buffer, dockArea, adi);
			
				surface.Context.SetSource (icon_buffer.Internal, 0, 0);
				surface.Context.PaintWithAlpha (1 - painterVisibility);
			
			} 
			
			if (Painter != null && painterVisibility > 0)
				DrawPainter (surface, dockArea);
			
			if (ActiveGlow) {
				Gdk.Color color = Style.BaseColors[(int) Gtk.StateType.Selected];
				
				Gdk.Rectangle extents;
				using (DockySurface tmp = surface.CreateMask (0, out extents)) {
					extents.Inflate (GlowSize * 2, GlowSize * 2);
					tmp.ExponentialBlur (GlowSize, extents);
					tmp.Context.Color = new Cairo.Color (
						(double) color.Red / ushort.MaxValue, 
						(double) color.Green / ushort.MaxValue, 
						(double) color.Blue / ushort.MaxValue, 
						.90).SetValue (1).MultiplySaturation (4);
					tmp.Context.Operator = Operator.Atop;
					tmp.Context.Paint ();
				
					surface.Context.Operator = Operator.DestOver;
					surface.Context.SetSource (tmp.Internal);
					surface.Context.Paint ();
					surface.Context.Operator = Operator.Over;
				}
			}
			
			if (DockOpacity < 1)
				SetDockOpacity (surface);
			
			// Draw UrgentGlow which is visible when Docky is hidden and an item need attention
			if (AutohideManager.Hidden && !ConfigurationMode && (!Preferences.FadeOnHide || Preferences.FadeOpacity == 0)) {
				foreach (AbstractDockItem adi in Items) {
					double diff = (render_time - adi.StateSetTime (ItemState.Urgent)).TotalMilliseconds;
					if (adi.Indicator != ActivityIndicator.None && (adi.State & ItemState.Urgent) == ItemState.Urgent &&
					    (DockServices.Theme.GlowTime.Days > 0 || diff < DockServices.Theme.GlowTime.TotalMilliseconds)) {
						
						if (urgent_glow_buffer == null)
							urgent_glow_buffer = CreateUrgentGlowBuffer ();
		
						DrawValue val = DrawValues [adi];
						DrawValue glowloc;
						if (Preferences.FadeOnHide)
							glowloc = val.MoveIn (Position, -urgent_glow_buffer.Height / 2 + DockHeightBuffer);
						else
							glowloc = val.MoveIn (Position, -urgent_glow_buffer.Height / 2 + DockHeightBuffer + ZoomedDockHeight);

						double opacity = 0.2 + (0.75 * (Math.Sin (diff / PulseTime.TotalMilliseconds * 2 * Math.PI) + 1) / 2);
						
						urgent_glow_buffer.ShowWithOptions (surface, glowloc.Center, 1, 0, opacity);
					}
				}
			}
			
			SetInputMask (cursorArea);
			
			Gdk.Rectangle staticArea = StaticDockArea (surface);
			staticArea.X += window_position.X;
			staticArea.Y += window_position.Y;
			staticArea.Intersect (monitor_geo);
			AutohideManager.SetIntersectArea (staticArea);
			
			cursorArea.X += window_position.X;
			cursorArea.Y += window_position.Y;
			AutohideManager.SetCursorArea (cursorArea);
		}