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, 10:02:52 pm
Xith3D CommunityGeneral CategoryNews (Moderators: Marvin Fröhlich, 'n ddrylliog)Massive HUD update
Pages: 1 [2]
Print
Author Topic: Massive HUD update  (Read 3537 times)
'n ddrylliog
Moderator
Guru
*****
Offline Offline

Posts: 1188



View Profile WWW Email
« Reply #15 on: 24. January 2007, 05:23:38 pm »

After all this time I am sure it is obvious that I love to fuss and will do so when I can Tongue
OK then Smiley
Logged
Marvin Fröhlich
Xith Lord
Administrator
Guru
*****
Offline Offline

Posts: 4381


May the 4th, be with you...


View Profile
« Reply #16 on: 24. January 2007, 11:58:16 pm »

EDIT: Please don't update to the current SVN until I tell you. There's a strange new bug in the HUD code, that causes some textures to disappear when a Frame is dragged.

This bug is killed. The current revision is now free to be checked out.

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

Posts: 4381


May the 4th, be with you...


View Profile
« Reply #17 on: 29. January 2007, 04:11:21 pm »

Please look at http://home.mindspring.com/~hawkwind/dump.zip

I have two widgets, one that display due to mouse over, one that shows for a fixed time.  Widgets are embedded into a hacked HUDT3DTest.  Zip includes some images.  Change as needed. Grin

Soo... I have "assimilated" your Widgets. I think the result is a lot easier and more common. Please have a look at org.xith3d.ui.hud.utils.WidgetMover and org.xith3d.ui.hud.utils.MouseHoverWidgetMover. WidgetMover moves any Widget type from its current location to some destination location. MouseHoverWidgetMover reacts on the onMouseEntered and onMouseLeft events and moves the Widget. It has a builtin delay and blocking functionality.

To use the MouseHoverWidgetMover you can use the following code:
Code:
class PinnableHeaderWidget extends WindowHeaderWidget
{
    private ToggleButton pinner;
   
    public ToggleButton getPinner()
    {
        return( pinner );
    }
   
    protected void init()
    {
        super.init();
       
        final Tuple2f cbLoc = getWidgetAssembler().getPosition( getCloseButton() );
       
        this.pinner = new ToggleButton( 16f, 16f, 1 );
        final Tuple2f threePixels = getContainer().getSizeOfPixels( 3, 3 );
        getWidgetAssembler().addWidget( pinner, cbLoc.x - threePixels.x - pinner.getWidth(),
                                                (getHeight() - pinner.getHeight()) / 2f );
    }
   
    public PinnableHeaderWidget(float width, float height, String title)
    {
        super( width, height, title );
    }
}

PinnableHeaderWidget headerWidget = new PinnableHeaderWidget( 150f, 20f, "Test" );

Frame f1 = new Frame( 150f, 300f, headerWidget );
f1.setDefaultCloseOperation( null );
this.addWidget( f1, this.getResX() - 30f, 200f );

final MouseHoverWidgetMover widgetMover = new MouseHoverWidgetMover( f1 );
widgetMover.setDestinationLocation( this.getResX() - f1.getWidth() - 10f, f1.getTop() );
widgetMover.setSpeed( 100f );
widgetMover.setMouseLeftDelay( 1000L );

headerWidget.getPinner().addButtonListener( new ButtonListener() {
    public void onButtonClicked(Button button, Object userObject)
    {
        widgetMover.setBlocked( ((ToggleButton)button).isToggled() );
    }
} );

This one is the same, but as a Frame extension:
Code:
class PinnableSlidingFrame extends Frame
{
    private MouseHoverWidgetMover widgetMover;
   
    protected WindowHeaderWidget createHeaderWidget(WindowHeaderWidget.Description headerDesc, String title)
    {
        return( new WindowHeaderWidget( getWidth(), 20f, headerDesc, title ) {
            protected void init()
            {
                super.init();
               
                final Tuple2f cbLoc = getWidgetAssembler().getPosition( getCloseButton() );
               
                ToggleButton pinner = new ToggleButton( 16f, 16f, 1 );
                final Tuple2f threePixels = getContainer().getSizeOfPixels( 3, 3 );
                getWidgetAssembler().addWidget( pinner, cbLoc.x - threePixels.x - pinner.getWidth(),
                                                        (getHeight() - pinner.getHeight()) / 2f );
               
                pinner.addButtonListener( new ButtonListener() {
                    public void onButtonClicked(Button button, Object userObject)
                    {
                        widgetMover.setBlocked( ((ToggleButton)button).isToggled() );
                    }
                } );
            }
        } );
    }
   
    public PinnableSlidingFrame(float width, float height, float locX, float locY, float destLocX, float destLocY, String title)
    {
        super( width, height, title );
       
        this.setDefaultCloseOperation( null );
       
        this.setLocation( locX, locY );
       
        this.widgetMover = new MouseHoverWidgetMover( this );
        widgetMover.setDestinationLocation( destLocX, destLocY );
        widgetMover.setSpeed( 100f );
        widgetMover.setMouseLeftDelay( 1000L );
    }
}

PinnableSlidingFrame f1 = new PinnableSlidingFrame( 150f, 300f,
                                                    this.getResX() - 30f, 200f,
                                                    this.getResX() - 160f, 200f,
                                                    "Test" );
this.addWidget( f1 );

And this one replaces the close Button:
Code:
class PinnableSlidingFrame extends Frame
{
    private ToggleButton pinner;
    private MouseHoverWidgetMover widgetMover;
   
    protected WindowHeaderWidget createHeaderWidget(WindowHeaderWidget.Description headerDesc, String title)
    {
        return( new WindowHeaderWidget( getWidth(), 20f, headerDesc, title ) {
            protected Button createCloseButton(Description desc)
            {
                PinnableSlidingFrame.this.pinner = new ToggleButton( 16f, 16f, 1 );
               
                return( pinner );
            }
        } );
    }
   
    protected void onCloseButtonClicked()
    {
        widgetMover.setBlocked( pinner.isToggled() );
    }
   
    public PinnableSlidingFrame(float width, float height, float locX, float locY, float destLocX, float destLocY, String title)
    {
        super( width, height, title );
       
        this.setLocation( locX, locY );
       
        this.widgetMover = new MouseHoverWidgetMover( this );
        widgetMover.setDestinationLocation( destLocX, destLocY );
        widgetMover.setSpeed( 100f );
        widgetMover.setMouseLeftDelay( 1000L );
    }
}

PinnableSlidingFrame f1 = new PinnableSlidingFrame( 150f, 300f,
                                                    this.getResX() - 30f, 200f,
                                                    this.getResX() - 160f, 200f,
                                                    "Test" );
this.addWidget( f1 );

Please tell me, if I missed anything.

Marvin
Logged
hawkwind
Getting respectable
***
Offline Offline

Posts: 363



View Profile Email
« Reply #18 on: 29. January 2007, 09:30:53 pm »

sounds good to me.  I am not ready to update yet, I will comment later when I do update.
Logged
Marvin Fröhlich
Xith Lord
Administrator
Guru
*****
Offline Offline

Posts: 4381


May the 4th, be with you...


View Profile
« Reply #19 on: 29. January 2007, 10:14:25 pm »

sounds good to me.  I am not ready to update yet, I will comment later when I do update.

ok
Logged
Pages: 1 [2]
Print
Jump to:  

Theme orange-lt created by panic