Resize frame
I would like to resize a frame with the mouse, just like the chat frame resizing, however i don't want anything fancy i just want to increase and decrase the scale of the frame based on the mouse's position. Here is my code so far:
Lua Code:
|
Try this:
lua Code:
This should create a resize button in the bottom right corner of your main frame that looks like the chat frame resize button. You can add a check for the left mouse button in the OnMouseUp/Down scripts like you have in your code if you want. |
Yes but i would like to scale the frame not resize it, (Just noticed i might messed up the thread's topic, sorry for that.)
|
I'm not really sure how to help you. Is there a particular reason you're scaling the frame instead of just resizing it?
|
Quote:
Scaling affects all child objects, sizing does not. |
Quote:
|
Quote:
|
left button at frame background and draging = drag frame
left button at resize button and draging = resize frame right button at resize button and draging = rescale frame Rescaling is affected by horizontal mouse movement only. Someone has to implement the y axis. :) It's not perfect but it's working. Nevertheles I do agree with Vrul. Scaling a fame is never the best way to do anything size-related. In best case it just adds an extra level of complexity to your code. In worst case all your visible objects are a total mess. :) [e] Didn't tested what would happen to child object of my test frame. And I'm seriously afraid of finding it out. ;D Lua Code:
|
F@ck me i can't convert it to TOPLEFT anchored resize, but beside that it's works thanks.
|
Using bottomleft is the easiest way to do it. Bottomleft is equal to 0/0 and topleft is 0/1.
If you need it to be anchored to topleft you'll have to calculate new y coordinates accordingly to topleft. (eg. subtact the y value of the cursor coordinates from UIParents height to get a value relative to topleft) |
Goddamns frames always jump on y axis.
I was trying to change: self.y = (self:GetTop() - self:GetHeight()) To: self.y = (UIParent:GetHeight() - self:GetTop()) But when i move the frame, then try to resize it it does a jump in the y axis. |
|
Quote:
Does it work if the overall UI scale is not set to default? (interface settings > UI scale) Regarding the anchor point: You can't just change bottomleft to topleft. The anchor point changes everything. Lets assume UIParent has a size of 100x100. As you know in wow 0/0 is the lower left corner and 1/1 is the top right corner. Always. Regardless of where something is anchored or if we are talking about frames, cursor coordinates, textures or whatever. Setpoint coordinates are relative to the anchor point. A positive x means a shift to the right. Negative x is left. Positive y shifts to the top (remember, in wow 0/0 is the bottom left corner and 0/1 is top left) and negative y shifts to the bottom. Now let's see what happens: setpoint("bottomleft", parent, "bottomleft", 20, 20) is something like: Code:
0/100 100/100 Code:
x |
Yeah i reverse engineered most part of it.
It works properly with every UIScale because it's using a different method. Also updated the code to scale every other child object: Lua Code:
I'm aware of the anchoring issue i tried it like this: self:GetParent():SetPoint("TOPLEFT", UIParent, "TOPLEFT", tx, - ty) And was using: self.y = (UIParent:GetHeight() - self:GetTop()) To get the y coordinates, which should be fine. But i also tried to multiple it with the UIParent:GetScale() any pretty much every other number on the universe, if the frame had 1 scale then it worked, but was faulty with every other scale level. But still every time i moved the frame, then tried to resize it, it randomly jumped +/- y axis. Not sure why, probably some other scaling issue, since you can't just get the coords with simply the GetBottom/GetTop. |
If you call this after you created a frame, then the frame is gonna be scaleable, and it's gonna build up everything needed for it:
Lua Code:
There are still a few thing to do it with, like change the resize button's texture onmousedown and up. Also ot exlude or only scale the scale button itself with lower frequency, to prevent it beeing unclickable. But its working properly. Right click on the resize texture, reset the frame to the original size. |
Nice one. I'll definitly bookmark this for later use. :)
Quote:
You can work around this annoying behavior with re-anchoring it to the desired anchor on OnDragStop. Lua Code:
|
Peggle does not have a license which allows you to "reverse engineer" and "ninja" its code. :mad:
Quote:
|
OT:
I recently asked myself if Blizzard would allow me to use obfuscate code to implement a synchronized (realm or bg or something) high score table in http://www.wowinterface.com/download...doManager.html. It wouldn't make any sense to create one without obfuscating code/data. I'm 100% sure that a clear text high score table would be 'hacked' immediately and be useless. :) Do you think it's worth to ask for a permission to add obfuscate code? |
Quote:
If i could have found a similar solution for it which works properly i would use that. I spent the last 3 days on this silly issue anyway. Peggles system only rescales the main frame and resizes other frames to it, mine rescales the frame and all of it's childrens. |
Quote:
|
All times are GMT -6. The time now is 04:32 PM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI