Thread Tools Display Modes
02-13-13, 03:11 PM   #21
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
I wrote DiscoKugel 2.
http://www.wowinterface.com/forums/s...ad.php?t=45817

Man this is awesome.
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW)

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)
  Reply With Quote
02-13-13, 06:42 PM   #22
gmarco
An Onyxian Warder
 
gmarco's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2009
Posts: 362
Zork your code is really cool but surely too much complex for a newbie programmer like me :-)

Slowly I have finished my alpha version of the addons, but I am plenty of questions. So I try to ask for finding more help.

I upload a picture which represent a ganklist. I'd like to click on a name, this set the text in the text input and then I can press del to delete it from the list or add a new name to it.

Now I'd like to ask.

1) in the frame I have created I have the button text that are "centered" ... I am trying to let them left justify but none of the methods I used till now seems to work.

2) Is possible to let the buttons to react to the OnClick event ? Something like:
button:SetScript("OnClick", function() ... bla bla

3) Is possible to have the scrollframe "bordered" like the input box below ?

4) How can I make a orizontal bar for divide the zones of a frame ?


The code is now:

Lua Code:
  1. -- Configuration Panel -------------------------------------------------------------------------------------
  2.  
  3. local options = CreateFrame("Frame", ADDON.."Options", InterfaceOptionsFramePanelContainer)
  4. options.name = GetAddOnMetadata(ADDON, "Title") or ADDON
  5. InterfaceOptions_AddCategory(options)
  6.  
  7. local title = options:CreateFontString("$parentTitle", "ARTWORK", "GameFontNormalLarge")
  8. title:SetPoint("TOPLEFT", 16, -16)
  9. title:SetText(options.name)
  10. options.title = title
  11.  
  12. local subtext = options:CreateFontString("$parentSubText", "ARTWORK", "GameFontHighlightSmall")
  13. subtext:SetPoint("TOPLEFT", title, "BOTTOMLEFT", 0, -8)
  14. subtext:SetPoint("RIGHT", -32, 0)
  15. subtext:SetHeight(32)
  16. subtext:SetJustifyH("LEFT")
  17. subtext:SetJustifyV("TOP")
  18. subtext:SetText(GetAddOnMetadata(ADDON, "Notes"))
  19. options.subtext = subtext
  20.  
  21. local enable = CreateFrame("CheckButton", "$parentEnable", options, "InterfaceOptionsCheckButtonTemplate")
  22. enable:SetPoint("TOPLEFT", subtext, "BOTTOMLEFT", -2, -8)
  23. enable.Text:SetText(ENABLE)
  24. enable.tooltipText = "Enable monitoring"
  25. enable:SetChecked(REMGANK_ENABLE);
  26. enable:SetScript("OnClick", function(self)
  27.    
  28.     if enable:GetChecked() then
  29.         REMGANK_ENABLE = 1
  30.         print(string_format("%s: is enabled", prgname))
  31.         frame_cleu:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
  32.     else
  33.         REMGANK_ENABLE = 0
  34.         print(string_format("%s: is disabled",prgname))
  35.         frame_cleu:UnregisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
  36.     end
  37.    
  38. end)
  39.  
  40.  -- Add button
  41. local RemGank_Add_Player_Button = CreateFrame("button","RemGank_Add_Player_Button", options, "UIPanelButtonTemplate")
  42. RemGank_Add_Player_Button:SetHeight(25)
  43. RemGank_Add_Player_Button:SetWidth(50)
  44. RemGank_Add_Player_Button:SetPoint("BOTTOMRIGHT", options, "BOTTOMRIGHT", -12, 12)
  45. RemGank_Add_Player_Button:SetText("Add")
  46. RemGank_Add_Player_Button:SetScript("OnClick",
  47.     function()
  48.  
  49.     end)
  50.    
  51. -- Del Button
  52. local RemGank_Del_Player_Button = CreateFrame("button","RemGank_Del_Player_Button", options, "UIPanelButtonTemplate")
  53. RemGank_Del_Player_Button:SetHeight(25)
  54. RemGank_Del_Player_Button:SetWidth(50)
  55. RemGank_Del_Player_Button:SetPoint("BOTTOMRIGHT", options, "BOTTOMRIGHT", -72, 12)
  56. RemGank_Del_Player_Button:SetText("Del")
  57. RemGank_Del_Player_Button:SetScript("OnClick",  
  58.     function()  
  59.    
  60.     end)
  61.  
  62. -- Text Input
  63. local RemGank_Input_eb2 = CreateFrame("EditBox","eb2",options,"InputBoxTemplate")
  64. RemGank_Input_eb2:SetMaxLetters(15)
  65. RemGank_Input_eb2:SetFont(framefontn,framefonth)
  66. RemGank_Input_eb2:SetAutoFocus(disable)
  67. RemGank_Input_eb2:SetSize(192, 24)
  68. RemGank_Input_eb2:SetPoint("BOTTOMRIGHT", options, "BOTTOMRIGHT", -132, 12)
  69.  
  70. local scrollFrame = CreateFrame("ScrollFrame", "MyFirstNotReallyScrollFrame", options, "FauxScrollFrameTemplate")
  71. scrollFrame:SetWidth(BUTTON_WIDTH * 3)
  72. scrollFrame:SetHeight(NUM_BUTTONS * BUTTON_HEIGHT)
  73. scrollFrame:SetPoint("BOTTOMRIGHT", options, "BOTTOMRIGHT", -38, 64)
  74. scrollFrame:EnableMouse(true)
  75. scrollFrame:SetScript("OnDragStart", function(self) self:StartMoving() end)
  76. scrollFrame:SetScript("OnDragStop", function(self) self:StopMovingOrSizing() end)
  77. scrollFrame:Show()
  78.  
  79. scrollFrame:SetScript("OnVerticalScroll", function(self, offset)
  80.     FauxScrollFrame_OnVerticalScroll(self, offset, BUTTON_HEIGHT, RemGank_ListFrame_Update(self))
  81. end)
  82.  
  83. for i = 1, NUM_BUTTONS do
  84.     local button = CreateFrame("Button", nil, scrollFrame:GetParent())
  85.     if i == 1 then
  86.         button:SetPoint("TOP", scrollFrame)
  87.     else
  88.         button:SetPoint("TOP", buttons[i - 1], "BOTTOM")
  89.         -- button:SetPoint("TOP", buttons[i - 1],  "LEFT", 0, 0)
  90.     end
  91.     button:SetNormalFontObject("GameFontNormal")
  92.     button:SetSize(BUTTON_WIDTH, BUTTON_HEIGHT)
  93.     button:SetText(RemGankLS[i])
  94.     button:SetScript("OnClick",  function()
  95.         RemGank_Input_eb2:SetText(RemGankLS[i])
  96.     end)
  97.     buttons[i] = button
  98. end
  99.  
  100. -- Updating ?
  101. print ("DEBUG: Force updating")
  102. RemGank_ListFrame_Update(scrollFrame)
  103.  
  104. function options.refresh()
  105.     enable:SetChecked(REMGANK_ENABLE)
  106.     RemGank_ListFrame_Update(scrollFrame)
  107. end
  108.  
  109. if LibStub and LibStub("LibAboutPanel", true) then
  110.     options.about = LibStub("LibAboutPanel").new(options.name, ADDON)
  111. end

Thanks again to all for your attention
Attached Thumbnails
Click image for larger version

Name:	remganklist.png
Views:	878
Size:	78.8 KB
ID:	7566  
__________________
This is Unix-Land. In quiet nights, you can hear the Windows machines reboot.
  Reply With Quote
02-14-13, 05:41 PM   #23
gmarco
An Onyxian Warder
 
gmarco's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2009
Posts: 362
Hi all,

continuing with experiment I have fixed some of the previous iussues.

2) Is possible to let the buttons to react to the OnClick event ? Something like:
button:SetScript("OnClick", function() ... bla bla
Now it works. I let it working removing:

Lua Code:
  1. scrollFrame:EnableMouse(true)
  2. scrollFrame:Show()

from the scrollframe definition.


1) in the frame I have created I have the button text that are "centered" ... I am trying to let them left justify but none of the methods I used till now seems to work.
I have used a different approach here... I used different templates for buttons so I justified them leaving the text centered. Later I'll try to understand how to make a left justified button text :-)


3) and 4) are still under investigation :-) but now not are so important now :-)


But now I have a different problem.
The scrollframe seems to loose the first (or the last) position.

I'll explain better with a picture.



The same iussue happens for the last item. Is it intended that the slider works in this way (it seems to me inverse) ??


Thanks very much for attention to everyone.

EDIT: I attach also a picture and the code of the (almost) finished addon.

Attached Files
File Type: zip Remgank-v2013021501.zip (5.7 KB, 508 views)
__________________
This is Unix-Land. In quiet nights, you can hear the Windows machines reboot.
  Reply With Quote
02-14-13, 09:50 PM   #24
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by gmarco View Post
Later I'll try to understand how to make a left justified button text :-)
Code:
button:GetFontString():SetJustifyH("LEFT")
However, depending on the template used, you may need to adjust the font string's points as well. For example, if the font string is anchored by its CENTER point to the button's CENTER point, left-aligning the text will make it start in the center of the button, so you'd need to do something like this:

Code:
local fontstring = button:GetFontString()
fontstring:ClearAllPoints()
fontstring:SetPoint("LEFT", button, 8, 0)
fontstring:SetPoint("RIGHT", button, -8, 0)
fontstring:SetJustifyH("LEFT")
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
02-14-13, 10:08 PM   #25
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
Not if the fontstring has a width set, iirc.
__________________
"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
02-15-13, 01:58 AM   #26
gmarco
An Onyxian Warder
 
gmarco's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2009
Posts: 362
Thanks Phanx and Seerah for answers.

I have checked the Phanx code and it works nicely (the 2nd bigger one) but I think I'll leave the button as they are now, because it doesn't work with all buttons templates or with no template at all.
Btw finally I understood how it works. As usual it was a little bit more complicated then I thought :-)

Ok. In the meantime I have solved also the question nr.3 I asked:

3) Is possible to have the scrollframe "bordered" like the input box below ?
I checked the rtest by Zork (thanks) and I have discovered the Templates world :-)

Now I am investigating why the scrollframe works nicely in the test addon I make following the Lombra suggestion/code posted at the beginning of this thread, while it have the problem I have pointed out with the picture when I build the scrollist array from my data.

If I used something like:

Lua Code:
  1. RemGankLS = { "qui", "quo", "qua", etc etc }

It works as expected and I don't have the iussue shown in the picture.

But I have a table in this way saved:

Lua Code:
  1. RemGankDB = {
  2.     ["qui"] = {
  3.         ["name"] = "qui",
  4.         ["date"] = "06.01.2013 19:28:24",
  5.         ["desc"] = "generic ganker",
  6.         ["lastloc"] = "Massiccio del Kun-Lai/Presidio del Fuoco Yongqi",
  7.         ["nrkill"] = 1,
  8.     },
  9.     ["quo"] = {
  10.         ["name"] = "quo",
  11.         ["date"] = "03.02.2013 17:35:10",
  12.         ["desc"] = "generic ganker",
  13.         ["lastloc"] = "Vallata dell'Eterna Primavera/Volta di Guo-Lai",
  14.         ["nrkill"] = 1,
  15.     },
  16.     ["qua"] = {
  17.         ["name"] = "qua",
  18.         ["date"] = "09.02.2013 10:57:16",
  19.         ["desc"] = "generic ganker",
  20.         ["lastloc"] = "Valle dei Quattro Venti/Mezzocolle",
  21.         ["nrkill"] = 1,
  22.     },
  23.        
  24.       --- etc etc
  25. }

So to use a number reference to the records for the scrollframe I was not able to find a better solution of doing something like this:

Lua Code:
  1. function RemGank_DB_Dump()
  2.     RemGankLS = {}
  3.     for name in pairs(RemGankDB) do    
  4.         name = name:lower()
  5.         if RemGankDB[name]["name"] then
  6.             table.insert(RemGankLS, RemGankDB[name]["name"])
  7.         end
  8.     end
  9.     -- Sort the list alphabetically
  10.     table.sort(RemGankLS)  
  11. end

And everything works but the slider have the problem I show.

Someone have an idea on why it happens or if the problem is the dumping how to call this code :

Lua Code:
  1. function RemGank_ListFrame_Update(self)
  2.     local numItems = #RemGankLS
  3.     FauxScrollFrame_Update(self, numItems, NUM_BUTTONS, BUTTON_HEIGHT)
  4.     local offset = FauxScrollFrame_GetOffset(self)
  5.     for line = 1, NUM_BUTTONS do
  6.         local lineplusoffset = line + offset
  7.         local button = buttons[line]
  8.         if lineplusoffset <= numItems then
  9.             button:SetText(RemGankLS[lineplusoffset])
  10.             button:Show()
  11.         else
  12.             button:Hide()
  13.         end
  14.     end
  15. end
  16.  
  17. -- [...]
  18.  
  19. for i = 1, NUM_BUTTONS do
  20.     local button = CreateFrame("Button", nil, scrollFrame:GetParent(), "UIPanelButtonTemplate")
  21.     if i == 1 then
  22.         button:SetPoint("TOP", scrollFrame)
  23.     else
  24.         button:SetPoint("TOP", buttons[i - 1], "BOTTOM")
  25.     end
  26.     button:SetNormalFontObject("GameFontNormal")
  27.     button:SetSize(BUTTON_WIDTH, BUTTON_HEIGHT)
  28.     button:SetText(RemGankLS[i])
  29.     button:SetScript("OnClick", function(self)
  30.         RemGank_Input_eb2:SetText(button:GetText())
  31.         info_name:SetText(button:GetText())
  32.         info_desc:SetText(RemGankDB[button:GetText()]["desc"])
  33.         info_loc_title:SetText("Last Kill:")
  34.         info_date:SetText(RemGankDB[button:GetText()]["date"])
  35.         info_loc:SetText(RemGankDB[button:GetText()]["lastloc"])
  36.         info_kills_title:SetText("Tot.Kills:")
  37.         info_kills:SetText(RemGankDB[button:GetText()]["nrkill"])
  38.     end)
  39.     buttons[i] = button
  40. end

without the need of dumping the first table RemGankDB (referenced by name) to RemGankLS (indexed by numbers) ?

Thanks for patience and sorry again about all these questions.
__________________
This is Unix-Land. In quiet nights, you can hear the Windows machines reboot.

Last edited by gmarco : 02-15-13 at 02:10 AM.
  Reply With Quote
02-15-13, 02:57 AM   #27
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
Next to Slider, Button, ScrollFrame templates there are "Frame" template.

You are probably looking for sth like a DialogBoxTemplate.

Check:
http://www.wowinterface.com/forums/s...54&postcount=1

You will find a pretty deep list of Frame templates. Try them out. I would start with "UIPanelDialogTemplate". You can actually combine templates.

Thus you can do this:

Lua Code:
  1. local sf = CreateFrame("ScrollFrame", "MYSCROLLFRAMENAME", UIParent, "UIPanelScrollFrameTemplate, UIPanelDialogTemplate")

That works for all templates that do not counterfit each other. One template my do artwork, the other may do functional stuff etc.
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW)

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)
  Reply With Quote
03-02-13, 09:31 PM   #28
Kharthus
A Fallenroot Satyr
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 26
I'm having a similar issue where the first action after the scroll frame is shown isn't updating the offset correctly. I'll show the frame, scroll, the slider will move, but the offset will stay at zero. If I hide the frame and re-show it, the offset updates correctly.

Example:

Offset at zero (slider is at the top)
scroll down
Offset at zero
scroll down
Offset at 15
scroll up
Offset at 30
scroll up
Offset at 15 (slider is at the top)
scroll down
Offset at zero

In the middle of my list you can do this:
scroll down
Offset at 75
scroll up
Offset at 90
scroll down
Offset at 75
scroll up
Offset at 90

I copied the code from another addon I wrote and it works correctly there, but in the new addon I'm getting this very very weird behavior.

It appears the slider is following the mouse movement, but the offset is one cycle behind. Any ideas how this is happening?

Last edited by Kharthus : 03-02-13 at 10:07 PM. Reason: updated
  Reply With Quote
03-03-13, 11:40 AM   #29
Kharthus
A Fallenroot Satyr
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 26
Well I found a solution, but I still don't understand why it's doing this. Ended up doubling up the function calls in the OnVerticalScroll handler.

Lua Code:
  1. <ScrollFrame name="LivestockCritterMenuScrollFrameTemplate" inherits="FauxScrollFrameTemplate" virtual="true">
  2.         <Anchors>
  3.             <Anchor point="TOPLEFT">
  4.                 <Offset>
  5.                     <AbsDimension x="0" y="-8"/>
  6.                 </Offset>
  7.             </Anchor>
  8.             <Anchor point="BOTTOMRIGHT">
  9.                 <Offset>
  10.                     <AbsDimension x="-30" y="8"/>
  11.                 </Offset>
  12.             </Anchor>
  13.         </Anchors>
  14.         <Scripts>
  15.             <OnVerticalScroll>
  16.                 FauxScrollFrame_OnVerticalScroll(self, offset, 15, Livestock.BuildMenu("CRITTER"));
  17.                 FauxScrollFrame_OnVerticalScroll(self, offset, 15, Livestock.BuildMenu("CRITTER"));
  18.             </OnVerticalScroll>
  19.         </Scripts>
  20.     </ScrollFrame>

Lua Code:
  1. function Livestock.BuildMenu(kind) -- type is a string, either "CRITTER", "LAND", "FLYING", or "WATER"
  2.     kind = string.upper(kind)
  3.     local token = buildtable[kind].token -- buildtable contains references and variables that are specific to each type of menu, indexed by the same string as the variable type
  4.     local settings, mounts, critters = LivestockSettings.Mounts
  5.    
  6.     Livestock.RecycleTable(mountstable)
  7.     Livestock.RecycleTable(critterstable)
  8.    
  9.     if kind == "CRITTER" then
  10.         critters = 0 -- reset critters to 0 so we can start counting critters
  11.         settings = LivestockSettings.Critters
  12.         for k in orderedPairs(settings) do -- Check the list of critters, increment critters, and add the index of the critters to critterstable
  13.             critters = critters + 1
  14.             tinsert(critterstable, settings[k].index)
  15.         end
  16.        
  17.     elseif kind == "LAND" then
  18.         mounts = 0 -- reset mounts to 0 so we can start counting land mounts
  19.         for k in orderedPairs(settings) do -- Check the list of mounts, increment mounts, and add the index of the mounts to mountstable
  20.             if (settings[k].type == "land") then
  21.                 mounts = mounts + 1
  22.                 tinsert(mountstable, settings[k].index)
  23.             end
  24.         end
  25.  
  26.     elseif kind == "FLYING" then -- code is the same for flying mounts with the appropriate changes; perhaps this could be a function call?
  27.         mounts = 0
  28.         for k in orderedPairs(settings) do
  29.             if (settings[k].type == "flying") then
  30.                 mounts = mounts + 1
  31.                 tinsert(mountstable, settings[k].index)
  32.             end
  33.         end
  34.        
  35.     elseif kind == "WATER" then -- code is the same for water mounts with the appropriate changes; perhaps this could be a function call?
  36.         mounts = 0
  37.         for k in orderedPairs(settings) do
  38.             if (settings[k].type == "water") then
  39.                 mounts = mounts + 1
  40.                 tinsert(mountstable, settings[k].index)
  41.             end
  42.         end
  43.     end
  44.    
  45.     local menuframe = _G["Livestock"..token.."Menu"] or CreateFrame("Frame","Livestock"..token.."Menu", LivestockMenuFrame, "LivestockBlueFrameTemplate") -- make the background of the menu (or reference it if it already exists), naming it with the proper token and number
  46.     local scrollframe = _G["Livestock"..token.."MenuScrollFrame"] or CreateFrame("ScrollFrame", "Livestock"..token.."MenuScrollFrame", menuframe, "Livestock"..token.."MenuScrollFrameTemplate")
  47.     scrollframe:Show()
  48.  
  49.     local header
  50.     if kind == "CRITTER" then
  51.         header = "LivestockCritterMenuButton"
  52.     elseif kind == "LAND" then
  53.         header = "LivestockLandMountMenuButton"
  54.     elseif kind == "FLYING" then
  55.         header = "LivestockFlyingMountMenuButton"
  56.     elseif kind == "WATER" then
  57.         header = "LivestockWaterMountMenuButton"
  58.     end
  59.     menuframe:SetPoint("TOPLEFT", header ,"BOTTOMLEFT",0,-10) -- set the first menu to appear below the associated button
  60.  
  61.     if (mounts or critters) <= menuLength then
  62.         menuframe:SetHeight((((mounts or critters) + 2) * buttonHeight) + 21)
  63.     else
  64.         menuframe:SetHeight((menuLength + 2) * buttonHeight + 21)
  65.     end
  66.  
  67.     local endButton -- this is the number of buttons in the menu...
  68.     if (mounts or critters) <= menuLength then
  69.         endButton = (mounts or critters)
  70.     else
  71.         endButton = menuLength
  72.     end
  73.  
  74.     local buttonplusoffset; -- an index into our data calculated from the scroll offset
  75.     FauxScrollFrame_Update(scrollframe,(mounts or critters),endButton,15);
  76.     DEFAULT_CHAT_FRAME:AddMessage("We're at "..FauxScrollFrame_GetOffset(scrollframe));
  77.  
  78.     for button = 1, endButton do -- iterate over the buttons we need
  79.         local menubutton = _G["Livestock"..token.."Menu".."Button"..button] or CreateFrame("Button", "Livestock"..token.."Menu".."Button"..button, menuframe, "LivestockMenuButtonTemplate") -- create or reference the button, with the appropriate name and number
  80.         menubutton:Show()
  81.         local text = _G["Livestock"..token.."Menu".."Button"..button.."Text"] -- reference the text of the button
  82.  
  83.         buttonplusoffset = button + FauxScrollFrame_GetOffset(scrollframe);
  84.  
  85.         if buttonplusoffset <= (mounts or critters) then
  86.             local name, creatureID, _
  87.             if kind == "CRITTER" then
  88.                 _, _, _, _, _, _, _, name, _, _, creatureID = C_PetJournal.GetPetInfoByIndex(critterstable[buttonplusoffset])
  89.             elseif kind == "LAND" or kind == "FLYING" or kind == "WATER" then
  90.                 creatureID, name = GetCompanionInfo("MOUNT", mountstable[buttonplusoffset])
  91.             end -- get the ID and name of the companion for the button by mapping the position of the button in the menus(s) to the index of the companion
  92.  
  93.             if name and creatureID then
  94.                 menubutton.critterID = creatureID
  95.                 menubutton.which = "toggle"..kind
  96.                 menubutton.name = name  -- associate the info for the companion with the frame itself to be used for mousing over / clicking
  97.  
  98.                 if text then
  99.                     if text.SetText ~= nil then
  100.                         text:SetText(name)
  101.                     end
  102.                 end
  103.             end
  104.  
  105.             if name and kind == "LAND" then
  106.                 local name2 = strconcat(name, "-")
  107.                 if settings[name2] then
  108.                     name = name2
  109.                 end
  110.             end
  111.  
  112.             if name and text and settings[name].show == 1 then -- if the name isn't nil (Blizzard bug sometimes returns nil for companion names >:o) and the settings say this companion is selected then
  113.                 if text.SetTextColor ~= nil then
  114.                     text:SetTextColor(1, 1, 1) -- set the color of the text to be white
  115.                 end
  116.             elseif name and text then
  117.                 if text.SetTextColor ~= nil then
  118.                     text:SetTextColor(0.4, 0.4, 0.4) -- otherwise set the color to be grey
  119.                 end
  120.             elseif not name and debug then -- debug message if the name is nil
  121.                 local which, index
  122.                 local creatureID, creatureName, spellID
  123.                 local numPets, numOwned = C_PetJournal.GetNumPets(true)
  124.                 if mounts then
  125.                     which = "MOUNT"
  126.                     index = mountstable[buttonplusoffset]
  127.                     creatureID, creatureName, spellID = GetCompanionInfo(which, index)
  128.                     DEFAULT_CHAT_FRAME:AddMessage("Max "..kind.." "..which.." is " .. (mounts or "nil"))
  129.                 else
  130.                     which = "CRITTER"
  131.                     index = critterstable[buttonplusoffset]
  132.                     spellID, _, _, _, _, _, _, creatureName, _, _, creatureID = C_PetJournal.GetPetInfoByIndex(critterstable[buttonplusoffset])
  133.                     DEFAULT_CHAT_FRAME:AddMessage("Max "..which.." is " .. (critters or "nil"))
  134.                 end
  135.                 DEFAULT_CHAT_FRAME:AddMessage(string.format("Error for "..which.." %u at menu build, ID: %s, name: %s, spellID: %s", index, (creatureID or "nil"), (creatureName or "nil"), (spellID or "nil")))
  136.             end
  137.  
  138.             menubutton:SetHeight(buttonHeight) -- give the button a height
  139.             if button == 1 then -- parent it to the menu's TOPLEFT corner if it's the first button, else underneath the previous button
  140.                 menubutton:SetPoint("TOPLEFT", menuframe, "TOPLEFT", 20, -10)
  141.             else
  142.                 menubutton:SetPoint("TOPLEFT", _G[menuframe:GetName().."Button"..(button - 1)], "BOTTOMLEFT")
  143.             end
  144.  
  145.             if button == endButton and token then -- set all the buttons to have the same width
  146.                 for i = 1, endButton do
  147.                     if _G["Livestock"..token.."Menu".."Button"..i].SetWidth ~= nil then
  148.                         _G["Livestock"..token.."Menu".."Button"..i]:SetWidth(maxWidth)
  149.                     end
  150.                 end
  151.             end
  152.         end
  153.         menuframe:SetWidth(maxWidth + 30) -- bump up the size of the menu frame background to compensate and make sure the border and background look nice
  154.        
  155.         local check = _G["Livestock"..token.."MenuCheckButton"] or CreateFrame("Button", "Livestock"..token.."MenuCheckButton", _G["Livestock"..token.."Menu"], "LivestockMenuButtonTemplate")
  156.         check.which = "check"..kind
  157.         local uncheck = _G["Livestock"..token.."MenuUncheckButton"] or CreateFrame("Button", "Livestock"..token.."MenuUncheckButton", _G["Livestock"..token.."Menu"], "LivestockMenuButtonTemplate")
  158.         uncheck.which = "uncheck"..kind
  159.         check:SetHeight(buttonHeight)
  160.         check:SetWidth(maxWidth)
  161.         uncheck:SetHeight(buttonHeight)
  162.         uncheck:SetWidth(maxWidth) -- reference them or make them, show them, set their heights and widths, associate info with the frame, etc.
  163.         _G[check:GetName().."Text"]:SetText(L.LIVESTOCK_MENU_SELECTALL)
  164.         _G[check:GetName().."Text"]:SetTextColor(1, 1, 0)
  165.         _G[uncheck:GetName().."Text"]:SetText(L.LIVESTOCK_MENU_SELECTNONE)
  166.         _G[uncheck:GetName().."Text"]:SetTextColor(1, 1, 0) -- set their text and color (yellow to stand out)
  167.         check:SetPoint("TOPLEFT", _G["Livestock"..token.."MenuButton"..endButton], "BOTTOMLEFT")
  168.         uncheck:SetPoint("TOPLEFT", check, "BOTTOMLEFT") -- stick the Uncheck All button under the Check All button... and we're done!
  169.     end
  170. end
  Reply With Quote
03-03-13, 05:25 PM   #30
gmarco
An Onyxian Warder
 
gmarco's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2009
Posts: 362
Thanks very much for you clues.

Lua Code:
  1. -- [...]
  2. RemGank_conf_scrollFrame:SetScript("OnVerticalScroll", function(self, offset)
  3.     FauxScrollFrame_OnVerticalScroll(self, offset, BUTTON_HEIGHT, RemGank_ListFrame_Update(self))
  4.     FauxScrollFrame_OnVerticalScroll(self, offset, BUTTON_HEIGHT, RemGank_ListFrame_Update(self))
  5. end)

It works and fixes the wrong offset problem. It is not a beautifull solution, but at least it is a working one :-)

Thanks again.
__________________
This is Unix-Land. In quiet nights, you can hear the Windows machines reboot.
  Reply With Quote
03-04-13, 02:39 PM   #31
Lombra
A Molten Giant
 
Lombra's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 554
To FauxScrollFrame_OnVerticalScroll you should pass your update function, not its return value. (which is nil)
Code:
FauxScrollFrame_OnVerticalScroll(self, offset, BUTTON_HEIGHT, RemGank_ListFrame_Update(self))
becomes
Code:
FauxScrollFrame_OnVerticalScroll(self, offset, BUTTON_HEIGHT, RemGank_ListFrame_Update)
__________________
Grab your sword and fight the Horde!
  Reply With Quote
03-04-13, 08:37 PM   #32
Kharthus
A Fallenroot Satyr
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 26
In my case I was actually trying to pass a value to another function, but it looks like FauxScrollFrame doesn't like that. I changed the code to this and it's working correctly again.

Lua Code:
  1. <ScrollFrame name="LivestockCritterMenuScrollFrameTemplate" inherits="FauxScrollFrameTemplate" virtual="true">
  2.         <Anchors>
  3.             <Anchor point="TOPLEFT">
  4.                 <Offset>
  5.                     <AbsDimension x="0" y="-8"/>
  6.                 </Offset>
  7.             </Anchor>
  8.             <Anchor point="BOTTOMRIGHT">
  9.                 <Offset>
  10.                     <AbsDimension x="-30" y="8"/>
  11.                 </Offset>
  12.             </Anchor>
  13.         </Anchors>
  14.         <Scripts>
  15.             <OnVerticalScroll>
  16.                 FauxScrollFrame_OnVerticalScroll(self, offset, 15, Livestock.CritterMenuUpdate)
  17.             </OnVerticalScroll>
  18.         </Scripts>
  19.     </ScrollFrame>

Lua Code:
  1. function Livestock.CritterMenuUpdate()
  2.     Livestock.BuildMenu("CRITTER")
  3. end
  Reply With Quote
03-05-13, 12:33 AM   #33
gmarco
An Onyxian Warder
 
gmarco's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2009
Posts: 362
To FauxScrollFrame_OnVerticalScroll you should pass your update function, not its return value. (which is nil)
Thanks Lombra. It works like a charm now :-)
__________________
This is Unix-Land. In quiet nights, you can hear the Windows machines reboot.
  Reply With Quote
03-09-13, 03:50 AM   #34
Aanson
A Flamescale Wyrmkin
Join Date: Aug 2009
Posts: 124
Originally Posted by gmarco View Post
Hi all,
I prefer if possible to avoid this approach and so I am trying to find some links, addons, code to check how this can be implemented with the plain LUA api interface.

I have tried to convert the xml approach to lua code but I didn't succeded.
They there. I wrote a complete Scroll Frame example on another forum of this website that will provide you with all of the code you're after, and an explanation:

Tutorials & Other Helpful Info

I hope you find it as useful as was intended


Aanson
__________________
__________________
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Help on ScrollFrame with LUA

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