
Originally Posted by
yereverluvinuncleber
Is there a way of altering the opacity of the overlays so they are not quite so intrusive overall?
The applied Hover(Color)-effect is currently using a "hard-wired" Alpha-Value of 0.25...
Well - for the next release of RC6/RC6Widgets -
I've adjusted cwAlphaImg to use the so far unused W.Tag (general purpose Variant-Prop) for that -
pre-initialized to 0.25 (but now changeable on the outside, to what you prefer).
If you don't want to wait for that next release, you can "hang-in" the cwAlphaImg-Class manually -
as a Project-Private Class from this identical code (out of RC6Widgets):
Code:
Option Explicit 'a very simple Image-Widget, which expects an ImageKey - and ensures ClickThrough-behaviour
Private WithEvents W As cWidgetBase
Private Sub Class_Initialize()
Set W = Cairo.WidgetBase
W.BackColor = -1 'we don't use any BackColor here
W.HoverColor = vbRed 'show no Hover-Effect by default
W.ImplementsHitTest = True 'when at False, no HitTest-Event would be triggered
W.ImplementsWheelMessages = True
W.Tag = 0.25 'we use this common cWidgetBase-Property here, to allow influencing the HoverColor-Alpha
End Sub
Public Property Get Widget() As cWidgetBase: Set Widget = W: End Property
Public Property Get Widgets() As cWidgets: Set Widgets = W.Widgets: End Property
Private Sub W_HitTest(ByVal x As Single, ByVal y As Single, HitResultHit As Boolean) 'ensure ClickThrough-behaviour in ImagePixels which are "fully Alpha"
HitResultHit = False
Dim Srf As cCairoSurface, Pxl() As Long
If Cairo.ImageList.Exists(W.ImageKey) And W.HoverColor <> -1 Then Set Srf = Cairo.ImageList(W.ImageKey) Else Exit Sub
If Not Srf.BindToArrayLong(Pxl) Or W.Width = 0 Or W.Height = 0 Then Exit Sub
HitResultHit = Pxl(x * Srf.Width / W.Width, y * Srf.Height / W.Height) 'only when the Pixel==0==FullAlpha, will HitResultHit be returned False
Srf.ReleaseArrayLong Pxl
End Sub
Private Sub W_MouseEnter(ByVal MouseLeaveWidget As RC6.cWidgetBase)
W.Parent.Refresh 'if we want to support widget-refreshs "on-hover", we have to trigger a Re-Paint
End Sub
Private Sub W_MouseLeave(ByVal MouseEnterWidget As RC6.cWidgetBase)
W.Parent.Refresh 'same here (trigger dynamic re-rendering, when the hover-state changes)
End Sub
Private Sub W_Paint(CC As RC6.cCairoContext, ByVal xAbs As Single, ByVal yAbs As Single, ByVal dx_Aligned As Single, ByVal dy_Aligned As Single, UserObj As Object)
Dim Srf As cCairoSurface ', x As Single, y As Single
If Cairo.ImageList.Exists(W.ImageKey) Then Set Srf = Cairo.ImageList(W.ImageKey) Else Exit Sub
CC.RenderSurfaceContent Srf, 0, 0, W.Width, W.Height, , W.Alpha 'render the current W.ImageKey-Surface (as loaded priorily into the ImageList)
If W.MouseOver And W.HoverColor <> -1 Then 'render a colored, slightly blurred copy of the Srf with 25% Alpha (in case of being hovered)
CC.RenderSurfaceContent Srf.GaussianBlur(0.1, , True, W.HoverColor), 0, 0, W.Width, W.Height, , W.Tag
End If
End Sub
Note, that you will then have to adapt the (I think it was 2) instancing-expressions from:
New_W("cwAlphaImg")
to
New cwAlphaImg
inside the cfAlpha Form-Class...
Olaf