HeroEngine Forums
Welcome, Guest. Please login or Register for HeroCloud Account.

Author Topic: _panel outside _window margins, but follows window movement  (Read 1785 times)

AWW_boss

  • General Accounts
  • *
  • Posts: 846
  • gdfgd
    • View Profile

How do i make one gui control (_panel in my example) follow the movement of the other gui control (_window in my example)? The _panel must be outside of the window margins. Ideas?
Logged

Thazager

  • General Accounts
  • *
  • Posts: 1156
  • Never stop learning
    • View Profile
    • Heroes and Villains MMORPG
Re: _panel outside _window margins, but follows window movement
« Reply #1 on: Sep 29, 13, 07:13:14 PM »

One way is by using script. Grab the location of the 1st GUI, and set the location based on it for the 2nd GUI. You could set it to not move until the one GUI got so far away from the other, before it starts to follow. This could be the size of the Gui so that it does not overlap.

distX = (GuiOne.position.x - GuiTwo.position.x)  // Though you might want absolute value
if distX >= maxDistX
  GuiTwo.position.x = GuiOne.position.x - maxDistX
.
Logged

AWW_boss

  • General Accounts
  • *
  • Posts: 846
  • gdfgd
    • View Profile
Re: _panel outside _window margins, but follows window movement
« Reply #2 on: Sep 30, 13, 12:23:54 AM »

Quote
One way is by using script. Grab the location of the 1st GUI, and set the location based on it for the 2nd GUI. You could set it to not move until the one GUI got so far away from the other, before it starts to follow. This could be the size of the Gui so that it does not overlap.

distX = (GuiOne.position.x - GuiTwo.position.x)  // Though you might want absolute value
if distX >= maxDistX
  GuiTwo.position.x = GuiOne.position.x - maxDistX
.


that came to my mind, but it didn't seem like the most elegant solution. Also the question is: where would i put this code? Which is the event the control fires during movement?
« Last Edit: Sep 30, 13, 12:35:53 AM by AWW_boss »
Logged

AWW_boss

  • General Accounts
  • *
  • Posts: 846
  • gdfgd
    • View Profile
Re: _panel outside _window margins, but follows window movement
« Reply #3 on: Sep 30, 13, 01:34:54 AM »

Oh, and by the way, gluedToNode didn't seem to work, since i guess it'd only work with models.
Logged

FI-ScottZ

  • General Accounts
  • *
  • Posts: 1407
    • View Profile
    • Forever Interactive, Inc.
Re: _panel outside _window margins, but follows window movement
« Reply #4 on: Sep 30, 13, 09:40:59 AM »

Boss, I believe you would use the owner field of a move panel.  See this page.

In particular, if you look at the examples on that page, if your one control was panel1, and you wanted panel2 to move in sync with panel1, then set panel1's owner to be "window.panel2".

I think that would work; or it might only move panel2, I'm not sure.  Otherwise, yeah you would need to do it via script.  All controls have a callback method call onLayout() which alerts you when it changes position, among other things.
« Last Edit: Sep 30, 13, 09:44:34 AM by ScottZarnke »
Logged
Scott Zarnke
Lead Programmer, Visions of Zosimos
CTO, Forever Interactive, Inc.

AWW_boss

  • General Accounts
  • *
  • Posts: 846
  • gdfgd
    • View Profile
Re: _panel outside _window margins, but follows window movement
« Reply #5 on: Sep 30, 13, 10:59:52 AM »

Seems that onLayout() is not called when the control is moved, but i found that with OnDragStop() i can get satsfying results. :))))

Thanks for pointing me to the right direction Scott, you help is always very welcome.
Logged