Go to Page... |
Thread Tools | Display Modes |
08-04-07, 11:32 PM | #1 |
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 |
|
08-05-07, 06:53 AM | #2 |
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. |
|
08-05-07, 08:27 AM | #3 |
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 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> |
|
WoWInterface » Developer Discussions » Lua/XML Help » Need some help with scaling and disabling mouse |
«
Previous Thread
|
Next Thread
»
|
Display Modes |
Linear Mode |
Switch to Hybrid Mode |
Switch to Threaded Mode |
|
|