Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

11991 Posts in 1587 Topics- by 3509 Members - Latest Member: lioneltenel

26. May 2012, 08:03:41 pm
Xith3D CommunityGeneral CategoryNews (Moderators: Marvin Fröhlich, 'n ddrylliog)GUI Widget Manipulator
Pages: [1]
Print
Author Topic: GUI Widget Manipulator  (Read 1715 times)
'n ddrylliog
Moderator
Guru
*****
Offline Offline

Posts: 1188



View Profile WWW Email
« on: 03. March 2007, 07:40:30 am »

Hi everyone !

I just wanted to notify you of the existence of a wonderful tool (admittedly, since I had the idea Grin) : WidgetManipulator.

Did it happen to you that you had 150 widgets to lay out on a Xith3D HUD and you shighed that you had no HUD editor ? Those time are (nearly) finished.

WidgetManipulator is used like this :

Code:
Widget anyWidget = new AnyWidget(10f, 10f, "blaah");
new WidgetManipulator(anyWidget);

THEN, in your game you should see little handles at each corner of your widget : north-west, north-east, south-east and south-west. These handles can be used to resize your widget.
Moreover, the now "manipulatable" component is draggable, you can then relocate it.

Now a small practical example. Let's say I want to add a Xith3D semi-transparent logo to Digibots (as if the interface wasn't bloated enough  Grin ).

I'd go to the Xith3D homepage, steal the logo, convert the white into alpha using the Gimp, then add it to my resource bag and finally ADD it to my HUD :

Code:
Widget xithLogo = new Image(100f, 100f, ResBag.getTexture(ResourceNames.XITH3DLOGO));
hud.addWidget(xithLogo);

Then here's what it gives :


Not really fancy, heh ?
So I add this line :

Code:
new WidgetManipulator(xithLogo);

And here's what I get :



Now you'll discover the real power of this tool.
After I've resized then dragged my component, a stack trace is automatically dumped to the console. It's not the current stack trace : it's the stack trace of when you called WidgetManipulator :



Then you just have to click on the third entry, which is from where you instanced the WidgetManipulator, and Eclipse brings you to the right place :



And then and THAT IS THE GREATEST MAGIC ! Just do : Ctrl + V (or paste, if you prefer Smiley ) and here's what it gives you :



Now just rename "image" to xithLogo and you're done ! (Note : if anyone has a hack so that I can guess the name of the variable the WidgetManipulator is passed, I'd be pleased to know that Smiley )



And now the Xith3D logo is well/better positionned :



Now, a few things :
- Draggability of objects is somewhat bugged. It's up to Marvin to fix that. Now he's informed so no excuses Smiley Especially, widgets stop moving when the mouse is moved so fast that it gets out of the widget in a render step and they don't stop dragging when the left button is released.
- If anyone has a knowledge of stack traces and now how to filter them so that it displays only the third line, please tell me (I haven't even searched, though, it's functional as it is).
- As I said, if there's a mean to guess a variable name which has been passed as a parameter to a constructor/function, please tell me.

ENJOY !

PS : Maybe i'll expand that to a "real" HUD editor, but it wouldn't be the same approach... It would be xml-based.
Logged
Marvin Fröhlich
Xith Lord
Administrator
Guru
*****
Offline Offline

Posts: 4381


May the 4th, be with you...


View Profile
« Reply #1 on: 03. March 2007, 10:15:40 am »

After I've resized then dragged my component, a stack trace is automatically dumped to the console. It's not the current stack trace : it's the stack trace of when you called

Hmm... This doesn'T seem to be WidgetManipuator internal functionality. Neither the stack trace thing, nor the clipboard one. I guess, you added a WidgetContainerListener, WidgetResizeListener and WidgetLocationListener, but you could add this as a built-in (optionally enableble) feature to the WidgetManipulator.

- Draggability of objects is somewhat bugged. It's up to Marvin to fix that. Now he's informed so no excuses Smiley Especially, widgets stop moving when the mouse is moved so fast that it gets out of the widget in a render step and they don't stop dragging when the left button is released.

I'll see what I can do. But I have other (more important) things to fix first.

- If anyone has a knowledge of stack traces and now how to filter them so that it displays only the third line, please tell me (I haven't even searched, though, it's functional as it is).

This is really easy. You can retrieve an array of StackTraceElement from the stack trace. This provides methods to retrieve information about each line in the stack trace.

Marvin
Logged
'n ddrylliog
Moderator
Guru
*****
Offline Offline

Posts: 1188



View Profile WWW Email
« Reply #2 on: 04. March 2007, 03:01:41 pm »

After I've resized then dragged my component, a stack trace is automatically dumped to the console. It's not the current stack trace : it's the stack trace of when you called

Hmm... This doesn'T seem to be WidgetManipuator internal functionality. Neither the stack trace thing, nor the clipboard one. I guess, you added a WidgetContainerListener, WidgetResizeListener and WidgetLocationListener, but you could add this as a built-in (optionally enableble) feature to the WidgetManipulator.
I don't see what you mean... do you mean it shouldn't be in WidgetManipulator ? I don't think so. WidgetManipulator is meant to be used like that. Stack trace outputting and clipboard copying is just something to ease a bit more the developer's lives.
Logged
Marvin Fröhlich
Xith Lord
Administrator
Guru
*****
Offline Offline

Posts: 4381


May the 4th, be with you...


View Profile
« Reply #3 on: 04. March 2007, 05:21:50 pm »

I don't see what you mean... do you mean it shouldn't be in WidgetManipulator ? I don't think so. WidgetManipulator is meant to be used like that. Stack trace outputting and clipboard copying is just something to ease a bit more the developer's lives.

You got me wrong. You described this strac trace and clipboard things as if they where already usable parts of the WidgetManipulator. But this functionality is not yet in there. I just wanted to ask, if you're planning to integrate it (which you seem to be).

So I didn't want to vote against this integration, but for it Wink.

Marvin
Logged
'n ddrylliog
Moderator
Guru
*****
Offline Offline

Posts: 1188



View Profile WWW Email
« Reply #4 on: 04. March 2007, 05:28:45 pm »

I don't see what you mean... do you mean it shouldn't be in WidgetManipulator ? I don't think so. WidgetManipulator is meant to be used like that. Stack trace outputting and clipboard copying is just something to ease a bit more the developer's lives.

You got me wrong. You described this strac trace and clipboard things as if they where already usable parts of the WidgetManipulator. But this functionality is not yet in there. I just wanted to ask, if you're planning to integrate it (which you seem to be).

So I didn't want to vote against this integration, but for it Wink.
AH ! now I understand Smiley I hadn't committed.. it's alright now..
Logged
Marvin Fröhlich
Xith Lord
Administrator
Guru
*****
Offline Offline

Posts: 4381


May the 4th, be with you...


View Profile
« Reply #5 on: 04. March 2007, 05:38:09 pm »

AH ! now I understand Smiley I hadn't committed.. it's alright now..

Hmm... no Smiley.

You commited somthing, but not the WidgetManipulator modifications Smiley.

And the KeySwitcher doesn't compile. Please remember: You cannot use "@Override" for interface implemented methods. I don't know, why your Eclipse doesn't complain.

Marvin
Logged
'n ddrylliog
Moderator
Guru
*****
Offline Offline

Posts: 1188



View Profile WWW Email
« Reply #6 on: 04. March 2007, 06:52:22 pm »

AH ! now I understand Smiley I hadn't committed.. it's alright now..

Hmm... no Smiley.

You commited somthing, but not the WidgetManipulator modifications Smiley.

And the KeySwitcher doesn't compile. Please remember: You cannot use "@Override" for interface implemented methods. I don't know, why your Eclipse doesn't complain.
Are you *sure* ?
What is _that_, then ?
http://xith-tk.svn.sourceforge.net/viewvc/xith-tk/trunk/src/org/xith3d/utility/hud/editor/WidgetManipulator.java?revision=1274&view=markup
See lines 124-156.

Amos
Logged
Marvin Fröhlich
Xith Lord
Administrator
Guru
*****
Offline Offline

Posts: 4381


May the 4th, be with you...


View Profile
« Reply #7 on: 04. March 2007, 06:57:31 pm »

Woops. I looked into to wrong class Cheesy. Sorry for the false alarm.

Marvin
Logged
'n ddrylliog
Moderator
Guru
*****
Offline Offline

Posts: 1188



View Profile WWW Email
« Reply #8 on: 04. March 2007, 07:06:39 pm »

Woops. I looked into to wrong class Cheesy. Sorry for the false alarm.
Hehe Smiley So, how do you find it Smiley
Logged
Marvin Fröhlich
Xith Lord
Administrator
Guru
*****
Offline Offline

Posts: 4381


May the 4th, be with you...


View Profile
« Reply #9 on: 04. March 2007, 07:14:02 pm »

Hehe Smiley So, how do you find it Smiley

Pretty cool.
Logged
Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic