play-co / timestep

GNU General Public License v3.0
16 stars 27 forks source link

adding back centerAnchor #39

Closed jishnu7 closed 8 years ago

jishnu7 commented 9 years ago

centerAnchor supposed to recenter the view on dimension change. It got removed in the timestep for devkit2.

jwilm commented 9 years ago

Did this fix work for you? I tried in simulator and on device without any change in behavior.

jishnu7 commented 9 years ago

Yes. I tried it in simulator, it was working fine. On Jan 24, 2015 12:01 AM, "Joe Wilm" notifications@github.com wrote:

Did this fix work for you? I tried in simulator and on device without any change in behavior.

— Reply to this email directly or view it on GitHub https://github.com/gameclosure/timestep/pull/39#issuecomment-71240324.

jwilm commented 9 years ago

Here's how this looks in my simulator:

box

It seems to me that centerAnchor shouldn't be part of the BoxLayout at all. Rather, it should be part of view initialization and view option updating.

if (opts.centerAnchor) {
  opts.anchorX = opts.w / 2;
  opts.anchorY = opts.h / 2;
}

Am I missing something? @mgh can you comment?

mgh commented 9 years ago

I assume it is in BoxLayout so that the anchor updates whenever the width and height changes (on reflow). It's unclear to me what the exact behavior should be -- should it be a convenience property for initialization that doesn't actually maintain a centered anchor? Should setting it automatically enable a box layout? I'd almost rather have it be a helper function than an opts property, though this runs counter to the trend toward 100% declarative opts.

jishnu7 commented 9 years ago

Sorry. My bad. This change is not working, I might have messed up with multiple copies of devkit-core.

jishnu7 commented 9 years ago

I tested this again today. Found that this patch is actually working. I'll post a screenshot

jwilm commented 9 years ago

Can you explain how to make this work? I have a fresh app with up to date devkit core and you're timestep patch. My result is the gif above.

rogueSkib commented 8 years ago

I would expect centerAnchor to apply once on view init for views without layout / reflow, and to apply on each reflow for views within a layout. Changing the individual anchors manually should be fine, but would get overwritten if a reflow occurs and the view is in a layout. If you all agree and this patch works accordingly, than we can merge. I'll give it a test!

rogueSkib commented 8 years ago

@mgh @jishnu7 I placed a new pull request based on this one that enforces centerAnchor whenever width or height are changed, regardless of the view's layout or lack thereof: https://github.com/gameclosure/timestep/pull/81

Closing this pull request, comment on the new one if it works for you and I'll merge!