Quantcast

Added main table last column delimiter

Petr Grabovoy [06-12-16 - 12:31]
Added main table last column delimiter
Filename
ViragDevTool.lua
ViragDevTool.xml
diff --git a/ViragDevTool.lua b/ViragDevTool.lua
index 66f6cfd..6d4db9c 100644
--- a/ViragDevTool.lua
+++ b/ViragDevTool.lua
@@ -120,6 +120,7 @@ ViragDevTool = {

         -- stores history of recent calls to /vdt
         MAX_HISTORY_SIZE = 50,
+        collResizerPosition = 450,
         history = {
             -- examples
             "find LFR",
@@ -552,7 +553,7 @@ function ViragDevTool:UpdateMainTableUIOptimized()
     self.waitFrame.updateNeeded = true
 end

-function ViragDevTool:ScrollBar_AddChildren(scrollFrame,strTemplate)
+function ViragDevTool:ScrollBar_AddChildren(scrollFrame, strTemplate)
     if scrollFrame.ScrollBarHeight == nil or scrollFrame:GetHeight() > scrollFrame.ScrollBarHeight then
         scrollFrame.ScrollBarHeight = scrollFrame:GetHeight()

@@ -562,6 +563,26 @@ function ViragDevTool:ScrollBar_AddChildren(scrollFrame,strTemplate)
     end
 end

+function ViragDevTool:DragResizeColumn(dragFrame, ignoreMousePosition)
+    local parentFrame = dragFrame:GetParent()
+    local offset = parentFrame:GetLeft()
+    local pos = dragFrame:GetLeft() - offset
+    local minX = 300
+    local maxX = parentFrame:GetWidth() - 150
+    if pos < minX then pos = minX end
+    if pos > maxX then pos = maxX end
+
+    if not ignoreMousePosition then
+        local x, y = GetCursorPosition()
+        x = x / parentFrame:GetEffectiveScale()
+        if x <= (minX + offset) then pos = minX end
+        if x >= (maxX + offset) then pos = maxX  end
+    end
+
+    dragFrame:ClearAllPoints()
+    self.settings.collResizerPosition = pos
+    dragFrame:SetPoint("TOPLEFT", parentFrame, "TOPLEFT", pos, -30)
+end

 function ViragDevTool:UIUpdateMainTableButton(node, info, id)
     local nameButton = node.nameButton;
@@ -742,7 +763,7 @@ end
 function ViragDevTool:SetMainTableButtonScript(button, info)
     --todo add left click = copy to chat
     local valueType = type(info.value)
-    local leftClickFn = function () end
+    local leftClickFn = function() end

     if valueType == "table" then
         leftClickFn = function(this, button, down)
@@ -760,14 +781,11 @@ function ViragDevTool:SetMainTableButtonScript(button, info)

     button:SetScript("OnMouseUp", function(this, button, down)
         if button == "RightButton" then
-            ViragDevTool:print( info.name .. " - "..tostring(info.value) )
+            ViragDevTool:print(info.name .. " - " .. tostring(info.value))
         else
             leftClickFn(this, button, down)
         end
-
     end)
-
-
 end

 function ViragDevTool:TryCallFunction(info)
@@ -952,7 +970,6 @@ end
 -----------------------------------------------------------------------------------------------
 -- EVENTS
 -----------------------------------------------------------------------------------------------
-
 function ViragDevTool:GetListenerFrame()
     if (self.listenerFrame == nil) then
         self.listenerFrame = CreateFrame("Frame", "WaitFrame", UIParent);
@@ -1294,6 +1311,8 @@ function ViragDevTool:SetupForSettings(s)
     -- setup events part 2 set scripts on frame to listen registered events
     self:SetMonitorEventScript()

+    self.wndRef.columnResizer:SetPoint("TOPLEFT", self.wndRef, "TOPLEFT", s.collResizerPosition, -30)
+
     return s
 end

diff --git a/ViragDevTool.xml b/ViragDevTool.xml
index b52bebe..76c4fee 100644
--- a/ViragDevTool.xml
+++ b/ViragDevTool.xml
@@ -62,6 +62,8 @@
             </Layer>
         </Layers>
     </Frame>
+
+
     <Slider name="ViragDevToolMinimalHybridScrollBarTemplate" parentKey="scrollBar" virtual="true">
         <Size x="22" y="0"/>

@@ -88,7 +90,8 @@
         <Scripts>
             <OnValueChanged function="HybridScrollFrame_OnValueChanged"/>
         </Scripts>
-        <ThumbTexture name="$parentThumbTexture" inherits="HybridScrollBarButton" file="Interface\Buttons\UI-ScrollBar-Knob" parentKey="thumbTexture">
+        <ThumbTexture name="$parentThumbTexture" inherits="HybridScrollBarButton"
+                      file="Interface\Buttons\UI-ScrollBar-Knob" parentKey="thumbTexture">
             <Size x="18" y="24"/>
             <TexCoords left="0.20" right="0.80" top="0.125" bottom="0.875"/>
         </ThumbTexture>
@@ -185,10 +188,9 @@
     </EditBox>


-
     <!--COLUMN FOR MAIN HybridScrollFrameTemplate -->

-    <Button text="Test" name="ViragDevToolColumnTemplate"  virtual="true">
+    <Button text="Test" name="ViragDevToolColumnTemplate" virtual="true">
         <Size x="50"/>
         <Anchors>
             <Anchor point="TOP"/>
@@ -267,26 +269,28 @@
             <Button text="table" name="$parentCountColumn" inherits="ViragDevToolColumnTemplate"
                     parentKey="rowNumberButton">
                 <Anchors>
-                    <Anchor point="LEFT" x = "5"/>
+                    <Anchor point="LEFT" x="5"/>
                 </Anchors>
             </Button>
             <!--COLUMN 2-->
             <Button text="123456" name="$parentTypeColumn" inherits="ViragDevToolColumnTemplate" parentKey="typeButton">
                 <Anchors>
                     <Anchor point="LEFT" relativeTo="$parentCountColumn" relativePoint="RIGHT"/>
+
                 </Anchors>
             </Button>
+
             <!--COLUMN 3-->
-            <Button text="Test Text" name="$parentNameColumn" inherits="ViragDevToolColumnTemplate" parentKey="nameButton">
-                <Size x="400"/>
+            <Button text="Test Text" name="$parentNameColumn" inherits="ViragDevToolColumnTemplate"
+                    parentKey="nameButton">
                 <Anchors>
+                    <Anchor point="RIGHT" relativeTo="ViragDevToolFrameColumnResizeButton" relativePoint="LEFT" x ="10"/>
                     <Anchor point="LEFT" relativeTo="$parentTypeColumn" relativePoint="RIGHT"/>
                 </Anchors>
             </Button>
             <!--COLUMN 4-->
             <Button text="Test Text" name="$parentValueColumn" inherits="ViragDevToolColumnTemplate"
                     parentKey="valueButton">
-                <Size x="700"/>
                 <Anchors>
                     <Anchor point="RIGHT"/>
                     <Anchor point="LEFT" relativeTo="$parentNameColumn" relativePoint="RIGHT"/>
@@ -308,17 +312,22 @@
         </Anchors>
         <Scripts>
             <OnLoad>
+
                 ViragDevTool:OnLoad(self)
                 self:SetUserPlaced(true)
-                self:SetMinResize(600, 100);
+                self:SetMinResize(600, 200);
                 self:SetMaxResize(1200, 900);
                 self:RegisterForDrag("LeftButton");
             </OnLoad>
+
+
             <OnDragStart>
-                self:StopMovingOrSizing();
                 self:StartMoving()
+               -- self.columnResizer:
             </OnDragStart>
+
             <OnDragStop>
+                self.isMoving = false
                 self:StopMovingOrSizing();
             </OnDragStop>
         </Scripts>
@@ -334,7 +343,6 @@
                         self:RegisterForDrag("LeftButton");
                     </OnLoad>
                     <OnDragStart>
-                        self:GetParent():StopMovingOrSizing();
                         self:SetButtonState("PUSHED", true);
                         self:GetHighlightTexture():Hide();
                         self:GetParent():StartSizing("BOTTOMRIGHT");
@@ -344,6 +352,7 @@
                         self:GetHighlightTexture():Show();
                         self:GetParent():StopMovingOrSizing();
                         self:GetParent().scrollFrame.scrollChild:SetWidth(self:GetParent():GetWidth() - 10 - 22) -- 10 is padding  22 is slider size
+                        ViragDevTool:DragResizeColumn(self:GetParent().columnResizer, true)
                         ViragDevTool:UpdateMainTableUI()
                         ViragDevTool:UpdateSideBarUI()
                     </OnDragStop>
@@ -476,6 +485,54 @@
                 </Anchors>
             </ScrollFrame>

+            <!--TABLE ROW RESIZER BUTTON -->
+            <Button name="$parentColumnResizeButton" parentKey="columnResizer" >
+                <Size x="15" y="15"/>
+
+                <Scripts>
+                    <OnLoad>
+                       -- self:SetFrameStrata("HIGH")
+                        self:RegisterForDrag("LeftButton");
+                    </OnLoad>
+                    <OnEnter>
+                        self:SetMovable(true)
+                        self:EnableMouse(true)
+                    </OnEnter>
+                    <OnDragStart>
+                        self.isMoving = true
+                        self:StartMoving()
+                    </OnDragStart>
+                    <OnUpdate>
+                        self:GetPoint()
+                        if  self.isMoving then
+                            ViragDevTool:DragResizeColumn(self)
+                        end
+                    </OnUpdate>
+
+                    <OnDragStop>
+                        self:StopMovingOrSizing();
+                        ViragDevTool:DragResizeColumn(self)
+                        self.isMoving = false
+                    </OnDragStop>
+
+                </Scripts>
+                <NormalTexture >
+                    <Anchors>
+                        <Anchor point="TOPRIGHT" x = "-6" />
+                        <Anchor point="BOTTOMLEFT" x = "6" y = "5"/>
+                    </Anchors>
+                    <Color r="0" g="0.5" b="0" a="0.7"/>
+                </NormalTexture>
+
+                <HighlightTexture>
+                    <Anchors>
+                        <Anchor point="TOPRIGHT"/>
+                        <Anchor point="BOTTOMLEFT"/>
+                    </Anchors>
+                    <Color r="0.1" g="0.5" b="0" a="0.7"/>
+                </HighlightTexture>
+            </Button>
+
             <!--*********************************************************************************************************
                                                         SIDEBAR
             *********************************************************************************************************-->
@@ -493,7 +550,6 @@
                         self:RegisterForDrag("LeftButton");
                     </OnLoad>
                     <OnDragStart>
-                        self:GetParent():StopMovingOrSizing();
                         self:GetParent():StartMoving()
                     </OnDragStart>
                     <OnDragStop>