Thread Tools Display Modes
08-04-07, 11:32 PM   #1
Evilive
A Murloc Raider
Join Date: Apr 2006
Posts: 4
Need some help with scaling and disabling mouse

I need a touch of help finishing an addon. Basically just SimpleCompass ripped off and mangled, because I prefer the Dark Age of Camelot compass.

The two things I can't quite seem to get right are. Scaling, the slider I set up for scaling works, however it relocates the visible frame from the upper left corner to bottom right corner (small size to larger size as scale is scale slider is adjusted) rather than just resizing and remaining centered in place. Disabling the mouse, I can get it to not recognize clicks, however I would prefer to click "through" it so I can pan the camera without worrying about having to click outside compass frame.

Here are the xml and lua for the base frame and the function for when an option is changed.
I figure whatever I need to alter is most likely within these.

Code:
<Frame name="WL_Comp_Frame" movable="true" parent="UIParent" frameStrata="MEDIUM">
		<Scripts>
			<OnLoad>
				WL_Comp_OnLoad();
			</OnLoad>
			<OnEvent> 
		  	WL_Comp_OnEvent(event, arg1);
		  </OnEvent> 
		  <OnUpdate> 
				WL_Comp_OnUpdate();	  	
		  </OnUpdate> 
		</Scripts>
		<Size>
			<AbsDimension x="128" y="32"/>
		</Size>
		<Layers>
			<Layer level="BACKGROUND">
				<Texture name="WL_Comp1Icon"/>
			</Layer>
		</Layers>
		<Anchors>
			<Anchor point="CENTER">
			</Anchor>
		</Anchors>
		<Frames>
			<Button name="WL_Comp_Body" enablemouse="true">
				<Size>
					<AbsDimension x="128" y="32"/>
				</Size>
				<Anchors>
					<Anchor point="CENTER"/>
				</Anchors>
				<Scripts>
					<OnLoad>
						this:RegisterForClicks("RightButtonUp");
						this:SetFrameLevel(this:GetParent():GetFrameLevel()-1);
					</OnLoad>
					<OnMouseDown>
						if ( arg1 == "LeftButton" and IsShiftKeyDown()) then
							this:GetParent():StartMoving();
						elseif ( arg1 == "RightButton" and IsShiftKeyDown()) then	
							WL_Comp_OptionsToggle();
						end
					</OnMouseDown>
					<OnMouseUp>
						if ( arg1 == "LeftButton" ) then
							this:GetParent():StopMovingOrSizing();
						end
					</OnMouseUp>
				</Scripts>
			</Button>
		</Frames>
	</Frame>
Code:
function WL_Comp_SetOptions()
	local s = WL_Comp_Saved_Options;
	if ( s.hidden == 1 and not WL_Comp_Options:IsVisible()) then
		WL_Comp_Frame:Hide();
	else
		WL_Comp_Frame:Show();
	end

	WL_Comp_Frame:SetScale(s.scale);
	WL_Comp_Frame:EnableMouse(s.frozen);
	WL_Comp_Frame:SetAlpha(s.alpha);
end
Any help is appreciated, I have a feeling this is a xml issue which a weakness for me.
  Reply With Quote
08-05-07, 06:53 AM   #2
Layrajha
A Frostmaul Preserver
 
Layrajha's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 275
Change the "Button" tag to "Frame".
Remove the "enablemouse=\"true\"" field of the former-button newly-simple-frame.
Remove the "OnMouseDown", "OnMouseUp" parts.
In the "OnLoad" part, remove the RegisterForClicks line.

Now the mouse should be totally disabled (click through). I think that removing the "enablemouse" field would have been enough, but it's a bit ugly to use a button when you can't click it


About the frame moving when you scale it, it's a bit strange. Usually, it happens when the frame's anchor is set with offset values. For instance, if your frame is set to be with its TOPLEFT corner on the TOPLEFT corner of UIParent, with a x offset of 100 pixels, scaling it twice smaller will make its TOPLEFT corner aligned with the TOPLEFT corner of UIParent with a x offset of 50 pixels only.
If you have two frames of the same size, you can have them superposed by aligning any of their "corners" (CENTER, TOPLEFT, BOTTOMRIGHT, etc...), and thus, if you didn't use CENTER but BOTTOMRIGHT, scaling one of the frame down would decenter it, even with no offset.

But, as you are using only CENTER anchors with no offset, I don't get the problem.
  Reply With Quote
08-05-07, 08:27 AM   #3
Evilive
A Murloc Raider
Join Date: Apr 2006
Posts: 4
Thanks Layrajha, I actually changed the options setting code for the disabling mouse to just hide the button, but keep the frame and button combo moveable when it is shown.

Code:
function WL_Comp_SetOptions()
	local s = WL_Comp_Saved_Options;
	if ( s.hidden == 1 and not WL_Comp_Options:IsVisible()) then
		WL_Comp_Frame:Hide();
	else
		WL_Comp_Frame:Show();
	end
	
	if(s.frozen == 1) then
		WL_Comp_Body:Hide();
	else
		WL_Comp_Body:Show();
	end
	
	WL_Comp_Frame:SetScale(s.scale);
	WL_Comp_Frame:SetAlpha(s.alpha);
end
Maybe it will help if you see the slider xml for the scaling also, silly me. I think I did not explain correctly the behavior I am experiencing when scaling. WL_Comp_Frame is being relocated completely depending on the scale setting, at minimum scale it is in the upper left corner of monitor. As scale is increased it moves away from the upper left corner of monitor, in a direction that is in the direction of a line drawn from the original position through the upper left corner of monitor.

I think you hit on the problem, there may be a UIParent problem.
Code:
		<Slider name="WL_Comp_Scale" inherits="OptionsSliderTemplate" minValue="0.25" maxValue="4" valueStep="0.05" defaultValue="1">
				<Anchors>
					<Anchor point="TOPLEFT" relativeTo="WL_Comp_Alpha" relativePoint="BOTTOMLEFT">
						<Offset>
							<AbsDimension x="0" y="-20"/>
						</Offset>
					</Anchor>
				</Anchors>
				<Scripts>
					<OnLoad>
						getglobal(this:GetName().."High"):SetText("400%");
						getglobal(this:GetName().."Low"):SetText("25%");
					</OnLoad>
					<OnShow>
						this:SetValue(WL_Comp_Saved_Options.scale or 1);
						getglobal(this:GetName().."Text"):SetText("Scale "..(tonumber(format("%0.2f",WL_Comp_Saved_Options.scale)) * 100) .."%");
					</OnShow>
					<OnValueChanged>
						if(this:IsVisible()) then
							WL_Comp_Saved_Options.scale = this:GetValue();
							WL_Comp_SetOptions();
							getglobal(this:GetName().."Text"):SetText("Scale "..(tonumber(format("%0.2f",WL_Comp_Saved_Options.scale)) * 100) .."%");
						end
					</OnValueChanged>
				</Scripts>
			</Slider>
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Need some help with scaling and disabling mouse


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off