HybridScrollFrame row background colour
3 Attachment(s)
This is my first addon. I have a list which is basically Meorawr's HybridScrollFrame demo, just with a different dataset.
https://gist.github.com/Meorawr/7d67...7a875db3fd1d7a If an item's itemName exists within a given itemArray, I want to colour the row background, which I've done like this: Code:
button.Text:SetText(item.text or ""); I'd be very grateful if someone could point me in the right direction. |
Off the top of my head it sounds like the problem is happening because you are coloring the display rather than marking the value as being colorable. As in there may be 1000 items but only 20 bars. You only want to color the bar that contains the item you want to have colored and uncolor the other bars.
If you set the default bar color it should ensure that each bar is uncolored until you ask it to color it based on the item. |
Code:
button.Text:SetText(item.text or ""); You could apply the texture to the Background element of the HybridScrollDemoListItemTemplate section of the XML (this defines what each row will look like). You can then just set the colour etc. (highligh or default) of the background texture when you set the text. |
Thanks, that's exactly what I needed! :)
I've made some further changes, and it's all working - but not on player login. The rows don't get coloured until you do an interface reload, but printing the values inside the functions to the console returns the right data. I've tried registering PLAYER_LOGIN and adding it to the events with a self:RefreshLayout() but that doesn't change anything. Is the code taking too long to run? Have I missed something obvious? I don't really know how to fix this and further improve/optimise the code. I've put my addon files in here: https://pastebin.com/u/Ylaana/1/tPZRxwDK Any advice is greatly appreciated (and I hope someone will find the addon useful :p). |
I can't see anything usable in the Pastebin page but then again, I'm not a Pastebin expert.
|
Sorry, I've set them all to public now so you should be able to see them. Here are the direct links:
https://pastebin.com/aK9HQctf https://pastebin.com/ajc1CuYC https://pastebin.com/nEf8Cy12 https://pastebin.com/KaXaKLH8 |
I don't have many Glyphs except a couple on a Druid (Cheetah etc.) so I'm not sure how to get one to display as active or in confict.
You do your RefreshLayout OnShow and and on receiving a GET_ITEM_INFO_RECEIVED event. Frames by default are shown (your xml frame does not have the hidden attribute) so you won't get an initial refresh unless you receive an event or manually hide/show the frame (the OnShow script is set after the frame is created ie. already shown). |
2 Attachment(s)
To determine which glyphs are active, the addon looks in your spellbook for any spells that have glyphs attached to them and puts those in a table. It then compares that table to the names of the glyphs in GlyphData.lua for your classID, and if a match is found the row background should be green. It also checks the conflicts to see if the active glyphs are in an exclusive set, so the other glyphs in that set are coloured red. I've attached an image of what it looks like on a paladin with the Valorous Charger's Bridle glyph on Divine Steed, which is exclusive with the Vengeful/Vigilant/Golden Charger's Bridles and Glyph of the Trusted Steed, and on a priest with the Shackle Undead and Voidling glyphs, with the latter being exclusive with the Glyphs of the Lightspawn and Sha.
Because Marks (of the Cheetah/Dolphin/etc.) are made by scribes but aren't technically glyphs (i.e. not trackable through the spellbook), I included them in the list but they won't get coloured in the same way as 'regular' glyphs, as Blizzard don't currently have an API call in place that would allow me to obtain that information from the barber shop interface. I don't know if I should just hide them altogether because a lot of people I spoke to about these Marks weren't even aware they existed, so I suppose just making them visible in this way could be helpful. Manually hiding/showing the frame by clicking the close button and then using /gl to show it again doesn't update the row colours, nor does triggering RefreshLayout on the PLAYER_LOGIN or PLAYER_ENTERING_WORLD events. I even tried on SPELLS_CHANGED and learning a new glyph to see if that would do anything, but again with no luck. I do want to make it so that learning a new glyph automatically refreshes the row colours, but that probably means re-scanning the spellbook to see what's changed and running through the active/exclusions lists again. |
Code:
local glyphedSpells = GetGlyphedSpells() This table needs to be refreshed when new data is available (the chached spell information won't have been flushed during a /reload which is why it is already available so early "second time in"). Something like adding glyphedSpells = GetGlyphedSpells() to your cache_writer OnEvent script (might refresh too often but gives you an idea of what's going on). Code:
button.GlyphActive:SetTexture("Interface\\Tooltips\\UI-Tooltip-Background") Code:
Code:
button.GlyphActive:SetGradientAlpha("HORIZONTAL", 0.15, 0.6, 0.15, 1, 0.15, 0.6, 0.15, 0) |
Hi, I remembered I had posted here asking for advice and just wanted to thank you for your help getting me started. I've been working on this addon for the past two years and gradually improving it, and I have a lot more planned! It's called GlyphList and it's available on CurseForge, I've just updated it for 10.2 :)
|
All times are GMT -6. The time now is 05:37 PM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI