Circuit Editor: Disable hover styling

35 views
Skip to first unread message

vorp

unread,
Feb 26, 2015, 3:16:14 PM2/26/15
to authoring-to...@googlegroups.com
I'm interested in changing the hover behavior in Circuit Editor.
Specifically, I've now got a disabled state (thanks for the help on that) and would like to remove virtually all effects of mouse hovering over a node.
It currently draws an outline, which I'm able to remove by modifying the DragSource brush.
However, this doesn't work ideally as the mouse hover will still effect the look by changing its style.

I've searched the code for MouseHover and MouseEnter behaviors but nothing's coming up that helps with what I'm after.
Can anyone point me in the right direction for limiting or removing mouse hover style changes?

Thanks!
-Len
 

Ron2

unread,
Feb 26, 2015, 5:52:17 PM2/26/15
to authoring-to...@googlegroups.com
Hi Len,

Good question. This will probably come up with another team that we've been working with, too.

I'm assuming you still want to let the user select the disabled node. So I see a couple of options.

#1: You could override D2dGraphAdapter's GetStyle(object) method, below. The 'object' will be your circuit element. You could call the base method and if the result is "Hot" (which means the user has moused over the element), then test if that circuit element is disabled and if so, return the DiagramDrawingStyle.Normal enum value.

        /// <summary>
        /// Gets the current rendering style for an item</summary>
        /// <param name="item">Rendered item</param>
        /// <returns>Rendering style set by SetStyle, Normal if no override is set</returns>
        public virtual DiagramDrawingStyle GetStyle(object item)
        {
            // Give the renderer an opportunity to override our style selection.
            DiagramDrawingStyle result = m_renderer.GetCustomStyle(item);
            if (result != DiagramDrawingStyle.None)
                return result;

            result = DiagramDrawingStyle.Normal;

#2 As you can see in the top of the above method, your renderer (D2dCircuitRenderer) has a GetCustomStyle() method. It's possible to set the style on a per-element basis. See the D2dGraphRenderer's SetCustomStyle(), ClearCustomStyle() and GetCustomStyle() methods.

Hope that helps!

--Ron

vorp

unread,
Mar 27, 2015, 3:12:51 PM3/27/15
to authoring-to...@googlegroups.com
Thanks for the help!
I think I've replicated your #1 option and I don't think #2 will help.
The problem is, once a node is selected (or has a non-Normal style for some reason) the hover still influences that style since it will set it back to Normal when the mouse is hovering.
What I'm after is having absolutely no influence of hovering on selected, non-selected, or disabled nodes.
I can create the effect I'm after by not setting m_hoverSubObject in d2dControl_MouseMove but that isn't really possible without altering ATF.
Is it possible to do what I'm after?
Thanks.
-Len

Ron2

unread,
Mar 27, 2015, 7:49:30 PM3/27/15
to authoring-to...@googlegroups.com
Hi Len,

Sorry my first attempt didn't work out. It's hard for me to test this without duplicating the whole feature.

If you don't ever need m_hoverSubObject to be set (like if you don't need circuit groups, then I don't think you need m_hoverSubObject) then you can modify your Pick() method to not set the SubItem in the DiagramHitRecord. Pick() gets called near the top of d2dControl_MouseMove. Then m_hoverSubObject will always be null.

Or, could you modify your D2dGraphRenderer's SetCustomStyle, to ignore setting the style for objects that you don't want to have a hover effect on? Currently, D2dGraphRenderer.SetCustomStyle() is not virtual, but you can make it virtual and I'll do the same for the GitHub version. ClearCustomStyle() should be virtual, too. These two methods get called by d2dControl_MouseMove.

As a last alternative, we could rename d2dControl_MouseMove to be MouseMove and make it protected virtual. m_hoverSubObject and m_hoverObject could be renamed HoverSubObject and HoverObject and made into protected properties. That way you could have total control over them.

--Ron
Reply all
Reply to author
Forward
0 new messages