CHANGED: #1471 CViewBitmap is now part of NELGUI library, and is under NLGUI namespace.
--HG-- branch : gui-refactoringhg/feature/sse2
parent
5dd0ce01f6
commit
8b84170dec
@ -0,0 +1,146 @@
|
||||
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
|
||||
#ifndef NL_VIEW_BITMAP_H
|
||||
#define NL_VIEW_BITMAP_H
|
||||
|
||||
#include "nel/gui/view_base.h"
|
||||
#include "nel/3d/u_texture.h"
|
||||
#include "nel/gui/view_renderer.h"
|
||||
|
||||
namespace NLGUI
|
||||
{
|
||||
|
||||
/**
|
||||
* class implementing a bitmap view
|
||||
* \author Matthieu 'TrapII' Besson
|
||||
* \author Nevrax France
|
||||
* \date 2002
|
||||
*/
|
||||
class CViewBitmap : public CViewBase
|
||||
{
|
||||
public:
|
||||
DECLARE_UI_CLASS(CViewBitmap)
|
||||
enum EType { Stretched = 0, Tiled, TypeCount };
|
||||
public:
|
||||
|
||||
/// Constructor
|
||||
CViewBitmap(const TCtorParam ¶m) : CViewBase(param)
|
||||
{
|
||||
_Color = NLMISC::CRGBA(255,255,255,255);
|
||||
_Scale = false;
|
||||
_Rot = 0;
|
||||
_Flip = false;
|
||||
_Tile = false;
|
||||
_Align = 0;
|
||||
_Type = Stretched;
|
||||
_InheritGCAlpha = false;
|
||||
|
||||
// Default parameters for createTexture
|
||||
_TxtOffsetX = 0;
|
||||
_TxtOffsetY = 0;
|
||||
_TxtWidth = -1;
|
||||
_TxtHeight = -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* parse an xml node and initialize the base view mambers. Must call CViewBase::parse
|
||||
* \param cur : pointer to the xml node to be parsed
|
||||
* \param parentGroup : the parent group of the view
|
||||
* \partam id : a refence to the string that will receive the view ID
|
||||
* \return true if success
|
||||
*/
|
||||
bool parse(xmlNodePtr cur,CInterfaceGroup * parentGroup);
|
||||
virtual uint32 getMemory() { return (uint32)(sizeof(*this)+_Id.size()); }
|
||||
|
||||
virtual void updateCoords ();
|
||||
|
||||
/// Draw the view
|
||||
virtual void draw ();
|
||||
|
||||
bool getScale() const { return _Scale; }
|
||||
void setScale (bool s) { _Scale = s; }
|
||||
bool getTile() const { return _Tile; }
|
||||
void setTile (bool s) { _Tile = s; }
|
||||
void setColor (const NLMISC::CRGBA &r) { _Color = r; }
|
||||
|
||||
// Reflected
|
||||
|
||||
virtual void setTexture(const std::string & TxName);
|
||||
virtual std::string getTexture () const;
|
||||
|
||||
/** Force the bitmap to match current texture size
|
||||
* The 'scale' flag isnot modified
|
||||
*/
|
||||
void fitTexture();
|
||||
|
||||
bool isTextureValid() const { return _TextureId != -1; }
|
||||
|
||||
void setColorAsString(const std::string & col);
|
||||
std::string getColorAsString() const;
|
||||
|
||||
void setColorAsInt(sint32 col);
|
||||
sint32 getColorAsInt() const;
|
||||
|
||||
void setColorRGBA(NLMISC::CRGBA col);
|
||||
NLMISC::CRGBA getColorRGBA() const;
|
||||
|
||||
virtual sint32 getAlpha() const { return _Color.A; }
|
||||
virtual void setAlpha (sint32 a) { _Color.A = (uint8)a; }
|
||||
|
||||
REFLECT_EXPORT_START(CViewBitmap, CViewBase)
|
||||
REFLECT_STRING ("color", getColorAsString, setColorAsString);
|
||||
REFLECT_SINT32 ("color_as_int", getColorAsInt, setColorAsInt);
|
||||
REFLECT_RGBA ("color_rgba", getColorRGBA, setColorRGBA);
|
||||
REFLECT_SINT32 ("alpha", getAlpha, setAlpha);
|
||||
REFLECT_STRING ("texture", getTexture, setTexture);
|
||||
REFLECT_BOOL("scale", getScale, setScale);
|
||||
REFLECT_EXPORT_END
|
||||
|
||||
/// \from CInterfaceElement
|
||||
sint32 getMaxUsedW() const;
|
||||
sint32 getMinUsedW() const;
|
||||
|
||||
virtual void serial(NLMISC::IStream &f);
|
||||
|
||||
protected:
|
||||
CViewRenderer::CTextureId _TextureId; /// Accelerator
|
||||
NLMISC::CRGBA _Color;
|
||||
sint32 _Rot;
|
||||
sint32 _Align; /// 1st bit - Left/Right (0/1) 2nd bit - Bottom/Top (0/1)
|
||||
EType _Type;
|
||||
bool _Scale : 1;
|
||||
bool _Flip : 1;
|
||||
bool _Tile : 1;
|
||||
bool _InheritGCAlpha : 1;
|
||||
|
||||
// For single texture
|
||||
|
||||
sint32 _TxtOffsetX; // Offset X of the single texture
|
||||
sint32 _TxtOffsetY; // Offset Y of the single texture
|
||||
sint32 _TxtWidth; // Width of the single texture
|
||||
sint32 _TxtHeight; // Height of the single texture
|
||||
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif // NL_VIEW_BITMAP_H
|
||||
|
||||
/* End of view_bitmap.h */
|
@ -0,0 +1,315 @@
|
||||
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
|
||||
#include "nel/gui/view_bitmap.h"
|
||||
#include "nel/misc/xml_auto_ptr.h"
|
||||
#include "nel/gui/widget_manager.h"
|
||||
#include "nel/gui/interface_group.h"
|
||||
#include "nel/gui/group_container_base.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace NLMISC;
|
||||
using namespace NL3D;
|
||||
|
||||
|
||||
NLMISC_REGISTER_OBJECT(CViewBase, CViewBitmap, std::string, "bitmap");
|
||||
REGISTER_UI_CLASS(CViewBitmap)
|
||||
|
||||
namespace NLGUI
|
||||
{
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
bool CViewBitmap::parse(xmlNodePtr cur, CInterfaceGroup * parentGroup)
|
||||
{
|
||||
CXMLAutoPtr prop;
|
||||
|
||||
//try to get props that can be inherited from groups
|
||||
//if a property is not defined, try to find it in the parent group.
|
||||
//if it is undefined, set it to zero
|
||||
if (! CViewBase::parse(cur,parentGroup) )
|
||||
{
|
||||
string tmp = string("cannot parse view:")+getId()+", parent:"+parentGroup->getId();
|
||||
nlinfo (tmp.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
//try to get the NEEDED specific props
|
||||
prop= (char*) xmlGetProp( cur, (xmlChar*)"color" );
|
||||
_Color = CRGBA(255,255,255,255);
|
||||
if (prop)
|
||||
_Color = convertColor (prop);
|
||||
|
||||
prop = (char*) xmlGetProp( cur, (xmlChar*)"txtoffsetx" );
|
||||
_TxtOffsetX = 0;
|
||||
if (prop) fromString((const char*)prop, _TxtOffsetX);
|
||||
|
||||
prop = (char*) xmlGetProp( cur, (xmlChar*)"txtoffsety" );
|
||||
_TxtOffsetY = 0;
|
||||
if (prop) fromString((const char*)prop, _TxtOffsetY);
|
||||
|
||||
prop = (char*) xmlGetProp( cur, (xmlChar*)"txtwidth" );
|
||||
_TxtWidth = -1;
|
||||
if (prop) fromString((const char*)prop, _TxtWidth);
|
||||
|
||||
prop = (char*) xmlGetProp( cur, (xmlChar*)"txtheight" );
|
||||
_TxtHeight = -1;
|
||||
if (prop) fromString((const char*)prop, _TxtHeight);
|
||||
|
||||
prop = (char*) xmlGetProp( cur, (xmlChar*)"texture" );
|
||||
if (prop)
|
||||
{
|
||||
string TxName = (const char *) prop;
|
||||
TxName = strlwr (TxName);
|
||||
setTexture (TxName);
|
||||
//CInterfaceManager *pIM = CInterfaceManager::getInstance();
|
||||
//CViewRenderer &rVR = *CViewRenderer::getInstance();
|
||||
//_TextureId = rVR.getTextureIdFromName (TxName);
|
||||
}
|
||||
|
||||
prop = (char*) xmlGetProp( cur, (xmlChar*)"scale" );
|
||||
_Scale = false;
|
||||
if (prop)
|
||||
_Scale = convertBool(prop);
|
||||
|
||||
prop = (char*) xmlGetProp( cur, (xmlChar*)"rot" );
|
||||
_Rot = 0;
|
||||
if (prop)
|
||||
fromString((const char*)prop, _Rot);
|
||||
|
||||
prop = (char*) xmlGetProp( cur, (xmlChar*)"flip" );
|
||||
_Flip = false;
|
||||
if (prop)
|
||||
_Flip = convertBool(prop);
|
||||
|
||||
prop = (char*) xmlGetProp( cur, (xmlChar*)"tile" );
|
||||
_Tile = false;
|
||||
if (prop)
|
||||
_Tile = convertBool(prop);
|
||||
|
||||
prop = (char*) xmlGetProp (cur, (xmlChar*)"align");
|
||||
_Align = 0;
|
||||
if (prop)
|
||||
{
|
||||
const char *seekPtr = prop.getDatas();
|
||||
while (*seekPtr != 0)
|
||||
{
|
||||
if ((*seekPtr=='l')||(*seekPtr=='L'))
|
||||
{
|
||||
_Align &= ~1;
|
||||
}
|
||||
if ((*seekPtr=='r')||(*seekPtr=='R'))
|
||||
{
|
||||
_Align |= 1;
|
||||
}
|
||||
if ((*seekPtr=='b')||(*seekPtr=='B'))
|
||||
{
|
||||
_Align &= ~2;
|
||||
}
|
||||
if ((*seekPtr=='t')||(*seekPtr=='T'))
|
||||
{
|
||||
_Align |= 2;
|
||||
}
|
||||
++seekPtr;
|
||||
}
|
||||
}
|
||||
|
||||
_InheritGCAlpha = false;
|
||||
prop = (char*) xmlGetProp( cur, (xmlChar*)"inherit_gc_alpha" );
|
||||
if (prop)
|
||||
{
|
||||
_InheritGCAlpha = convertBool(prop);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void CViewBitmap::draw ()
|
||||
{
|
||||
CViewRenderer &rVR = *CViewRenderer::getInstance();
|
||||
|
||||
CRGBA col;
|
||||
if(getModulateGlobalColor())
|
||||
{
|
||||
col.modulateFromColor (_Color, CWidgetManager::getInstance()->getGlobalColorForContent());
|
||||
}
|
||||
else
|
||||
{
|
||||
col= _Color;
|
||||
col.A = (uint8)(((sint32)col.A*((sint32)CWidgetManager::getInstance()->getGlobalColorForContent().A+1))>>8);
|
||||
}
|
||||
|
||||
if (_InheritGCAlpha)
|
||||
{
|
||||
// search a parent container
|
||||
CInterfaceGroup *gr = getParent();
|
||||
while (gr)
|
||||
{
|
||||
if (gr->isGroupContainer())
|
||||
{
|
||||
CGroupContainerBase *gc = static_cast<CGroupContainerBase*>(gr);
|
||||
col.A = (uint8)(((sint32)col.A*((sint32)gc->getCurrentContainerAlpha()+1))>>8);
|
||||
break;
|
||||
}
|
||||
gr = gr->getParent();
|
||||
}
|
||||
}
|
||||
|
||||
if (_Scale && !_Tile)
|
||||
{
|
||||
rVR.drawRotFlipBitmap (_RenderLayer, _XReal, _YReal,
|
||||
_WReal, _HReal,
|
||||
(uint8)_Rot, _Flip,
|
||||
_TextureId,
|
||||
col );
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!_Tile)
|
||||
{
|
||||
rVR.draw11RotFlipBitmap (_RenderLayer, _XReal, _YReal,
|
||||
(uint8)_Rot, _Flip,
|
||||
_TextureId,
|
||||
col);
|
||||
}
|
||||
else
|
||||
{
|
||||
rVR.drawRotFlipBitmapTiled(_RenderLayer, _XReal, _YReal,
|
||||
_WReal, _HReal,
|
||||
(uint8)_Rot, _Flip,
|
||||
_TextureId,
|
||||
_Align,
|
||||
col);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void CViewBitmap::updateCoords()
|
||||
{
|
||||
if (!_Scale)
|
||||
{
|
||||
CViewRenderer &rVR = *CViewRenderer::getInstance();
|
||||
sint32 txw, txh;
|
||||
rVR.getTextureSizeFromId (_TextureId, txw, txh);
|
||||
_W = txw;
|
||||
_H = txh;
|
||||
}
|
||||
CViewBase::updateCoords();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void CViewBitmap::setTexture(const std::string & TxName)
|
||||
{
|
||||
// CInterfaceManager *pIM = CInterfaceManager::getInstance();
|
||||
// CViewRenderer &rVR = *CViewRenderer::getInstance();
|
||||
|
||||
_TextureId.setTexture (TxName.c_str (), _TxtOffsetX, _TxtOffsetY, _TxtWidth, _TxtHeight, false);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
std::string CViewBitmap::getTexture () const
|
||||
{
|
||||
CViewRenderer &rVR = *CViewRenderer::getInstance();
|
||||
return rVR.getTextureNameFromId (_TextureId);
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
void CViewBitmap::fitTexture()
|
||||
{
|
||||
CViewRenderer &rVR = *CViewRenderer::getInstance();
|
||||
sint32 w, h;
|
||||
rVR.getTextureSizeFromId(_TextureId, w, h);
|
||||
setW(w);
|
||||
setH(h);
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
void CViewBitmap::setColorAsString(const std::string & col)
|
||||
{
|
||||
_Color = convertColor (col.c_str());
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
std::string CViewBitmap::getColorAsString() const
|
||||
{
|
||||
return NLMISC::toString(_Color.R) + " " + NLMISC::toString(_Color.G) + " " + NLMISC::toString(_Color.B) + " " + NLMISC::toString(_Color.A);
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
void CViewBitmap::setColorAsInt(sint32 col)
|
||||
{
|
||||
_Color.setPacked(col);
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
sint32 CViewBitmap::getColorAsInt() const
|
||||
{
|
||||
return _Color.getPacked();
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
void CViewBitmap::setColorRGBA(NLMISC::CRGBA col)
|
||||
{
|
||||
_Color = col;
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
NLMISC::CRGBA CViewBitmap::getColorRGBA() const
|
||||
{
|
||||
return _Color;
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
sint32 CViewBitmap::getMaxUsedW() const
|
||||
{
|
||||
sint32 txw, txh;
|
||||
CViewRenderer &rVR = *CViewRenderer::getInstance();
|
||||
rVR.getTextureSizeFromId (_TextureId, txw, txh);
|
||||
return txw;
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
sint32 CViewBitmap::getMinUsedW() const
|
||||
{
|
||||
return getMaxUsedW();
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
void CViewBitmap::serial(NLMISC::IStream &f)
|
||||
{
|
||||
CViewBase::serial(f);
|
||||
f.serial(_TextureId);
|
||||
f.serial(_Color);
|
||||
f.serial(_Rot);
|
||||
f.serialEnum(_Align);
|
||||
f.serialEnum(_Type);
|
||||
nlSerialBitBool(f, _Scale);
|
||||
nlSerialBitBool(f, _Flip);
|
||||
nlSerialBitBool(f, _Tile);
|
||||
nlSerialBitBool(f, _InheritGCAlpha);
|
||||
f.serial(_TxtOffsetX);
|
||||
f.serial(_TxtOffsetY);
|
||||
f.serial(_TxtWidth);
|
||||
f.serial(_TxtHeight);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
@ -1,311 +0,0 @@
|
||||
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
|
||||
#include "view_bitmap.h"
|
||||
#include "nel/misc/xml_auto_ptr.h"
|
||||
#include "nel/gui/widget_manager.h"
|
||||
#include "nel/gui/interface_group.h"
|
||||
#include "nel/gui/group_container_base.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace NLMISC;
|
||||
using namespace NL3D;
|
||||
|
||||
|
||||
NLMISC_REGISTER_OBJECT(CViewBase, CViewBitmap, std::string, "bitmap");
|
||||
REGISTER_UI_CLASS(CViewBitmap)
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
bool CViewBitmap::parse(xmlNodePtr cur, CInterfaceGroup * parentGroup)
|
||||
{
|
||||
CXMLAutoPtr prop;
|
||||
|
||||
//try to get props that can be inherited from groups
|
||||
//if a property is not defined, try to find it in the parent group.
|
||||
//if it is undefined, set it to zero
|
||||
if (! CViewBase::parse(cur,parentGroup) )
|
||||
{
|
||||
string tmp = string("cannot parse view:")+getId()+", parent:"+parentGroup->getId();
|
||||
nlinfo (tmp.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
//try to get the NEEDED specific props
|
||||
prop= (char*) xmlGetProp( cur, (xmlChar*)"color" );
|
||||
_Color = CRGBA(255,255,255,255);
|
||||
if (prop)
|
||||
_Color = convertColor (prop);
|
||||
|
||||
prop = (char*) xmlGetProp( cur, (xmlChar*)"txtoffsetx" );
|
||||
_TxtOffsetX = 0;
|
||||
if (prop) fromString((const char*)prop, _TxtOffsetX);
|
||||
|
||||
prop = (char*) xmlGetProp( cur, (xmlChar*)"txtoffsety" );
|
||||
_TxtOffsetY = 0;
|
||||
if (prop) fromString((const char*)prop, _TxtOffsetY);
|
||||
|
||||
prop = (char*) xmlGetProp( cur, (xmlChar*)"txtwidth" );
|
||||
_TxtWidth = -1;
|
||||
if (prop) fromString((const char*)prop, _TxtWidth);
|
||||
|
||||
prop = (char*) xmlGetProp( cur, (xmlChar*)"txtheight" );
|
||||
_TxtHeight = -1;
|
||||
if (prop) fromString((const char*)prop, _TxtHeight);
|
||||
|
||||
prop = (char*) xmlGetProp( cur, (xmlChar*)"texture" );
|
||||
if (prop)
|
||||
{
|
||||
string TxName = (const char *) prop;
|
||||
TxName = strlwr (TxName);
|
||||
setTexture (TxName);
|
||||
//CInterfaceManager *pIM = CInterfaceManager::getInstance();
|
||||
//CViewRenderer &rVR = *CViewRenderer::getInstance();
|
||||
//_TextureId = rVR.getTextureIdFromName (TxName);
|
||||
}
|
||||
|
||||
prop = (char*) xmlGetProp( cur, (xmlChar*)"scale" );
|
||||
_Scale = false;
|
||||
if (prop)
|
||||
_Scale = convertBool(prop);
|
||||
|
||||
prop = (char*) xmlGetProp( cur, (xmlChar*)"rot" );
|
||||
_Rot = 0;
|
||||
if (prop)
|
||||
fromString((const char*)prop, _Rot);
|
||||
|
||||
prop = (char*) xmlGetProp( cur, (xmlChar*)"flip" );
|
||||
_Flip = false;
|
||||
if (prop)
|
||||
_Flip = convertBool(prop);
|
||||
|
||||
prop = (char*) xmlGetProp( cur, (xmlChar*)"tile" );
|
||||
_Tile = false;
|
||||
if (prop)
|
||||
_Tile = convertBool(prop);
|
||||
|
||||
prop = (char*) xmlGetProp (cur, (xmlChar*)"align");
|
||||
_Align = 0;
|
||||
if (prop)
|
||||
{
|
||||
const char *seekPtr = prop.getDatas();
|
||||
while (*seekPtr != 0)
|
||||
{
|
||||
if ((*seekPtr=='l')||(*seekPtr=='L'))
|
||||
{
|
||||
_Align &= ~1;
|
||||
}
|
||||
if ((*seekPtr=='r')||(*seekPtr=='R'))
|
||||
{
|
||||
_Align |= 1;
|
||||
}
|
||||
if ((*seekPtr=='b')||(*seekPtr=='B'))
|
||||
{
|
||||
_Align &= ~2;
|
||||
}
|
||||
if ((*seekPtr=='t')||(*seekPtr=='T'))
|
||||
{
|
||||
_Align |= 2;
|
||||
}
|
||||
++seekPtr;
|
||||
}
|
||||
}
|
||||
|
||||
_InheritGCAlpha = false;
|
||||
prop = (char*) xmlGetProp( cur, (xmlChar*)"inherit_gc_alpha" );
|
||||
if (prop)
|
||||
{
|
||||
_InheritGCAlpha = convertBool(prop);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void CViewBitmap::draw ()
|
||||
{
|
||||
CViewRenderer &rVR = *CViewRenderer::getInstance();
|
||||
|
||||
CRGBA col;
|
||||
if(getModulateGlobalColor())
|
||||
{
|
||||
col.modulateFromColor (_Color, CWidgetManager::getInstance()->getGlobalColorForContent());
|
||||
}
|
||||
else
|
||||
{
|
||||
col= _Color;
|
||||
col.A = (uint8)(((sint32)col.A*((sint32)CWidgetManager::getInstance()->getGlobalColorForContent().A+1))>>8);
|
||||
}
|
||||
|
||||
if (_InheritGCAlpha)
|
||||
{
|
||||
// search a parent container
|
||||
CInterfaceGroup *gr = getParent();
|
||||
while (gr)
|
||||
{
|
||||
if (gr->isGroupContainer())
|
||||
{
|
||||
CGroupContainerBase *gc = static_cast<CGroupContainerBase*>(gr);
|
||||
col.A = (uint8)(((sint32)col.A*((sint32)gc->getCurrentContainerAlpha()+1))>>8);
|
||||
break;
|
||||
}
|
||||
gr = gr->getParent();
|
||||
}
|
||||
}
|
||||
|
||||
if (_Scale && !_Tile)
|
||||
{
|
||||
rVR.drawRotFlipBitmap (_RenderLayer, _XReal, _YReal,
|
||||
_WReal, _HReal,
|
||||
(uint8)_Rot, _Flip,
|
||||
_TextureId,
|
||||
col );
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!_Tile)
|
||||
{
|
||||
rVR.draw11RotFlipBitmap (_RenderLayer, _XReal, _YReal,
|
||||
(uint8)_Rot, _Flip,
|
||||
_TextureId,
|
||||
col);
|
||||
}
|
||||
else
|
||||
{
|
||||
rVR.drawRotFlipBitmapTiled(_RenderLayer, _XReal, _YReal,
|
||||
_WReal, _HReal,
|
||||
(uint8)_Rot, _Flip,
|
||||
_TextureId,
|
||||
_Align,
|
||||
col);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void CViewBitmap::updateCoords()
|
||||
{
|
||||
if (!_Scale)
|
||||
{
|
||||
CViewRenderer &rVR = *CViewRenderer::getInstance();
|
||||
sint32 txw, txh;
|
||||
rVR.getTextureSizeFromId (_TextureId, txw, txh);
|
||||
_W = txw;
|
||||
_H = txh;
|
||||
}
|
||||
CViewBase::updateCoords();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void CViewBitmap::setTexture(const std::string & TxName)
|
||||
{
|
||||
// CInterfaceManager *pIM = CInterfaceManager::getInstance();
|
||||
// CViewRenderer &rVR = *CViewRenderer::getInstance();
|
||||
|
||||
_TextureId.setTexture (TxName.c_str (), _TxtOffsetX, _TxtOffsetY, _TxtWidth, _TxtHeight, false);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
std::string CViewBitmap::getTexture () const
|
||||
{
|
||||
CViewRenderer &rVR = *CViewRenderer::getInstance();
|
||||
return rVR.getTextureNameFromId (_TextureId);
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
void CViewBitmap::fitTexture()
|
||||
{
|
||||
CViewRenderer &rVR = *CViewRenderer::getInstance();
|
||||
sint32 w, h;
|
||||
rVR.getTextureSizeFromId(_TextureId, w, h);
|
||||
setW(w);
|
||||
setH(h);
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
void CViewBitmap::setColorAsString(const std::string & col)
|
||||
{
|
||||
_Color = convertColor (col.c_str());
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
std::string CViewBitmap::getColorAsString() const
|
||||
{
|
||||
return NLMISC::toString(_Color.R) + " " + NLMISC::toString(_Color.G) + " " + NLMISC::toString(_Color.B) + " " + NLMISC::toString(_Color.A);
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
void CViewBitmap::setColorAsInt(sint32 col)
|
||||
{
|
||||
_Color.setPacked(col);
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
sint32 CViewBitmap::getColorAsInt() const
|
||||
{
|
||||
return _Color.getPacked();
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
void CViewBitmap::setColorRGBA(NLMISC::CRGBA col)
|
||||
{
|
||||
_Color = col;
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
NLMISC::CRGBA CViewBitmap::getColorRGBA() const
|
||||
{
|
||||
return _Color;
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
sint32 CViewBitmap::getMaxUsedW() const
|
||||
{
|
||||
sint32 txw, txh;
|
||||
CViewRenderer &rVR = *CViewRenderer::getInstance();
|
||||
rVR.getTextureSizeFromId (_TextureId, txw, txh);
|
||||
return txw;
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
sint32 CViewBitmap::getMinUsedW() const
|
||||
{
|
||||
return getMaxUsedW();
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
void CViewBitmap::serial(NLMISC::IStream &f)
|
||||
{
|
||||
CViewBase::serial(f);
|
||||
f.serial(_TextureId);
|
||||
f.serial(_Color);
|
||||
f.serial(_Rot);
|
||||
f.serialEnum(_Align);
|
||||
f.serialEnum(_Type);
|
||||
nlSerialBitBool(f, _Scale);
|
||||
nlSerialBitBool(f, _Flip);
|
||||
nlSerialBitBool(f, _Tile);
|
||||
nlSerialBitBool(f, _InheritGCAlpha);
|
||||
f.serial(_TxtOffsetX);
|
||||
f.serial(_TxtOffsetY);
|
||||
f.serial(_TxtWidth);
|
||||
f.serial(_TxtHeight);
|
||||
}
|
||||
|
||||
|
||||
// ***************************************************************************
|
@ -1,141 +0,0 @@
|
||||
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
|
||||
#ifndef NL_VIEW_BITMAP_H
|
||||
#define NL_VIEW_BITMAP_H
|
||||
|
||||
#include "nel/gui/view_base.h"
|
||||
#include "nel/3d/u_texture.h"
|
||||
#include "nel/gui/view_renderer.h"
|
||||
|
||||
/**
|
||||
* class implementing a bitmap view
|
||||
* \author Matthieu 'TrapII' Besson
|
||||
* \author Nevrax France
|
||||
* \date 2002
|
||||
*/
|
||||
class CViewBitmap : public CViewBase
|
||||
{
|
||||
public:
|
||||
DECLARE_UI_CLASS(CViewBitmap)
|
||||
enum EType { Stretched = 0, Tiled, TypeCount };
|
||||
public:
|
||||
|
||||
/// Constructor
|
||||
CViewBitmap(const TCtorParam ¶m) : CViewBase(param)
|
||||
{
|
||||
_Color = NLMISC::CRGBA(255,255,255,255);
|
||||
_Scale = false;
|
||||
_Rot = 0;
|
||||
_Flip = false;
|
||||
_Tile = false;
|
||||
_Align = 0;
|
||||
_Type = Stretched;
|
||||
_InheritGCAlpha = false;
|
||||
|
||||
// Default parameters for createTexture
|
||||
_TxtOffsetX = 0;
|
||||
_TxtOffsetY = 0;
|
||||
_TxtWidth = -1;
|
||||
_TxtHeight = -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* parse an xml node and initialize the base view mambers. Must call CViewBase::parse
|
||||
* \param cur : pointer to the xml node to be parsed
|
||||
* \param parentGroup : the parent group of the view
|
||||
* \partam id : a refence to the string that will receive the view ID
|
||||
* \return true if success
|
||||
*/
|
||||
bool parse(xmlNodePtr cur,CInterfaceGroup * parentGroup);
|
||||
virtual uint32 getMemory() { return (uint32)(sizeof(*this)+_Id.size()); }
|
||||
|
||||
virtual void updateCoords ();
|
||||
|
||||
/// Draw the view
|
||||
virtual void draw ();
|
||||
|
||||
bool getScale() const { return _Scale; }
|
||||
void setScale (bool s) { _Scale = s; }
|
||||
bool getTile() const { return _Tile; }
|
||||
void setTile (bool s) { _Tile = s; }
|
||||
void setColor (const NLMISC::CRGBA &r) { _Color = r; }
|
||||
|
||||
// Reflected
|
||||
|
||||
virtual void setTexture(const std::string & TxName);
|
||||
virtual std::string getTexture () const;
|
||||
|
||||
/** Force the bitmap to match current texture size
|
||||
* The 'scale' flag isnot modified
|
||||
*/
|
||||
void fitTexture();
|
||||
|
||||
bool isTextureValid() const { return _TextureId != -1; }
|
||||
|
||||
void setColorAsString(const std::string & col);
|
||||
std::string getColorAsString() const;
|
||||
|
||||
void setColorAsInt(sint32 col);
|
||||
sint32 getColorAsInt() const;
|
||||
|
||||
void setColorRGBA(NLMISC::CRGBA col);
|
||||
NLMISC::CRGBA getColorRGBA() const;
|
||||
|
||||
virtual sint32 getAlpha() const { return _Color.A; }
|
||||
virtual void setAlpha (sint32 a) { _Color.A = (uint8)a; }
|
||||
|
||||
REFLECT_EXPORT_START(CViewBitmap, CViewBase)
|
||||
REFLECT_STRING ("color", getColorAsString, setColorAsString);
|
||||
REFLECT_SINT32 ("color_as_int", getColorAsInt, setColorAsInt);
|
||||
REFLECT_RGBA ("color_rgba", getColorRGBA, setColorRGBA);
|
||||
REFLECT_SINT32 ("alpha", getAlpha, setAlpha);
|
||||
REFLECT_STRING ("texture", getTexture, setTexture);
|
||||
REFLECT_BOOL("scale", getScale, setScale);
|
||||
REFLECT_EXPORT_END
|
||||
|
||||
/// \from CInterfaceElement
|
||||
sint32 getMaxUsedW() const;
|
||||
sint32 getMinUsedW() const;
|
||||
|
||||
virtual void serial(NLMISC::IStream &f);
|
||||
|
||||
protected:
|
||||
CViewRenderer::CTextureId _TextureId; /// Accelerator
|
||||
NLMISC::CRGBA _Color;
|
||||
sint32 _Rot;
|
||||
sint32 _Align; /// 1st bit - Left/Right (0/1) 2nd bit - Bottom/Top (0/1)
|
||||
EType _Type;
|
||||
bool _Scale : 1;
|
||||
bool _Flip : 1;
|
||||
bool _Tile : 1;
|
||||
bool _InheritGCAlpha : 1;
|
||||
|
||||
// For single texture
|
||||
|
||||
sint32 _TxtOffsetX; // Offset X of the single texture
|
||||
sint32 _TxtOffsetY; // Offset Y of the single texture
|
||||
sint32 _TxtWidth; // Width of the single texture
|
||||
sint32 _TxtHeight; // Height of the single texture
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif // NL_VIEW_BITMAP_H
|
||||
|
||||
/* End of view_bitmap.h */
|
Loading…
Reference in New Issue