/*****************************************************************************
 * $LastChangedDate: 2011-04-09 21:58:06 -0400 (Sat, 09 Apr 2011) $
 * @file
 * @author  Jim E. Brooks  http://www.palomino3d.org
 * @brief   HUD (2D box).
 *//*
 * LEGAL:   COPYRIGHT (C) 2008 JIM E. BROOKS
 *          THIS SOURCE CODE IS RELEASED UNDER THE TERMS
 *          OF THE GNU GENERAL PUBLIC LICENSE VERSION 2 (GPL 2).
 *****************************************************************************/

#ifndef HUD_HUD_BOX_HH
#define HUD_HUD_BOX_HH 1

#include "gfx/graphics.hh"
using namespace gfx;

namespace hud {

////////////////////////////////////////////////////////////////////////////
/// @brief Draws a 2D box.
///
/// Set2D() vs. Set3D():
/// --------------------
/// HudBox is a 2D box.
/// But it can be defined in terms of either 2D or 3D.
/// Set3D() is for enclosing a 3D object in world space.
/// It computes a 2D rectangle in terms of a 3D position and 2D width,height.
///
class HudBox : public HudObject
{
PREVENT_COPYING(HudBox)
typedef HudObject Parent;
friend class Hud;
public:
                    HudBox( const Rect<int>& rect = Rect<int>(), const RGBA color = RGBA() );
                    ~HudBox();
    void            Set2D( const Rect<int>& rect );
    void            Set3D( const WorldVertex& pos3, const uint width2, const uint height2 );
    void            SetColor( const RGBA color ) { mColor = color; }
    void            SetDrawX( const bool drawX ) { mDrawX = drawX; }

private:
    virtual void    Update( View& view );

private:
    /// @brief Optional definition of 2D box in 3D terms.
    struct Definition3D
    {
        Definition3D( void )
        : mValid(false), mPos3(0,0,0), mWidth2(0), mHeight2(0)
        { }

        bool        mValid;     ///< if false, HudBox is defined by 2D HudBox::mRect
        WorldVertex mPos3;      ///< 3D position
        uint        mWidth2;    ///< 2D width of box
        uint        mHeight2;   ///< 2D height of box
    };

private:
    Rect<int>       mRect;      ///< box's rectangle
    RGBA            mColor;     ///< box's color
    Definition3D    m3D;        ///< optional definition in terms of 3D world space
    bool            mDrawX;     ///< draw X over box (to indicate radar-lock)
public:
    DECLARE_TYPESIG(TYPESIG_HUD_BOX)
};

} // namespace hud

#endif // HUD_HUD_BOX_HH
