Layout Managers

I’m having a little trouble with layout managers. I can use the grid one and I can get my ImageButton working, but as soon as I use absolute layout I can’t get it right. So I fell back to the TestWidgetImage and changed from grid to absolute and it stops working.

Help please?

I was never able to get absolute layout managers working either, but I didn’t spend a lot of time trying.



I’m the original author of ImageWidget, AnimatedImageWidget, and the test classes, so if there’s a problem with any of it, it could be due to my lack of understanding rather than a limitation of the other Widget objects.

Ok, I’ll keep looking at things. Maybe with a ‘team’ effort we’ll figure out what’s going on.

Sorry I’m not chiming in here, I really don’t know anything about the widget library, that was a pure Gregg Patton effort. I haven’t seen him on here in awhile.

Ok, turns out the problem is with the getPreferredSize from the WidgetImage.



I added this to WidgetImage:



   public Vector2f getPreferredSize() {
      return new Vector2f( image.getWidth(), image.getHeight());
   }



and added this to WidgetImageButton:


   public Vector2f getPreferredSize() {
      return _image.getPreferredSize();
   }



And the absolute layout started working!! Of course I had to take a look at the WidgetAbsoluteLayout code to figure it out, but it's pretty strait forward.

I'll let you do the cvs checkin for WidgetImage and such.

Thanks.



That’s probably better than what it was doing before.



However, the actual preferred size will have to be based on the image scaling.



I guess I’ll need to take a look at that when I can.



Hopefully, Mojo will check in your patch since it’s better than the current behavior.



-Mike

Scaling… oh boy. See how much I still have to learn! Sorry, I’ll keep working on it.

://

You seem to be doing great to me :slight_smile:



Despite the forum-assigned title of “jME expert”, I am far from it :slight_smile: At best, I’m “jME regular” :slight_smile:

I’ve checked in the change to WidgetImage. If you want to send me the WidgetImageButton java files I’ll see about putting them in too. email them to the address in my profile.

I’ll do that as soon as I’ve worked out a couple more things. I have to add the notification stuff like in the button.