Quantcast
Fade frame in/out on mouseover. - WoWInterface
Thread Tools Display Modes
10-13-17, 04:00 PM   #1
Lesteryoung
A Cliff Giant
Join Date: Aug 2015
Posts: 76
Fade frame in/out on mouseover.

Hi, could someone write an addon that fades the alpha of the following frame to 0 when not mousing over the mentioned frame.

The idea being that I don't need to see this bit unless I'm mousing over to use it.

Here it is: https://i.imgur.com/LNZlwfl.jpg

Thanks.
  Reply With Quote
10-13-17, 07:35 PM   #2
Ammako
A Frostmaul Preserver
AddOn Author - Click to view addons
Join Date: Jun 2016
Posts: 256
Use /fstack in chat and then mouse over it to get the exact frame name.

I don't have game time right now so I can't easily write something and test it on my own right now, since starter accounts can't form groups. Unless someone were willing to help with that.

You'd probably want to do something like this:

Lua Code:
  1. local frame = CreateFrame("frame")
  2. frame:RegisterEvent("ADDON_LOADED")
  3. frame:SetScript("OnEvent", function(self, event, ...)
  4.     if select(1, ...) == "Blizzard_CompactRaidFrames" then
  5.         frameName:SetAlpha(0)
  6.         frameName:HookScript("OnEnter", function() frameName:SetAlpha(1) end)
  7.         frameName:HookScript("OnLeave", function() frameName:SetAlpha(0) end)
  8.     end
  9. end)

(In this case frameName doesn't exist; I can't check the right frame name right now and I don't want to make any guesses, so you'll have to get the name of the frame with /fstack and replace frameName with it in the code.)

Also this is untested but this should be the general idea of what you might want to do. If it doesn't work it may just need a few tweaks.
  Reply With Quote
10-13-17, 08:18 PM   #3
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,759
Just a note that
Lua Code:
  1. frame:SetScript("OnEvent", function(self, event, ...)
  2.      if select(1, ...) == "Blizzard_CompactRaidFrames" then
can be written as
Lua Code:
  1. frame:SetScript("OnEvent", function(self, event, addon)
  2.      if addon == "Blizzard_CompactRaidFrames" then

Same result, without an extra function call.
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
10-13-17, 09:45 PM   #4
Ammako
A Frostmaul Preserver
AddOn Author - Click to view addons
Join Date: Jun 2016
Posts: 256
I knew select() wasn't efficient but I was lazy and I knew someone else would show up with the better code.
  Reply With Quote
10-13-17, 10:11 PM   #5
Lesteryoung
A Cliff Giant
Join Date: Aug 2015
Posts: 76
The frames that need to be hidden are:

CompactRaidFrameManagerToggleButton
CompactRaidFrameManagerBg
CompactRaidFrameManagerBorderBottomRight
CompactRaidFrameManagerBorderRight
CompactRaidFrameManagerBorderTopRight

I can find and hide these frames myself no problem, and I did already experiment with that before making the thread, however, I'd like to be able to still use the raid frame manager on mouseover, which I need help with.
  Reply With Quote
10-13-17, 11:02 PM   #6
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,276
If you hide() the fame you won't be able to detect OnEnter/OnLeave events. That is why you need to use SetAlpha(0)/SetAlpha(1) insead of hide()/show()
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
  Reply With Quote
10-13-17, 11:21 PM   #7
Lesteryoung
A Cliff Giant
Join Date: Aug 2015
Posts: 76
I understand, that's why I made the thread, because I can find and simply hide a frame myself, but unsure about setting alpha to fade in/out on mouseover.

Ammako's code assumes there is one frame I'm trying to hide, but it's a cluster of different frames, I can't simple put in CompactRaidFrameManager because that hides all of the raid frames and not just the unit on the side.
  Reply With Quote
10-14-17, 01:18 PM   #8
Ammako
A Frostmaul Preserver
AddOn Author - Click to view addons
Join Date: Jun 2016
Posts: 256
Alright. If you do CompactRaidFrameContainer:SetParent(UIParent) this should prevent raid frames from inheriting CompactRaidFrameManager Alpha.

Only problem is, whenever you mouse over any buttons on the raid frame manager, it'll act as if you moused away from CompactRaidFrameManager, because the child element now has mouse focus even though your cursor is technically still within CompactRaidFrameManager. It will keep flickering in and out and you can't really see the buttons you're wanting to click on.

My idea was to go through all child frames of CompactRaidFrameManager and applying the hookscript to everything, but that seems overkill and didn't even work anyway (though maybe I was doing it wrong, but I'm having to run through Ragefire Chasm on LFD every time I make a change and need to test it which really isn't the most convenient thing in the world.)

I'll see if I can get PTR running without having to download the whole 40GB of it from scratch, then I can probably just keep listing groups on group finder there which would be much easier.

I have another idea in mind though that's probably better, so I'll see if that works.

Also, it looks like Blizzard_RaidUI is the addon being loaded when you join a group and raid frames are loaded, not Blizzard_CompactRaidFrames.
Another thing is that if you /reload while raid frames are already loaded, the code may not work anymore unless you can get your addon to load before Blizzard_RaidUI. It might be better to make the addon load on demand whenever Blizzard_RaidUI is loaded though, and get rid of the ADDON_LOADED event handler stuff altogether. If that's possible, at least; I've never messed with that.
  Reply With Quote
10-14-17, 01:36 PM   #9
Lesteryoung
A Cliff Giant
Join Date: Aug 2015
Posts: 76
Woah! This has proven to be much more complicated than I had imagined.

I have no qualms about calling off this request, so continue to explore only if you're interested.

What about fading the alpha of only one frame, the "CompactRaidFrameManagerToggleButton", I can hide the rest of the graphics on the raid frame thingy since they're just aesthetic.
  Reply With Quote
10-14-17, 02:39 PM   #10
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,276
Code:
CompactRaidFrameManager:HookScript("OnEnter", function(self) if self:IsMouseOver() then self:SetAlpha(1) end end)
CompactRaidFrameManager:HookScript("OnLeave", function(self) if not self:IsMouseOver() then self:SetAlpha(0) end end)
CompactRaidFrameManager:HookScript("OnShow", function(self) if not self:IsMouseOver() then self:SetAlpha(0) else self:SetAlpha(1) end end)
CompactRaidFrameManagerToggleButton:HookScript("OnLeave", function(self) if not CompactRaidFrameManager:IsMouseOver() then CompactRaidFrameManager:SetAlpha(0) end end)
If you want to test outside a raid add:
Code:
CompactRaidFrameManager:HookScript("OnHide", function(self) self:Show() end)
CompactRaidFrameManager:Show()
Edit: So it doesn't fade/show while mousing over internal objects.
Edit2: The last edit made the ToggleButton OnEnter redundant.
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 10-14-17 at 03:16 PM.
  Reply With Quote
10-14-17, 02:54 PM   #11
Ammako
A Frostmaul Preserver
AddOn Author - Click to view addons
Join Date: Jun 2016
Posts: 256
My other idea I had worked perfectly, actually.

lua Code:
  1. local isOpen = false
  2.  
  3. local function setAlphaZero()
  4.     if not isOpen then
  5.         CompactRaidFrameManager:SetAlpha(0)
  6.     end
  7. end
  8.  
  9. CompactRaidFrameContainer:SetParent(UIParent)
  10. CompactRaidFrameManager:SetAlpha(0)
  11.  
  12. CompactRaidFrameManager:HookScript("OnEnter", function()
  13.     CompactRaidFrameManager:SetAlpha(1)
  14. end)
  15. CompactRaidFrameManager:HookScript("OnLeave", setAlphaZero)
  16.  
  17. CompactRaidFrameManagerToggleButton:HookScript("OnEnter", function()
  18.     CompactRaidFrameManager:SetAlpha(1)
  19. end)
  20. CompactRaidFrameManagerToggleButton:HookScript("OnLeave", setAlphaZero)
  21.  
  22. CompactRaidFrameManagerToggleButton:HookScript("OnClick", function()
  23.     if isOpen then
  24.         isOpen = false
  25.     else
  26.         isOpen = true
  27.     end
  28. end)

.toc
Code:
## Interface: 70300
## Title: Test
## LoadOnDemand: 1
## LoadWith: Blizzard_RaidUI

Test.lua
The drawer gets hidden when you join a group, and when you mouse over it reappears. When you click the arrow to open the drawer, it registers that the menu is open and keeps Alpha to 1 until the drawer is closed, at which point the code is allowed to set Alpha to 0 again.

Edit: Totally ninjaed by Fizzle with the better solution, though.
  Reply With Quote
10-14-17, 03:51 PM   #12
Lesteryoung
A Cliff Giant
Join Date: Aug 2015
Posts: 76
Thank you Ammako, your code is pretty much exactly what I was looking for.

Fizzle's code doesn't work, it hides everything instead of just the bar on the side.

Thank you to the both of you.

You should consider uploading this code as an addon to curse or here, I'm sure other people get annoyed by the raid bar on the side.
  Reply With Quote
10-14-17, 04:28 PM   #13
Ammako
A Frostmaul Preserver
AddOn Author - Click to view addons
Join Date: Jun 2016
Posts: 256
I'm going to go with a much cleaner, less error-prone solution, actually.

lua Code:
  1. local function setAlphaZero()
  2.     if not CompactRaidFrameManagerDisplayFrame:IsVisible() then
  3.         CompactRaidFrameManager:SetAlpha(0)
  4.     end
  5. end
  6.  
  7. CompactRaidFrameContainer:SetParent(UIParent)
  8. CompactRaidFrameManager:SetAlpha(0)
  9.  
  10. CompactRaidFrameManager:HookScript("OnEnter", function() CompactRaidFrameManager:SetAlpha(1) end)
  11. CompactRaidFrameManager:HookScript("OnLeave", setAlphaZero)
  12.  
  13. CompactRaidFrameManagerToggleButton:HookScript("OnEnter", function() CompactRaidFrameManager:SetAlpha(1) end)
  14. CompactRaidFrameManagerToggleButton:HookScript("OnLeave", setAlphaZero)

I tried replacing the hooks on ToggleButton with an extra CompactRaidFrameManager:IsMouseOver() check, like what Fizzle did, but it gave wonky results where the side bar remains visible when you close the raid frame manager drawer, until you manually move your mouse back over and away again to "refresh" it, so I'll probably keep it like that.
  Reply With Quote
10-14-17, 05:16 PM   #14
Lesteryoung
A Cliff Giant
Join Date: Aug 2015
Posts: 76
Thanks again.
  Reply With Quote
10-14-17, 05:27 PM   #15
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,276
Mine just didn't re-parent the container which is why it looked funny. Glad you found a solution that works.
Code:
CompactRaidFrameManager:HookScript("OnEnter", function(self) if self:IsMouseOver() then self:SetAlpha(1) end end)
CompactRaidFrameManager:HookScript("OnLeave", function(self) if not self:IsMouseOver() then self:SetAlpha(0) end end)
CompactRaidFrameManager:HookScript("OnShow", function(self) if not self:IsMouseOver() then self:SetAlpha(0) else self:SetAlpha(1) end end)
CompactRaidFrameManagerToggleButton:HookScript("OnEnter", function(self) if CompactRaidFrameManager:IsMouseOver() then CompactRaidFrameManager:SetAlpha(1) end end)
CompactRaidFrameManagerToggleButton:HookScript("OnLeave", function(self) if not CompactRaidFrameManager:IsMouseOver() then CompactRaidFrameManager:SetAlpha(0) end end)
CompactRaidFrameContainer:SetParent(UIParent)
CompactRaidFrameManager:SetAlpha(0) -- if in raid when logging in
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 10-14-17 at 06:20 PM.
  Reply With Quote
10-14-17, 07:00 PM   #16
Ammako
A Frostmaul Preserver
AddOn Author - Click to view addons
Join Date: Jun 2016
Posts: 256
Also I guess LoadOnDemand isn't even needed, and removing it lets everything continue to work when you /reload.
I should probably have tried it that way before assuming raid frames weren't loaded until you explicitly joined a party/group.

@Fizzlemizz: I think there is value in keeping the panel visible at all times while it is open but I guess that might depend on user preference.
  Reply With Quote
10-14-17, 07:08 PM   #17
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,276
The change in the container position let's you know it's open but as you say, that's personal preference, it wouldn't be too hard to remedy to hide only when "closed".

Then again, I don't use the Blizzard raid frames sooo .
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
  Reply With Quote
10-14-17, 07:21 PM   #18
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,276
Couldn't help myself, the show always when open option
Code:
CompactRaidFrameManager:HookScript("OnEnter", function(self) if self:IsMouseOver() and self.collapsed then self:SetAlpha(1) end end)
CompactRaidFrameManager:HookScript("OnLeave", function(self) if not self:IsMouseOver() and self.collapsed then self:SetAlpha(0) end end)
CompactRaidFrameManagerToggleButton:HookScript("OnEnter", function(self) local f = self:GetParent() if f:IsMouseOver() and f.collapsed then f:SetAlpha(1) end end)
CompactRaidFrameManagerToggleButton:HookScript("OnLeave", function(self) local f = self:GetParent() if not f:IsMouseOver() and f.collapsed then f:SetAlpha(0) end end)
CompactRaidFrameContainer:SetParent(UIParent)
CompactRaidFrameManager:SetAlpha(0) -- if in raid when logging in
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 10-14-17 at 08:55 PM.
  Reply With Quote
10-14-17, 09:17 PM   #19
Lesteryoung
A Cliff Giant
Join Date: Aug 2015
Posts: 76
Well, unfortunately, after using the code for a few hours, I have issues to report.

1) The code is giving off lots of taint, my taint log is like 2mb after 30min of play.

2) The code causes the raid frames to be click through, so if a frame is over say, the chat log, it clicks into the chat instead of clicking on the frame.
  Reply With Quote
10-14-17, 10:37 PM   #20
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,276
Then maybe something a little sneakier. I didn't get any taintLog activity or errors for this but only did 1 world boss with it:
Lua Code:
  1. local texture1ist1 = { CompactRaidFrameManager:GetRegions() }
  2. local texture1ist2 = select(1, CompactRaidFrameManagerToggleButton:GetRegions())
  3. local function SetShown(self)
  4.     if self:IsMouseOver() and self.collapsed then
  5.         texture1ist2:SetAlpha(1)
  6.         for _,v in pairs(texture1ist1) do
  7.             v:SetAlpha(1)
  8.         end
  9.     elseif not self:IsMouseOver() and self.collapsed then
  10.         texture1ist2:SetAlpha(0)
  11.         for _,v in pairs(texture1ist1) do
  12.             v:SetAlpha(0)
  13.         end
  14.     end
  15. end
  16. CompactRaidFrameManager:HookScript("OnEnter", SetShown)
  17. CompactRaidFrameManager:HookScript("OnLeave", SetShown)
  18. CompactRaidFrameManagerToggleButton:HookScript("OnEnter", function(self) SetShown(self:GetParent()) end)
  19. CompactRaidFrameManagerToggleButton:HookScript("OnLeave", function(self) SetShown(self:GetParent()) end)
  20. SetShown(CompactRaidFrameManager)
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 10-14-17 at 11:36 PM.
  Reply With Quote

WoWInterface » AddOns, Compilations, Macros » AddOn Search/Requests » Fade frame in/out on mouseover.

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off