void RenderPreview(Cairo.Context context, Gdk.Point position, double opacity) { if (brandedIcon != null) { /* if (previewSurface == null) { * previewSurface = new SurfaceWrapper (context, brandedIcon); * } * double scale = PreviewSize / previewSurface.Width; * * context.Save (); * context.Translate (position.X, position.Y); * context.Scale (scale * IconScale, scale * IconScale); * context.SetSourceSurface (previewSurface.Surface, -previewSurface.Width / 2, -previewSurface.Height / 2); * context.PaintWithAlpha (opacity); * context.Restore (); */ double scale = PreviewSize / brandedIcon.Width; context.Save(); context.Translate(position.X, position.Y); context.Scale(scale * IconScale, scale * IconScale); context.DrawImage(this, brandedIcon.WithAlpha(opacity), -brandedIcon.Width / 2, -brandedIcon.Height / 2); context.Restore(); } }
void RenderPreview(Cairo.Context context, Gdk.Point position, double opacity) { if (brandedIcon != null) { double scale = PreviewSize / brandedIcon.Width; context.Save(); context.Translate(position.X, position.Y); context.Scale(scale * IconScale, scale * IconScale); context.DrawImage(this, brandedIcon.WithAlpha(opacity), -brandedIcon.Width / 2, -brandedIcon.Height / 2); context.Restore(); } }
protected override bool OnExposeEvent(Gdk.EventExpose evnt) { if (image != null) { var alloc = Allocation; alloc.Inflate(-Xpad, -Ypad); using (var ctx = CairoHelper.Create(evnt.Window)) { var x = Math.Round(alloc.X + (alloc.Width - image.Width) * Xalign); var y = Math.Round(alloc.Y + (alloc.Height - image.Height) * Yalign); ctx.Save(); ctx.DrawImage(this, IsParentDisabled() ? image.WithAlpha(0.4) : image, x, y); ctx.Restore(); } } return(true); }
static TestStatusIcon() { try { Running = Xwt.Drawing.Image.FromResource("unit-running-16.png"); Failure = Xwt.Drawing.Image.FromResource("unit-failed-16.png"); None = Xwt.Drawing.Image.FromResource("unit-not-yet-run-16.png"); NotRun = Xwt.Drawing.Image.FromResource("unit-skipped-16.png"); Success = Xwt.Drawing.Image.FromResource("unit-success-16.png"); SuccessAndFailure = Xwt.Drawing.Image.FromResource("unit-mixed-results-16.png"); Loading = Xwt.Drawing.Image.FromResource("unit-loading-16.png"); Inconclusive = Xwt.Drawing.Image.FromResource("unit-inconclusive-16.png"); OldFailure = Failure.WithAlpha(0.4); OldSuccess = Success.WithAlpha(0.4); OldSuccessAndFailure = SuccessAndFailure.WithAlpha(0.4); OldInconclusive = Inconclusive.WithAlpha(0.4); } catch (Exception e) { LoggingService.LogError("Error while loading icons.", e); } }
static TestStatusIcon () { try { Running = Xwt.Drawing.Image.FromResource ("unit-running-light-16.png"); Failure = Xwt.Drawing.Image.FromResource ("unit-failed-light-16.png"); None = Xwt.Drawing.Image.FromResource ("unit-not-yet-run-light-16.png"); NotRun = Xwt.Drawing.Image.FromResource ("unit-skipped-light-16.png"); Success = Xwt.Drawing.Image.FromResource ("unit-success-light-16.png"); SuccessAndFailure = Xwt.Drawing.Image.FromResource ("unit-mixed-results-light-16.png"); Loading = Xwt.Drawing.Image.FromResource ("unit-loading-light-16.png"); Inconclusive = Xwt.Drawing.Image.FromResource ("unit-inconclusive-light-16.png"); OldFailure = Failure.WithAlpha (0.4); OldSuccess = Success.WithAlpha (0.4); OldSuccessAndFailure = SuccessAndFailure.WithAlpha (0.4); OldInconclusive = Inconclusive.WithAlpha (0.4); } catch (Exception e) { LoggingService.LogError ("Error while loading icons.", e); } }
public void SetAlertMode(int seconds) { astep = 0; alertEnd = DateTime.Now.AddSeconds(seconds); if (animation != 0) { GLib.Source.Remove(animation); } animation = GLib.Timeout.Add(60, new GLib.TimeoutHandler(AnimateIcon)); if (images == null) { images = new Xwt.Drawing.Image [10]; for (int n = 0; n < 10; n++) { images [n] = icon.WithAlpha(((double)(9 - n)) / 10.0); } } }
void DrawTab(Context ctx, DockNotebookTab tab, Gdk.Rectangle allocation, Gdk.Rectangle tabBounds, bool highlight, bool active, bool dragging, Pango.Layout la) { // This logic is stupid to have here, should be in the caller! if (dragging) { tabBounds.X = (int)(tabBounds.X + (dragX - tabBounds.X) * dragXProgress); tabBounds.X = Clamp(tabBounds.X, tabStartX, tabEndX - tabBounds.Width); } double rightPadding = (active ? TabActivePadding.Right : TabPadding.Right) - (LeanWidth / 2); rightPadding = (rightPadding * Math.Min(1.0, Math.Max(0.5, (tabBounds.Width - 30) / 70.0))); double leftPadding = (active ? TabActivePadding.Left : TabPadding.Left) - (LeanWidth / 2); leftPadding = (leftPadding * Math.Min(1.0, Math.Max(0.5, (tabBounds.Width - 30) / 70.0))); double bottomPadding = active ? TabActivePadding.Bottom : TabPadding.Bottom; DrawTabBackground(this, ctx, allocation, tabBounds.Width, tabBounds.X, active); ctx.LineWidth = 1; ctx.NewPath(); // Render Close Button (do this first so we can tell how much text to render) var closeButtonAlloation = new Cairo.Rectangle(tabBounds.Right - rightPadding - (tabCloseImage.Width / 2) - CloseButtonMarginRight, tabBounds.Height - bottomPadding - tabCloseImage.Height - CloseButtonMarginBottom, tabCloseImage.Width, tabCloseImage.Height); tab.CloseButtonActiveArea = closeButtonAlloation.Inflate(2, 2); bool closeButtonHovered = tracker.Hovered && tab.CloseButtonActiveArea.Contains(tracker.MousePosition); bool tabHovered = tracker.Hovered && tab.Allocation.Contains(tracker.MousePosition); bool drawCloseButton = active || tabHovered; if (!closeButtonHovered && tab.DirtyStrength > 0.5) { ctx.DrawImage(this, tabDirtyImage, closeButtonAlloation.X, closeButtonAlloation.Y); drawCloseButton = false; } if (drawCloseButton) { ctx.DrawImage(this, tabCloseImage.WithAlpha((closeButtonHovered ? 1.0 : 0.5) * tab.Opacity), closeButtonAlloation.X, closeButtonAlloation.Y); } // Render Text double tw = tabBounds.Width - (leftPadding + rightPadding); if (drawCloseButton || tab.DirtyStrength > 0.5) { tw -= closeButtonAlloation.Width / 2; } double tx = tabBounds.X + leftPadding; var baseline = la.GetLine(0).Layout.GetPixelBaseline(); double ty = tabBounds.Height - bottomPadding - baseline; ctx.MoveTo(tx, ty); if (!MonoDevelop.Core.Platform.IsMac && !MonoDevelop.Core.Platform.IsWindows) { // This is a work around for a linux specific problem. // A bug in the proprietary ATI driver caused TAB text not to draw. // If that bug get's fixed remove this HACK asap. la.Ellipsize = Pango.EllipsizeMode.End; la.Width = (int)(tw * Pango.Scale.PangoScale); ctx.SetSourceColor((tab.Notify ? Styles.TabBarNotifyTextColor : (active ? Styles.TabBarActiveTextColor : Styles.TabBarInactiveTextColor)).ToCairoColor()); Pango.CairoHelper.ShowLayout(ctx, la.GetLine(0).Layout); } else { // ellipses are for space wasting ..., we cant afford that using (var lg = new LinearGradient(tx + tw - 10, 0, tx + tw, 0)) { var color = (tab.Notify ? Styles.TabBarNotifyTextColor : (active ? Styles.TabBarActiveTextColor : Styles.TabBarInactiveTextColor)).ToCairoColor(); color = color.MultiplyAlpha(tab.Opacity); lg.AddColorStop(0, color); color.A = 0; lg.AddColorStop(1, color); ctx.SetSource(lg); Pango.CairoHelper.ShowLayout(ctx, la.GetLine(0).Layout); } } la.Dispose(); }
void RenderIcon(Cairo.Context context, Xwt.Drawing.Image surface, double opacity) { context.DrawImage(this, surface.WithAlpha(opacity), Allocation.X + (Allocation.Width - surface.Width) / 2, Allocation.Y + (Allocation.Height - surface.Height) / 2); }