Quantcast

Adjusted dock tab dragging

failcoder [08-20-15 - 12:05]
Adjusted dock tab dragging
Filename
SVUI_!Core/system/_docklets/raidleader.lua
SVUI_!Core/system/dock.lua
SVUI_Chat/SVUI_Chat.lua
diff --git a/SVUI_!Core/system/_docklets/raidleader.lua b/SVUI_!Core/system/_docklets/raidleader.lua
index acab1b2..2e84146 100644
--- a/SVUI_!Core/system/_docklets/raidleader.lua
+++ b/SVUI_!Core/system/_docklets/raidleader.lua
@@ -73,7 +73,7 @@ end

 local function NewToolButton(name, parent, template, width, height, point, relativeto, point2, xOfs, yOfs, textDisplay)
 	local button = CreateFrame("Button", name, parent, template)
-	button:RemoveTextures()
+	button:RemoveTextures(true)
 	button:SetWidth(width)
 	button:SetHeight(height)
 	button:SetPoint(point, relativeto, point2, xOfs, yOfs)
@@ -203,7 +203,7 @@ function MOD:LoadRaidLeaderTools()
 		markerButton:SetParent(self.RaidTool.Menu)
 		markerButton:SetHeight(18)
 		markerButton:SetWidth(109)
-		markerButton:RemoveTextures()
+		markerButton:RemoveTextures(true)
 		markerButton:SetStyle("DockButton")

 		local markersText = markerButton:CreateFontString(nil,"OVERLAY")
diff --git a/SVUI_!Core/system/dock.lua b/SVUI_!Core/system/dock.lua
index d1de2d1..3bba0d8 100644
--- a/SVUI_!Core/system/dock.lua
+++ b/SVUI_!Core/system/dock.lua
@@ -195,9 +195,7 @@ local function SaveCurrentPosition(button)
 			local frame = button.FrameLink;
 			frame:ClearAllPoints();
 			frame:SetPoint("BOTTOMLEFT", button, "TOPLEFT", -3, 6);
-			if(frame.UpdateBackdrop) then
-				frame:UpdateBackdrop()
-			end
+			if(frame.UpdateBackdrop) then frame:UpdateBackdrop() end
 			local saved = MOD.private.Dimensions[name];
 			local currentWidth, currentHeight = frame:GetSize();
 			if(saved) then
@@ -267,9 +265,7 @@ local function LoadSavedDimensions(button)
 				width, height = frame:GetSize()
 			end
 			frame:SetSize(width, height)
-			if(frame.UpdateBackdrop) then
-				frame:UpdateBackdrop()
-			end
+			if(frame.UpdateBackdrop) then frame:UpdateBackdrop() end
 		end
 	end
 end
@@ -356,7 +352,7 @@ local UpdateBackdrop = function(self)
 	else
 		self.backdrop:SetAlpha(0);
 	end
-
+	self.backdrop:SetFrameLevel(0)
 	self:SetAlpha(current or 1);
 end

@@ -367,11 +363,7 @@ function MOD.SetThemedBackdrop(frame, forceTop)
 	backdrop:SetFrameStrata("BACKGROUND")
 	backdrop.forceTop = forceTop

-	if(frameLevel > 0) then
-		backdrop:SetFrameLevel(frameLevel - 1)
-	else
-		backdrop:SetFrameLevel(0)
-	end
+	backdrop:SetFrameLevel(0)

 	local underlay = backdrop:CreateTexture(nil, "BACKGROUND")
 	underlay:InsetPoints(backdrop)
@@ -888,7 +880,9 @@ end
 local DockBar_UpdateOrder = function(self)
 	--print('DockBar_UpdateOrder')
 	wipe(ORDER_TEST);
-	wipe(self.Data.Order);
+	for k,v in pairs(self.Data.Order) do
+		self.Data.Order[k] = nil;
+	end
 	local location = self.Data.Location;
 	local buttonList = self.Data.Buttons;
 	local safeIndex = 1;
@@ -908,11 +902,13 @@ end

 local DockBar_ChangeOrder = function(self, button, targetIndex)
 	--print('DockBar_ChangeOrder')
+
 	local location = self.Data.Location;
 	local targetName = button:GetName();
 	local currentIndex = button.OrderIndex;
 	wipe(ORDER_TEST);
 	wipe(ORDER_TEMP);
+
 	for i = 1, #MOD.private.Order[location] do
 		local nextName = MOD.private.Order[location][i];
 		if(i == targetIndex) then
@@ -939,6 +935,16 @@ local DockBar_ChangeOrder = function(self, button, targetIndex)
 end

 local DockBar_CheckOrder = function(self, targetName)
+	for otherLoc,otherData in pairs(MOD.private.Order) do
+		for x = 1, #otherData do
+			local otherName = otherData[x];
+			local registeredLocation = MOD.private.Locations[otherName];
+			if(registeredLocation ~= otherLoc) then
+				MOD.private.Order[otherLoc][x] = nil;
+			end
+		end
+	end
+
 	local found = false;
 	local location = self.Data.Location;
 	local savedOrderList = MOD.private.Order[location];
@@ -1031,28 +1037,29 @@ local DockBar_AddButton = function(self, button, order)
 	if not button then return end
 	local name = button:GetName();
 	local currentLocation = self.Data.Location
-	if(MOD.private.Disabled[name]) then return end
 	order = order or 0;
 	--if(self.Data.Buttons[name] and (order == 0)) then return end
-
 	local registeredLocation = MOD.private.Locations[name];
-
-	if(registeredLocation == 'Floating') then return end;
-
+
 	if(registeredLocation) then
-		if(registeredLocation ~= currentLocation) then
+		if(registeredLocation == 'Floating') then
+			return
+		elseif(registeredLocation ~= currentLocation) then
 			if(MOD[registeredLocation].Bar.Data.Buttons[name]) then
 				MOD[registeredLocation].Bar:Remove(button, true);
 			else
-				MOD[registeredLocation].Bar:Add(button);
+				--MOD[registeredLocation].Bar:Add(button);
 				return
 			end
 		end
 	end
+	if(MOD.private.Disabled[name]) then return end
+
+	MOD.private.Dimensions[name] = nil;

 	button:Show()
 	self.Data.Buttons[name] = button;
-	MOD.private.Disabled[name] = nil;
+
 	DockBar_CheckOrder(self, name);
 	if(order > 0) then
 		DockBar_ChangeOrder(self, button, order)
@@ -1109,6 +1116,7 @@ local DockBar_RemoveButton = function(self, button, isMoving)
 		button:Hide()
 		MOD.private.Disabled[name] = currentLocation;
 		if(button.FrameLink) then
+			button.FrameLink:SetParent(UIParent)
 			local frameName = button.FrameLink:GetName()
 			MOD.private.Windows[frameName] = nil;
 			if(button.FrameLink.UpdateBackdrop) then
@@ -1150,13 +1158,11 @@ end
 local function SetFloatingDock(dock)
 	local name = dock:GetName();
 	dock:SetDocked(false);
+	MOD.private.Disabled[name] = nil;
 	dock:Show();
-	MOD.private.Locations[name] = "Floating";
 	dock.isFloating = true;
 	SaveCurrentPosition(dock);
-	if(ShowDockletWindow(dock, "Floating")) then
-		ActivateDockletButton(dock);
-	end
+
 	if(dock.FrameLink) then
 		dock.FrameLink:ClearAllPoints();
 		dock.FrameLink:SetPoint("BOTTOMLEFT", dock, "TOPLEFT", -3, 6);
@@ -1165,6 +1171,11 @@ local function SetFloatingDock(dock)
 		dock.FrameLink.resize:Show();
 	end
 	LoadSavedDimensions(dock);
+	if(ShowDockletWindow(dock, "Floating")) then
+		ActivateDockletButton(dock);
+	end
+	if(MOD.private.Locations[name] == 'Floating') then return end
+	MOD.private.Locations[name] = "Floating";
 	UpdateAllLayouts()
 end

@@ -1191,10 +1202,9 @@ local DockButton_OnDragStop = function(self)
 		local name = self:GetName();
 		local previous = MOD.private.Locations[name];
 		self.OrderIndex = 0;
-		if((not DRAG_TARGETBAR) and self.CanFloat) then
+		if(not DRAG_TARGETBAR) then
 			SetFloatingDock(self)
 		else
-			--print(name .. ' Docked')
 			local target = DRAG_TARGETBAR;
 			if(not target) then
 				target = MOD[previous];
@@ -1208,12 +1218,14 @@ local DockButton_OnDragStop = function(self)
 			end

 			target:Add(self, DRAG_ORDERINDEX);
+
+			if(self.FrameLink and self.FrameLink.UpdateBackdrop) then
+				self.FrameLink:UpdateBackdrop()
+			end
+
 			SV.Events:Trigger("DOCKLET_MOVED", self.LocationKey);
 		end

-		if(self.FrameLink and self.FrameLink.UpdateBackdrop) then
-			self.FrameLink:UpdateBackdrop()
-		end
 		DRAG_ENABLED = false;
 	end
 end
@@ -1337,20 +1349,8 @@ local DockButton_SetDocked = function(self, attach)
 		if(lookup and (lookup == "Floating")) then
 			SetFloatingDock(self);
 		end
-		--print(name .. ' Added')
-	else
-		--print('DockButton_SetDocked REMOVE '..name)
-		if(lookup and (lookup == "Floating")) then
-			self.OrderIndex = 0;
-			self:Hide();
-			MOD.private.Disabled[name] = lookup;
-			if(self.FrameLink) then
-				local frameName = self.FrameLink:GetName()
-				self.FrameLink:FadeOut(0.2, 1, 0, true);
-			end
-		elseif(parent.Remove) then
-			parent:Remove(self)
-		end
+	elseif(parent and parent.Remove) then
+		parent:Remove(self)
 	end
 end

@@ -1698,7 +1698,6 @@ function MOD:NewDocklet(location, globalName, readableName, texture, onenter)
 	frame:SetFrameStrata("BACKGROUND");

 	frame.Parent = newParent;
-	frame.CanFloat = true;
 	frame.Bar = newParent.Bar;
 	frame.Disable = Docklet_Disable;
 	frame.Enable = Docklet_Enable;
@@ -1721,7 +1720,6 @@ function MOD:NewDocklet(location, globalName, readableName, texture, onenter)

 	local buttonName = ("%sButton"):format(globalName)
 	frame.Button = newParent.Bar:Create(readableName, buttonName, texture, onenter, false, frame);
-	frame.Button.CanFloat = true;
 	DOCK_REGISTRY[globalName] = frame;
 	frame:SetAlpha(0);
 	DOCK_CHECK = true;
diff --git a/SVUI_Chat/SVUI_Chat.lua b/SVUI_Chat/SVUI_Chat.lua
index 54bc08c..81c5749 100644
--- a/SVUI_Chat/SVUI_Chat.lua
+++ b/SVUI_Chat/SVUI_Chat.lua
@@ -724,9 +724,9 @@ do
 	local ChatDock_LeftClickCallback = function(self, button)
 		local chatTab = self.link
 		local chatFrame = _G[("ChatFrame%d"):format(chatTab:GetID())];
-		if(not self.isFloating) then
-			FCF_Tab_OnClick(chatTab, button);
-		end
+		-- if(not self.isFloating) then
+		-- 	FCF_Tab_OnClick(chatTab, button);
+		-- end
 		ScrollIndicator:ClearAllPoints()
 		ScrollIndicator:SetPoint("BOTTOMRIGHT", chatFrame, "BOTTOMRIGHT", 6, 0)
 		if(chatFrame:AtBottom() and ScrollIndicator:IsShown()) then
@@ -1476,7 +1476,6 @@ do

 	local _hook_GDMFrameSetPoint = function(self)
 		self:SetAllPoints(SV.Dock.BottomLeft.Bar)
-		--print("_hook_GDMScrollSetPoint")
 	end

 	local _hook_GDMScrollSetPoint = function(self, point, anchor, attachTo, x, y)