View Single Post
Unread 02-12-13, 09:25 AM   #12
gmarco
A Flamescale Wyrmkin
 
gmarco's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2009
Posts: 100
I am doing good progress

The code finally is displaying something :-)

Lua Code:
  1. local NUM_BUTTONS = 8
  2. local BUTTON_HEIGHT = 20
  3. local BUTTON_WIDTH = 96
  4.  
  5. local list = {"aaaa","bbbbb","cccccc","ddddddd","eeeeee","ffffff","gggggg","hhhhh"}
  6. local buttons = {}
  7.  
  8. local function update(self)
  9.     local numItems = #list
  10.     print ("DEBUG: nr. items " .. numItems)
  11.     FauxScrollFrame_Update(self, numItems, NUM_BUTTONS, BUTTON_HEIGHT)
  12.     local offset = FauxScrollFrame_GetOffset(self)
  13.     for line = 1, NUM_BUTTONS do
  14.         local lineplusoffset = line + offset
  15.         local button = buttons[line]
  16.         if lineplusoffset > numItems then
  17.             button:Hide()
  18.         else
  19.             button:SetText(list[lineplusoffset])
  20.             button:Show()
  21.         end
  22.     end
  23. end
  24.  
  25. local scrollFrame = CreateFrame("ScrollFrame", "MyFirstNotReallyScrollFrame", UIParent, "FauxScrollFrameTemplate")
  26. scrollFrame:SetWidth(BUTTON_WIDTH)
  27. scrollFrame:SetHeight(BUTTON_HEIGHT*6)
  28. scrollFrame:SetPoint("CENTER",UIParent)
  29. scrollFrame:EnableMouse(true)
  30. scrollFrame:SetMovable(true)
  31. scrollFrame:RegisterForDrag("LeftButton")
  32. scrollFrame:SetScript("OnDragStart", function(self) self:StartMoving() end)
  33. scrollFrame:SetScript("OnDragStop", function(self) self:StopMovingOrSizing() end)
  34. scrollFrame:Show()
  35. scrollFrame:SetClampedToScreen(true)
  36. scrollFrame:SetScript("OnVerticalScroll", function(self, offset)
  37.     FauxScrollFrame_OnVerticalScroll(self, offset, BUTTON_HEIGHT, update)
  38. end)
  39.  
  40. for i = 1, NUM_BUTTONS do
  41.     local button = CreateFrame("Button", nil, scrollFrame:GetParent())
  42.     if i == 1 then
  43.         button:SetPoint("TOP", scrollFrame)
  44.     else
  45.         button:SetPoint("TOP", buttons[i - 1], "BOTTOM")
  46.     end
  47.     button:SetNormalFontObject("GameFontNormal")
  48.     button:SetSize(BUTTON_WIDTH, BUTTON_HEIGHT)
  49.     button:SetText(list[i])
  50.     buttons[i] = button
  51. end
  52.  
  53.  
  54.  
  55. -- enabling the last line will make the slidebar disappears.
  56. -- print ("DEBUG: Force updating")
  57. -- update(scrollFrame)

Now I get the scrollframe with sliders but it is wrong. You can check the picture to see...
It doesn't cover the out of scrollframe part nor it scrolls using the slide.

Other thing: If I enable the manual update of the frame (last line) the sliders will disappears (!??!) :-)

Thanks again for any inputs/clues/tips :-)
Attached Thumbnails
Click image for larger version

Name:	img-001.png
Views:	200
Size:	49.1 KB
ID:	7563  
__________________
This is Unix-Land. In quiet nights, you can hear the Windows machines reboot.
gmarco is online now   Reply With Quote