View Single Post
01-22-10, 10:38 AM   #52
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,935
Aha, interesting. The problem I still get without nUI loaded is that it tries to scroll past the end of the list of tracked items ( I assume to get to the bottom of the watchframe ) but the list itself doesn't move, but the scrollbox does. And then, because this isn't working right it then goes and disconnects the watchframe from the moveable scrollframe and until I scroll back to the last tracked item it acts like the nUI added version.

Edit: Another problem is when it reaches the bottom of the screen it decides to all of a sudden reset its positioning to the top of the list. But this could be due to the running out of space and the watchframe running some other code to arrange what gets displayed... hmm... wonder if there are other functions being called. Will have to look into that.

Edit2: Ah, testing with and without nUI and the problems are similar, just happens in different ways. In essence it forgets somewhere that it doesn't belong to UIParent. So, it sounds like under certain circumstances it is reparenting back until I do something to get its attention back again. Will take a look at what watchframe.lua does again in case there are some more events and functions that are triggering the reset and tell it to reset mine at the same time. May have to store current position in scrolling list if that is the case so that it is unnoticeable.

Here's the code anyway. It should work with or without nUI as I am testing for it before using the nUI commands.

Code:
local ObjectivesBackdrop = {                         
	bgFile = "Interface/Tooltips/UI-Tooltip-Background", 
    edgeFile = "Interface/Tooltips/UI-Tooltip-Border", 
    tile = true, 
    tileSize = 16, 
    edgeSize = 16, 
    insets = { left = 4, right = 4, top = 4, bottom = 4 }
};                       

local ObjectivesBackcolor = { 
   	red=0,green=0,blue=0,alpha=1 
};

local ObjectivesBordercolor = { 
  	red=255,green=255,blue=0,alpha=1 
}; 

local WatchFrameScrollFrame;
local nUI_Loaded = false;

local function ResetWatchFrame(parent)
	
	if ( nUI_Loaded ) then
		nUI_Movers:lockFrame( WatchFrame, false, nil ); -- OBJECTIVES_TRACKER_LABEL );
		nUI_Options.movedWatchFrame = true;
	end

	WatchFrame.moving = true;
	WatchFrame.sizing = true;
	
	WatchFrame:SetMovable( true );
	WatchFrame:SetResizable( true );
	WatchFrame:StartMoving();
	WatchFrame:StartSizing( "TOPLEFT" );
	
	WatchFrame:ClearAllPoints();
	WatchFrame:SetParent(parent);
	WatchFrame:SetHeight( 500 );
	WatchFrame:SetWidth( parent:GetWidth() );
	WatchFrame:SetPoint( "TOPLEFT", parent, "TOPLEFT", 30,-10 );
	WatchFrame:SetPoint( "TOPRIGHT", parent, "TOPRIGHT", -35, -10);

	WatchFrame.moving = nil;
	WatchFrame.sizing = nil;

	WATCHFRAME_IGNORECURSOR = "1";			
	WATCHFRAME_LASTWIDTH    = WatchFrame:GetWidth() ;
	
	WatchFrame:StopMovingOrSizing();
	WatchFrame:SetUserPlaced( true );
	WatchFrame_Expand( WatchFrame );

	if ( nUI_Loaded ) then
		nUI_Movers:lockFrame( WatchFrame, true, nil );
	end
end

-- Frame is moving
local function OnMouseDown(self)
	if ( ( not self.isLocked ) or ( self.isLocked == 0 ) ) then
        self:StartMoving();
        self.isMoving = true;
	end
end

-- Frame has stopped moving
local function OnMouseUp(self)
	if ( self.isMoving ) then
		self:StopMovingOrSizing();
		self.isMoving = false;
	end
end

-- Frame has been hidden
local function OnHide(self)
	if ( self.isMoving ) then
		self:StopMovingOrSizing();
		self.isMoving = false;
	end
end

local function CreateScrollFrame()
	
	local f = CreateFrame( "Frame", "WatchFrame_Container",UIParent);
	f:SetWidth(400);
	f:SetHeight(200);
	f:SetClampedToScreen(true);
	f:SetFrameStrata("HIGH");
	f:SetPoint("CENTER",UIParent,"CENTER",0,0);
	f:SetBackdrop(ObjectivesBackdrop);
	f:SetBackdropColor(ObjectivesBackcolor.red,ObjectivesBackcolor.green,ObjectivesBackcolor.blue, ObjectivesBackcolor.alpha);
	f:SetBackdropBorderColor(ObjectivesBordercolor.red, ObjectivesBordercolor.green,ObjectivesBordercolor.blue, ObjectivesBordercolor.alpha);
	f:RegisterForDrag("LeftButton");
	f:EnableMouse(true);
	f:SetMovable(true);
	f:SetScript("OnMouseDown",OnMouseDown);
	f:SetScript("OnMouseUp",OnMouseUp);
	f:SetScript("OnHide",OnHide);

	local s = CreateFrame( "ScrollFrame", "WatchFrame_ScrollFrame", f, "UIPanelScrollFrameTemplate" );
	s:SetPoint("TOPLEFT", 5, -5);
	s:SetPoint("BOTTOMRIGHT", -30, 5);
	f.Scroll = s;
	
	local c = CreateFrame("Frame","WatchFrame_ScrollChild",s);
	s:SetScrollChild(c);
	c:SetWidth(2);
	c:SetHeight(2);
	c:SetAllPoints(s);
	f.Child = c;
		
	return f;
end

local plugin    = CreateFrame( "Frame", "Mini_ObjectiveFrame", UIParent );

local function onEvent()
	if event == "VARIABLES_LOADED" then		
		WatchFrameScrollFrame = CreateScrollFrame();
		ResetWatchFrame(WatchFrameScrollFrame.Child);
		if ( nUI_Loaded ) then
			nUI_ResetWatchFrame = function() end;
		end
		WatchFrame.ClearAllPoints = function() end
		WatchFrame.SetPoint = function() end
		WatchFrame.SetAllPoints = function() end		
	elseif event == "ADDON_LOADED" then
		nUI_Loaded = false;
		if ( arg1 == "nUI" ) then
			nUI_Loaded = true;
			plugin:UnregisterEvent( "ADDON_LOADED" );
		end
	end	
end
plugin:SetScript( "OnEvent", onEvent );
plugin:RegisterEvent( "VARIABLES_LOADED" );
plugin:RegisterEvent( "ADDON_LOADED" );
__________________


Characters:
Gwynedda - 70 - Demon Warlock
Galaviel - 65 - Resto Druid
Gamaliel - 61 - Disc Priest
Gwynytha - 60 - Survival Hunter
Lienae - 60 - Resto Shaman
Plus several others below level 60

Info Panel IDs : http://www.wowinterface.com/forums/s...818#post136818

Last edited by Xrystal : 01-22-10 at 11:05 AM.