Quantcast

working HybridScrollFrame same functionality as before

Petr Grabovoy [05-26-16 - 19:04]
working HybridScrollFrame same functionality as before
Filename
VarrenDevTool.lua
VarrenDevTool.xml
diff --git a/VarrenDevTool.lua b/VarrenDevTool.lua
index 2a99b91..2523550 100644
--- a/VarrenDevTool.lua
+++ b/VarrenDevTool.lua
@@ -8,22 +8,24 @@ local _G = _G

 local MyMod_MEATATABLE_KEY = "$mt "

-function MyMod_OnLoad()
+function MyMod_OnLoad(self)
     print("load")
     MyMod_LoadData(_G)
     local prevButton;
-
+    self.scrollFrame.update = MyModScrollBar_Update;
+    --[[
     for i = 1, (700 / 16) do
-        local frame = CreateFrame("FRAME", "MyModEntry" .. i, MyMod, "MyModEntryTemplate");
+        local frame = CreateFrame("FRAME", "MyModEntry" .. i, self, "MyModEntryTemplate");
         if i == 1 then
             frame:SetPoint("TOPLEFT", MyModScrollBar, "TOPLEFT", 8, 0)
         else
             frame:SetPoint("TOPLEFT", MyModChildFrames[i - 1], "BOTTOMLEFT")
         end

-        MyModChildFrames[i] = frame
-    end
+        --MyModChildFrames[i] = frame
+    end--]]

+    HybridScrollFrame_CreateButtons(self.scrollFrame, "MyModEntryTemplate", 0, -2);
     MyModScrollBar:Show()
 end

@@ -79,12 +81,16 @@ function MyMod_Table_Length(T)
 end

 function MyModScrollBar_Update()
+    print("ok: " )
+    local lineplusoffset ; -- an index into our data calculated from the scroll offset
+
+    local scrollFrame = MyModScrollBar
+    local buttons = scrollFrame.buttons;
+    local offset = HybridScrollFrame_GetOffset(scrollFrame)

-    local lineplusoffset; -- an index into our data calculated from the scroll offset
-    FauxScrollFrame_Update(MyModScrollBar, MyModData.count, 5, 16);
-    for k, v in pairs(MyModChildFrames) do
+    for k, v in pairs(buttons) do

-        lineplusoffset = k + FauxScrollFrame_GetOffset(MyModScrollBar);
+        lineplusoffset = k + offset;
         if lineplusoffset <= MyModData.count then
             MyMod_UpdateListItem(v, MyModData[lineplusoffset])

@@ -93,6 +99,10 @@ function MyModScrollBar_Update()
             v:Hide();
         end
     end
+
+    HybridScrollFrame_Update(scrollFrame, MyModData.count * 16, 700);
+
+    print("UPDATED")
 end

 function MyMod_Back_Button_Click()
diff --git a/VarrenDevTool.xml b/VarrenDevTool.xml
index 5f6b6c2..c559848 100644
--- a/VarrenDevTool.xml
+++ b/VarrenDevTool.xml
@@ -27,9 +27,8 @@
             <Anchor point="CENTER"/>
         </Anchors>
         <Scripts>
-            <OnLoad>
-                MyMod_OnLoad()
-            </OnLoad>
+            <OnLoad function="MyMod_OnLoad"/>
+            <OnShow function="MyModScrollBar_Update"/>
         </Scripts>
         <Backdrop bgFile="Interface\DialogFrame\UI-DialogBox-Background"
                   tile="true">
@@ -44,7 +43,7 @@
             </EdgeSize>
         </Backdrop>
         <Frames>
-            <ScrollFrame name="MyModScrollBar" inherits="FauxScrollFrameTemplate" hidden="true">
+            <ScrollFrame name="MyModScrollBar" inherits="HybridScrollFrameTemplate" parentKey="scrollFrame" >
                 <Anchors>
                     <Anchor point="TOPLEFT">
                         <Offset>
@@ -57,14 +56,15 @@
                         </Offset>
                     </Anchor>
                 </Anchors>
-                <Scripts>
-                    <OnVerticalScroll>
-                        FauxScrollFrame_OnVerticalScroll(self, offset, 16, MyModScrollBar_Update);
-                    </OnVerticalScroll>
-                    <OnShow>
-                        MyModScrollBar_Update()
-                    </OnShow>
-                </Scripts>
+
+                <Frames>
+                    <Slider name="$parentScrollBar" inherits="HybridScrollBarTemplate">
+                        <Anchors>
+                            <Anchor point="TOPLEFT" relativePoint="TOPRIGHT" x="3" y="-12"/>
+                            <Anchor point="BOTTOMLEFT" relativePoint="BOTTOMRIGHT" x="3" y="13"/>
+                        </Anchors>
+                    </Slider>
+                </Frames>
             </ScrollFrame>
             <Button text="Undo" name="MyMod_Back_Button" inherits="UIPanelButtonTemplate">
                 <Size>