From cad4bd501a14a915b0304d29103d37788f253587 Mon Sep 17 00:00:00 2001 From: Dmytro Ovcharov Date: Thu, 20 Jul 2017 17:20:54 +0300 Subject: Fixes BXC #53775 --- .../MonoDevelop.Components/EventBoxTooltip.cs | 71 ++++++++++++++++++++-- 1 file changed, 65 insertions(+), 6 deletions(-) (limited to 'main/src') diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/EventBoxTooltip.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/EventBoxTooltip.cs index ad48d0c426..670fb6d708 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/EventBoxTooltip.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/EventBoxTooltip.cs @@ -29,9 +29,11 @@ using Gtk; using System; using MonoDevelop.Components.AtkCocoaHelper; using MonoDevelop.Ide.Tasks; +using MonoDevelop.Ide; +using Gdk; namespace MonoDevelop.Components -{ +{ public class EventBoxTooltip : IDisposable { EventBox eventBox; @@ -43,24 +45,48 @@ namespace MonoDevelop.Components get { return eventBox.Accessible; } - } - + } + /// /// The EventBox should have Visible set to false otherwise the tooltip pop window /// will have the wrong location. /// + + ImageView image; + Pixbuf normalPixbuf; + Pixbuf activePixbuf; + public EventBoxTooltip (EventBox eventBox) { this.eventBox = eventBox; + eventBox.CanFocus = true; eventBox.EnterNotifyEvent += HandleEnterNotifyEvent; eventBox.LeaveNotifyEvent += HandleLeaveNotifyEvent; eventBox.FocusInEvent += HandleFocusInEvent; eventBox.FocusOutEvent += HandleFocusOutEvent; + image = eventBox.Child as ImageView; + + if (image != null) { + normalPixbuf = image.Image.ToPixbuf (); + } + normalPixbuf = image.Image.ToPixbuf (); + activePixbuf = normalPixbuf.ColorShiftPixbuf (); + + eventBox.FocusGrabbed += (sender, e) => { + if (image != null) + image.Image = activePixbuf.ToXwtImage (); + }; + + eventBox.Focused += (o, args) => { + if (image != null) + image.Image = normalPixbuf.ToXwtImage (); + }; + Position = PopupPosition.TopLeft; - // Accessibility: Disguise this eventbox as a label + // Accessibility: Disguise this eventbox as a label eventBox.Accessible.SetRole (AtkCocoa.Roles.AXStaticText); eventBox.CanFocus = true; } @@ -89,7 +115,7 @@ namespace MonoDevelop.Components [GLib.ConnectBefore] void HandleFocusInEvent (object sender, EventArgs e) { - mouseOver = true; + mouseOver = true; ShowTooltip (); } @@ -146,6 +172,39 @@ namespace MonoDevelop.Components public TaskSeverity? Severity { get; set; } public PopupPosition Position { get; set; } - } + } +#region Extension method for Pixbuf + internal static class PixbufExtension + { + public static unsafe Pixbuf ColorShiftPixbuf (this Pixbuf src, byte shift = 120) + { + var dest = new Gdk.Pixbuf (src.Colorspace, src.HasAlpha, src.BitsPerSample, src.Width, src.Height); + + byte* src_pixels_orig = (byte*)src.Pixels; + byte* dest_pixels_orig = (byte*)dest.Pixels; + + for (int i = 0; i < src.Height; i++) { + byte* src_pixels = src_pixels_orig + i * src.Rowstride; + byte* dest_pixels = dest_pixels_orig + i * dest.Rowstride; + + for (int j = 0; j < src.Width; j++) { + *(dest_pixels++) = PixelClamp (*(src_pixels++) + shift); + *(dest_pixels++) = PixelClamp (*(src_pixels++) + shift); + *(dest_pixels++) = PixelClamp (*(src_pixels++) + shift); + + if (src.HasAlpha) { + *(dest_pixels++) = *(src_pixels++); + } + } + } + return dest; + } + + static byte PixelClamp (int val) + { + return (byte)System.Math.Max (0, System.Math.Min (255, val)); + } + } +#endregion } -- cgit v1.2.3 From 6d1f24ea82a5f1ad9be4e811f2ac362f0f9cb703 Mon Sep 17 00:00:00 2001 From: Dmytro Ovcharov Date: Thu, 20 Jul 2017 17:28:40 +0300 Subject: BXC #53775 --- .../src/core/MonoDevelop.Ide/MonoDevelop.Components/EventBoxTooltip.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'main/src') diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/EventBoxTooltip.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/EventBoxTooltip.cs index 670fb6d708..daba07577a 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/EventBoxTooltip.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/EventBoxTooltip.cs @@ -70,9 +70,8 @@ namespace MonoDevelop.Components if (image != null) { normalPixbuf = image.Image.ToPixbuf (); + activePixbuf = normalPixbuf.ColorShiftPixbuf (); } - normalPixbuf = image.Image.ToPixbuf (); - activePixbuf = normalPixbuf.ColorShiftPixbuf (); eventBox.FocusGrabbed += (sender, e) => { if (image != null) -- cgit v1.2.3 From d3616cbb6548316f6f1f6122c12694e067763389 Mon Sep 17 00:00:00 2001 From: Dmytro Ovcharov Date: Fri, 21 Jul 2017 08:55:50 +0300 Subject: BXC #53775 --- .../MonoDevelop.Components/EventBoxTooltip.cs | 47 +++------------------- .../MonoDevelop.Ide/ImageService.cs | 36 +++++++++++++++++ 2 files changed, 42 insertions(+), 41 deletions(-) (limited to 'main/src') diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/EventBoxTooltip.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/EventBoxTooltip.cs index daba07577a..3d6e6223f9 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/EventBoxTooltip.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/EventBoxTooltip.cs @@ -37,8 +37,11 @@ namespace MonoDevelop.Components public class EventBoxTooltip : IDisposable { EventBox eventBox; - string tip; - TooltipPopoverWindow tooltipWindow; + TooltipPopoverWindow tooltipWindow; + ImageView image; + Pixbuf normalPixbuf; + Pixbuf activePixbuf; + string tip; bool mouseOver; public Atk.Object Accessible { @@ -51,11 +54,6 @@ namespace MonoDevelop.Components /// The EventBox should have Visible set to false otherwise the tooltip pop window /// will have the wrong location. /// - - ImageView image; - Pixbuf normalPixbuf; - Pixbuf activePixbuf; - public EventBoxTooltip (EventBox eventBox) { this.eventBox = eventBox; @@ -171,39 +169,6 @@ namespace MonoDevelop.Components public TaskSeverity? Severity { get; set; } public PopupPosition Position { get; set; } - } -#region Extension method for Pixbuf - internal static class PixbufExtension - { - public static unsafe Pixbuf ColorShiftPixbuf (this Pixbuf src, byte shift = 120) - { - var dest = new Gdk.Pixbuf (src.Colorspace, src.HasAlpha, src.BitsPerSample, src.Width, src.Height); - - byte* src_pixels_orig = (byte*)src.Pixels; - byte* dest_pixels_orig = (byte*)dest.Pixels; - - for (int i = 0; i < src.Height; i++) { - byte* src_pixels = src_pixels_orig + i * src.Rowstride; - byte* dest_pixels = dest_pixels_orig + i * dest.Rowstride; - - for (int j = 0; j < src.Width; j++) { - *(dest_pixels++) = PixelClamp (*(src_pixels++) + shift); - *(dest_pixels++) = PixelClamp (*(src_pixels++) + shift); - *(dest_pixels++) = PixelClamp (*(src_pixels++) + shift); - - if (src.HasAlpha) { - *(dest_pixels++) = *(src_pixels++); - } - } - } - return dest; - } - - static byte PixelClamp (int val) - { - return (byte)System.Math.Max (0, System.Math.Min (255, val)); - } - } -#endregion + } } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/ImageService.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/ImageService.cs index e277d65b7c..2b7a3da97f 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/ImageService.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/ImageService.cs @@ -39,6 +39,7 @@ using System.Threading.Tasks; using System.Net; using Xwt.Backends; using Gtk; +using Gdk; namespace MonoDevelop.Ide { @@ -837,6 +838,41 @@ namespace MonoDevelop.Ide image.Pixbuf = gravatar.Image.ToPixbuf (); }; } + + public static Pixbuf ColorShiftPixbuf (this Pixbuf src, byte shift = 120) + { + var dest = new Gdk.Pixbuf (src.Colorspace, src.HasAlpha, src.BitsPerSample, src.Width, src.Height); + + unsafe + { + + byte* src_pixels_orig = (byte*)src.Pixels; + byte* dest_pixels_orig = (byte*)dest.Pixels; + + for (int i = 0; i < src.Height; i++) { + byte* src_pixels = src_pixels_orig + i * src.Rowstride; + byte* dest_pixels = dest_pixels_orig + i * dest.Rowstride; + + for (int j = 0; j < src.Width; j++) { + *(dest_pixels++) = PixelClamp (*(src_pixels++) + shift); + *(dest_pixels++) = PixelClamp (*(src_pixels++) + shift); + *(dest_pixels++) = PixelClamp (*(src_pixels++) + shift); + + if (src.HasAlpha) { + *(dest_pixels++) = *(src_pixels++); + } + } + } + } + return dest; + } + + static byte PixelClamp (int val) + { + return (byte)System.Math.Max (0, System.Math.Min (255, val)); + } + + } class CustomImageLoader : Xwt.Drawing.IImageLoader -- cgit v1.2.3