Problem Description
Ok... I know it can be viewed as a feature request more than as a bug per se.
But I choose to report it as a bug because the modification is so small that it looks more like a design oversight than anything else.
So here is the thing:
You can't ask the anchor behavior to just anchor your object vertically OR horizontally, leaving the other axis alone.
In my case, I just wanted a UI element to stick to the left border and keep using its default Y position.
But in some scaling mode (like scale outer) the difference between window border and object position can change. Thus Unecessarily moving the object.
And in any cases, I always wondered why the options between Left, Top, Right and Bottom edge were so inconsistent.
Here is my simple fix:
edittime.js
@@ -76,8 +76,8 @@
// new cr.Property(ept_combo, name, "Item 1", description, "Item 1|Item 2|Item 3") // a dropdown list (initial_value is string of initially selected item)
var property_list = [
[ul]
[li]new cr.Property(ept_combo, "Left edge", "Window left", "Anchor the object's left edge to a window edge.", "Window left|Window right"),[/li]
[li]new cr.Property(ept_combo, "Top edge", "Window top", "Anchor the object's top edge to a window edge.", "Window top|Window bottom"),[/li]
[/ul]+ new cr.Property(ept_combo, "Left edge", "Window left", "Anchor the object's left edge to a window edge.", "None|Window left|Window right"),
+ new cr.Property(ept_combo, "Top edge", "Window top", "Anchor the object's top edge to a window edge.", "None|Window top|Window bottom"),
new cr.Property(ept_combo, "Right edge", "None", "Anchor the object's right edge.", "None|Window right"),
new cr.Property(ept_combo, "Bottom edge", "None", "Anchor the object's bottom edge.", "None|Window bottom"),
new cr.Property(ept_combo, "Initial state", "Enabled", "Whether to initially have the behavior enabled or disabled.", "Disabled|Enabled")[/code:2hkpntpj]
[b]runtime.js[/b][code:2hkpntpj]@@ -95,7 +95,7 @@
var bbox = this.inst.bbox;
// Anchor left to window left
[ul]
[li]if (this.anch_left === 0)[/li]
[/ul]+ if (this.anch_left === 1)
{
inst.update_bbox();
n = (layer.viewLeft + this.xleft) - bbox.left;
@@ -108,7 +108,7 @@
}
// Anchor left to window right
[ul]
[li]else if (this.anch_left === 1)[/li]
[/ul]+ else if (this.anch_left === 2)
{
inst.update_bbox();
n = (layer.viewRight - this.xright) - bbox.left;
@@ -121,7 +121,7 @@
}
// Anchor top to window top
[ul]
[li]if (this.anch_top === 0)[/li]
[/ul]+ if (this.anch_top === 1)
{
inst.update_bbox();
n = (layer.viewTop + this.ytop) - bbox.top;
@@ -134,7 +134,7 @@
}
// Anchor top to window bottom
[ul]
[li]else if (this.anch_top === 1)[/li]
[/ul]+ else if (this.anch_top === 2)
{
inst.update_bbox();
n = (layer.viewBottom - this.ybottom) - bbox.top;[/code:2hkpntpj]
(To really really be complete, maybe adding "window left" and "window top" for right edge and bottom edge option, imagining some cases where the object it is assigned to would change size while still be anchored to it's opposite border window... why not? (: )
I could of course fork the behavior... but just for that it would be... sad.
In any case, Ash, don't hesitate to throw this post in another part of the forum if you don't think it should be here =)
[b]Construct 2 Version ID[/b]
r168
[b]Edit:[/b]
Ok after a bit more fiddling, I realised that the plugin was using the first two edges constraint to position the object and the two last to stretch it... which is highly unintuitive I'd say.
Using my fix, you'd have strange result if you do Top Edge: None + Bottom Edge: Bottom. I thought first that the object's bottom edge would stick to its initial bottom position, but with the current implementation, it will just stretch the object vertically to keep the bottom edge at its initial bottom position.
So ok, it might be a mix of feature request and design/conceptual bug report... A matter of opinion (: