Remove more dead code (#108)

This commit is contained in:
sfan5
2022-06-01 15:03:52 +02:00
committed by GitHub
parent 128cf1696c
commit aa095d9525
91 changed files with 8 additions and 14864 deletions

View File

@ -1,167 +0,0 @@
// Copyright (C) 2002-2012 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#include "CDefaultGUIElementFactory.h"
#ifdef _IRR_COMPILE_WITH_GUI_
#include "IGUIEnvironment.h"
#include "IGUIButton.h"
#include "IGUICheckBox.h"
#include "IGUIColorSelectDialog.h"
#include "IGUIComboBox.h"
#include "IGUIContextMenu.h"
#include "IGUIEditBox.h"
#include "IGUIFileOpenDialog.h"
#include "IGUIInOutFader.h"
#include "IGUIImage.h"
#include "IGUIListBox.h"
#include "IGUIMeshViewer.h"
#include "IGUIScrollBar.h"
#include "IGUISpinBox.h"
#include "IGUIStaticText.h"
#include "IGUITabControl.h"
#include "IGUITable.h"
#include "IGUIToolbar.h"
#include "IGUIWindow.h"
#include "IGUITreeView.h"
#include "IGUIProfiler.h"
namespace irr
{
namespace gui
{
CDefaultGUIElementFactory::CDefaultGUIElementFactory(IGUIEnvironment* env)
: Environment(env)
{
#ifdef _DEBUG
setDebugName("CDefaultGUIElementFactory");
#endif
// don't grab the gui environment here to prevent cyclic references
}
//! adds an element to the env based on its type id
IGUIElement* CDefaultGUIElementFactory::addGUIElement(EGUI_ELEMENT_TYPE type, IGUIElement* parent)
{
switch(type)
{
case EGUIET_BUTTON:
return Environment->addButton(core::rect<s32>(0,0,100,100),parent);
case EGUIET_CHECK_BOX:
return Environment->addCheckBox(false, core::rect<s32>(0,0,100,100), parent);
case EGUIET_COLOR_SELECT_DIALOG:
return Environment->addColorSelectDialog(0,true,parent);
case EGUIET_COMBO_BOX:
return Environment->addComboBox(core::rect<s32>(0,0,100,100),parent);
case EGUIET_CONTEXT_MENU:
return Environment->addContextMenu(core::rect<s32>(0,0,100,100),parent);
case EGUIET_MENU:
return Environment->addMenu(parent);
case EGUIET_EDIT_BOX:
return Environment->addEditBox(0,core::rect<s32>(0,0,100,100),true, parent);
case EGUIET_FILE_OPEN_DIALOG:
return Environment->addFileOpenDialog(0,true,parent);
case EGUIET_IMAGE:
return Environment->addImage(0,core::position2di(0,0), true, parent);
case EGUIET_IN_OUT_FADER:
return Environment->addInOutFader(0,parent);
case EGUIET_LIST_BOX:
return Environment->addListBox(core::rect<s32>(0,0,100,100),parent);
case EGUIET_MESH_VIEWER:
return Environment->addMeshViewer(core::rect<s32>(0,0,100,100),parent);
case EGUIET_MODAL_SCREEN:
return Environment->addModalScreen(parent);
case EGUIET_MESSAGE_BOX:
return Environment->addMessageBox(0,0,false,0,parent);
case EGUIET_SCROLL_BAR:
return Environment->addScrollBar(false,core::rect<s32>(0,0,100,100),parent);
case EGUIET_STATIC_TEXT:
return Environment->addStaticText(0,core::rect<s32>(0,0,100,100),false,true,parent);
case EGUIET_TAB:
return Environment->addTab(core::rect<s32>(0,0,100,100),parent);
case EGUIET_TAB_CONTROL:
return Environment->addTabControl(core::rect<s32>(0,0,100,100),parent);
case EGUIET_TABLE:
return Environment->addTable(core::rect<s32>(0,0,100,100), parent);
case EGUIET_TOOL_BAR:
return Environment->addToolBar(parent);
case EGUIET_WINDOW:
return Environment->addWindow(core::rect<s32>(0,0,100,100),false,0,parent);
case EGUIET_SPIN_BOX:
return Environment->addSpinBox(L"0.0", core::rect<s32>(0,0,100,100), true, parent);
case EGUIET_TREE_VIEW:
return Environment->addTreeView(core::rect<s32>(0,0,100,100),parent);
case EGUIET_PROFILER:
return Environment->addProfilerDisplay(core::rect<s32>(0,0,100,100), parent);
default:
return 0;
}
}
//! adds an element to the environment based on its type name
IGUIElement* CDefaultGUIElementFactory::addGUIElement(const c8* typeName, IGUIElement* parent)
{
return addGUIElement( getTypeFromName(typeName), parent );
}
//! Returns the amount of element types this factory is able to create.
s32 CDefaultGUIElementFactory::getCreatableGUIElementTypeCount() const
{
return EGUIET_COUNT;
}
//! Returns the type of a creatable element type.
EGUI_ELEMENT_TYPE CDefaultGUIElementFactory::getCreateableGUIElementType(s32 idx) const
{
if (idx>=0 && idx<EGUIET_COUNT)
return (EGUI_ELEMENT_TYPE)idx;
return EGUIET_ELEMENT;
}
//! Returns the type name of a creatable element type.
const c8* CDefaultGUIElementFactory::getCreateableGUIElementTypeName(s32 idx) const
{
if (idx>=0 && idx<EGUIET_COUNT)
return GUIElementTypeNames[idx];
return 0;
}
//! Returns the type name of a creatable element type.
const c8* CDefaultGUIElementFactory::getCreateableGUIElementTypeName(EGUI_ELEMENT_TYPE type) const
{
// for this factory, type == index
if (type>=0 && type<EGUIET_COUNT)
return GUIElementTypeNames[type];
return 0;
}
EGUI_ELEMENT_TYPE CDefaultGUIElementFactory::getTypeFromName(const c8* name) const
{
for ( u32 i=0; GUIElementTypeNames[i]; ++i)
if (!strcmp(name, GUIElementTypeNames[i]) )
return (EGUI_ELEMENT_TYPE)i;
return EGUIET_ELEMENT;
}
} // end namespace gui
} // end namespace irr
#endif // _IRR_COMPILE_WITH_GUI_

View File

@ -1,70 +0,0 @@
// Copyright (C) 2002-2012 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __C_DEFAULT_GUI_ELEMENT_FACTORY_H_INCLUDED__
#define __C_DEFAULT_GUI_ELEMENT_FACTORY_H_INCLUDED__
#include "IrrCompileConfig.h"
#ifdef _IRR_COMPILE_WITH_GUI_
#include "IGUIElementFactory.h"
namespace irr
{
namespace gui
{
class IGUIElement;
class IGUIEnvironment;
//! This interface makes it possible to dynamically create gui elements.
class CDefaultGUIElementFactory : public IGUIElementFactory
{
public:
CDefaultGUIElementFactory(IGUIEnvironment* env);
//! Adds an element to the gui environment based on its type id.
/** \param type: Type of the element to add.
\param parent: Parent scene node of the new element. A value of 0 adds it to the root.
\return Returns pointer to the new element or 0 if unsuccessful. */
virtual IGUIElement* addGUIElement(EGUI_ELEMENT_TYPE type, IGUIElement* parent=0) _IRR_OVERRIDE_;
//! Adds a GUI element to the GUI Environment based on its type name.
/** \param typeName: Type name of the element to add. Taken from the GUIElementTypeNames c8* array.
\param parent: Parent scene node of the new element. A value of 0 adds it to the root.
\return Returns pointer to the new element or 0 if unsuccessful. */
virtual IGUIElement* addGUIElement(const c8* typeName, IGUIElement* parent=0) _IRR_OVERRIDE_;
//! Returns the amount of GUI element types this factory is able to create.
virtual s32 getCreatableGUIElementTypeCount() const _IRR_OVERRIDE_;
//! Returns the type of a createable GUI element type based on the index.
/** \param idx: Index of the element type in this factory. The value must be equal or greater than 0
and lower than getCreatableGUIElementTypeCount(). */
virtual EGUI_ELEMENT_TYPE getCreateableGUIElementType(s32 idx) const _IRR_OVERRIDE_;
//! Returns the type name of a createable GUI element type based on the index.
/** \param idx: Index of the element type in this factory. The value must be equal or greater than 0
and lower than getCreatableGUIElementTypeCount(). */
virtual const c8* getCreateableGUIElementTypeName(s32 idx) const _IRR_OVERRIDE_;
//! Returns the type name of a createable GUI element based on its type.
/** \param type: Type of the GUI element.
\return: Returns the name of the type if this factory can create it, otherwise it returns 0. */
virtual const c8* getCreateableGUIElementTypeName(EGUI_ELEMENT_TYPE type) const _IRR_OVERRIDE_;
private:
EGUI_ELEMENT_TYPE getTypeFromName(const c8* name) const;
IGUIEnvironment* Environment;
};
} // end namespace gui
} // end namespace irr
#endif // _IRR_COMPILE_WITH_GUI_
#endif // __C_DEFAULT_GUI_ELEMENT_FACTORY_H_INCLUDED__

View File

@ -1,122 +0,0 @@
// Copyright (C) 2002-2012 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#include "CDefaultSceneNodeFactory.h"
#include "ISceneManager.h"
#include "IDummyTransformationSceneNode.h"
#include "ICameraSceneNode.h"
#include "IBillboardSceneNode.h"
#include "IAnimatedMeshSceneNode.h"
#include "IMeshSceneNode.h"
namespace irr
{
namespace scene
{
CDefaultSceneNodeFactory::CDefaultSceneNodeFactory(ISceneManager* mgr)
: Manager(mgr)
{
#ifdef _DEBUG
setDebugName("CDefaultSceneNodeFactory");
#endif
// don't grab the scene manager here to prevent cyclic references
SupportedSceneNodeTypes.push_back(SSceneNodeTypePair(ESNT_MESH, "mesh"));
SupportedSceneNodeTypes.push_back(SSceneNodeTypePair(ESNT_EMPTY, "empty"));
SupportedSceneNodeTypes.push_back(SSceneNodeTypePair(ESNT_DUMMY_TRANSFORMATION, "dummyTransformation"));
SupportedSceneNodeTypes.push_back(SSceneNodeTypePair(ESNT_CAMERA, "camera"));
SupportedSceneNodeTypes.push_back(SSceneNodeTypePair(ESNT_BILLBOARD, "billBoard"));
SupportedSceneNodeTypes.push_back(SSceneNodeTypePair(ESNT_ANIMATED_MESH, "animatedMesh"));
}
//! adds a scene node to the scene graph based on its type id
ISceneNode* CDefaultSceneNodeFactory::addSceneNode(ESCENE_NODE_TYPE type, ISceneNode* parent)
{
switch(type)
{
case ESNT_MESH:
return Manager->addMeshSceneNode(0, parent, -1, core::vector3df(),
core::vector3df(), core::vector3df(1,1,1), true);
case ESNT_EMPTY:
return Manager->addEmptySceneNode(parent);
case ESNT_DUMMY_TRANSFORMATION:
return Manager->addDummyTransformationSceneNode(parent);
case ESNT_CAMERA:
return Manager->addCameraSceneNode(parent);
case ESNT_BILLBOARD:
return Manager->addBillboardSceneNode(parent);
case ESNT_ANIMATED_MESH:
return Manager->addAnimatedMeshSceneNode(0, parent, -1, core::vector3df(),
core::vector3df(), core::vector3df(1,1,1), true);
default:
break;
}
return 0;
}
//! adds a scene node to the scene graph based on its type name
ISceneNode* CDefaultSceneNodeFactory::addSceneNode(const c8* typeName, ISceneNode* parent)
{
return addSceneNode( getTypeFromName(typeName), parent );
}
//! returns amount of scene node types this factory is able to create
u32 CDefaultSceneNodeFactory::getCreatableSceneNodeTypeCount() const
{
return SupportedSceneNodeTypes.size();
}
//! returns type of a creatable scene node type
ESCENE_NODE_TYPE CDefaultSceneNodeFactory::getCreateableSceneNodeType(u32 idx) const
{
if (idx<SupportedSceneNodeTypes.size())
return SupportedSceneNodeTypes[idx].Type;
else
return ESNT_UNKNOWN;
}
//! returns type name of a creatable scene node type
const c8* CDefaultSceneNodeFactory::getCreateableSceneNodeTypeName(u32 idx) const
{
if (idx<SupportedSceneNodeTypes.size())
return SupportedSceneNodeTypes[idx].TypeName.c_str();
else
return 0;
}
//! returns type name of a creatable scene node type
const c8* CDefaultSceneNodeFactory::getCreateableSceneNodeTypeName(ESCENE_NODE_TYPE type) const
{
for (u32 i=0; i<SupportedSceneNodeTypes.size(); ++i)
if (SupportedSceneNodeTypes[i].Type == type)
return SupportedSceneNodeTypes[i].TypeName.c_str();
return 0;
}
ESCENE_NODE_TYPE CDefaultSceneNodeFactory::getTypeFromName(const c8* name) const
{
for (u32 i=0; i<SupportedSceneNodeTypes.size(); ++i)
if (SupportedSceneNodeTypes[i].TypeName == name)
return SupportedSceneNodeTypes[i].Type;
return ESNT_UNKNOWN;
}
} // end namespace scene
} // end namespace irr

View File

@ -1,80 +0,0 @@
// Copyright (C) 2002-2012 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __C_DEFAULT_SCENE_NODE_FACTORY_H_INCLUDED__
#define __C_DEFAULT_SCENE_NODE_FACTORY_H_INCLUDED__
#include "ISceneNodeFactory.h"
#include "irrArray.h"
#include "irrString.h"
namespace irr
{
namespace scene
{
class ISceneNode;
class ISceneManager;
//! Interface making it possible to dynamicly create scene nodes and animators
class CDefaultSceneNodeFactory : public ISceneNodeFactory
{
public:
CDefaultSceneNodeFactory(ISceneManager* mgr);
//! adds a scene node to the scene graph based on its type id
/** \param type: Type of the scene node to add.
\param parent: Parent scene node of the new node, can be null to add the scene node to the root.
\return Returns pointer to the new scene node or null if not successful. */
virtual ISceneNode* addSceneNode(ESCENE_NODE_TYPE type, ISceneNode* parent=0) _IRR_OVERRIDE_;
//! adds a scene node to the scene graph based on its type name
/** \param typeName: Type name of the scene node to add.
\param parent: Parent scene node of the new node, can be null to add the scene node to the root.
\return Returns pointer to the new scene node or null if not successful. */
virtual ISceneNode* addSceneNode(const c8* typeName, ISceneNode* parent=0) _IRR_OVERRIDE_;
//! returns amount of scene node types this factory is able to create
virtual u32 getCreatableSceneNodeTypeCount() const _IRR_OVERRIDE_;
//! returns type name of a creatable scene node type by index
/** \param idx: Index of scene node type in this factory. Must be a value between 0 and
uetCreatableSceneNodeTypeCount() */
virtual const c8* getCreateableSceneNodeTypeName(u32 idx) const _IRR_OVERRIDE_;
//! returns type of a creatable scene node type
/** \param idx: Index of scene node type in this factory. Must be a value between 0 and
getCreatableSceneNodeTypeCount() */
virtual ESCENE_NODE_TYPE getCreateableSceneNodeType(u32 idx) const _IRR_OVERRIDE_;
//! returns type name of a creatable scene node type
/** \param idx: Type of scene node.
\return: Returns name of scene node type if this factory can create the type, otherwise 0. */
virtual const c8* getCreateableSceneNodeTypeName(ESCENE_NODE_TYPE type) const _IRR_OVERRIDE_;
private:
ESCENE_NODE_TYPE getTypeFromName(const c8* name) const;
struct SSceneNodeTypePair
{
SSceneNodeTypePair(ESCENE_NODE_TYPE type, const c8* name)
: Type(type), TypeName(name)
{}
ESCENE_NODE_TYPE Type;
core::stringc TypeName;
};
core::array<SSceneNodeTypePair> SupportedSceneNodeTypes;
ISceneManager* Manager;
};
} // end namespace scene
} // end namespace irr
#endif

View File

@ -8,7 +8,6 @@
#include "IReadFile.h"
#include "IWriteFile.h"
#include "CZipReader.h"
#include "CMountPointReader.h"
#include "CFileList.h"
#include "stdio.h"
#include "os.h"
@ -55,26 +54,6 @@ CFileSystem::CFileSystem()
//! reset current working directory
getWorkingDirectory();
#ifdef __IRR_COMPILE_WITH_PAK_ARCHIVE_LOADER_
ArchiveLoader.push_back(new CArchiveLoaderPAK(this));
#endif
#ifdef __IRR_COMPILE_WITH_NPK_ARCHIVE_LOADER_
ArchiveLoader.push_back(new CArchiveLoaderNPK(this));
#endif
#ifdef __IRR_COMPILE_WITH_TAR_ARCHIVE_LOADER_
ArchiveLoader.push_back(new CArchiveLoaderTAR(this));
#endif
#ifdef __IRR_COMPILE_WITH_WAD_ARCHIVE_LOADER_
ArchiveLoader.push_back(new CArchiveLoaderWAD(this));
#endif
#ifdef __IRR_COMPILE_WITH_MOUNT_ARCHIVE_LOADER_
ArchiveLoader.push_back(new CArchiveLoaderMount(this));
#endif
#ifdef __IRR_COMPILE_WITH_ZIP_ARCHIVE_LOADER_
ArchiveLoader.push_back(new CArchiveLoaderZIP(this));
#endif
@ -219,8 +198,6 @@ bool CFileSystem::addFileArchive(const io::path& filename, bool ignoreCase,
bool ret = false;
// see if archive is already added
if (changeArchivePassword(filename, password, retArchive))
return true;
s32 i;
@ -316,29 +293,6 @@ bool CFileSystem::addFileArchive(const io::path& filename, bool ignoreCase,
return ret;
}
// don't expose!
bool CFileSystem::changeArchivePassword(const path& filename,
const core::stringc& password,
IFileArchive** archive)
{
for (s32 idx = 0; idx < (s32)FileArchives.size(); ++idx)
{
// TODO: This should go into a path normalization method
// We need to check for directory names with trailing slash and without
const path absPath = getAbsolutePath(filename);
const path arcPath = FileArchives[idx]->getFileList()->getPath();
if ((absPath == arcPath) || ((absPath+_IRR_TEXT("/")) == arcPath))
{
if (password.size())
FileArchives[idx]->Password=password;
if (archive)
*archive = FileArchives[idx];
return true;
}
}
return false;
}
bool CFileSystem::addFileArchive(IReadFile* file, bool ignoreCase,
bool ignorePaths, E_FILE_ARCHIVE_TYPE archiveType,
@ -349,9 +303,6 @@ bool CFileSystem::addFileArchive(IReadFile* file, bool ignoreCase,
if (file)
{
if (changeArchivePassword(file->getFileName(), password, retArchive))
return true;
IFileArchive* archive = 0;
s32 i;

View File

@ -14,8 +14,6 @@ namespace io
{
class CZipReader;
class CPakReader;
class CMountPointReader;
/*!
FileSystem which uses normal files and one zipfile
@ -129,11 +127,6 @@ public:
private:
// don't expose, needs refactoring
bool changeArchivePassword(const path& filename,
const core::stringc& password,
IFileArchive** archive = 0);
//! Currently used FileSystemType
EFileSystemType FileSystemType;
//! WorkingDirectory for Native and Virtual filesystems

View File

@ -1,479 +0,0 @@
// Copyright (C) 2002-2012 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#include "CGUIColorSelectDialog.h"
#ifdef _IRR_COMPILE_WITH_GUI_
#include "IGUISkin.h"
#include "IGUIEnvironment.h"
#include "IVideoDriver.h"
#include "IGUIButton.h"
#include "IGUIStaticText.h"
#include "IGUIFont.h"
#include "IGUISpriteBank.h"
#include "IFileList.h"
#include "os.h"
#include "fast_atof.h"
namespace irr
{
namespace gui
{
const s32 CSD_WIDTH = 350;
const s32 CSD_HEIGHT = 300;
namespace
{
struct subElementPredefines
{
const wchar_t *pre;
const wchar_t *init;
const wchar_t *post;
int x, y;
int range_down ,range_up;
};
static const subElementPredefines Template [] =
{
{ L"A:", L"0", 0,50,165, 0, 255 },
{ L"R:", L"0", 0,20,205, 0, 255 },
{ L"G:", L"0", 0,20,230, 0, 255 },
{ L"B:", L"0", 0,20,255, 0, 255 },
{ L"H:", L"0", L"°",80,205, 0, 360 },
{ L"S:", L"0", L"%",80,230, 0, 100 },
{ L"L:", L"0", L"%",80,255, 0, 100 },
};
}
//! constructor
CGUIColorSelectDialog::CGUIColorSelectDialog(const wchar_t* title, IGUIEnvironment* environment, IGUIElement* parent, s32 id)
: IGUIColorSelectDialog(environment, parent, id,
core::rect<s32>((parent->getAbsolutePosition().getWidth()-CSD_WIDTH)/2,
(parent->getAbsolutePosition().getHeight()-CSD_HEIGHT)/2,
(parent->getAbsolutePosition().getWidth()-CSD_WIDTH)/2+CSD_WIDTH,
(parent->getAbsolutePosition().getHeight()-CSD_HEIGHT)/2+CSD_HEIGHT)),
Dragging(false)
{
#ifdef _DEBUG
IGUIElement::setDebugName("CGUIColorSelectDialog");
#endif
Text = title;
IGUISkin* skin = Environment->getSkin();
const s32 buttonw = environment->getSkin()->getSize(EGDS_WINDOW_BUTTON_WIDTH);
const s32 posx = RelativeRect.getWidth() - buttonw - 4;
CloseButton = Environment->addButton(core::rect<s32>(posx, 3, posx + buttonw, 3 + buttonw),
this, -1, L"", skin ? skin->getDefaultText(EGDT_WINDOW_CLOSE) : L"Close");
if (skin && skin->getSpriteBank())
{
CloseButton->setSpriteBank(skin->getSpriteBank());
CloseButton->setSprite(EGBS_BUTTON_UP, skin->getIcon(EGDI_WINDOW_CLOSE), skin->getColor(EGDC_WINDOW_SYMBOL));
CloseButton->setSprite(EGBS_BUTTON_DOWN, skin->getIcon(EGDI_WINDOW_CLOSE), skin->getColor(EGDC_WINDOW_SYMBOL));
}
CloseButton->setSubElement(true);
CloseButton->setTabStop(false);
CloseButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT);
CloseButton->grab();
OKButton = Environment->addButton(
core::rect<s32>(RelativeRect.getWidth()-80, 30, RelativeRect.getWidth()-10, 50),
this, -1, skin ? skin->getDefaultText(EGDT_MSG_BOX_OK) : L"OK");
OKButton->setSubElement(true);
OKButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT);
OKButton->grab();
CancelButton = Environment->addButton(
core::rect<s32>(RelativeRect.getWidth()-80, 55, RelativeRect.getWidth()-10, 75),
this, -1, skin ? skin->getDefaultText(EGDT_MSG_BOX_CANCEL) : L"Cancel");
CancelButton->setSubElement(true);
CancelButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT);
CancelButton->grab();
video::IVideoDriver* driver = Environment->getVideoDriver();
ColorRing.Texture = driver->getTexture ( "#colorring" );
if ( 0 == ColorRing.Texture )
{
buildColorRing(core::dimension2d<u32>(128, 128), 1,
Environment->getSkin()->getColor(EGDC_3D_SHADOW));
}
core::rect<s32> r(20,20, 0,0);
ColorRing.Control = Environment->addImage(ColorRing.Texture, r.UpperLeftCorner, true, this);
ColorRing.Control->setSubElement(true);
ColorRing.Control->grab();
for ( u32 i = 0; i != sizeof (Template) / sizeof ( subElementPredefines ); ++i )
{
if ( Template[i].pre )
{
r.UpperLeftCorner.X = Template[i].x;
r.UpperLeftCorner.Y = Template[i].y;
r.LowerRightCorner.X = r.UpperLeftCorner.X + 15;
r.LowerRightCorner.Y = r.UpperLeftCorner.Y + 20;
IGUIElement *t = Environment->addStaticText(Template[i].pre, r, false, false, this);
t->setSubElement(true);
}
if ( Template[i].post )
{
r.UpperLeftCorner.X = Template[i].x + 56;
r.UpperLeftCorner.Y = Template[i].y;
r.LowerRightCorner.X = r.UpperLeftCorner.X + 15;
r.LowerRightCorner.Y = r.UpperLeftCorner.Y + 20;
IGUIElement *t = Environment->addStaticText( Template[i].post, r, false, false, this);
t->setSubElement(true);
}
r.UpperLeftCorner.X = Template[i].x + 15;
r.UpperLeftCorner.Y = Template[i].y-2;
r.LowerRightCorner.X = r.UpperLeftCorner.X + 40;
r.LowerRightCorner.Y = r.UpperLeftCorner.Y + 20;
gui::IGUISpinBox* spin = Environment->addSpinBox( Template[i].init, r, true, this);
spin->setSubElement(true);
spin->setDecimalPlaces(0);
spin->setRange((f32)Template[i].range_down, (f32)Template[i].range_up);
spin->grab();
Battery.push_back(spin);
}
bringToFront(CancelButton);
bringToFront(OKButton);
}
//! destructor
CGUIColorSelectDialog::~CGUIColorSelectDialog()
{
if (CloseButton)
CloseButton->drop();
if (OKButton)
OKButton->drop();
if (CancelButton)
CancelButton->drop();
for (u32 i = 0; i != Battery.size(); ++i)
Battery[i]->drop();
if (ColorRing.Control)
ColorRing.Control->drop();
}
//! renders a antialiased, colored ring
void CGUIColorSelectDialog::buildColorRing( const core::dimension2d<u32> & dim, s32 supersample, const video::SColor& borderColor )
{
const core::dimension2d<u32> d(dim.Width * supersample, dim.Height * supersample);
video::IVideoDriver* driver = Environment->getVideoDriver();
video::IImage *RawTexture = driver->createImage(video::ECF_A8R8G8B8, d);
RawTexture->fill ( 0x00808080 );
const s32 radiusOut = ( d.Width / 2 ) - 4;
const s32 fullR2 = radiusOut * radiusOut;
video::SColorf rgb(0,0,0);
video::SColorHSL hsl;
hsl.Luminance = 50;
hsl.Saturation = 100;
core::position2d<s32> p;
for ( p.Y = -radiusOut; p.Y <= radiusOut; p.Y += 1 )
{
s32 y2 = p.Y * p.Y;
for (p.X = -radiusOut; p.X <= radiusOut; p.X += 1)
{
s32 r2 = y2 + ( p.X * p.X );
// test point in circle
s32 testa = r2 - fullR2;
if ( testa < 0 )
{
// dotproduct u ( x,y ) * v ( 1, 0 ) = cosinus(a)
const f32 r = sqrtf((f32) r2);
// normalize, dotproduct = xnorm
const f32 xn = r == 0.f ? 0.f : -p.X * core::reciprocal(r);
hsl.Hue = acosf(xn)*core::RADTODEG;
if ( p.Y > 0 )
hsl.Hue = 360 - hsl.Hue;
hsl.Hue -= 90;
const f32 rTest = r / radiusOut;
#if 0
if (rTest < 0.33f)
{
// luminance from 0 to 50
hsl.Luminance = 50*(rTest/0.33);
hsl.Saturation = 0.f;
hsl.toRGB(rgb);
}
else
if ( rTest < 0.66f )
{
// saturation from 0 to 100
hsl.Saturation = 100*(( rTest - 0.33f ) / 0.33f);
hsl.Luminance = 50;
hsl.toRGB(rgb);
}
else
{
// luminance from 50 to 100
hsl.Luminance = 100*(0.5f + ( ( rTest - 0.66f ) / .66f ));
hsl.Saturation = 100;
hsl.toRGB(rgb);
}
// borders should be slightly transparent
if ( rTest >= 0.95f )
rgb.a = (1.f-rTest)*20;
else
rgb.a=1.f;
#else
if ( rTest > 0.5f )
{
hsl.Saturation = 100;
hsl.Luminance = 50;
hsl.toRGB(rgb);
}
// borders should be slightly transparent
if ( rTest < 0.5f )
rgb.a = 0;
else if ( rTest >= 0.95f )
rgb.a = (1.f-rTest)*20;
else if ( rTest <= 0.55f )
rgb.a = (rTest-0.5f)*20;
else
rgb.a=1.f;
#endif
RawTexture->setPixel(4+p.X+radiusOut, 4+p.Y+radiusOut, rgb.toSColor());
}
}
}
if ( supersample > 1 )
{
video::IImage * filter = driver->createImage(video::ECF_A8R8G8B8, dim );
RawTexture->copyToScalingBoxFilter(filter);
RawTexture->drop();
RawTexture = filter;
}
bool generateMipLevels = driver->getTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS);
driver->setTextureCreationFlag( video::ETCF_CREATE_MIP_MAPS, false);
ColorRing.Texture = driver->addTexture ( "#colorring", RawTexture);
RawTexture->drop();
driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, generateMipLevels);
}
//! called if an event happened.
bool CGUIColorSelectDialog::OnEvent(const SEvent& event)
{
if (isEnabled())
{
switch(event.EventType)
{
case EET_GUI_EVENT:
switch(event.GUIEvent.EventType)
{
case EGET_SPINBOX_CHANGED:
{
for ( u32 i = 0; i!= Battery.size (); ++i )
{
if ( event.GUIEvent.Caller == Battery[i] )
{
if (i<4)
{
video::SColor rgb((u32)Battery[0]->getValue(), (u32)Battery[1]->getValue(),
(u32)Battery[2]->getValue(), (u32)Battery[3]->getValue());
video::SColorHSL hsl;
video::SColorf rgb2(rgb);
hsl.fromRGB(rgb2);
Battery[4]->setValue(hsl.Hue);
Battery[5]->setValue(hsl.Saturation);
Battery[6]->setValue(hsl.Luminance);
}
else
{
video::SColorHSL hsl(Battery[4]->getValue(), Battery[5]->getValue(),
Battery[6]->getValue());
video::SColorf rgb2;
hsl.toRGB(rgb2);
video::SColor rgb = rgb2.toSColor();
Battery[1]->setValue((f32)rgb.getRed());
Battery[2]->setValue((f32)rgb.getGreen());
Battery[3]->setValue((f32)rgb.getBlue());
}
}
}
return true;
}
case EGET_ELEMENT_FOCUS_LOST:
Dragging = false;
break;
case EGET_BUTTON_CLICKED:
if (event.GUIEvent.Caller == CloseButton ||
event.GUIEvent.Caller == CancelButton)
{
sendCancelEvent();
remove();
return true;
}
else
if (event.GUIEvent.Caller == OKButton)
{
sendSelectedEvent();
remove();
return true;
}
break;
case EGET_LISTBOX_CHANGED:
case EGET_LISTBOX_SELECTED_AGAIN:
default:
break;
}
break;
case EET_MOUSE_INPUT_EVENT:
switch(event.MouseInput.Event)
{
case EMIE_LMOUSE_PRESSED_DOWN:
DragStart.X = event.MouseInput.X;
DragStart.Y = event.MouseInput.Y;
Dragging = true;
return true;
case EMIE_LMOUSE_LEFT_UP:
Dragging = false;
return true;
case EMIE_MOUSE_MOVED:
if (Dragging)
{
// gui window should not be dragged outside its parent
if (Parent)
if (event.MouseInput.X < Parent->getAbsolutePosition().UpperLeftCorner.X +1 ||
event.MouseInput.Y < Parent->getAbsolutePosition().UpperLeftCorner.Y +1 ||
event.MouseInput.X > Parent->getAbsolutePosition().LowerRightCorner.X -1 ||
event.MouseInput.Y > Parent->getAbsolutePosition().LowerRightCorner.Y -1)
return true;
move(core::position2d<s32>(event.MouseInput.X - DragStart.X, event.MouseInput.Y - DragStart.Y));
DragStart.X = event.MouseInput.X;
DragStart.Y = event.MouseInput.Y;
return true;
}
default:
break;
}
default:
break;
}
}
return IGUIElement::OnEvent(event);
}
//! draws the element and its children
void CGUIColorSelectDialog::draw()
{
if (!IsVisible)
return;
IGUISkin* skin = Environment->getSkin();
core::rect<s32> rect = skin->draw3DWindowBackground(this, true, skin->getColor(EGDC_ACTIVE_BORDER),
AbsoluteRect, &AbsoluteClippingRect);
if (Text.size())
{
rect.UpperLeftCorner.X += 2;
rect.LowerRightCorner.X -= skin->getSize(EGDS_WINDOW_BUTTON_WIDTH) + 5;
IGUIFont* font = skin->getFont(EGDF_WINDOW);
if (font)
font->draw(Text.c_str(), rect, skin->getColor(EGDC_ACTIVE_CAPTION), false, true,
&AbsoluteClippingRect);
}
IGUIElement::draw();
// draw color selector after the window elements
core::vector2di pos(ColorRing.Control->getAbsolutePosition().UpperLeftCorner);
pos.X += ColorRing.Texture->getOriginalSize().Width/2;
pos.Y += ColorRing.Texture->getOriginalSize().Height/2;
#if 0
const f32 h = Battery[4]->getValue();
const f32 s = Battery[5]->getValue();
const f32 l = Battery[6]->getValue();
const f32 factor = 58.f*(((s==0)&&(l<50))?(l*0.33f/50):(
(s<100)?((.33f+(s*0.33f/100))):((0.66f+(l-50)*0.33f/50))));
#else
const f32 factor = 44;
#endif
pos.X += core::round32(sinf(Battery[4]->getValue()*core::DEGTORAD)*factor);
pos.Y -= core::round32(cosf(Battery[4]->getValue()*core::DEGTORAD)*factor);
Environment->getVideoDriver()->draw2DPolygon(pos, 4, 0xffffffff, 4);
}
video::SColor CGUIColorSelectDialog::getColor()
{
return video::SColor((u32)Battery[0]->getValue(), (u32)Battery[1]->getValue(),
(u32)Battery[2]->getValue(), (u32)Battery[3]->getValue());
}
video::SColorHSL CGUIColorSelectDialog::getColorHSL()
{
return video::SColorHSL(Battery[4]->getValue(), Battery[5]->getValue(),
Battery[6]->getValue());
}
//! sends the event that the file has been selected.
void CGUIColorSelectDialog::sendSelectedEvent()
{
SEvent event;
event.EventType = EET_GUI_EVENT;
event.GUIEvent.Caller = this;
event.GUIEvent.Element = 0;
event.GUIEvent.EventType = EGET_FILE_SELECTED;
Parent->OnEvent(event);
}
//! sends the event that the file choose process has been canceld
void CGUIColorSelectDialog::sendCancelEvent()
{
SEvent event;
event.EventType = EET_GUI_EVENT;
event.GUIEvent.Caller = this;
event.GUIEvent.Element = 0;
event.GUIEvent.EventType = EGET_FILE_CHOOSE_DIALOG_CANCELLED;
Parent->OnEvent(event);
}
} // end namespace gui
} // end namespace irr
#endif // _IRR_COMPILE_WITH_GUI_

View File

@ -1,74 +0,0 @@
// Copyright (C) 2002-2012 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __C_GUI_COLOR_SELECT_DIALOG_H_INCLUDED__
#define __C_GUI_COLOR_SELECT_DIALOG_H_INCLUDED__
#include "IrrCompileConfig.h"
#ifdef _IRR_COMPILE_WITH_GUI_
#include "IGUIColorSelectDialog.h"
#include "IGUIButton.h"
#include "IGUISpinBox.h"
#include "IGUIImage.h"
#include "irrArray.h"
namespace irr
{
namespace gui
{
class CGUIColorSelectDialog : public IGUIColorSelectDialog
{
public:
//! constructor
CGUIColorSelectDialog(const wchar_t* title, IGUIEnvironment* environment, IGUIElement* parent, s32 id);
//! destructor
virtual ~CGUIColorSelectDialog();
//! called if an event happened.
virtual bool OnEvent(const SEvent& event) _IRR_OVERRIDE_;
//! draws the element and its children
virtual void draw() _IRR_OVERRIDE_;
virtual video::SColor getColor() _IRR_OVERRIDE_;
virtual video::SColorHSL getColorHSL() _IRR_OVERRIDE_;
private:
//! sends the event that the file has been selected.
void sendSelectedEvent();
//! sends the event that the file choose process has been canceld
void sendCancelEvent();
core::position2d<s32> DragStart;
bool Dragging;
IGUIButton* CloseButton;
IGUIButton* OKButton;
IGUIButton* CancelButton;
core::array<IGUISpinBox*> Battery;
struct SColorCircle
{
IGUIImage * Control;
video::ITexture * Texture;
};
SColorCircle ColorRing;
void buildColorRing( const core::dimension2d<u32> & dim, s32 supersample, const video::SColor& borderColor );
};
} // end namespace gui
} // end namespace irr
#endif // _IRR_COMPILE_WITH_GUI_
#endif // __C_GUI_COLOR_SELECT_DIALOG_H_INCLUDED__

View File

@ -1,773 +0,0 @@
// Copyright (C) 2002-2012 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#include "CGUIContextMenu.h"
#ifdef _IRR_COMPILE_WITH_GUI_
#include "IGUISkin.h"
#include "IGUIEnvironment.h"
#include "IVideoDriver.h"
#include "IGUIFont.h"
#include "IGUISpriteBank.h"
#include "os.h"
namespace irr
{
namespace gui
{
//! constructor
CGUIContextMenu::CGUIContextMenu(IGUIEnvironment* environment,
IGUIElement* parent, s32 id,
core::rect<s32> rectangle, bool getFocus, bool allowFocus)
: IGUIContextMenu(environment, parent, id, rectangle), EventParent(0), LastFont(0),
CloseHandling(ECMC_REMOVE), HighLighted(-1), ChangeTime(0), AllowFocus(allowFocus)
{
#ifdef _DEBUG
setDebugName("CGUIContextMenu");
#endif
Pos = rectangle.UpperLeftCorner;
recalculateSize();
if (getFocus)
Environment->setFocus(this);
setNotClipped(true);
}
//! destructor
CGUIContextMenu::~CGUIContextMenu()
{
for (u32 i=0; i<Items.size(); ++i)
if (Items[i].SubMenu)
Items[i].SubMenu->drop();
if (LastFont)
LastFont->drop();
}
//! set behavior when menus are closed
void CGUIContextMenu::setCloseHandling(ECONTEXT_MENU_CLOSE onClose)
{
CloseHandling = onClose;
}
//! get current behavior when the menue will be closed
ECONTEXT_MENU_CLOSE CGUIContextMenu::getCloseHandling() const
{
return CloseHandling;
}
//! Returns amount of menu items
u32 CGUIContextMenu::getItemCount() const
{
return Items.size();
}
//! Adds a menu item.
u32 CGUIContextMenu::addItem(const wchar_t* text, s32 commandId, bool enabled, bool hasSubMenu, bool checked, bool autoChecking)
{
return insertItem(Items.size(), text, commandId, enabled, hasSubMenu, checked, autoChecking);
}
//! Insert a menu item at specified position.
u32 CGUIContextMenu::insertItem(u32 idx, const wchar_t* text, s32 commandId, bool enabled,
bool hasSubMenu, bool checked, bool autoChecking)
{
SItem s;
s.Enabled = enabled;
s.Checked = checked;
s.AutoChecking = autoChecking;
s.Text = text;
s.IsSeparator = (text == 0);
s.SubMenu = 0;
s.CommandId = commandId;
s.PosY = 0;
if (hasSubMenu)
{
s.SubMenu = new CGUIContextMenu(Environment, this, commandId,
core::rect<s32>(0,0,100,100), false, false);
s.SubMenu->setVisible(false);
}
u32 result = idx;
if ( idx < Items.size() )
{
Items.insert(s, idx);
}
else
{
Items.push_back(s);
result = Items.size() - 1;
}
recalculateSize();
return result;
}
s32 CGUIContextMenu::findItemWithCommandId(s32 commandId, u32 idxStartSearch) const
{
for ( u32 i=idxStartSearch; i<Items.size(); ++i )
{
if ( Items[i].CommandId == commandId )
{
return (s32)i;
}
}
return -1;
}
//! Adds a sub menu from an element that already exists.
void CGUIContextMenu::setSubMenu(u32 index, CGUIContextMenu* menu)
{
if (index >= Items.size())
return;
if (menu)
menu->grab();
if (Items[index].SubMenu)
Items[index].SubMenu->drop();
Items[index].SubMenu = menu;
if (menu)
{
menu->setVisible(false);
menu->AllowFocus = false;
if ( Environment->getFocus() == menu )
{
Environment->setFocus( this );
}
}
recalculateSize();
}
//! Adds a separator item to the menu
void CGUIContextMenu::addSeparator()
{
addItem(0, -1, true, false, false, false);
}
//! Returns text of the menu item.
const wchar_t* CGUIContextMenu::getItemText(u32 idx) const
{
if (idx >= Items.size())
return 0;
return Items[idx].Text.c_str();
}
//! Sets text of the menu item.
void CGUIContextMenu::setItemText(u32 idx, const wchar_t* text)
{
if (idx >= Items.size())
return;
Items[idx].Text = text;
recalculateSize();
}
//! should the element change the checked status on clicking
void CGUIContextMenu::setItemAutoChecking(u32 idx, bool autoChecking)
{
if ( idx >= Items.size())
return;
Items[idx].AutoChecking = autoChecking;
}
//! does the element change the checked status on clicking
bool CGUIContextMenu::getItemAutoChecking(u32 idx) const
{
if (idx >= Items.size())
return false;
return Items[idx].AutoChecking;
}
//! Returns if a menu item is enabled
bool CGUIContextMenu::isItemEnabled(u32 idx) const
{
if (idx >= Items.size())
{
return false;
}
return Items[idx].Enabled;
}
//! Returns if a menu item is checked
bool CGUIContextMenu::isItemChecked(u32 idx) const
{
if (idx >= Items.size())
{
return false;
}
return Items[idx].Checked;
}
//! Sets if the menu item should be enabled.
void CGUIContextMenu::setItemEnabled(u32 idx, bool enabled)
{
if (idx >= Items.size())
return;
Items[idx].Enabled = enabled;
}
//! Sets if the menu item should be checked.
void CGUIContextMenu::setItemChecked(u32 idx, bool checked )
{
if (idx >= Items.size())
return;
Items[idx].Checked = checked;
}
//! Removes a menu item
void CGUIContextMenu::removeItem(u32 idx)
{
if (idx >= Items.size())
return;
if (Items[idx].SubMenu)
{
Items[idx].SubMenu->drop();
Items[idx].SubMenu = 0;
}
Items.erase(idx);
recalculateSize();
}
//! Removes all menu items
void CGUIContextMenu::removeAllItems()
{
for (u32 i=0; i<Items.size(); ++i)
if (Items[i].SubMenu)
Items[i].SubMenu->drop();
Items.clear();
recalculateSize();
}
//! called if an event happened.
bool CGUIContextMenu::OnEvent(const SEvent& event)
{
if (isEnabled())
{
switch(event.EventType)
{
case EET_GUI_EVENT:
switch(event.GUIEvent.EventType)
{
case EGET_ELEMENT_FOCUS_LOST:
if (event.GUIEvent.Caller == this && !isMyChild(event.GUIEvent.Element) && AllowFocus)
{
// set event parent of submenus
IGUIElement * p = EventParent ? EventParent : Parent;
if ( p ) // can be 0 when element got removed already
{
setEventParent(p);
SEvent eventClose;
eventClose.EventType = EET_GUI_EVENT;
eventClose.GUIEvent.Caller = this;
eventClose.GUIEvent.Element = 0;
eventClose.GUIEvent.EventType = EGET_ELEMENT_CLOSED;
if ( !p->OnEvent(eventClose) )
{
if ( CloseHandling & ECMC_HIDE )
{
setVisible(false);
}
if ( CloseHandling & ECMC_REMOVE )
{
remove();
}
}
}
return false;
}
break;
case EGET_ELEMENT_FOCUSED:
if (event.GUIEvent.Caller == this && !AllowFocus)
{
return true;
}
break;
default:
break;
}
break;
case EET_MOUSE_INPUT_EVENT:
switch(event.MouseInput.Event)
{
case EMIE_LMOUSE_LEFT_UP:
{
// menu might be removed if it loses focus in sendClick, so grab a reference
grab();
const u32 t = sendClick(core::position2d<s32>(event.MouseInput.X, event.MouseInput.Y));
if ((t==0 || t==1) && Environment->hasFocus(this))
Environment->removeFocus(this);
drop();
}
return true;
case EMIE_LMOUSE_PRESSED_DOWN:
return true;
case EMIE_MOUSE_MOVED:
if (Environment->hasFocus(this))
highlight(core::position2d<s32>(event.MouseInput.X, event.MouseInput.Y), true);
return true;
default:
break;
}
break;
default:
break;
}
}
return IGUIElement::OnEvent(event);
}
//! Sets the visible state of this element.
void CGUIContextMenu::setVisible(bool visible)
{
HighLighted = -1;
ChangeTime = os::Timer::getTime();
for (u32 j=0; j<Items.size(); ++j)
if (Items[j].SubMenu)
Items[j].SubMenu->setVisible(false);
IGUIElement::setVisible(visible);
}
//! sends a click Returns:
//! 0 if click went outside of the element,
//! 1 if a valid button was clicked,
//! 2 if a nonclickable element was clicked
u32 CGUIContextMenu::sendClick(const core::position2d<s32>& p)
{
u32 t = 0;
// get number of open submenu
s32 openmenu = -1;
s32 j;
for (j=0; j<(s32)Items.size(); ++j)
if (Items[j].SubMenu && Items[j].SubMenu->isVisible())
{
openmenu = j;
break;
}
// delegate click operation to submenu
if (openmenu != -1)
{
t = Items[j].SubMenu->sendClick(p);
if (t != 0)
return t; // clicked something
}
// check click on myself
if (isPointInside(p) &&
(u32)HighLighted < Items.size())
{
if (!Items[HighLighted].Enabled ||
Items[HighLighted].IsSeparator ||
Items[HighLighted].SubMenu)
return 2;
if ( Items[HighLighted].AutoChecking )
{
Items[HighLighted].Checked = Items[HighLighted].Checked ? false : true;
}
SEvent event;
event.EventType = EET_GUI_EVENT;
event.GUIEvent.Caller = this;
event.GUIEvent.Element = 0;
event.GUIEvent.EventType = EGET_MENU_ITEM_SELECTED;
if (EventParent)
EventParent->OnEvent(event);
else if (Parent)
Parent->OnEvent(event);
return 1;
}
return 0;
}
//! returns true, if an element was highligted
bool CGUIContextMenu::highlight(const core::position2d<s32>& p, bool canOpenSubMenu)
{
if (!isEnabled())
{
return false;
}
// get number of open submenu
s32 openmenu = -1;
s32 i;
for (i=0; i<(s32)Items.size(); ++i)
if (Items[i].Enabled && Items[i].SubMenu && Items[i].SubMenu->isVisible())
{
openmenu = i;
break;
}
// delegate highlight operation to submenu
if (openmenu != -1)
{
if (Items[openmenu].Enabled && Items[openmenu].SubMenu->highlight(p, canOpenSubMenu))
{
HighLighted = openmenu;
ChangeTime = os::Timer::getTime();
return true;
}
}
// highlight myself
for (i=0; i<(s32)Items.size(); ++i)
{
if (Items[i].Enabled && getHRect(Items[i], AbsoluteRect).isPointInside(p))
{
HighLighted = i;
ChangeTime = os::Timer::getTime();
// make submenus visible/invisible
for (s32 j=0; j<(s32)Items.size(); ++j)
if (Items[j].SubMenu)
{
if ( j == i && canOpenSubMenu && Items[j].Enabled )
Items[j].SubMenu->setVisible(true);
else if ( j != i )
Items[j].SubMenu->setVisible(false);
}
return true;
}
}
HighLighted = openmenu;
return false;
}
//! returns the item highlight-area
core::rect<s32> CGUIContextMenu::getHRect(const SItem& i, const core::rect<s32>& absolute) const
{
core::rect<s32> r = absolute;
r.UpperLeftCorner.Y += i.PosY;
r.LowerRightCorner.Y = r.UpperLeftCorner.Y + i.Dim.Height;
return r;
}
//! Gets drawing rect of Item
core::rect<s32> CGUIContextMenu::getRect(const SItem& i, const core::rect<s32>& absolute) const
{
core::rect<s32> r = absolute;
r.UpperLeftCorner.Y += i.PosY;
r.LowerRightCorner.Y = r.UpperLeftCorner.Y + i.Dim.Height;
r.UpperLeftCorner.X += 20;
return r;
}
//! draws the element and its children
void CGUIContextMenu::draw()
{
if (!IsVisible)
return;
IGUISkin* skin = Environment->getSkin();
if (!skin)
return;
IGUIFont* font = skin->getFont(EGDF_MENU);
if (font != LastFont)
{
if (LastFont)
LastFont->drop();
LastFont = font;
if (LastFont)
LastFont->grab();
recalculateSize();
}
IGUISpriteBank* sprites = skin->getSpriteBank();
core::rect<s32> rect = AbsoluteRect;
core::rect<s32>* clip = 0;
// draw frame
skin->draw3DMenuPane(this, AbsoluteRect, clip);
// loop through all menu items
rect = AbsoluteRect;
s32 y = AbsoluteRect.UpperLeftCorner.Y;
for (s32 i=0; i<(s32)Items.size(); ++i)
{
if (Items[i].IsSeparator)
{
// draw separator
rect = AbsoluteRect;
rect.UpperLeftCorner.Y += Items[i].PosY + 3;
rect.LowerRightCorner.Y = rect.UpperLeftCorner.Y + 1;
rect.UpperLeftCorner.X += 5;
rect.LowerRightCorner.X -= 5;
skin->draw2DRectangle(this, skin->getColor(EGDC_3D_SHADOW), rect, clip);
rect.LowerRightCorner.Y += 1;
rect.UpperLeftCorner.Y += 1;
skin->draw2DRectangle(this, skin->getColor(EGDC_3D_HIGH_LIGHT), rect, clip);
y += 10;
}
else
{
rect = getRect(Items[i], AbsoluteRect);
// draw highlighted
if (i == HighLighted && Items[i].Enabled)
{
core::rect<s32> r = AbsoluteRect;
r.LowerRightCorner.Y = rect.LowerRightCorner.Y;
r.UpperLeftCorner.Y = rect.UpperLeftCorner.Y;
r.LowerRightCorner.X -= 5;
r.UpperLeftCorner.X += 5;
skin->draw2DRectangle(this, skin->getColor(EGDC_HIGH_LIGHT), r, clip);
}
// draw text
EGUI_DEFAULT_COLOR c = EGDC_BUTTON_TEXT;
if (i == HighLighted)
c = EGDC_HIGH_LIGHT_TEXT;
if (!Items[i].Enabled)
c = EGDC_GRAY_TEXT;
if (font)
font->draw(Items[i].Text.c_str(), rect,
skin->getColor(c), false, true, clip);
// draw submenu symbol
if (Items[i].SubMenu && sprites)
{
core::rect<s32> r = rect;
r.UpperLeftCorner.X = r.LowerRightCorner.X - 15;
sprites->draw2DSprite(skin->getIcon(EGDI_CURSOR_RIGHT),
r.getCenter(), clip, skin->getColor(c),
(i == HighLighted) ? ChangeTime : 0,
(i == HighLighted) ? os::Timer::getTime() : 0,
(i == HighLighted), true);
}
// draw checked symbol
if (Items[i].Checked && sprites)
{
core::rect<s32> r = rect;
r.LowerRightCorner.X = r.UpperLeftCorner.X - 15;
r.UpperLeftCorner.X = r.LowerRightCorner.X + 15;
sprites->draw2DSprite(skin->getIcon(EGDI_CHECK_BOX_CHECKED),
r.getCenter(), clip, skin->getColor(c),
(i == HighLighted) ? ChangeTime : 0,
(i == HighLighted) ? os::Timer::getTime() : 0,
(i == HighLighted), true);
}
}
}
IGUIElement::draw();
}
void CGUIContextMenu::recalculateSize()
{
IGUIFont* font = Environment->getSkin()->getFont(EGDF_MENU);
if (!font)
return;
core::rect<s32> rect;
rect.UpperLeftCorner = RelativeRect.UpperLeftCorner;
u32 width = 100;
u32 height = 3;
u32 i;
for (i=0; i<Items.size(); ++i)
{
if (Items[i].IsSeparator)
{
Items[i].Dim.Width = 100;
Items[i].Dim.Height = 10;
}
else
{
Items[i].Dim = font->getDimension(Items[i].Text.c_str());
Items[i].Dim.Width += 40;
if (Items[i].Dim.Width > width)
width = Items[i].Dim.Width;
}
Items[i].PosY = height;
height += Items[i].Dim.Height;
}
height += 5;
if (height < 10)
height = 10;
rect.LowerRightCorner.X = RelativeRect.UpperLeftCorner.X + width;
rect.LowerRightCorner.Y = RelativeRect.UpperLeftCorner.Y + height;
setRelativePosition(rect);
// recalculate submenus
for (i=0; i<Items.size(); ++i)
{
if (Items[i].SubMenu)
{
// move submenu
const s32 w = Items[i].SubMenu->getAbsolutePosition().getWidth();
const s32 h = Items[i].SubMenu->getAbsolutePosition().getHeight();
core::rect<s32> subRect(width-5, Items[i].PosY, width+w-5, Items[i].PosY+h);
gui::IGUIElement * root = Environment->getRootGUIElement();
if ( root )
{
core::rect<s32> rectRoot( root->getAbsolutePosition() );
// if it would be drawn beyond the right border, then add it to the left side
if ( getAbsolutePosition().UpperLeftCorner.X+subRect.LowerRightCorner.X > rectRoot.LowerRightCorner.X )
{
subRect.UpperLeftCorner.X = -w;
subRect.LowerRightCorner.X = 0;
}
// if it would be drawn below bottom border, move it up, but not further than to top.
irr::s32 belowBottom = getAbsolutePosition().UpperLeftCorner.Y+subRect.LowerRightCorner.Y - rectRoot.LowerRightCorner.Y;
if ( belowBottom > 0 )
{
irr::s32 belowTop = getAbsolutePosition().UpperLeftCorner.Y+subRect.UpperLeftCorner.Y;
irr::s32 moveUp = belowBottom < belowTop ? belowBottom : belowTop;
subRect.UpperLeftCorner.Y -= moveUp;
subRect.LowerRightCorner.Y -= moveUp;
}
}
Items[i].SubMenu->setRelativePosition(subRect);
}
}
}
//! Returns the selected item in the menu
s32 CGUIContextMenu::getSelectedItem() const
{
return HighLighted;
}
//! \return Returns a pointer to the submenu of an item.
IGUIContextMenu* CGUIContextMenu::getSubMenu(u32 idx) const
{
if (idx >= Items.size())
return 0;
return Items[idx].SubMenu;
}
//! Returns command id of a menu item
s32 CGUIContextMenu::getItemCommandId(u32 idx) const
{
if (idx >= Items.size())
return -1;
return Items[idx].CommandId;
}
//! Sets the command id of a menu item
void CGUIContextMenu::setItemCommandId(u32 idx, s32 id)
{
if (idx >= Items.size())
return;
Items[idx].CommandId = id;
}
// because sometimes the element has no parent at click time
void CGUIContextMenu::setEventParent(IGUIElement *parent)
{
EventParent = parent;
for (u32 i=0; i<Items.size(); ++i)
if (Items[i].SubMenu)
Items[i].SubMenu->setEventParent(parent);
}
bool CGUIContextMenu::hasOpenSubMenu() const
{
for (u32 i=0; i<Items.size(); ++i)
if (Items[i].SubMenu && Items[i].SubMenu->isVisible())
return true;
return false;
}
void CGUIContextMenu::closeAllSubMenus()
{
for (u32 i=0; i<Items.size(); ++i)
if (Items[i].SubMenu)
Items[i].SubMenu->setVisible(false);
//HighLighted = -1;
}
} // end namespace
} // end namespace
#endif // _IRR_COMPILE_WITH_GUI_

View File

@ -1,168 +0,0 @@
// Copyright (C) 2002-2012 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __C_GUI_CONTEXT_MENU_H_INCLUDED__
#define __C_GUI_CONTEXT_MENU_H_INCLUDED__
#include "IrrCompileConfig.h"
#ifdef _IRR_COMPILE_WITH_GUI_
#include "IGUIContextMenu.h"
#include "irrString.h"
#include "irrArray.h"
#include "IGUIFont.h"
namespace irr
{
namespace gui
{
//! GUI Context menu interface.
class CGUIContextMenu : public IGUIContextMenu
{
public:
//! constructor
CGUIContextMenu(IGUIEnvironment* environment,
IGUIElement* parent, s32 id, core::rect<s32> rectangle,
bool getFocus = true, bool allowFocus = true);
//! destructor
virtual ~CGUIContextMenu();
//! set behavior when menus are closed
virtual void setCloseHandling(ECONTEXT_MENU_CLOSE onClose) _IRR_OVERRIDE_;
//! get current behavior when the menue will be closed
virtual ECONTEXT_MENU_CLOSE getCloseHandling() const _IRR_OVERRIDE_;
//! Returns amount of menu items
virtual u32 getItemCount() const _IRR_OVERRIDE_;
//! Adds a menu item.
virtual u32 addItem(const wchar_t* text, s32 commandid,
bool enabled, bool hasSubMenu, bool checked, bool autoChecking) _IRR_OVERRIDE_;
//! Insert a menu item at specified position.
virtual u32 insertItem(u32 idx, const wchar_t* text, s32 commandId, bool enabled,
bool hasSubMenu, bool checked, bool autoChecking) _IRR_OVERRIDE_;
//! Find a item which has the given CommandId starting from given index
virtual s32 findItemWithCommandId(s32 commandId, u32 idxStartSearch) const _IRR_OVERRIDE_;
//! Adds a separator item to the menu
virtual void addSeparator() _IRR_OVERRIDE_;
//! Returns text of the menu item.
virtual const wchar_t* getItemText(u32 idx) const _IRR_OVERRIDE_;
//! Sets text of the menu item.
virtual void setItemText(u32 idx, const wchar_t* text) _IRR_OVERRIDE_;
//! Returns if a menu item is enabled
virtual bool isItemEnabled(u32 idx) const _IRR_OVERRIDE_;
//! Sets if the menu item should be enabled.
virtual void setItemEnabled(u32 idx, bool enabled) _IRR_OVERRIDE_;
//! Returns if a menu item is checked
virtual bool isItemChecked(u32 idx) const _IRR_OVERRIDE_;
//! Sets if the menu item should be checked.
virtual void setItemChecked(u32 idx, bool enabled) _IRR_OVERRIDE_;
//! Removes a menu item
virtual void removeItem(u32 idx) _IRR_OVERRIDE_;
//! Removes all menu items
virtual void removeAllItems() _IRR_OVERRIDE_;
//! called if an event happened.
virtual bool OnEvent(const SEvent& event) _IRR_OVERRIDE_;
//! draws the element and its children
virtual void draw() _IRR_OVERRIDE_;
//! Returns the selected item in the menu
virtual s32 getSelectedItem() const _IRR_OVERRIDE_;
//! Returns a pointer to the submenu of an item.
//! \return Pointer to the submenu of an item.
virtual IGUIContextMenu* getSubMenu(u32 idx) const _IRR_OVERRIDE_;
//! Sets the visible state of this element.
virtual void setVisible(bool visible) _IRR_OVERRIDE_;
//! should the element change the checked status on clicking
virtual void setItemAutoChecking(u32 idx, bool autoChecking) _IRR_OVERRIDE_;
//! does the element change the checked status on clicking
virtual bool getItemAutoChecking(u32 idx) const _IRR_OVERRIDE_;
//! Returns command id of a menu item
virtual s32 getItemCommandId(u32 idx) const _IRR_OVERRIDE_;
//! Sets the command id of a menu item
virtual void setItemCommandId(u32 idx, s32 id) _IRR_OVERRIDE_;
//! Adds a sub menu from an element that already exists.
virtual void setSubMenu(u32 index, CGUIContextMenu* menu);
//! When an eventparent is set it receives events instead of the usual parent element
virtual void setEventParent(IGUIElement *parent) _IRR_OVERRIDE_;
protected:
void closeAllSubMenus();
bool hasOpenSubMenu() const;
struct SItem
{
core::stringw Text;
bool IsSeparator;
bool Enabled;
bool Checked;
bool AutoChecking;
core::dimension2d<u32> Dim;
s32 PosY;
CGUIContextMenu* SubMenu;
s32 CommandId;
};
virtual void recalculateSize();
//! returns true, if an element was highlighted
virtual bool highlight(const core::position2d<s32>& p, bool canOpenSubMenu);
//! sends a click Returns:
//! 0 if click went outside of the element,
//! 1 if a valid button was clicked,
//! 2 if a nonclickable element was clicked
virtual u32 sendClick(const core::position2d<s32>& p);
//! returns the item highlight-area
virtual core::rect<s32> getHRect(const SItem& i, const core::rect<s32>& absolute) const;
//! Gets drawing rect of Item
virtual core::rect<s32> getRect(const SItem& i, const core::rect<s32>& absolute) const;
core::array<SItem> Items;
core::position2d<s32> Pos;
IGUIElement* EventParent;
IGUIFont *LastFont;
ECONTEXT_MENU_CLOSE CloseHandling;
s32 HighLighted;
u32 ChangeTime;
bool AllowFocus;
};
} // end namespace gui
} // end namespace irr
#endif // _IRR_COMPILE_WITH_GUI_
#endif // __C_GUI_CONTEXT_MENU_H_INCLUDED__

View File

@ -11,33 +11,19 @@
#include "CGUISkin.h"
#include "CGUIButton.h"
#include "CGUIWindow.h"
#include "CGUIScrollBar.h"
#include "CGUIFont.h"
#include "CGUISpriteBank.h"
#include "CGUIImage.h"
#include "CGUIMeshViewer.h"
#include "CGUICheckBox.h"
#include "CGUIListBox.h"
#include "CGUITreeView.h"
#include "CGUIImageList.h"
#include "CGUIFileOpenDialog.h"
#include "CGUIColorSelectDialog.h"
#include "CGUIStaticText.h"
#include "CGUIEditBox.h"
#include "CGUISpinBox.h"
#include "CGUIInOutFader.h"
#include "CGUIMessageBox.h"
#include "CGUIModalScreen.h"
#include "CGUITabControl.h"
#include "CGUIContextMenu.h"
#include "CGUIComboBox.h"
#include "CGUIMenu.h"
#include "CGUIToolBar.h"
#include "CGUITable.h"
#include "CGUIProfiler.h"
#include "CDefaultGUIElementFactory.h"
#include "IWriteFile.h"
#include "BuiltInFont.h"
@ -69,11 +55,6 @@ CGUIEnvironment::CGUIEnvironment(io::IFileSystem* fs, video::IVideoDriver* drive
IGUIEnvironment::setDebugName("CGUIEnvironment");
#endif
// gui factory
IGUIElementFactory* factory = new CDefaultGUIElementFactory(this);
registerGUIElementFactory(factory);
factory->drop();
loadBuiltInFont();
IGUISkin* skin = createSkin( gui::EGST_WINDOWS_METALLIC );
@ -140,10 +121,6 @@ CGUIEnvironment::~CGUIEnvironment()
for (i=0; i<Fonts.size(); ++i)
Fonts[i].Font->drop();
// remove all factories
for (i=0; i<GUIElementFactoryList.size(); ++i)
GUIElementFactoryList[i]->drop();
if (Operator)
{
Operator->drop();
@ -707,106 +684,6 @@ IGUISkin* CGUIEnvironment::createSkin(EGUI_SKIN_TYPE type)
}
//! Returns the default element factory which can create all built in elements
IGUIElementFactory* CGUIEnvironment::getDefaultGUIElementFactory() const
{
return getGUIElementFactory(0);
}
//! Adds an element factory to the gui environment.
/** Use this to extend the gui environment with new element types which it should be
able to create automatically, for example when loading data from xml files. */
void CGUIEnvironment::registerGUIElementFactory(IGUIElementFactory* factoryToAdd)
{
if (factoryToAdd)
{
factoryToAdd->grab();
GUIElementFactoryList.push_back(factoryToAdd);
}
}
//! Returns amount of registered scene node factories.
u32 CGUIEnvironment::getRegisteredGUIElementFactoryCount() const
{
return GUIElementFactoryList.size();
}
//! Returns a scene node factory by index
IGUIElementFactory* CGUIEnvironment::getGUIElementFactory(u32 index) const
{
if (index < GUIElementFactoryList.size())
return GUIElementFactoryList[index];
else
return 0;
}
//! adds a GUI Element using its name
IGUIElement* CGUIEnvironment::addGUIElement(const c8* elementName, IGUIElement* parent)
{
IGUIElement* node=0;
if (!parent)
parent = this;
for (s32 i=GUIElementFactoryList.size()-1; i>=0 && !node; --i)
node = GUIElementFactoryList[i]->addGUIElement(elementName, parent);
return node;
}
//! Saves the current gui into a file.
//! \param filename: Name of the file .
bool CGUIEnvironment::saveGUI(const io::path& filename, IGUIElement* start)
{
io::IWriteFile* file = FileSystem->createAndWriteFile(filename);
if (!file)
{
return false;
}
bool ret = saveGUI(file, start);
file->drop();
return ret;
}
//! Saves the current gui into a file.
bool CGUIEnvironment::saveGUI(io::IWriteFile* file, IGUIElement* start)
{
return false;
}
//! Loads the gui. Note that the current gui is not cleared before.
//! \param filename: Name of the file.
bool CGUIEnvironment::loadGUI(const io::path& filename, IGUIElement* parent)
{
io::IReadFile* read = FileSystem->createAndOpenFile(filename);
if (!read)
{
os::Printer::log("Unable to open gui file", filename, ELL_ERROR);
return false;
}
bool ret = loadGUI(read, parent);
read->drop();
return ret;
}
//! Loads the gui. Note that the current gui is not cleared before.
bool CGUIEnvironment::loadGUI(io::IReadFile* file, IGUIElement* parent)
{
return false;
}
//! adds a button. The returned pointer must not be dropped.
IGUIButton* CGUIEnvironment::addButton(const core::rect<s32>& rectangle, IGUIElement* parent, s32 id, const wchar_t* text, const wchar_t *tooltiptext)
{
@ -822,83 +699,6 @@ IGUIButton* CGUIEnvironment::addButton(const core::rect<s32>& rectangle, IGUIEle
}
//! adds a window. The returned pointer must not be dropped.
IGUIWindow* CGUIEnvironment::addWindow(const core::rect<s32>& rectangle, bool modal,
const wchar_t* text, IGUIElement* parent, s32 id)
{
parent = parent ? parent : this;
IGUIWindow* win = new CGUIWindow(this, parent, id, rectangle);
if (text)
win->setText(text);
win->drop();
if (modal)
{
// Careful, don't just set the modal as parent above. That will mess up the focus (and is hard to change because we have to be very
// careful not to get virtual function call, like OnEvent, in the window.
CGUIModalScreen * modalScreen = new CGUIModalScreen(this, parent, -1);
modalScreen->drop();
modalScreen->addChild(win);
}
return win;
}
//! adds a modal screen. The returned pointer must not be dropped.
IGUIElement* CGUIEnvironment::addModalScreen(IGUIElement* parent, int blinkMode)
{
parent = parent ? parent : this;
CGUIModalScreen *win = new CGUIModalScreen(this, parent, -1);
win->setBlinkMode(blinkMode);
win->drop();
return win;
}
//! Adds a message box.
IGUIWindow* CGUIEnvironment::addMessageBox(const wchar_t* caption, const wchar_t* text,
bool modal, s32 flag, IGUIElement* parent, s32 id, video::ITexture* image)
{
if (!CurrentSkin)
return 0;
parent = parent ? parent : this;
core::rect<s32> rect;
core::dimension2d<u32> screenDim, msgBoxDim;
screenDim.Width = parent->getAbsolutePosition().getWidth();
screenDim.Height = parent->getAbsolutePosition().getHeight();
msgBoxDim.Width = 2;
msgBoxDim.Height = 2;
rect.UpperLeftCorner.X = (screenDim.Width - msgBoxDim.Width) / 2;
rect.UpperLeftCorner.Y = (screenDim.Height - msgBoxDim.Height) / 2;
rect.LowerRightCorner.X = rect.UpperLeftCorner.X + msgBoxDim.Width;
rect.LowerRightCorner.Y = rect.UpperLeftCorner.Y + msgBoxDim.Height;
IGUIWindow* win = new CGUIMessageBox(this, caption, text, flag,
parent, id, rect, image);
win->drop();
if (modal)
{
// Careful, don't just set the modal as parent above. That will mess up the focus (and is hard to change because we have to be very
// careful not to get virtual function call, like OnEvent, in the CGUIMessageBox.
CGUIModalScreen * modalScreen = new CGUIModalScreen(this, parent, -1);
modalScreen->drop();
modalScreen->addChild( win );
}
return win;
}
//! adds a scrollbar. The returned pointer must not be dropped.
IGUIScrollBar* CGUIEnvironment::addScrollBar(bool horizontal, const core::rect<s32>& rectangle, IGUIElement* parent, s32 id)
{
@ -907,21 +707,6 @@ IGUIScrollBar* CGUIEnvironment::addScrollBar(bool horizontal, const core::rect<s
return bar;
}
//! Adds a table to the environment
IGUITable* CGUIEnvironment::addTable(const core::rect<s32>& rectangle, IGUIElement* parent, s32 id, bool drawBackground)
{
CGUITable* b = new CGUITable(this, parent ? parent : this, id, rectangle, true, drawBackground, false);
b->drop();
return b;
}
//! Adds an element to display the information from the Irrlicht profiler
IGUIProfiler* CGUIEnvironment::addProfilerDisplay(const core::rect<s32>& rectangle, IGUIElement* parent, s32 id)
{
CGUIProfiler* p = new CGUIProfiler(this, parent ? parent : this, id, rectangle, NULL);
p->drop();
return p;
}
//! Adds an image element.
IGUIImage* CGUIEnvironment::addImage(video::ITexture* image, core::position2d<s32> pos,
@ -965,20 +750,6 @@ IGUIImage* CGUIEnvironment::addImage(const core::rect<s32>& rectangle, IGUIEleme
}
//! adds an mesh viewer. The returned pointer must not be dropped.
IGUIMeshViewer* CGUIEnvironment::addMeshViewer(const core::rect<s32>& rectangle, IGUIElement* parent, s32 id, const wchar_t* text)
{
IGUIMeshViewer* v = new CGUIMeshViewer(this, parent ? parent : this,
id, rectangle);
if (text)
v->setText(text);
v->drop();
return v;
}
//! adds a checkbox
IGUICheckBox* CGUIEnvironment::addCheckBox(bool checked, const core::rect<s32>& rectangle, IGUIElement* parent, s32 id, const wchar_t* text)
{
@ -1013,19 +784,6 @@ IGUIListBox* CGUIEnvironment::addListBox(const core::rect<s32>& rectangle,
return b;
}
//! adds a tree view
IGUITreeView* CGUIEnvironment::addTreeView(const core::rect<s32>& rectangle,
IGUIElement* parent, s32 id,
bool drawBackground,
bool scrollBarVertical, bool scrollBarHorizontal)
{
IGUITreeView* b = new CGUITreeView(this, parent ? parent : this, id, rectangle,
true, drawBackground, scrollBarVertical, scrollBarHorizontal);
b->setIconFont ( getBuiltInFont () );
b->drop();
return b;
}
//! adds a file open dialog. The returned pointer must not be dropped.
IGUIFileOpenDialog* CGUIEnvironment::addFileOpenDialog(const wchar_t* title,
@ -1034,42 +792,13 @@ IGUIFileOpenDialog* CGUIEnvironment::addFileOpenDialog(const wchar_t* title,
{
parent = parent ? parent : this;
if (modal)
return nullptr;
IGUIFileOpenDialog* d = new CGUIFileOpenDialog(title, this, parent, id,
restoreCWD, startDir);
d->drop();
if (modal)
{
// Careful, don't just set the modal as parent above. That will mess up the focus (and is hard to change because we have to be very
// careful not to get virtual function call, like OnEvent, in the window.
CGUIModalScreen * modalScreen = new CGUIModalScreen(this, parent, -1);
modalScreen->drop();
modalScreen->addChild(d);
}
return d;
}
//! adds a color select dialog. The returned pointer must not be dropped.
IGUIColorSelectDialog* CGUIEnvironment::addColorSelectDialog(const wchar_t* title,
bool modal, IGUIElement* parent, s32 id)
{
parent = parent ? parent : this;
IGUIColorSelectDialog* d = new CGUIColorSelectDialog( title,
this, parent, id);
d->drop();
if (modal)
{
// Careful, don't just set the modal as parent above. That will mess up the focus (and is hard to change because we have to be very
// careful not to get virtual function call, like OnEvent, in the window.
CGUIModalScreen * modalScreen = new CGUIModalScreen(this, parent, -1);
modalScreen->drop();
modalScreen->addChild(d);
}
return d;
}
@ -1103,19 +832,6 @@ IGUIEditBox* CGUIEnvironment::addEditBox(const wchar_t* text,
}
//! Adds a spin box to the environment
IGUISpinBox* CGUIEnvironment::addSpinBox(const wchar_t* text,
const core::rect<s32> &rectangle,
bool border,IGUIElement* parent, s32 id)
{
IGUISpinBox* d = new CGUISpinBox(text, border,this,
parent ? parent : this, id, rectangle);
d->drop();
return d;
}
//! Adds a tab control to the environment.
IGUITabControl* CGUIEnvironment::addTabControl(const core::rect<s32>& rectangle,
IGUIElement* parent, bool fillbackground, bool border, s32 id)
@ -1138,65 +854,6 @@ IGUITab* CGUIEnvironment::addTab(const core::rect<s32>& rectangle,
}
//! Adds a context menu to the environment.
IGUIContextMenu* CGUIEnvironment::addContextMenu(const core::rect<s32>& rectangle,
IGUIElement* parent, s32 id)
{
IGUIContextMenu* c = new CGUIContextMenu(this,
parent ? parent : this, id, rectangle, true);
c->drop();
return c;
}
//! Adds a menu to the environment.
IGUIContextMenu* CGUIEnvironment::addMenu(IGUIElement* parent, s32 id)
{
if (!parent)
parent = this;
IGUIContextMenu* c = new CGUIMenu(this,
parent, id, core::rect<s32>(0,0,
parent->getAbsolutePosition().getWidth(),
parent->getAbsolutePosition().getHeight()));
c->drop();
return c;
}
//! Adds a toolbar to the environment. It is like a menu is always placed on top
//! in its parent, and contains buttons.
IGUIToolBar* CGUIEnvironment::addToolBar(IGUIElement* parent, s32 id)
{
if (!parent)
parent = this;
IGUIToolBar* b = new CGUIToolBar(this, parent, id, core::rect<s32>(0,0,10,10));
b->drop();
return b;
}
//! Adds an element for fading in or out.
IGUIInOutFader* CGUIEnvironment::addInOutFader(const core::rect<s32>* rectangle, IGUIElement* parent, s32 id)
{
core::rect<s32> rect;
if (rectangle)
rect = *rectangle;
else if (Driver)
rect = core::rect<s32>(core::dimension2di(Driver->getScreenSize()));
if (!parent)
parent = this;
IGUIInOutFader* fader = new CGUIInOutFader(this, parent, id, rect);
fader->drop();
return fader;
}
//! Adds a combo box to the environment.
IGUIComboBox* CGUIEnvironment::addComboBox(const core::rect<s32>& rectangle,
IGUIElement* parent, s32 id)

View File

@ -92,17 +92,6 @@ public:
//! adds an button. The returned pointer must not be dropped.
virtual IGUIButton* addButton(const core::rect<s32>& rectangle, IGUIElement* parent=0, s32 id=-1, const wchar_t* text=0,const wchar_t* tooltiptext = 0) _IRR_OVERRIDE_;
//! adds a window. The returned pointer must not be dropped.
virtual IGUIWindow* addWindow(const core::rect<s32>& rectangle, bool modal = false,
const wchar_t* text=0, IGUIElement* parent=0, s32 id=-1) _IRR_OVERRIDE_;
//! adds a modal screen. The returned pointer must not be dropped.
virtual IGUIElement* addModalScreen(IGUIElement* parent, int blinkMode) _IRR_OVERRIDE_;
//! Adds a message box.
virtual IGUIWindow* addMessageBox(const wchar_t* caption, const wchar_t* text=0,
bool modal = true, s32 flag = EMBF_OK, IGUIElement* parent=0, s32 id=-1, video::ITexture* image=0) _IRR_OVERRIDE_;
//! adds a scrollbar. The returned pointer must not be dropped.
virtual IGUIScrollBar* addScrollBar(bool horizontal, const core::rect<s32>& rectangle,
IGUIElement* parent=0, s32 id=-1) _IRR_OVERRIDE_;
@ -123,24 +112,11 @@ public:
virtual IGUIListBox* addListBox(const core::rect<s32>& rectangle,
IGUIElement* parent=0, s32 id=-1, bool drawBackground=false) _IRR_OVERRIDE_;
//! adds a tree view
virtual IGUITreeView* addTreeView(const core::rect<s32>& rectangle,
IGUIElement* parent=0, s32 id=-1, bool drawBackground=false,
bool scrollBarVertical = true, bool scrollBarHorizontal = false) _IRR_OVERRIDE_;
//! adds an mesh viewer. The returned pointer must not be dropped.
virtual IGUIMeshViewer* addMeshViewer(const core::rect<s32>& rectangle,
IGUIElement* parent=0, s32 id=-1, const wchar_t* text=0) _IRR_OVERRIDE_;
//! Adds a file open dialog.
virtual IGUIFileOpenDialog* addFileOpenDialog(const wchar_t* title = 0,
bool modal=true, IGUIElement* parent=0, s32 id=-1,
bool restoreCWD=false, io::path::char_type* startDir=0) _IRR_OVERRIDE_;
//! Adds a color select dialog.
virtual IGUIColorSelectDialog* addColorSelectDialog(const wchar_t* title = 0,
bool modal=true, IGUIElement* parent=0, s32 id=-1) _IRR_OVERRIDE_;
//! adds a static text. The returned pointer must not be dropped.
virtual IGUIStaticText* addStaticText(const wchar_t* text, const core::rect<s32>& rectangle,
bool border=false, bool wordWrap=true, IGUIElement* parent=0, s32 id=-1, bool drawBackground = false) _IRR_OVERRIDE_;
@ -149,10 +125,6 @@ public:
virtual IGUIEditBox* addEditBox(const wchar_t* text, const core::rect<s32>& rectangle,
bool border=false, IGUIElement* parent=0, s32 id=-1) _IRR_OVERRIDE_;
//! Adds a spin box to the environment
virtual IGUISpinBox* addSpinBox(const wchar_t* text, const core::rect<s32>& rectangle,
bool border=false,IGUIElement* parent=0, s32 id=-1) _IRR_OVERRIDE_;
//! Adds a tab control to the environment.
virtual IGUITabControl* addTabControl(const core::rect<s32>& rectangle,
IGUIElement* parent=0, bool fillbackground=false, bool border=true, s32 id=-1) _IRR_OVERRIDE_;
@ -161,29 +133,10 @@ public:
virtual IGUITab* addTab(const core::rect<s32>& rectangle,
IGUIElement* parent=0, s32 id=-1) _IRR_OVERRIDE_;
//! Adds a context menu to the environment.
virtual IGUIContextMenu* addContextMenu(const core::rect<s32>& rectangle,
IGUIElement* parent=0, s32 id=-1) _IRR_OVERRIDE_;
//! Adds a menu to the environment.
virtual IGUIContextMenu* addMenu(IGUIElement* parent=0, s32 id=-1) _IRR_OVERRIDE_;
//! Adds a toolbar to the environment. It is like a menu is always placed on top
//! in its parent, and contains buttons.
virtual IGUIToolBar* addToolBar(IGUIElement* parent=0, s32 id=-1) _IRR_OVERRIDE_;
//! Adds a combo box to the environment.
virtual IGUIComboBox* addComboBox(const core::rect<s32>& rectangle,
IGUIElement* parent=0, s32 id=-1) _IRR_OVERRIDE_;
//! Adds a table element.
virtual IGUITable* addTable(const core::rect<s32>& rectangle,
IGUIElement* parent=0, s32 id=-1, bool drawBackground=false) _IRR_OVERRIDE_;
//! Adds an element to display the information from the Irrlicht profiler
virtual IGUIProfiler* addProfilerDisplay(const core::rect<s32>& rectangle,
IGUIElement* parent=0, s32 id=-1) _IRR_OVERRIDE_;
//! sets the focus to an element
virtual bool setFocus(IGUIElement* element) _IRR_OVERRIDE_;
@ -199,55 +152,11 @@ public:
//! Returns the element last known to be under the mouse
virtual IGUIElement* getHovered() const _IRR_OVERRIDE_;
//! Adds an element for fading in or out.
virtual IGUIInOutFader* addInOutFader(const core::rect<s32>* rectangle=0, IGUIElement* parent=0, s32 id=-1) _IRR_OVERRIDE_;
//! Returns the root gui element.
virtual IGUIElement* getRootGUIElement() _IRR_OVERRIDE_;
virtual void OnPostRender( u32 time ) _IRR_OVERRIDE_;
//! Returns the default element factory which can create all built in elements
virtual IGUIElementFactory* getDefaultGUIElementFactory() const _IRR_OVERRIDE_;
//! Adds an element factory to the gui environment.
/** Use this to extend the gui environment with new element types which it should be
able to create automatically, for example when loading data from xml files. */
virtual void registerGUIElementFactory(IGUIElementFactory* factoryToAdd) _IRR_OVERRIDE_;
//! Returns amount of registered scene node factories.
virtual u32 getRegisteredGUIElementFactoryCount() const _IRR_OVERRIDE_;
//! Returns a scene node factory by index
virtual IGUIElementFactory* getGUIElementFactory(u32 index) const _IRR_OVERRIDE_;
//! Adds a GUI Element by its name
virtual IGUIElement* addGUIElement(const c8* elementName, IGUIElement* parent=0) _IRR_OVERRIDE_;
//! Saves the current gui into a file.
/** \param filename: Name of the file.
\param start: The element to start saving from.
if not specified, the root element will be used */
virtual bool saveGUI( const io::path& filename, IGUIElement* start=0) _IRR_OVERRIDE_;
//! Saves the current gui into a file.
/** \param file: The file to save the GUI to.
\param start: The element to start saving from.
if not specified, the root element will be used */
virtual bool saveGUI(io::IWriteFile* file, IGUIElement* start=0) _IRR_OVERRIDE_;
//! Loads the gui. Note that the current gui is not cleared before.
/** \param filename: Name of the file.
\param parent: The parent of all loaded GUI elements,
if not specified, the root element will be used */
virtual bool loadGUI(const io::path& filename, IGUIElement* parent=0) _IRR_OVERRIDE_;
//! Loads the gui. Note that the current gui is not cleared before.
/** \param file: IReadFile to load the GUI from
\param parent: The parent of all loaded GUI elements,
if not specified, the root element will be used */
virtual bool loadGUI(io::IReadFile* file, IGUIElement* parent=0) _IRR_OVERRIDE_;
//! Find the next element which would be selected when pressing the tab-key
virtual IGUIElement* getNextElement(bool reverse=false, bool group=false) _IRR_OVERRIDE_;
@ -302,8 +211,6 @@ private:
SToolTip ToolTip;
core::array<IGUIElementFactory*> GUIElementFactoryList;
core::array<SFont> Fonts;
core::array<SSpriteBank> Banks;
video::IVideoDriver* Driver;

View File

@ -1,156 +0,0 @@
// Copyright (C) 2002-2012 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#include "CGUIInOutFader.h"
#ifdef _IRR_COMPILE_WITH_GUI_
#include "IGUIEnvironment.h"
#include "IVideoDriver.h"
#include "os.h"
namespace irr
{
namespace gui
{
//! constructor
CGUIInOutFader::CGUIInOutFader(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle)
: IGUIInOutFader(environment, parent, id, rectangle)
{
#ifdef _DEBUG
setDebugName("CGUIInOutFader");
#endif
Action = EFA_NOTHING;
StartTime = 0;
EndTime = 0;
setColor(video::SColor(0,0,0,0));
}
//! draws the element and its children
void CGUIInOutFader::draw()
{
if (!IsVisible || !Action)
return;
u32 now = os::Timer::getTime();
if (now > EndTime && Action == EFA_FADE_IN)
{
Action = EFA_NOTHING;
return;
}
video::IVideoDriver* driver = Environment->getVideoDriver();
if (driver)
{
f32 d;
if (now > EndTime)
d = 0.0f;
else
d = (EndTime - now) / (f32)(EndTime - StartTime);
video::SColor newCol = FullColor.getInterpolated(TransColor, d);
driver->draw2DRectangle(newCol, AbsoluteRect, &AbsoluteClippingRect);
}
IGUIElement::draw();
}
//! Gets the color to fade out to or to fade in from.
video::SColor CGUIInOutFader::getColor() const
{
return Color[1];
}
//! Sets the color to fade out to or to fade in from.
void CGUIInOutFader::setColor(video::SColor color)
{
video::SColor s = color;
video::SColor d = color;
s.setAlpha ( 255 );
d.setAlpha ( 0 );
setColor ( s,d );
/*
Color[0] = color;
FullColor = Color[0];
TransColor = Color[0];
if (Action == EFA_FADE_OUT)
{
FullColor.setAlpha(0);
TransColor.setAlpha(255);
}
else
if (Action == EFA_FADE_IN)
{
FullColor.setAlpha(255);
TransColor.setAlpha(0);
}
*/
}
void CGUIInOutFader::setColor(video::SColor source, video::SColor dest)
{
Color[0] = source;
Color[1] = dest;
if (Action == EFA_FADE_OUT)
{
FullColor = Color[1];
TransColor = Color[0];
}
else
if (Action == EFA_FADE_IN)
{
FullColor = Color[0];
TransColor = Color[1];
}
}
//! Returns if the fade in or out process is done.
bool CGUIInOutFader::isReady() const
{
u32 now = os::Timer::getTime();
bool ret = (now > EndTime);
return ret;
}
//! Starts the fade in process.
void CGUIInOutFader::fadeIn(u32 time)
{
StartTime = os::Timer::getTime();
EndTime = StartTime + time;
Action = EFA_FADE_IN;
setColor(Color[0],Color[1]);
}
//! Starts the fade out process.
void CGUIInOutFader::fadeOut(u32 time)
{
StartTime = os::Timer::getTime();
EndTime = StartTime + time;
Action = EFA_FADE_OUT;
setColor(Color[0],Color[1]);
}
} // end namespace gui
} // end namespace irr
#endif // _IRR_COMPILE_WITH_GUI_

View File

@ -1,69 +0,0 @@
// Copyright (C) 2002-2012 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __C_GUI_IN_OUT_FADER_H_INCLUDED__
#define __C_GUI_IN_OUT_FADER_H_INCLUDED__
#include "IrrCompileConfig.h"
#ifdef _IRR_COMPILE_WITH_GUI_
#include "IGUIInOutFader.h"
namespace irr
{
namespace gui
{
class CGUIInOutFader : public IGUIInOutFader
{
public:
//! constructor
CGUIInOutFader(IGUIEnvironment* environment, IGUIElement* parent,
s32 id, core::rect<s32> rectangle);
//! draws the element and its children
virtual void draw() _IRR_OVERRIDE_;
//! Gets the color to fade out to or to fade in from.
virtual video::SColor getColor() const _IRR_OVERRIDE_;
//! Sets the color to fade out to or to fade in from.
virtual void setColor(video::SColor color ) _IRR_OVERRIDE_;
virtual void setColor(video::SColor source, video::SColor dest) _IRR_OVERRIDE_;
//! Starts the fade in process.
virtual void fadeIn(u32 time) _IRR_OVERRIDE_;
//! Starts the fade out process.
virtual void fadeOut(u32 time) _IRR_OVERRIDE_;
//! Returns if the fade in or out process is done.
virtual bool isReady() const _IRR_OVERRIDE_;
private:
enum EFadeAction
{
EFA_NOTHING = 0,
EFA_FADE_IN,
EFA_FADE_OUT
};
u32 StartTime;
u32 EndTime;
EFadeAction Action;
video::SColor Color[2];
video::SColor FullColor;
video::SColor TransColor;
};
} // end namespace gui
} // end namespace irr
#endif // _IRR_COMPILE_WITH_GUI_
#endif // __C_GUI_IN_OUT_FADER_H_INCLUDED__

View File

@ -1,289 +0,0 @@
// Copyright (C) 2002-2012 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#include "CGUIMenu.h"
#ifdef _IRR_COMPILE_WITH_GUI_
#include "IGUISkin.h"
#include "IGUIEnvironment.h"
#include "IVideoDriver.h"
#include "IGUIFont.h"
#include "IGUIWindow.h"
#include "os.h"
namespace irr
{
namespace gui
{
//! constructor
CGUIMenu::CGUIMenu(IGUIEnvironment* environment, IGUIElement* parent,
s32 id, core::rect<s32> rectangle)
: CGUIContextMenu(environment, parent, id, rectangle, false, true)
{
#ifdef _DEBUG
setDebugName("CGUIMenu");
#endif
Type = EGUIET_MENU;
setNotClipped(false);
recalculateSize();
}
//! draws the element and its children
void CGUIMenu::draw()
{
if (!IsVisible)
return;
IGUISkin* skin = Environment->getSkin();
IGUIFont* font = skin->getFont(EGDF_MENU);
if (font != LastFont)
{
if (LastFont)
LastFont->drop();
LastFont = font;
if (LastFont)
LastFont->grab();
recalculateSize();
}
core::rect<s32> rect = AbsoluteRect;
// draw frame
skin->draw3DToolBar(this, rect, &AbsoluteClippingRect);
// loop through all menu items
rect = AbsoluteRect;
for (s32 i=0; i<(s32)Items.size(); ++i)
{
if (!Items[i].IsSeparator)
{
rect = getRect(Items[i], AbsoluteRect);
// draw highlighted
if (i == HighLighted && Items[i].Enabled)
{
skin->draw3DSunkenPane(this, skin->getColor(EGDC_3D_DARK_SHADOW),
true, true, rect, &AbsoluteClippingRect);
}
// draw text
EGUI_DEFAULT_COLOR c = EGDC_BUTTON_TEXT;
if (i == HighLighted)
c = EGDC_HIGH_LIGHT_TEXT;
if (!Items[i].Enabled)
c = EGDC_GRAY_TEXT;
if (font)
font->draw(Items[i].Text.c_str(), rect,
skin->getColor(c), true, true, &AbsoluteClippingRect);
}
}
IGUIElement::draw();
}
//! called if an event happened.
bool CGUIMenu::OnEvent(const SEvent& event)
{
if (isEnabled())
{
switch(event.EventType)
{
case EET_GUI_EVENT:
switch(event.GUIEvent.EventType)
{
case gui::EGET_ELEMENT_FOCUS_LOST:
if (event.GUIEvent.Caller == this && !isMyChild(event.GUIEvent.Element))
{
closeAllSubMenus();
HighLighted = -1;
}
break;
case gui::EGET_ELEMENT_FOCUSED:
if (event.GUIEvent.Caller == this && Parent)
{
Parent->bringToFront(this);
}
break;
default:
break;
}
break;
case EET_MOUSE_INPUT_EVENT:
switch(event.MouseInput.Event)
{
case EMIE_LMOUSE_PRESSED_DOWN:
{
if (Parent)
Parent->bringToFront(this);
core::position2d<s32> p(event.MouseInput.X, event.MouseInput.Y);
bool shouldCloseSubMenu = hasOpenSubMenu();
if (!AbsoluteClippingRect.isPointInside(p))
{
shouldCloseSubMenu = false;
}
highlight(core::position2d<s32>(event.MouseInput.X, event.MouseInput.Y), true);
if ( shouldCloseSubMenu )
{
Environment->removeFocus(this);
}
return true;
}
case EMIE_LMOUSE_LEFT_UP:
{
core::position2d<s32> p(event.MouseInput.X, event.MouseInput.Y);
if (!AbsoluteClippingRect.isPointInside(p))
{
s32 t = sendClick(p);
if ((t==0 || t==1) && Environment->hasFocus(this))
Environment->removeFocus(this);
}
return true;
}
case EMIE_MOUSE_MOVED:
if (Environment->hasFocus(this) && HighLighted >= 0)
{
s32 oldHighLighted = HighLighted;
highlight(core::position2d<s32>(event.MouseInput.X, event.MouseInput.Y), true);
if ( HighLighted < 0 )
HighLighted = oldHighLighted; // keep last hightlight active when moving outside the area
}
return true;
default:
break;
}
break;
default:
break;
}
}
return IGUIElement::OnEvent(event);
}
void CGUIMenu::recalculateSize()
{
core::rect<s32> clientRect; // client rect of parent
if ( Parent && Parent->hasType(EGUIET_WINDOW) )
{
clientRect = static_cast<IGUIWindow*>(Parent)->getClientRect();
}
else if ( Parent )
{
clientRect = core::rect<s32>(0,0, Parent->getAbsolutePosition().getWidth(),
Parent->getAbsolutePosition().getHeight());
}
else
{
clientRect = RelativeRect;
}
IGUISkin* skin = Environment->getSkin();
IGUIFont* font = skin->getFont(EGDF_MENU);
if (!font)
{
if (Parent && skin)
RelativeRect = core::rect<s32>(clientRect.UpperLeftCorner.X, clientRect.UpperLeftCorner.Y,
clientRect.LowerRightCorner.X, clientRect.UpperLeftCorner.Y+skin->getSize(EGDS_MENU_HEIGHT));
return;
}
core::rect<s32> rect;
rect.UpperLeftCorner = clientRect.UpperLeftCorner;
s32 height = font->getDimension(L"A").Height + 5;
//if (skin && height < skin->getSize ( EGDS_MENU_HEIGHT ))
// height = skin->getSize(EGDS_MENU_HEIGHT);
s32 width = rect.UpperLeftCorner.X;
s32 i;
for (i=0; i<(s32)Items.size(); ++i)
{
if (Items[i].IsSeparator)
{
Items[i].Dim.Width = 0;
Items[i].Dim.Height = height;
}
else
{
Items[i].Dim = font->getDimension(Items[i].Text.c_str());
Items[i].Dim.Width += 20;
}
Items[i].PosY = width;
width += Items[i].Dim.Width;
}
width = clientRect.getWidth();
rect.LowerRightCorner.X = rect.UpperLeftCorner.X + width;
rect.LowerRightCorner.Y = rect.UpperLeftCorner.Y + height;
setRelativePosition(rect);
// recalculate submenus
for (i=0; i<(s32)Items.size(); ++i)
if (Items[i].SubMenu)
{
// move submenu
s32 w = Items[i].SubMenu->getAbsolutePosition().getWidth();
s32 h = Items[i].SubMenu->getAbsolutePosition().getHeight();
Items[i].SubMenu->setRelativePosition(
core::rect<s32>(Items[i].PosY, height ,
Items[i].PosY+w-5, height+h));
}
}
//! returns the item highlight-area
core::rect<s32> CGUIMenu::getHRect(const SItem& i, const core::rect<s32>& absolute) const
{
core::rect<s32> r = absolute;
r.UpperLeftCorner.X += i.PosY;
r.LowerRightCorner.X = r.UpperLeftCorner.X + i.Dim.Width;
return r;
}
//! Gets drawing rect of Item
core::rect<s32> CGUIMenu::getRect(const SItem& i, const core::rect<s32>& absolute) const
{
return getHRect(i, absolute);
}
void CGUIMenu::updateAbsolutePosition()
{
if (Parent)
DesiredRect.LowerRightCorner.X = Parent->getAbsolutePosition().getWidth();
IGUIElement::updateAbsolutePosition();
}
} // end namespace
} // end namespace
#endif // _IRR_COMPILE_WITH_GUI_

View File

@ -1,52 +0,0 @@
// Copyright (C) 2002-2012 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __C_GUI_MENU_H_INCLUDED__
#define __C_GUI_MENU_H_INCLUDED__
#include "IrrCompileConfig.h"
#ifdef _IRR_COMPILE_WITH_GUI_
#include "CGUIContextMenu.h"
namespace irr
{
namespace gui
{
//! GUI menu interface.
class CGUIMenu : public CGUIContextMenu
{
public:
//! constructor
CGUIMenu(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle);
//! draws the element and its children
virtual void draw() _IRR_OVERRIDE_;
//! called if an event happened.
virtual bool OnEvent(const SEvent& event) _IRR_OVERRIDE_;
//! Updates the absolute position.
virtual void updateAbsolutePosition() _IRR_OVERRIDE_;
protected:
virtual void recalculateSize() _IRR_OVERRIDE_;
//! returns the item highlight-area
virtual core::rect<s32> getHRect(const SItem& i, const core::rect<s32>& absolute) const _IRR_OVERRIDE_;
//! Gets drawing rect of Item
virtual core::rect<s32> getRect(const SItem& i, const core::rect<s32>& absolute) const _IRR_OVERRIDE_;
};
} // end namespace gui
} // end namespace irr
#endif // __C_GUI_MENU_H_INCLUDED__
#endif // _IRR_COMPILE_WITH_GUI_

View File

@ -1,171 +0,0 @@
// Copyright (C) 2002-2012 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#include "CGUIMeshViewer.h"
#ifdef _IRR_COMPILE_WITH_GUI_
#include "IGUIEnvironment.h"
#include "IVideoDriver.h"
#include "IAnimatedMesh.h"
#include "IMesh.h"
#include "os.h"
#include "IGUISkin.h"
namespace irr
{
namespace gui
{
//! constructor
CGUIMeshViewer::CGUIMeshViewer(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle)
: IGUIMeshViewer(environment, parent, id, rectangle), Mesh(0)
{
#ifdef _DEBUG
setDebugName("CGUIMeshViewer");
#endif
}
//! destructor
CGUIMeshViewer::~CGUIMeshViewer()
{
if (Mesh)
Mesh->drop();
}
//! sets the mesh to be shown
void CGUIMeshViewer::setMesh(scene::IAnimatedMesh* mesh)
{
if (mesh)
mesh->grab();
if (Mesh)
Mesh->drop();
Mesh = mesh;
/* This might be used for proper transformation etc.
core::vector3df center(0.0f,0.0f,0.0f);
core::aabbox3d<f32> box;
box = Mesh->getMesh(0)->getBoundingBox();
center = (box.MaxEdge + box.MinEdge) / 2;
*/
}
//! Gets the displayed mesh
scene::IAnimatedMesh* CGUIMeshViewer::getMesh() const
{
return Mesh;
}
//! sets the material
void CGUIMeshViewer::setMaterial(const video::SMaterial& material)
{
Material = material;
}
//! gets the material
const video::SMaterial& CGUIMeshViewer::getMaterial() const
{
return Material;
}
//! called if an event happened.
bool CGUIMeshViewer::OnEvent(const SEvent& event)
{
return IGUIElement::OnEvent(event);
}
//! draws the element and its children
void CGUIMeshViewer::draw()
{
if (!IsVisible)
return;
IGUISkin* skin = Environment->getSkin();
video::IVideoDriver* driver = Environment->getVideoDriver();
core::rect<s32> viewPort = AbsoluteRect;
viewPort.LowerRightCorner.X -= 1;
viewPort.LowerRightCorner.Y -= 1;
viewPort.UpperLeftCorner.X += 1;
viewPort.UpperLeftCorner.Y += 1;
viewPort.clipAgainst(AbsoluteClippingRect);
// draw the frame
core::rect<s32> frameRect(AbsoluteRect);
frameRect.LowerRightCorner.Y = frameRect.UpperLeftCorner.Y + 1;
skin->draw2DRectangle(this, skin->getColor(EGDC_3D_SHADOW), frameRect, &AbsoluteClippingRect);
frameRect.LowerRightCorner.Y = AbsoluteRect.LowerRightCorner.Y;
frameRect.LowerRightCorner.X = frameRect.UpperLeftCorner.X + 1;
skin->draw2DRectangle(this, skin->getColor(EGDC_3D_SHADOW), frameRect, &AbsoluteClippingRect);
frameRect = AbsoluteRect;
frameRect.UpperLeftCorner.X = frameRect.LowerRightCorner.X - 1;
skin->draw2DRectangle(this, skin->getColor(EGDC_3D_HIGH_LIGHT), frameRect, &AbsoluteClippingRect);
frameRect = AbsoluteRect;
frameRect.UpperLeftCorner.Y = AbsoluteRect.LowerRightCorner.Y - 1;
skin->draw2DRectangle(this, skin->getColor(EGDC_3D_HIGH_LIGHT), frameRect, &AbsoluteClippingRect);
// draw the mesh
if (Mesh)
{
//TODO: if outside of screen, dont draw.
// - why is the absolute clipping rect not already the screen?
core::rect<s32> oldViewPort = driver->getViewPort();
driver->setViewPort(viewPort);
core::matrix4 mat;
//CameraControl->calculateProjectionMatrix(mat);
//driver->setTransform(video::TS_PROJECTION, mat);
mat.makeIdentity();
mat.setTranslation(core::vector3df(0,0,0));
driver->setTransform(video::ETS_WORLD, mat);
//CameraControl->calculateViewMatrix(mat);
//driver->setTransform(video::TS_VIEW, mat);
driver->setMaterial(Material);
u32 frame = 0;
if(Mesh->getFrameCount())
frame = (os::Timer::getTime()/20)%Mesh->getFrameCount();
const scene::IMesh* const m = Mesh->getMesh(frame);
for (u32 i=0; i<m->getMeshBufferCount(); ++i)
{
scene::IMeshBuffer* mb = m->getMeshBuffer(i);
driver->drawVertexPrimitiveList(mb->getVertices(),
mb->getVertexCount(), mb->getIndices(),
mb->getPrimitiveCount(), mb->getVertexType(),
mb->getPrimitiveType(), mb->getIndexType());
}
driver->setViewPort(oldViewPort);
}
IGUIElement::draw();
}
} // end namespace gui
} // end namespace irr
#endif // _IRR_COMPILE_WITH_GUI_

View File

@ -1,61 +0,0 @@
// Copyright (C) 2002-2012 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __C_GUI_MESH_VIEWER_H_INCLUDED__
#define __C_GUI_MESH_VIEWER_H_INCLUDED__
#include "IrrCompileConfig.h"
#ifdef _IRR_COMPILE_WITH_GUI_
#include "IGUIMeshViewer.h"
#include "SMaterial.h"
namespace irr
{
namespace gui
{
class CGUIMeshViewer : public IGUIMeshViewer
{
public:
//! constructor
CGUIMeshViewer(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle);
//! destructor
virtual ~CGUIMeshViewer();
//! sets the mesh to be shown
virtual void setMesh(scene::IAnimatedMesh* mesh) _IRR_OVERRIDE_;
//! Gets the displayed mesh
virtual scene::IAnimatedMesh* getMesh() const _IRR_OVERRIDE_;
//! sets the material
virtual void setMaterial(const video::SMaterial& material) _IRR_OVERRIDE_;
//! gets the material
virtual const video::SMaterial& getMaterial() const _IRR_OVERRIDE_;
//! called if an event happened.
virtual bool OnEvent(const SEvent& event) _IRR_OVERRIDE_;
//! draws the element and its children
virtual void draw() _IRR_OVERRIDE_;
private:
video::SMaterial Material;
scene::IAnimatedMesh* Mesh;
};
} // end namespace gui
} // end namespace irr
#endif // _IRR_COMPILE_WITH_GUI_
#endif // __C_GUI_MESH_VIEWER_H_INCLUDED__

View File

@ -1,420 +0,0 @@
// Copyright (C) 2002-2012 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#include "CGUIMessageBox.h"
#ifdef _IRR_COMPILE_WITH_GUI_
#include "IGUISkin.h"
#include "IGUIEnvironment.h"
#include "IGUIButton.h"
#include "IGUIFont.h"
#include "ITexture.h"
namespace irr
{
namespace gui
{
//! constructor
CGUIMessageBox::CGUIMessageBox(IGUIEnvironment* environment, const wchar_t* caption,
const wchar_t* text, s32 flags,
IGUIElement* parent, s32 id, core::rect<s32> rectangle, video::ITexture* image)
: CGUIWindow(environment, parent, id, rectangle),
OkButton(0), CancelButton(0), YesButton(0), NoButton(0), StaticText(0),
Icon(0), IconTexture(image),
Flags(flags), MessageText(text), Pressed(false)
{
#ifdef _DEBUG
setDebugName("CGUIMessageBox");
#endif
// set element type
Type = EGUIET_MESSAGE_BOX;
// remove focus
Environment->setFocus(0);
// remove buttons
getMaximizeButton()->remove();
getMinimizeButton()->remove();
if (caption)
setText(caption);
Environment->setFocus(this);
if ( IconTexture )
IconTexture->grab();
refreshControls();
}
//! destructor
CGUIMessageBox::~CGUIMessageBox()
{
if (StaticText)
StaticText->drop();
if (OkButton)
OkButton->drop();
if (CancelButton)
CancelButton->drop();
if (YesButton)
YesButton->drop();
if (NoButton)
NoButton->drop();
if (Icon)
Icon->drop();
if ( IconTexture )
IconTexture->drop();
}
void CGUIMessageBox::setButton(IGUIButton*& button, bool isAvailable, const core::rect<s32> & btnRect, const wchar_t * text, IGUIElement*& focusMe)
{
// add/remove ok button
if (isAvailable)
{
if (!button)
{
button = Environment->addButton(btnRect, this);
button->setSubElement(true);
button->grab();
}
else
button->setRelativePosition(btnRect);
button->setText(text);
focusMe = button;
}
else if (button)
{
button->drop();
button->remove();
button =0;
}
}
void CGUIMessageBox::refreshControls()
{
// Layout can be seen as 4 boxes (a layoutmanager would be nice)
// One box at top over the whole width for title
// Two boxes with same height at the middle beside each other for icon and for text
// One box at the bottom for the buttons
const IGUISkin* skin = Environment->getSkin();
const s32 buttonHeight = skin->getSize(EGDS_BUTTON_HEIGHT);
const s32 buttonWidth = skin->getSize(EGDS_BUTTON_WIDTH);
const s32 titleHeight = skin->getSize(EGDS_WINDOW_BUTTON_WIDTH)+2; // titlebar has no own constant
const s32 buttonDistance = skin->getSize(EGDS_WINDOW_BUTTON_WIDTH);
const s32 borderWidth = skin->getSize(EGDS_MESSAGE_BOX_GAP_SPACE);
// add the static text for the message
core::rect<s32> staticRect;
staticRect.UpperLeftCorner.X = borderWidth;
staticRect.UpperLeftCorner.Y = titleHeight + borderWidth;
staticRect.LowerRightCorner.X = staticRect.UpperLeftCorner.X + skin->getSize(EGDS_MESSAGE_BOX_MAX_TEXT_WIDTH);
staticRect.LowerRightCorner.Y = staticRect.UpperLeftCorner.Y + skin->getSize(EGDS_MESSAGE_BOX_MAX_TEXT_HEIGHT);
if (!StaticText)
{
StaticText = Environment->addStaticText(MessageText.c_str(), staticRect, false, false, this);
StaticText->setWordWrap(true);
StaticText->setSubElement(true);
StaticText->grab();
}
else
{
StaticText->setRelativePosition(staticRect);
StaticText->setText(MessageText.c_str());
}
s32 textHeight = StaticText->getTextHeight();
s32 textWidth = StaticText->getTextWidth() + 6; // +6 because the static itself needs that
const s32 iconHeight = IconTexture ? IconTexture->getOriginalSize().Height : 0;
if ( textWidth < skin->getSize(EGDS_MESSAGE_BOX_MIN_TEXT_WIDTH) )
textWidth = skin->getSize(EGDS_MESSAGE_BOX_MIN_TEXT_WIDTH) + 6;
// no neeed to check for max because it couldn't get larger due to statictextbox.
if ( textHeight < skin->getSize(EGDS_MESSAGE_BOX_MIN_TEXT_HEIGHT) )
textHeight = skin->getSize(EGDS_MESSAGE_BOX_MIN_TEXT_HEIGHT);
if ( textHeight > skin->getSize(EGDS_MESSAGE_BOX_MAX_TEXT_HEIGHT) )
textHeight = skin->getSize(EGDS_MESSAGE_BOX_MAX_TEXT_HEIGHT);
// content is text + icons + borders (but not titlebar)
s32 contentHeight = textHeight > iconHeight ? textHeight : iconHeight;
contentHeight += borderWidth;
s32 contentWidth = 0;
// add icon
if ( IconTexture )
{
core::position2d<s32> iconPos;
iconPos.Y = titleHeight + borderWidth;
if ( iconHeight < textHeight )
iconPos.Y += (textHeight-iconHeight) / 2;
iconPos.X = borderWidth;
if (!Icon)
{
Icon = Environment->addImage(IconTexture, iconPos, true, this);
Icon->setSubElement(true);
Icon->grab();
}
else
{
core::rect<s32> iconRect( iconPos.X, iconPos.Y, iconPos.X + IconTexture->getOriginalSize().Width, iconPos.Y + IconTexture->getOriginalSize().Height );
Icon->setRelativePosition(iconRect);
}
contentWidth += borderWidth + IconTexture->getOriginalSize().Width;
}
else if ( Icon )
{
Icon->drop();
Icon->remove();
Icon = 0;
}
// position text
core::rect<s32> textRect;
textRect.UpperLeftCorner.X = contentWidth + borderWidth;
textRect.UpperLeftCorner.Y = titleHeight + borderWidth;
if ( textHeight < iconHeight )
textRect.UpperLeftCorner.Y += (iconHeight-textHeight) / 2;
textRect.LowerRightCorner.X = textRect.UpperLeftCorner.X + textWidth;
textRect.LowerRightCorner.Y = textRect.UpperLeftCorner.Y + textHeight;
contentWidth += 2*borderWidth + textWidth;
StaticText->setRelativePosition( textRect );
// find out button size needs
s32 countButtons = 0;
if (Flags & EMBF_OK)
++countButtons;
if (Flags & EMBF_CANCEL)
++countButtons;
if (Flags & EMBF_YES)
++countButtons;
if (Flags & EMBF_NO)
++countButtons;
s32 buttonBoxWidth = countButtons * buttonWidth + 2 * borderWidth;
if ( countButtons > 1 )
buttonBoxWidth += (countButtons-1) * buttonDistance;
s32 buttonBoxHeight = buttonHeight + 2 * borderWidth;
// calc new message box sizes
core::rect<s32> tmp = getRelativePosition();
s32 msgBoxHeight = titleHeight + contentHeight + buttonBoxHeight;
s32 msgBoxWidth = contentWidth > buttonBoxWidth ? contentWidth : buttonBoxWidth;
// adjust message box position
tmp.UpperLeftCorner.Y = (Parent->getAbsolutePosition().getHeight() - msgBoxHeight) / 2;
tmp.LowerRightCorner.Y = tmp.UpperLeftCorner.Y + msgBoxHeight;
tmp.UpperLeftCorner.X = (Parent->getAbsolutePosition().getWidth() - msgBoxWidth) / 2;
tmp.LowerRightCorner.X = tmp.UpperLeftCorner.X + msgBoxWidth;
setRelativePosition(tmp);
// add buttons
core::rect<s32> btnRect;
btnRect.UpperLeftCorner.Y = titleHeight + contentHeight + borderWidth;
btnRect.LowerRightCorner.Y = btnRect.UpperLeftCorner.Y + buttonHeight;
btnRect.UpperLeftCorner.X = borderWidth;
if ( contentWidth > buttonBoxWidth )
btnRect.UpperLeftCorner.X += (contentWidth - buttonBoxWidth) / 2; // center buttons
btnRect.LowerRightCorner.X = btnRect.UpperLeftCorner.X + buttonWidth;
IGUIElement* focusMe = 0;
setButton(OkButton, (Flags & EMBF_OK) != 0, btnRect, skin->getDefaultText(EGDT_MSG_BOX_OK), focusMe);
if ( Flags & EMBF_OK )
btnRect += core::position2d<s32>(buttonWidth + buttonDistance, 0);
setButton(CancelButton, (Flags & EMBF_CANCEL) != 0, btnRect, skin->getDefaultText(EGDT_MSG_BOX_CANCEL), focusMe);
if ( Flags & EMBF_CANCEL )
btnRect += core::position2d<s32>(buttonWidth + buttonDistance, 0);
setButton(YesButton, (Flags & EMBF_YES) != 0, btnRect, skin->getDefaultText(EGDT_MSG_BOX_YES), focusMe);
if ( Flags & EMBF_YES )
btnRect += core::position2d<s32>(buttonWidth + buttonDistance, 0);
setButton(NoButton, (Flags & EMBF_NO) != 0, btnRect, skin->getDefaultText(EGDT_MSG_BOX_NO), focusMe);
if (Environment->hasFocus(this) && focusMe)
Environment->setFocus(focusMe);
}
//! called if an event happened.
bool CGUIMessageBox::OnEvent(const SEvent& event)
{
if (isEnabled())
{
SEvent outevent;
outevent.EventType = EET_GUI_EVENT;
outevent.GUIEvent.Caller = this;
outevent.GUIEvent.Element = 0;
switch(event.EventType)
{
case EET_KEY_INPUT_EVENT:
if (event.KeyInput.PressedDown)
{
switch (event.KeyInput.Key)
{
case KEY_RETURN:
if (OkButton)
{
OkButton->setPressed(true);
Pressed = true;
}
break;
case KEY_KEY_Y:
if (YesButton)
{
YesButton->setPressed(true);
Pressed = true;
}
break;
case KEY_KEY_N:
if (NoButton)
{
NoButton->setPressed(true);
Pressed = true;
}
break;
case KEY_ESCAPE:
if (Pressed)
{
// cancel press
if (OkButton) OkButton->setPressed(false);
if (YesButton) YesButton->setPressed(false);
if (NoButton) NoButton->setPressed(false);
Pressed = false;
}
else
if (CancelButton)
{
CancelButton->setPressed(true);
Pressed = true;
}
else
if (CloseButton && CloseButton->isVisible())
{
CloseButton->setPressed(true);
Pressed = true;
}
break;
default: // no other key is handled here
break;
}
}
else
if (Pressed)
{
if (OkButton && event.KeyInput.Key == KEY_RETURN)
{
setVisible(false); // this is a workaround to make sure it's no longer the hovered element, crashes on pressing 1-2 times ESC
Environment->setFocus(0);
outevent.GUIEvent.EventType = EGET_MESSAGEBOX_OK;
Parent->OnEvent(outevent);
remove();
return true;
}
else
if ((CancelButton || CloseButton) && event.KeyInput.Key == KEY_ESCAPE)
{
setVisible(false); // this is a workaround to make sure it's no longer the hovered element, crashes on pressing 1-2 times ESC
Environment->setFocus(0);
outevent.GUIEvent.EventType = EGET_MESSAGEBOX_CANCEL;
Parent->OnEvent(outevent);
remove();
return true;
}
else
if (YesButton && event.KeyInput.Key == KEY_KEY_Y)
{
setVisible(false); // this is a workaround to make sure it's no longer the hovered element, crashes on pressing 1-2 times ESC
Environment->setFocus(0);
outevent.GUIEvent.EventType = EGET_MESSAGEBOX_YES;
Parent->OnEvent(outevent);
remove();
return true;
}
else
if (NoButton && event.KeyInput.Key == KEY_KEY_N)
{
setVisible(false); // this is a workaround to make sure it's no longer the hovered element, crashes on pressing 1-2 times ESC
Environment->setFocus(0);
outevent.GUIEvent.EventType = EGET_MESSAGEBOX_NO;
Parent->OnEvent(outevent);
remove();
return true;
}
}
break;
case EET_GUI_EVENT:
if (event.GUIEvent.EventType == EGET_BUTTON_CLICKED)
{
if (event.GUIEvent.Caller == OkButton)
{
setVisible(false); // this is a workaround to make sure it's no longer the hovered element, crashes on pressing 1-2 times ESC
Environment->setFocus(0);
outevent.GUIEvent.EventType = EGET_MESSAGEBOX_OK;
Parent->OnEvent(outevent);
remove();
return true;
}
else
if (event.GUIEvent.Caller == CancelButton ||
event.GUIEvent.Caller == CloseButton)
{
setVisible(false); // this is a workaround to make sure it's no longer the hovered element, crashes on pressing 1-2 times ESC
Environment->setFocus(0);
outevent.GUIEvent.EventType = EGET_MESSAGEBOX_CANCEL;
Parent->OnEvent(outevent);
remove();
return true;
}
else
if (event.GUIEvent.Caller == YesButton)
{
setVisible(false); // this is a workaround to make sure it's no longer the hovered element, crashes on pressing 1-2 times ESC
Environment->setFocus(0);
outevent.GUIEvent.EventType = EGET_MESSAGEBOX_YES;
Parent->OnEvent(outevent);
remove();
return true;
}
else
if (event.GUIEvent.Caller == NoButton)
{
setVisible(false); // this is a workaround to make sure it's no longer the hovered element, crashes on pressing 1-2 times ESC
Environment->setFocus(0);
outevent.GUIEvent.EventType = EGET_MESSAGEBOX_NO;
Parent->OnEvent(outevent);
remove();
return true;
}
}
break;
default:
break;
}
}
return CGUIWindow::OnEvent(event);
}
} // end namespace gui
} // end namespace irr
#endif // _IRR_COMPILE_WITH_GUI_

View File

@ -1,58 +0,0 @@
// Copyright (C) 2002-2012 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __C_GUI_MESSAGE_BOX_H_INCLUDED__
#define __C_GUI_MESSAGE_BOX_H_INCLUDED__
#include "IrrCompileConfig.h"
#ifdef _IRR_COMPILE_WITH_GUI_
#include "CGUIWindow.h"
#include "IGUIStaticText.h"
#include "IGUIImage.h"
#include "irrArray.h"
namespace irr
{
namespace gui
{
class CGUIMessageBox : public CGUIWindow
{
public:
//! constructor
CGUIMessageBox(IGUIEnvironment* environment, const wchar_t* caption,
const wchar_t* text, s32 flag,
IGUIElement* parent, s32 id, core::rect<s32> rectangle, video::ITexture* image=0);
//! destructor
virtual ~CGUIMessageBox();
//! called if an event happened.
virtual bool OnEvent(const SEvent& event) _IRR_OVERRIDE_;
private:
void refreshControls();
void setButton(IGUIButton*& button, bool isAvailable, const core::rect<s32> & btnRect, const wchar_t * text, IGUIElement*& focusMe);
IGUIButton* OkButton;
IGUIButton* CancelButton;
IGUIButton* YesButton;
IGUIButton* NoButton;
IGUIStaticText* StaticText;
IGUIImage * Icon;
video::ITexture * IconTexture;
s32 Flags;
core::stringw MessageText;
bool Pressed;
};
} // end namespace gui
} // end namespace irr
#endif // _IRR_COMPILE_WITH_GUI_
#endif

View File

@ -1,231 +0,0 @@
// Copyright (C) 2002-2012 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#include "CGUIModalScreen.h"
#ifdef _IRR_COMPILE_WITH_GUI_
#include "IGUIEnvironment.h"
#include "os.h"
#include "IVideoDriver.h"
#include "IGUISkin.h"
namespace irr
{
namespace gui
{
//! constructor
CGUIModalScreen::CGUIModalScreen(IGUIEnvironment* environment, IGUIElement* parent, s32 id)
: IGUIElement(EGUIET_MODAL_SCREEN, environment, parent, id, core::recti(0, 0, parent->getAbsolutePosition().getWidth(), parent->getAbsolutePosition().getHeight()) ),
BlinkMode(3),
MouseDownTime(0)
{
#ifdef _DEBUG
setDebugName("CGUIModalScreen");
#endif
setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT);
// this element is a tab group
setTabGroup(true);
}
bool CGUIModalScreen::canTakeFocus(IGUIElement* target) const
{
return (target && ((const IGUIElement*)target == this // this element can take it
|| isMyChild(target) // own children also
|| (target->getType() == EGUIET_MODAL_SCREEN ) // other modals also fine (is now on top or explicitely requested)
|| (target->getParent() && target->getParent()->getType() == EGUIET_MODAL_SCREEN ))) // children of other modals will do
;
}
bool CGUIModalScreen::isVisible() const
{
// any parent invisible?
IGUIElement * parentElement = getParent();
while ( parentElement )
{
if ( !parentElement->isVisible() )
return false;
parentElement = parentElement->getParent();
}
// if we have no children then the modal is probably abused as a way to block input
if ( Children.empty() )
{
return IGUIElement::isVisible();
}
// any child visible?
for (const auto& child : Children)
{
if ( child->isVisible() )
return true;
}
return false;
}
bool CGUIModalScreen::isPointInside(const core::position2d<s32>& point) const
{
return true;
}
//! called if an event happened.
bool CGUIModalScreen::OnEvent(const SEvent& event)
{
if (!isEnabled() || !isVisible() )
return IGUIElement::OnEvent(event);
switch(event.EventType)
{
case EET_GUI_EVENT:
switch(event.GUIEvent.EventType)
{
case EGET_ELEMENT_FOCUSED:
if ( event.GUIEvent.Caller == this && isMyChild(event.GUIEvent.Element) )
{
Environment->removeFocus(0); // can't setFocus otherwise at it still has focus here
Environment->setFocus(event.GUIEvent.Element);
if ( BlinkMode&1 )
MouseDownTime = os::Timer::getTime();
return true;
}
if ( !canTakeFocus(event.GUIEvent.Caller))
{
if ( !Children.empty() )
Environment->setFocus(Children.front());
else
Environment->setFocus(this);
}
IGUIElement::OnEvent(event);
return false;
case EGET_ELEMENT_FOCUS_LOST:
if ( !canTakeFocus(event.GUIEvent.Element))
{
if ( isMyChild(event.GUIEvent.Caller) )
{
if ( !Children.empty() )
Environment->setFocus(Children.front());
else
Environment->setFocus(this);
}
else if ( BlinkMode&1 )
{
MouseDownTime = os::Timer::getTime();
}
return true;
}
else
{
return IGUIElement::OnEvent(event);
}
case EGET_ELEMENT_CLOSED:
// do not interfere with children being removed
return IGUIElement::OnEvent(event);
default:
break;
}
break;
case EET_MOUSE_INPUT_EVENT:
if (event.MouseInput.Event == EMIE_LMOUSE_PRESSED_DOWN && (BlinkMode & 2))
{
MouseDownTime = os::Timer::getTime();
}
break;
case EET_KEY_INPUT_EVENT:
// CAREFUL when changing - there's an identical check in CGUIEnvironment::postEventFromUser
if (Environment->getFocusBehavior() & EFF_SET_ON_TAB &&
event.KeyInput.PressedDown &&
event.KeyInput.Key == KEY_TAB)
{
IGUIElement* next = Environment->getNextElement(event.KeyInput.Shift, event.KeyInput.Control);
if ( next && isMyChild(next) )
{
// Pass on the TAB-key, otherwise focus-tabbing inside modal screens breaks
return false;
}
}
default:
break;
}
IGUIElement::OnEvent(event); // anyone knows why events are passed on here? Causes p.e. problems when this is child of a CGUIWindow.
return true; // absorb everything else
}
//! draws the element and its children
void CGUIModalScreen::draw()
{
IGUISkin *skin = Environment->getSkin();
if (!skin)
return;
u32 now = os::Timer::getTime();
if (BlinkMode && now - MouseDownTime < 300 && (now / 70)%2)
{
core::rect<s32> r;
video::SColor c = Environment->getSkin()->getColor(gui::EGDC_3D_HIGH_LIGHT);
for (auto child : Children)
{
if (child->isVisible())
{
r = child->getAbsolutePosition();
r.LowerRightCorner.X += 1;
r.LowerRightCorner.Y += 1;
r.UpperLeftCorner.X -= 1;
r.UpperLeftCorner.Y -= 1;
skin->draw2DRectangle(this, c, r, &AbsoluteClippingRect);
}
}
}
IGUIElement::draw();
}
//! Removes a child.
void CGUIModalScreen::removeChild(IGUIElement* child)
{
IGUIElement::removeChild(child);
if (Children.empty())
{
remove();
}
}
//! adds a child
void CGUIModalScreen::addChild(IGUIElement* child)
{
IGUIElement::addChild(child);
Environment->setFocus(child);
}
void CGUIModalScreen::updateAbsolutePosition()
{
core::rect<s32> parentRect(0,0,0,0);
if (Parent)
{
parentRect = Parent->getAbsolutePosition();
RelativeRect.UpperLeftCorner.X = 0;
RelativeRect.UpperLeftCorner.Y = 0;
RelativeRect.LowerRightCorner.X = parentRect.getWidth();
RelativeRect.LowerRightCorner.Y = parentRect.getHeight();
}
IGUIElement::updateAbsolutePosition();
}
} // end namespace gui
} // end namespace irr
#endif // _IRR_COMPILE_WITH_GUI_

View File

@ -1,80 +0,0 @@
// Copyright (C) 2002-2012 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __C_GUI_MODAL_SCREEN_H_INCLUDED__
#define __C_GUI_MODAL_SCREEN_H_INCLUDED__
#include "IrrCompileConfig.h"
#ifdef _IRR_COMPILE_WITH_GUI_
#include "IGUIElement.h"
namespace irr
{
namespace gui
{
class CGUIModalScreen : public IGUIElement
{
public:
//! constructor
CGUIModalScreen(IGUIEnvironment* environment, IGUIElement* parent, s32 id);
//! called if an event happened.
virtual bool OnEvent(const SEvent& event) _IRR_OVERRIDE_;
//! Removes a child.
virtual void removeChild(IGUIElement* child) _IRR_OVERRIDE_;
//! Adds a child
virtual void addChild(IGUIElement* child) _IRR_OVERRIDE_;
//! draws the element and its children
virtual void draw() _IRR_OVERRIDE_;
//! Updates the absolute position.
virtual void updateAbsolutePosition() _IRR_OVERRIDE_;
//! Modalscreen is not a typical element, but rather acts like a state for it's children.
//! isVisible is overriden to give this a useful behavior, so that a modal will no longer
//! be active when its parent is invisible or all its children are invisible.
virtual bool isVisible() const _IRR_OVERRIDE_;
//! Modals are infinite so every point is inside
virtual bool isPointInside(const core::position2d<s32>& point) const _IRR_OVERRIDE_;
//! Set when to blink.
//! Bitset of following values (can be combined)
//! 0 = never
//! 1 = focus changes
//! 2 = Left mouse button pressed down
void setBlinkMode(u32 blink)
{
BlinkMode = blink;
}
u32 getBlinkMode() const
{
return BlinkMode;
}
protected:
virtual bool canTakeFocus(IGUIElement* target) const;
private:
u32 BlinkMode;
u32 MouseDownTime;
};
} // end namespace gui
} // end namespace irr
#endif // _IRR_COMPILE_WITH_GUI_
#endif

View File

@ -1,331 +0,0 @@
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
// Written by Michael Zeilfelder
#include "CGUIProfiler.h"
#ifdef _IRR_COMPILE_WITH_GUI_
#include "IGUITable.h"
#include "IGUIScrollBar.h"
#include "IGUIEnvironment.h"
#include "CProfiler.h"
namespace irr
{
namespace gui
{
//! constructor
CGUIProfiler::CGUIProfiler(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle, IProfiler* profiler)
: IGUIProfiler(environment, parent, id, rectangle, profiler)
, Profiler(profiler)
, DisplayTable(0), CurrentGroupIdx(0), CurrentGroupPage(0), NumGroupPages(1)
, DrawBackground(false), Frozen(false), UnfreezeOnce(false), ShowGroupsTogether(false)
, MinCalls(0), MinTimeSum(0), MinTimeAverage(0.f), MinTimeMax(0)
{
if ( !Profiler )
Profiler = &getProfiler();
core::recti r(0, 0, rectangle.getWidth(), rectangle.getHeight());
// Really just too lazy to code a complete new element for this.
// If anyone can do this nicer he's welcome.
DisplayTable = Environment->addTable(r, this, -1, DrawBackground);
DisplayTable->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT);
DisplayTable->setSubElement(true);
rebuildColumns();
}
void CGUIProfiler::fillRow(u32 rowIndex, const SProfileData& data, bool overviewTitle, bool groupTitle)
{
DisplayTable->setCellText(rowIndex, 0, data.getName());
if ( !overviewTitle )
DisplayTable->setCellText(rowIndex, 1, core::stringw(data.getCallsCounter()));
if ( data.getCallsCounter() > 0 )
{
DisplayTable->setCellText(rowIndex, 2, core::stringw(data.getTimeSum()));
DisplayTable->setCellText(rowIndex, 3, core::stringw((u32)((f32)data.getTimeSum()/(f32)data.getCallsCounter())));
DisplayTable->setCellText(rowIndex, 4, core::stringw(data.getLongestTime()));
}
if ( overviewTitle || groupTitle )
{
const video::SColor titleColor(255, 0, 0, 255);
DisplayTable->setCellColor(rowIndex, 0, titleColor);
}
}
void CGUIProfiler::rebuildColumns()
{
if ( DisplayTable )
{
DisplayTable->clear();
DisplayTable->addColumn(L"name ");
DisplayTable->addColumn(L"count calls");
DisplayTable->addColumn(L"time(sum)");
DisplayTable->addColumn(L"time(avg)");
DisplayTable->addColumn(L"time(max) ");
DisplayTable->setActiveColumn(-1);
}
}
u32 CGUIProfiler::addDataToTable(u32 rowIndex, u32 dataIndex, u32 groupIndex)
{
const SProfileData& data = Profiler->getProfileDataByIndex(dataIndex);
if ( data.getGroupIndex() == groupIndex
&& data.getCallsCounter() >= MinCalls
&& ( data.getCallsCounter() == 0 ||
(data.getTimeSum() >= MinTimeSum &&
(f32)data.getTimeSum()/(f32)data.getCallsCounter() >= MinTimeAverage &&
data.getLongestTime() >= MinTimeMax))
)
{
rowIndex = DisplayTable->addRow(rowIndex);
fillRow(rowIndex, data, false, false);
++rowIndex;
}
return rowIndex;
}
void CGUIProfiler::updateDisplay()
{
if ( DisplayTable )
{
DisplayTable->clearRows();
if ( CurrentGroupIdx < Profiler->getGroupCount() )
{
bool overview = CurrentGroupIdx == 0;
u32 rowIndex = 0;
// show description row (overview or name of the following group)
const SProfileData& groupData = Profiler->getGroupData(CurrentGroupIdx);
if ( !ShowGroupsTogether && (overview || groupData.getCallsCounter() >= MinCalls) )
{
rowIndex = DisplayTable->addRow(rowIndex);
fillRow(rowIndex, groupData, overview, true);
++rowIndex;
}
// show overview over all groups?
if ( overview )
{
for ( u32 i=1; i<Profiler->getGroupCount(); ++i )
{
const SProfileData& groupDataOv = Profiler->getGroupData(i);
if (groupDataOv.getCallsCounter() >= MinCalls )
{
rowIndex = DisplayTable->addRow(rowIndex);
fillRow(rowIndex, groupDataOv, false, false);
++rowIndex;
}
}
}
// show data for all elements in current group
else
{
for ( u32 i=0; i < Profiler->getProfileDataCount(); ++i )
{
rowIndex = addDataToTable(rowIndex, i, CurrentGroupIdx);
}
}
// Show the rest of the groups
if (ShowGroupsTogether)
{
for ( u32 groupIdx = CurrentGroupIdx+1; groupIdx < Profiler->getGroupCount(); ++groupIdx)
{
for ( u32 i=0; i < Profiler->getProfileDataCount(); ++i )
{
rowIndex = addDataToTable(rowIndex, i, groupIdx);
}
}
}
}
// IGUITable has no page-wise scrolling yet. The following code can be replaced when we add that.
// For now we use some CGUITable implementation info to figure this out.
// (If you wonder why I didn't code page-scrolling directly in CGUITable ... because then it needs to be a
// public interface and I don't have enough time currently to design & implement that well)
s32 itemsTotalHeight = DisplayTable->getRowCount() * DisplayTable->getItemHeight();
s32 tableHeight = DisplayTable->getAbsolutePosition().getHeight();
s32 heightTitleRow = DisplayTable->getItemHeight()+1;
if ( itemsTotalHeight+heightTitleRow < tableHeight )
{
NumGroupPages = 1;
}
else
{
s32 heightHScrollBar = DisplayTable->getHorizontalScrollBar() ? DisplayTable->getHorizontalScrollBar()->getAbsolutePosition().getHeight() : 0;
s32 pageHeight = tableHeight - (heightTitleRow+heightHScrollBar);
if ( pageHeight > 0 )
{
NumGroupPages = (itemsTotalHeight/pageHeight);
if ( itemsTotalHeight % pageHeight )
++NumGroupPages;
}
else // won't see anything, but that's up to the user
{
NumGroupPages = DisplayTable->getRowCount();
}
if ( NumGroupPages < 1 )
NumGroupPages = 1;
}
if ( CurrentGroupPage < 0 )
CurrentGroupPage = (s32)NumGroupPages-1;
IGUIScrollBar* vScrollBar = DisplayTable->getVerticalScrollBar();
if ( vScrollBar )
{
if ( NumGroupPages < 2 )
vScrollBar->setPos(0);
else
{
f32 factor = (f32)CurrentGroupPage/(f32)(NumGroupPages-1);
vScrollBar->setPos( s32(factor * (f32)vScrollBar->getMax()) );
}
}
}
}
void CGUIProfiler::draw()
{
if ( isVisible() )
{
if (!Frozen || UnfreezeOnce)
{
UnfreezeOnce = false;
updateDisplay();
}
}
IGUIElement::draw();
}
void CGUIProfiler::nextPage(bool includeOverview)
{
UnfreezeOnce = true;
if ( CurrentGroupPage < NumGroupPages-1 )
++CurrentGroupPage;
else
{
CurrentGroupPage = 0;
if ( ++CurrentGroupIdx >= Profiler->getGroupCount() )
{
if ( includeOverview )
CurrentGroupIdx = 0;
else
CurrentGroupIdx = 1; // can be invalid
}
}
}
void CGUIProfiler::previousPage(bool includeOverview)
{
UnfreezeOnce = true;
if ( CurrentGroupPage > 0 )
{
--CurrentGroupPage;
}
else
{
CurrentGroupPage = -1; // unknown because NumGroupPages has to be re-calculated first
if ( CurrentGroupIdx > 0 )
--CurrentGroupIdx;
else
CurrentGroupIdx = Profiler->getGroupCount()-1;
if ( CurrentGroupIdx == 0 && !includeOverview )
{
if ( Profiler->getGroupCount() )
CurrentGroupIdx = Profiler->getGroupCount()-1;
if ( CurrentGroupIdx == 0 )
CurrentGroupIdx = 1; // invalid to avoid showing the overview
}
}
}
void CGUIProfiler::setShowGroupsTogether(bool groupsTogether)
{
ShowGroupsTogether = groupsTogether;
}
bool CGUIProfiler::getShowGroupsTogether() const
{
return ShowGroupsTogether;
}
void CGUIProfiler::firstPage(bool includeOverview)
{
UnfreezeOnce = true;
if ( includeOverview )
CurrentGroupIdx = 0;
else
CurrentGroupIdx = 1; // can be invalid
CurrentGroupPage = 0;
}
//! Sets another skin independent font.
void CGUIProfiler::setOverrideFont(IGUIFont* font)
{
if ( DisplayTable )
{
DisplayTable->setOverrideFont(font);
rebuildColumns();
}
}
//! Gets the override font (if any)
IGUIFont * CGUIProfiler::getOverrideFont() const
{
if ( DisplayTable )
return DisplayTable->getOverrideFont();
return 0;
}
//! Get the font which is used right now for drawing
IGUIFont* CGUIProfiler::getActiveFont() const
{
if ( DisplayTable )
return DisplayTable->getActiveFont();
return 0;
}
//! Sets whether to draw the background. By default disabled,
void CGUIProfiler::setDrawBackground(bool draw)
{
DrawBackground = draw;
if ( DisplayTable )
DisplayTable->setDrawBackground(draw);
}
//! Checks if background drawing is enabled
bool CGUIProfiler::isDrawBackgroundEnabled() const
{
return DrawBackground;
}
//! Allows to freeze updates which makes it easier to read the numbers
void CGUIProfiler::setFrozen(bool freeze)
{
Frozen = freeze;
}
//! Are updates currently frozen
bool CGUIProfiler::getFrozen() const
{
return Frozen;
}
void CGUIProfiler::setFilters(irr::u32 minCalls, irr::u32 minTimeSum, irr::f32 minTimeAverage, irr::u32 minTimeMax)
{
MinCalls = minCalls;
MinTimeSum = minTimeSum;
MinTimeAverage = minTimeAverage;
MinTimeMax = minTimeMax;
}
} // end namespace gui
} // end namespace irr
#endif // _IRR_COMPILE_WITH_GUI_

View File

@ -1,106 +0,0 @@
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
// Written by Michael Zeilfelder
#ifndef C_GUI_PROFILER_H_INCLUDED__
#define C_GUI_PROFILER_H_INCLUDED__
#include "IrrCompileConfig.h"
#ifdef _IRR_COMPILE_WITH_GUI_
#include "IGUIProfiler.h"
namespace irr
{
class IProfiler;
struct SProfileData;
namespace gui
{
class IGUITable;
//! Element to display profiler information
class CGUIProfiler : public IGUIProfiler
{
public:
//! constructor
CGUIProfiler(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle, IProfiler* profiler);
//! Show first page of profile data
virtual void firstPage(bool includeOverview) _IRR_OVERRIDE_;
//! Show next page of profile data
virtual void nextPage(bool includeOverview) _IRR_OVERRIDE_;
//! Show previous page of profile data
virtual void previousPage(bool includeOverview) _IRR_OVERRIDE_;
//! Try to show as many group-pages together as possible instead of showing at most one group per page.
/** \param groupsTogether When true show several groups on one page, when false show max. one group per page. Default is false. */
virtual void setShowGroupsTogether(bool groupsTogether) _IRR_OVERRIDE_;
//! Can several groups be displayed per page?
virtual bool getShowGroupsTogether() const _IRR_OVERRIDE_;
//! Sets another skin independent font.
virtual void setOverrideFont(IGUIFont* font) _IRR_OVERRIDE_;
//! Gets the override font (if any)
virtual IGUIFont* getOverrideFont() const _IRR_OVERRIDE_;
//! Get the font which is used right now for drawing
virtual IGUIFont* getActiveFont() const _IRR_OVERRIDE_;
//! Sets whether to draw the background. By default disabled,
virtual void setDrawBackground(bool draw) _IRR_OVERRIDE_;
//! Checks if background drawing is enabled
/** \return true if background drawing is enabled, false otherwise */
virtual bool isDrawBackgroundEnabled() const _IRR_OVERRIDE_;
//! Allows to freeze updates which makes it easier to read the numbers
virtual void setFrozen(bool freeze) _IRR_OVERRIDE_;
//! Are updates currently frozen
virtual bool getFrozen() const _IRR_OVERRIDE_;
//! Filters prevents data that doesn't achieve the conditions from being displayed
virtual void setFilters(irr::u32 minCalls, irr::u32 minTimeSum, irr::f32 minTimeAverage, irr::u32 minTimeMax) _IRR_OVERRIDE_;
virtual IGUIElement* getElementFromPoint(const core::position2d<s32>& point) _IRR_OVERRIDE_
{
// This element should never get focus from mouse-clicks
return 0;
}
virtual void draw() _IRR_OVERRIDE_;
protected:
void updateDisplay();
void fillRow(u32 rowIndex, const SProfileData& data, bool overviewTitle, bool groupTitle);
u32 addDataToTable(u32 rowIndex, u32 dataIndex, u32 groupIndex);
void rebuildColumns();
IProfiler * Profiler;
irr::gui::IGUITable* DisplayTable;
irr::u32 CurrentGroupIdx;
irr::s32 CurrentGroupPage;
irr::s32 NumGroupPages;
bool DrawBackground;
bool Frozen;
bool UnfreezeOnce;
bool ShowGroupsTogether;
irr::u32 MinCalls;
irr::u32 MinTimeSum;
irr::f32 MinTimeAverage;
irr::u32 MinTimeMax;
};
} // end namespace gui
} // end namespace irr
#endif // _IRR_COMPILE_WITH_GUI_
#endif // __C_GUI_IMAGE_H_INCLUDED__

View File

@ -1,323 +0,0 @@
// Copyright (C) 2006-2012 Michael Zeilfelder
// This file uses the licence of the Irrlicht Engine.
#include "CGUISpinBox.h"
#ifdef _IRR_COMPILE_WITH_GUI_
#include "CGUIEditBox.h"
#include "CGUIButton.h"
#include "IGUIEnvironment.h"
#include "IEventReceiver.h"
#include "fast_atof.h"
#include <wchar.h>
namespace irr
{
namespace gui
{
//! constructor
CGUISpinBox::CGUISpinBox(const wchar_t* text, bool border,IGUIEnvironment* environment,
IGUIElement* parent, s32 id, const core::rect<s32>& rectangle)
: IGUISpinBox(environment, parent, id, rectangle),
EditBox(0), ButtonSpinUp(0), ButtonSpinDown(0), StepSize(1.f),
RangeMin(-FLT_MAX), RangeMax(FLT_MAX), FormatString(L"%f"),
DecimalPlaces(-1), ValidateOn(EGUI_SBV_ENTER|EGUI_SBV_LOSE_FOCUS)
{
#ifdef _DEBUG
setDebugName("CGUISpinBox");
#endif
CurrentIconColor = video::SColor(255,255,255,255);
s32 ButtonWidth = 16;
ButtonSpinDown = Environment->addButton(
core::rect<s32>(rectangle.getWidth() - ButtonWidth, rectangle.getHeight()/2 +1,
rectangle.getWidth(), rectangle.getHeight()), this);
ButtonSpinDown->grab();
ButtonSpinDown->setSubElement(true);
ButtonSpinDown->setTabStop(false);
ButtonSpinDown->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_CENTER, EGUIA_LOWERRIGHT);
ButtonSpinUp = Environment->addButton(
core::rect<s32>(rectangle.getWidth() - ButtonWidth, 0,
rectangle.getWidth(), rectangle.getHeight()/2), this);
ButtonSpinUp->grab();
ButtonSpinUp->setSubElement(true);
ButtonSpinUp->setTabStop(false);
ButtonSpinUp->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_CENTER);
const core::rect<s32> rectEdit(0, 0, rectangle.getWidth() - ButtonWidth - 1, rectangle.getHeight());
EditBox = Environment->addEditBox(text, rectEdit, border, this, -1);
EditBox->grab();
EditBox->setSubElement(true);
EditBox->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT);
refreshSprites();
}
//! destructor
CGUISpinBox::~CGUISpinBox()
{
if (ButtonSpinUp)
ButtonSpinUp->drop();
if (ButtonSpinDown)
ButtonSpinDown->drop();
if (EditBox)
EditBox->drop();
}
void CGUISpinBox::refreshSprites()
{
IGUISpriteBank *sb = 0;
if (Environment && Environment->getSkin())
{
sb = Environment->getSkin()->getSpriteBank();
}
if (sb)
{
IGUISkin * skin = Environment->getSkin();
CurrentIconColor = skin->getColor(isEnabled() ? EGDC_WINDOW_SYMBOL : EGDC_GRAY_WINDOW_SYMBOL);
ButtonSpinDown->setSpriteBank(sb);
ButtonSpinDown->setSprite(EGBS_BUTTON_UP, skin->getIcon(EGDI_SMALL_CURSOR_DOWN), CurrentIconColor);
ButtonSpinDown->setSprite(EGBS_BUTTON_DOWN, skin->getIcon(EGDI_SMALL_CURSOR_DOWN), CurrentIconColor);
ButtonSpinUp->setSpriteBank(sb);
ButtonSpinUp->setSprite(EGBS_BUTTON_UP, skin->getIcon(EGDI_SMALL_CURSOR_UP), CurrentIconColor);
ButtonSpinUp->setSprite(EGBS_BUTTON_DOWN, skin->getIcon(EGDI_SMALL_CURSOR_UP), CurrentIconColor);
}
else
{
ButtonSpinDown->setText(L"-");
ButtonSpinUp->setText(L"+");
}
}
IGUIEditBox* CGUISpinBox::getEditBox() const
{
return EditBox;
}
void CGUISpinBox::setValue(f32 val)
{
wchar_t str[100];
swprintf_irr(str, 99, FormatString.c_str(), val);
EditBox->setText(str);
verifyValueRange();
}
f32 CGUISpinBox::getValue() const
{
const wchar_t* val = EditBox->getText();
if ( !val )
return 0.f;
core::stringc tmp(val);
return core::fast_atof(tmp.c_str());
}
void CGUISpinBox::setRange(f32 min, f32 max)
{
if (max<min)
core::swap(min, max);
RangeMin = min;
RangeMax = max;
// we have to round the range - otherwise we can get into an infinte setValue/verifyValueRange cycle.
wchar_t str[100];
swprintf_irr(str, 99, FormatString.c_str(), RangeMin);
RangeMin = core::fast_atof(core::stringc(str).c_str());
swprintf_irr(str, 99, FormatString.c_str(), RangeMax);
RangeMax = core::fast_atof(core::stringc(str).c_str());
verifyValueRange();
}
f32 CGUISpinBox::getMin() const
{
return RangeMin;
}
f32 CGUISpinBox::getMax() const
{
return RangeMax;
}
f32 CGUISpinBox::getStepSize() const
{
return StepSize;
}
void CGUISpinBox::setStepSize(f32 step)
{
StepSize = step;
}
//! Sets the number of decimal places to display.
void CGUISpinBox::setDecimalPlaces(s32 places)
{
DecimalPlaces = places;
if (places == -1)
FormatString = "%f";
else
{
FormatString = "%.";
FormatString += places;
FormatString += "f";
}
setRange( RangeMin, RangeMax );
setValue(getValue());
}
//! Sets when the spinbox has to validate entered text.
void CGUISpinBox::setValidateOn(u32 validateOn)
{
ValidateOn = validateOn;
}
//! Gets when the spinbox has to validate entered text.
u32 CGUISpinBox::getValidateOn() const
{
return ValidateOn;
}
bool CGUISpinBox::OnEvent(const SEvent& event)
{
if (IsEnabled)
{
bool changeEvent = false;
bool eatEvent = false;
switch(event.EventType)
{
case EET_MOUSE_INPUT_EVENT:
switch(event.MouseInput.Event)
{
case EMIE_MOUSE_WHEEL:
{
f32 val = getValue() + (StepSize * (event.MouseInput.Wheel < 0 ? -1.f : 1.f));
setValue(val);
changeEvent = true;
eatEvent = true;
}
break;
default:
break;
}
break;
case EET_GUI_EVENT:
if (event.GUIEvent.EventType == EGET_BUTTON_CLICKED)
{
if (event.GUIEvent.Caller == ButtonSpinUp)
{
f32 val = getValue();
val += StepSize;
setValue(val);
changeEvent = true;
}
else if ( event.GUIEvent.Caller == ButtonSpinDown)
{
f32 val = getValue();
val -= StepSize;
setValue(val);
changeEvent = true;
}
}
if (event.GUIEvent.Caller == EditBox)
{
if ( (event.GUIEvent.EventType == EGET_EDITBOX_CHANGED && ValidateOn & EGUI_SBV_CHANGE)
|| (event.GUIEvent.EventType == EGET_EDITBOX_ENTER && ValidateOn & EGUI_SBV_ENTER)
|| (event.GUIEvent.EventType == EGET_ELEMENT_FOCUS_LOST && ValidateOn & EGUI_SBV_LOSE_FOCUS)
)
{
verifyValueRange();
changeEvent = true;
}
}
break;
default:
break;
}
if ( changeEvent )
{
SEvent e;
e.EventType = EET_GUI_EVENT;
e.GUIEvent.Caller = this;
e.GUIEvent.Element = 0;
e.GUIEvent.EventType = EGET_SPINBOX_CHANGED;
if ( Parent )
Parent->OnEvent(e);
if ( eatEvent )
return true;
}
}
return IGUIElement::OnEvent(event);
}
void CGUISpinBox::draw()
{
if ( !isVisible() )
return;
IGUISkin* skin = Environment->getSkin();
if (!skin)
return;
video::SColor iconColor = skin->getColor(isEnabled() ? EGDC_WINDOW_SYMBOL : EGDC_GRAY_WINDOW_SYMBOL);
if ( iconColor != CurrentIconColor )
{
refreshSprites();
}
IGUISpinBox::draw();
}
void CGUISpinBox::verifyValueRange()
{
f32 val = getValue();
if ( val+core::ROUNDING_ERROR_f32 < RangeMin )
val = RangeMin;
else if ( val-core::ROUNDING_ERROR_f32 > RangeMax )
val = RangeMax;
else
return;
setValue(val);
}
//! Sets the new caption of the element
void CGUISpinBox::setText(const wchar_t* text)
{
EditBox->setText(text);
setValue(getValue());
verifyValueRange();
}
//! Returns caption of this element.
const wchar_t* CGUISpinBox::getText() const
{
return EditBox->getText();
}
} // end namespace gui
} // end namespace irr
#endif // _IRR_COMPILE_WITH_GUI_

View File

@ -1,110 +0,0 @@
// Copyright (C) 2006-2012 Michael Zeilfelder
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __C_GUI_SPIN_BOX_H_INCLUDED__
#define __C_GUI_SPIN_BOX_H_INCLUDED__
#include "IrrCompileConfig.h"
#ifdef _IRR_COMPILE_WITH_GUI_
#include "IGUISpinBox.h"
namespace irr
{
namespace gui
{
class IGUIEditBox;
class IGUIButton;
class CGUISpinBox : public IGUISpinBox
{
public:
//! constructor
CGUISpinBox(const wchar_t* text, bool border, IGUIEnvironment* environment,
IGUIElement* parent, s32 id, const core::rect<s32>& rectangle);
//! destructor
virtual ~CGUISpinBox();
//! Access the edit box used in the spin control
/** \param enable: If set to true, the override color, which can be set
with IGUIEditBox::setOverrideColor is used, otherwise the
EGDC_BUTTON_TEXT color of the skin. */
virtual IGUIEditBox* getEditBox() const _IRR_OVERRIDE_;
//! set the current value of the spinbox
/** \param val: value to be set in the spinbox */
virtual void setValue(f32 val) _IRR_OVERRIDE_;
//! Get the current value of the spinbox
virtual f32 getValue() const _IRR_OVERRIDE_;
//! set the range of values which can be used in the spinbox
/** \param min: minimum value
\param max: maximum value */
virtual void setRange(f32 min, f32 max) _IRR_OVERRIDE_;
//! get the minimum value which can be used in the spinbox
virtual f32 getMin() const _IRR_OVERRIDE_;
//! get the maximum value which can be used in the spinbox
virtual f32 getMax() const _IRR_OVERRIDE_;
//! step size by which values are changed when pressing the spin buttons
/** \param step: stepsize used for value changes when pressing spin buttons */
virtual void setStepSize(f32 step=1.f) _IRR_OVERRIDE_;
//! returns the step size
virtual f32 getStepSize() const _IRR_OVERRIDE_;
//! called if an event happened.
virtual bool OnEvent(const SEvent& event) _IRR_OVERRIDE_;
//! Draws the element and its children.
virtual void draw() _IRR_OVERRIDE_;
//! Sets the new caption of the element
virtual void setText(const wchar_t* text) _IRR_OVERRIDE_;
//! Returns caption of this element.
virtual const wchar_t* getText() const _IRR_OVERRIDE_;
//! Sets the number of decimal places to display.
//! Note that this also rounds the range to the same number of decimal places.
/** \param places: The number of decimal places to display, use -1 to reset */
virtual void setDecimalPlaces(s32 places) _IRR_OVERRIDE_;
//! Sets when the spinbox has to validate entered text.
/** \param validateOn Can be any combination of EGUI_SPINBOX_VALIDATION bit flags */
virtual void setValidateOn(u32 validateOn) _IRR_OVERRIDE_;
//! Gets when the spinbox has to validate entered text.
virtual u32 getValidateOn() const _IRR_OVERRIDE_;
protected:
virtual void verifyValueRange();
void refreshSprites();
IGUIEditBox * EditBox;
IGUIButton * ButtonSpinUp;
IGUIButton * ButtonSpinDown;
video::SColor CurrentIconColor;
f32 StepSize;
f32 RangeMin;
f32 RangeMax;
core::stringw FormatString;
s32 DecimalPlaces;
u32 ValidateOn; // combination of EGUI_SPINBOX_VALIDATION bit-flags
};
} // end namespace gui
} // end namespace irr
#endif // _IRR_COMPILE_WITH_GUI_
#endif // __C_GUI_SPIN_BOX_H_INCLUDED__

File diff suppressed because it is too large Load Diff

View File

@ -1,244 +0,0 @@
// Copyright (C) 2002-2012 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
// 07.10.2005 - Multicolor-Listbox addet by A. Buschhueter (Acki)
// A_Buschhueter@gmx.de
#ifndef __C_GUI_TABLE_BAR_H_INCLUDED__
#define __C_GUI_TABLE_BAR_H_INCLUDED__
#include "IrrCompileConfig.h"
#ifdef _IRR_COMPILE_WITH_GUI_
#include "IGUITable.h"
#include "irrArray.h"
namespace irr
{
namespace gui
{
class IGUIFont;
class IGUIScrollBar;
class CGUITable : public IGUITable
{
public:
//! constructor
CGUITable(IGUIEnvironment* environment, IGUIElement* parent,
s32 id, const core::rect<s32>& rectangle, bool clip=true,
bool drawBack=false, bool moveOverSelect=true);
//! destructor
~CGUITable();
//! Adds a column
//! If columnIndex is outside the current range, do push new column at the end
virtual void addColumn(const wchar_t* caption, s32 columnIndex=-1) _IRR_OVERRIDE_;
//! remove a column from the table
virtual void removeColumn(u32 columnIndex) _IRR_OVERRIDE_;
//! Returns the number of columns in the table control
virtual s32 getColumnCount() const _IRR_OVERRIDE_;
//! Makes a column active. This will trigger an ordering process.
/** \param idx: The id of the column to make active.
\return True if successful. */
virtual bool setActiveColumn(s32 columnIndex, bool doOrder=false) _IRR_OVERRIDE_;
//! Returns which header is currently active
virtual s32 getActiveColumn() const _IRR_OVERRIDE_;
//! Returns the ordering used by the currently active column
virtual EGUI_ORDERING_MODE getActiveColumnOrdering() const _IRR_OVERRIDE_;
//! set a column width
virtual void setColumnWidth(u32 columnIndex, u32 width) _IRR_OVERRIDE_;
//! Get the width of a column
virtual u32 getColumnWidth(u32 columnIndex) const _IRR_OVERRIDE_;
//! columns can be resized by drag 'n drop
virtual void setResizableColumns(bool resizable) _IRR_OVERRIDE_;
//! can columns be resized by drag 'n drop?
virtual bool hasResizableColumns() const _IRR_OVERRIDE_;
//! This tells the table control which ordering mode should be used when
//! a column header is clicked.
/** \param columnIndex: The index of the column header.
\param state: If true, a EGET_TABLE_HEADER_CHANGED message will be sent and you can order the table data as you whish.*/
//! \param mode: One of the modes defined in EGUI_COLUMN_ORDERING
virtual void setColumnOrdering(u32 columnIndex, EGUI_COLUMN_ORDERING mode) _IRR_OVERRIDE_;
//! Returns which row is currently selected
virtual s32 getSelected() const _IRR_OVERRIDE_;
//! set currently selected row
virtual void setSelected( s32 index ) _IRR_OVERRIDE_;
//! Returns amount of rows in the tab control
virtual s32 getRowCount() const _IRR_OVERRIDE_;
//! adds a row to the table
/** \param rowIndex: zero based index of rows. The row will be
inserted at this position. If a row already exists
there, it will be placed after it. If the row is larger
than the actual number of rows by more than one, it
won't be created. Note that if you create a row that is
not at the end, there might be performance issues*/
virtual u32 addRow(u32 rowIndex) _IRR_OVERRIDE_;
//! Remove a row from the table
virtual void removeRow(u32 rowIndex) _IRR_OVERRIDE_;
//! clear the table rows, but keep the columns intact
virtual void clearRows() _IRR_OVERRIDE_;
//! Swap two row positions. This is useful for a custom ordering algo.
virtual void swapRows(u32 rowIndexA, u32 rowIndexB) _IRR_OVERRIDE_;
//! This tells the table to start ordering all the rows. You
//! need to explicitly tell the table to reorder the rows when
//! a new row is added or the cells data is changed. This makes
//! the system more flexible and doesn't make you pay the cost
//! of ordering when adding a lot of rows.
//! \param columnIndex: When set to -1 the active column is used.
virtual void orderRows(s32 columnIndex=-1, EGUI_ORDERING_MODE mode=EGOM_NONE) _IRR_OVERRIDE_;
//! Set the text of a cell
virtual void setCellText(u32 rowIndex, u32 columnIndex, const core::stringw& text) _IRR_OVERRIDE_;
//! Set the text of a cell, and set a color of this cell.
virtual void setCellText(u32 rowIndex, u32 columnIndex, const core::stringw& text, video::SColor color) _IRR_OVERRIDE_;
//! Set the data of a cell
//! data will not be serialized.
virtual void setCellData(u32 rowIndex, u32 columnIndex, void *data) _IRR_OVERRIDE_;
//! Set the color of a cell text
virtual void setCellColor(u32 rowIndex, u32 columnIndex, video::SColor color) _IRR_OVERRIDE_;
//! Get the text of a cell
virtual const wchar_t* getCellText(u32 rowIndex, u32 columnIndex ) const _IRR_OVERRIDE_;
//! Get the data of a cell
virtual void* getCellData(u32 rowIndex, u32 columnIndex ) const _IRR_OVERRIDE_;
//! clears the table, deletes all items in the table
virtual void clear() _IRR_OVERRIDE_;
//! called if an event happened.
virtual bool OnEvent(const SEvent &event) _IRR_OVERRIDE_;
//! draws the element and its children
virtual void draw() _IRR_OVERRIDE_;
//! Set flags, as defined in EGUI_TABLE_DRAW_FLAGS, which influence the layout
virtual void setDrawFlags(s32 flags) _IRR_OVERRIDE_;
//! Get the flags, as defined in EGUI_TABLE_DRAW_FLAGS, which influence the layout
virtual s32 getDrawFlags() const _IRR_OVERRIDE_;
//! Sets another skin independent font.
virtual void setOverrideFont(IGUIFont* font=0) _IRR_OVERRIDE_;
//! Gets the override font (if any)
virtual IGUIFont* getOverrideFont() const _IRR_OVERRIDE_;
//! Get the font which is used right now for drawing
virtual IGUIFont* getActiveFont() const _IRR_OVERRIDE_;
//! Get the height of items/rows
virtual s32 getItemHeight() const _IRR_OVERRIDE_;
//! Access the vertical scrollbar
virtual IGUIScrollBar* getVerticalScrollBar() const _IRR_OVERRIDE_;
//! Access the horizontal scrollbar
virtual IGUIScrollBar* getHorizontalScrollBar() const _IRR_OVERRIDE_;
//! Sets whether to draw the background.
virtual void setDrawBackground(bool draw) _IRR_OVERRIDE_;
//! Checks if background drawing is enabled
/** \return true if background drawing is enabled, false otherwise */
virtual bool isDrawBackgroundEnabled() const _IRR_OVERRIDE_;
protected:
void refreshControls();
void checkScrollbars();
private:
struct Cell
{
Cell() : IsOverrideColor(false), Data(0) {}
core::stringw Text;
core::stringw BrokenText;
bool IsOverrideColor;
video::SColor Color;
void *Data;
};
struct Row
{
Row() {}
core::array<Cell> Items;
};
struct Column
{
Column() : Width(0), OrderingMode(EGCO_NONE) {}
core::stringw Name;
u32 Width;
EGUI_COLUMN_ORDERING OrderingMode;
};
void breakText(const core::stringw &text, core::stringw & brokenText, u32 cellWidth);
void selectNew(s32 ypos, bool onlyHover=false);
bool selectColumnHeader(s32 xpos, s32 ypos);
bool dragColumnStart(s32 xpos, s32 ypos);
bool dragColumnUpdate(s32 xpos);
void recalculateHeights();
void recalculateWidths();
core::array< Column > Columns;
core::array< Row > Rows;
gui::IGUIScrollBar* VerticalScrollBar;
gui::IGUIScrollBar* HorizontalScrollBar;
bool Clip;
bool DrawBack;
bool MoveOverSelect;
bool Selecting;
s32 CurrentResizedColumn;
s32 ResizeStart;
bool ResizableColumns;
s32 ItemHeight;
s32 TotalItemHeight;
s32 TotalItemWidth;
s32 Selected;
s32 CellHeightPadding;
s32 CellWidthPadding;
s32 ActiveTab;
EGUI_ORDERING_MODE CurrentOrdering;
s32 DrawFlags;
s32 ScrollBarSize;
gui::IGUIFont* OverrideFont;
};
} // end namespace gui
} // end namespace irr
#endif // _IRR_COMPILE_WITH_GUI_
#endif

View File

@ -1,185 +0,0 @@
// Copyright (C) 2002-2012 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#include "CGUIToolBar.h"
#ifdef _IRR_COMPILE_WITH_GUI_
#include "IGUISkin.h"
#include "IGUIEnvironment.h"
#include "IVideoDriver.h"
#include "IGUIButton.h"
#include "IGUIFont.h"
#include "CGUIButton.h"
namespace irr
{
namespace gui
{
//! constructor
CGUIToolBar::CGUIToolBar(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle)
:IGUIToolBar(environment, parent, id, rectangle), ButtonX(5)
{
#ifdef _DEBUG
setDebugName("CGUIToolBar");
#endif
// calculate position and find other menubars
s32 y = 0;
s32 parentwidth = 100;
if (parent)
{
parentwidth = Parent->getAbsolutePosition().getWidth();
s32 parentheight = Parent->getAbsolutePosition().getHeight();
for (const auto& e : parent->getChildren())
{
if ( e->hasType(EGUIET_CONTEXT_MENU)
|| e->hasType(EGUIET_MENU)
|| e->hasType(EGUIET_TOOL_BAR) )
{
core::rect<s32> r = e->getAbsolutePosition();
if (r.UpperLeftCorner.X == 0 && r.UpperLeftCorner.Y <= y &&
r.LowerRightCorner.X == parentwidth
&& parentheight > r.LowerRightCorner.Y )
y = r.LowerRightCorner.Y;
}
else
{
e->getType();
}
}
}
core::rect<s32> rr;
rr.UpperLeftCorner.X = 0;
rr.UpperLeftCorner.Y = y;
s32 height = Environment->getSkin()->getSize ( EGDS_MENU_HEIGHT );
/*IGUISkin* skin = Environment->getSkin();
IGUIFont* font = skin->getFont();
if (font)
{
s32 t = font->getDimension(L"A").Height + 5;
if (t > height)
height = t;
}*/
rr.LowerRightCorner.X = parentwidth;
rr.LowerRightCorner.Y = rr.UpperLeftCorner.Y + height;
setRelativePosition(rr);
}
//! called if an event happened.
bool CGUIToolBar::OnEvent(const SEvent& event)
{
if (isEnabled())
{
if (event.EventType == EET_MOUSE_INPUT_EVENT &&
event.MouseInput.Event == EMIE_LMOUSE_PRESSED_DOWN)
{
if (AbsoluteClippingRect.isPointInside(core::position2di(event.MouseInput.X, event.MouseInput.Y)))
return true;
}
}
return IGUIElement::OnEvent(event);
}
//! draws the element and its children
void CGUIToolBar::draw()
{
if (!IsVisible)
return;
IGUISkin* skin = Environment->getSkin();
if (!skin)
return;
core::rect<s32> rect = AbsoluteRect;
core::rect<s32>* clip = &AbsoluteClippingRect;
// draw frame
skin->draw3DToolBar(this, rect, clip);
IGUIElement::draw();
}
//! Updates the absolute position.
void CGUIToolBar::updateAbsolutePosition()
{
if (Parent)
{
DesiredRect.UpperLeftCorner.X = 0;
DesiredRect.LowerRightCorner.X = Parent->getAbsolutePosition().getWidth();
}
IGUIElement::updateAbsolutePosition();
}
//! Adds a button to the tool bar
IGUIButton* CGUIToolBar::addButton(s32 id, const wchar_t* text,const wchar_t* tooltiptext,
video::ITexture* img, video::ITexture* pressed, bool isPushButton,
bool useAlphaChannel)
{
ButtonX += 3;
core::rect<s32> rectangle(ButtonX,2,ButtonX+1,3);
if ( img )
{
const core::dimension2du &size = img->getOriginalSize();
rectangle.LowerRightCorner.X = rectangle.UpperLeftCorner.X + size.Width + 8;
rectangle.LowerRightCorner.Y = rectangle.UpperLeftCorner.Y + size.Height + 6;
}
if ( text )
{
IGUISkin* skin = Environment->getSkin();
IGUIFont * font = skin->getFont(EGDF_BUTTON);
if ( font )
{
core::dimension2d<u32> dim = font->getDimension(text);
if ( (s32)dim.Width > rectangle.getWidth() )
rectangle.LowerRightCorner.X = rectangle.UpperLeftCorner.X + dim.Width + 8;
if ( (s32)dim.Height > rectangle.getHeight() )
rectangle.LowerRightCorner.Y = rectangle.UpperLeftCorner.Y + dim.Height + 6;
}
}
ButtonX += rectangle.getWidth();
IGUIButton* button = new CGUIButton(Environment, this, id, rectangle);
button->drop();
if (text)
button->setText(text);
if (tooltiptext)
button->setToolTipText(tooltiptext);
if (img)
button->setImage(img);
if (pressed)
button->setPressedImage(pressed);
if (isPushButton)
button->setIsPushButton(isPushButton);
if (useAlphaChannel)
button->setUseAlphaChannel(useAlphaChannel);
return button;
}
} // end namespace gui
} // end namespace irr
#endif // _IRR_COMPILE_WITH_GUI_

View File

@ -1,52 +0,0 @@
// Copyright (C) 2002-2012 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __C_GUI_TOOL_BAR_H_INCLUDED__
#define __C_GUI_TOOL_BAR_H_INCLUDED__
#include "IrrCompileConfig.h"
#ifdef _IRR_COMPILE_WITH_GUI_
#include "IGUIToolbar.h"
namespace irr
{
namespace gui
{
//! Stays at the top of its parent like the menu bar and contains tool buttons
class CGUIToolBar : public IGUIToolBar
{
public:
//! constructor
CGUIToolBar(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle);
//! called if an event happened.
virtual bool OnEvent(const SEvent& event) _IRR_OVERRIDE_;
//! draws the element and its children
virtual void draw() _IRR_OVERRIDE_;
//! Updates the absolute position.
virtual void updateAbsolutePosition() _IRR_OVERRIDE_;
//! Adds a button to the tool bar
virtual IGUIButton* addButton(s32 id=-1, const wchar_t* text=0,const wchar_t* tooltiptext=0,
video::ITexture* img=0, video::ITexture* pressed=0,
bool isPushButton=false, bool useAlphaChannel=false) _IRR_OVERRIDE_;
private:
s32 ButtonX;
};
} // end namespace gui
} // end namespace irr
#endif // _IRR_COMPILE_WITH_GUI_
#endif

File diff suppressed because it is too large Load Diff

View File

@ -1,357 +0,0 @@
// This file is part of the "Irrlicht Engine".
// written by Reinhard Ostermeier, reinhard@nospam.r-ostermeier.de
#ifndef __C_GUI_TREE_VIEW_H_INCLUDED__
#define __C_GUI_TREE_VIEW_H_INCLUDED__
#include "IGUITreeView.h"
namespace irr
{
namespace gui
{
// forward declarations
class IGUIFont;
class IGUIScrollBar;
class CGUITreeView;
//! Node for gui tree view
class CGUITreeViewNode : public IGUITreeViewNode
{
friend class CGUITreeView;
public:
//! constructor
CGUITreeViewNode( CGUITreeView* owner, CGUITreeViewNode* parent );
//! destructor
~CGUITreeViewNode();
//! returns the owner (tree view) of this node
virtual IGUITreeView* getOwner() const _IRR_OVERRIDE_;
//! Returns the parent node of this node.
virtual IGUITreeViewNode* getParent() const _IRR_OVERRIDE_;
//! returns the text of the node
virtual const wchar_t* getText() const _IRR_OVERRIDE_
{ return Text.c_str(); }
//! sets the text of the node
virtual void setText( const wchar_t* text ) _IRR_OVERRIDE_;
//! returns the icon text of the node
virtual const wchar_t* getIcon() const _IRR_OVERRIDE_
{ return Icon.c_str(); }
//! sets the icon text of the node
virtual void setIcon( const wchar_t* icon ) _IRR_OVERRIDE_;
//! returns the image index of the node
virtual u32 getImageIndex() const _IRR_OVERRIDE_
{ return ImageIndex; }
//! sets the image index of the node
virtual void setImageIndex( u32 imageIndex ) _IRR_OVERRIDE_
{ ImageIndex = imageIndex; }
//! returns the image index of the node
virtual u32 getSelectedImageIndex() const _IRR_OVERRIDE_
{ return SelectedImageIndex; }
//! sets the image index of the node
virtual void setSelectedImageIndex( u32 imageIndex ) _IRR_OVERRIDE_
{ SelectedImageIndex = imageIndex; }
//! returns the user data (void*) of this node
virtual void* getData() const _IRR_OVERRIDE_
{ return Data; }
//! sets the user data (void*) of this node
virtual void setData( void* data ) _IRR_OVERRIDE_
{ Data = data; }
//! returns the user data2 (IReferenceCounted) of this node
virtual IReferenceCounted* getData2() const _IRR_OVERRIDE_
{ return Data2; }
//! sets the user data2 (IReferenceCounted) of this node
virtual void setData2( IReferenceCounted* data ) _IRR_OVERRIDE_
{
if( Data2 )
{
Data2->drop();
}
Data2 = data;
if( Data2 )
{
Data2->grab();
}
}
//! returns the child item count
virtual u32 getChildCount() const _IRR_OVERRIDE_
{ return Children.size(); }
//! removes all children (recursive) from this node
virtual void clearChildren() _IRR_OVERRIDE_;
//! returns true if this node has child nodes
virtual bool hasChildren() const _IRR_OVERRIDE_
{ return !Children.empty(); }
//! Adds a new node behind the last child node.
//! \param text text of the new node
//! \param icon icon text of the new node
//! \param imageIndex index of the image for the new node (-1 = none)
//! \param selectedImageIndex index of the selected image for the new node (-1 = same as imageIndex)
//! \param data user data (void*) of the new node
//! \param data2 user data2 (IReferenceCounted*) of the new node
//! \return
//! returns the new node
virtual IGUITreeViewNode* addChildBack(
const wchar_t* text,
const wchar_t* icon = 0,
s32 imageIndex = -1,
s32 selectedImageIndex = -1,
void* data = 0,
IReferenceCounted* data2 = 0) _IRR_OVERRIDE_;
//! Adds a new node before the first child node.
//! \param text text of the new node
//! \param icon icon text of the new node
//! \param imageIndex index of the image for the new node (-1 = none)
//! \param selectedImageIndex index of the selected image for the new node (-1 = same as imageIndex)
//! \param data user data (void*) of the new node
//! \param data2 user data2 (IReferenceCounted*) of the new node
//! \return
//! returns the new node
virtual IGUITreeViewNode* addChildFront(
const wchar_t* text,
const wchar_t* icon = 0,
s32 imageIndex = -1,
s32 selectedImageIndex = -1,
void* data = 0,
IReferenceCounted* data2 = 0 ) _IRR_OVERRIDE_;
//! Adds a new node behind the other node.
//! The other node has also te be a child node from this node.
//! \param text text of the new node
//! \param icon icon text of the new node
//! \param imageIndex index of the image for the new node (-1 = none)
//! \param selectedImageIndex index of the selected image for the new node (-1 = same as imageIndex)
//! \param data user data (void*) of the new node
//! \param data2 user data2 (IReferenceCounted*) of the new node
//! \return
//! returns the new node or 0 if other is no child node from this
virtual IGUITreeViewNode* insertChildAfter(
IGUITreeViewNode* other,
const wchar_t* text,
const wchar_t* icon = 0,
s32 imageIndex = -1,
s32 selectedImageIndex = -1,
void* data = 0,
IReferenceCounted* data2 = 0 ) _IRR_OVERRIDE_;
//! Adds a new node before the other node.
//! The other node has also te be a child node from this node.
//! \param text text of the new node
//! \param icon icon text of the new node
//! \param imageIndex index of the image for the new node (-1 = none)
//! \param selectedImageIndex index of the selected image for the new node (-1 = same as imageIndex)
//! \param data user data (void*) of the new node
//! \param data2 user data2 (IReferenceCounted*) of the new node
//! \return
//! returns the new node or 0 if other is no child node from this
virtual IGUITreeViewNode* insertChildBefore(
IGUITreeViewNode* other,
const wchar_t* text,
const wchar_t* icon = 0,
s32 imageIndex = -1,
s32 selectedImageIndex = -1,
void* data = 0,
IReferenceCounted* data2 = 0 ) _IRR_OVERRIDE_;
//! Return the first child note from this node.
virtual IGUITreeViewNode* getFirstChild() const _IRR_OVERRIDE_;
//! Return the last child note from this node.
virtual IGUITreeViewNode* getLastChild() const _IRR_OVERRIDE_;
//! Returns the preverse sibling node from this node.
virtual IGUITreeViewNode* getPrevSibling() const _IRR_OVERRIDE_;
//! Returns the next sibling node from this node.
virtual IGUITreeViewNode* getNextSibling() const _IRR_OVERRIDE_;
//! Returns the next visible (expanded, may be out of scrolling) node from this node.
virtual IGUITreeViewNode* getNextVisible() const _IRR_OVERRIDE_;
//! Deletes a child node.
virtual bool deleteChild( IGUITreeViewNode* child ) _IRR_OVERRIDE_;
//! Moves a child node one position up.
virtual bool moveChildUp( IGUITreeViewNode* child ) _IRR_OVERRIDE_;
//! Moves a child node one position down.
virtual bool moveChildDown( IGUITreeViewNode* child ) _IRR_OVERRIDE_;
//! Returns true if the node is expanded (children are visible).
virtual bool getExpanded() const _IRR_OVERRIDE_
{ return Expanded; }
//! Sets if the node is expanded.
virtual void setExpanded( bool expanded ) _IRR_OVERRIDE_;
//! Returns true if the node is currently selected.
virtual bool getSelected() const _IRR_OVERRIDE_;
//! Sets this node as selected.
virtual void setSelected( bool selected ) _IRR_OVERRIDE_;
//! Returns true if this node is the root node.
virtual bool isRoot() const _IRR_OVERRIDE_;
//! Returns the level of this node.
virtual s32 getLevel() const _IRR_OVERRIDE_;
//! Returns true if this node is visible (all parents are expanded).
virtual bool isVisible() const _IRR_OVERRIDE_;
private:
CGUITreeView* Owner;
CGUITreeViewNode* Parent;
core::stringw Text;
core::stringw Icon;
s32 ImageIndex;
s32 SelectedImageIndex;
void* Data;
IReferenceCounted* Data2;
bool Expanded;
std::list<CGUITreeViewNode*> Children;
// Position of this node in Parent->Children.
// Only valid when Parent != NULL
std::list<CGUITreeViewNode*>::iterator ParentPos;
};
//! Default tree view GUI element.
class CGUITreeView : public IGUITreeView
{
friend class CGUITreeViewNode;
public:
//! constructor
CGUITreeView( IGUIEnvironment* environment, IGUIElement* parent,
s32 id, core::rect<s32> rectangle, bool clip = true,
bool drawBack = false, bool scrollBarVertical = true, bool scrollBarHorizontal = true );
//! destructor
virtual ~CGUITreeView();
//! returns the root node (not visible) from the tree.
virtual IGUITreeViewNode* getRoot() const _IRR_OVERRIDE_
{ return Root; }
//! returns the selected node of the tree or 0 if none is selected
virtual IGUITreeViewNode* getSelected() const _IRR_OVERRIDE_
{ return Selected; }
//! returns true if the tree lines are visible
virtual bool getLinesVisible() const _IRR_OVERRIDE_
{ return LinesVisible; }
//! sets if the tree lines are visible
virtual void setLinesVisible( bool visible ) _IRR_OVERRIDE_
{ LinesVisible = visible; }
//! called if an event happened.
virtual bool OnEvent( const SEvent &event ) _IRR_OVERRIDE_;
//! draws the element and its children
virtual void draw() _IRR_OVERRIDE_;
//! Sets the font which should be used as icon font. This font is set to the Irrlicht engine
//! built-in-font by default. Icons can be displayed in front of every list item.
//! An icon is a string, displayed with the icon font. When using the build-in-font of the
//! Irrlicht engine as icon font, the icon strings defined in GUIIcons.h can be used.
virtual void setIconFont( IGUIFont* font ) _IRR_OVERRIDE_;
//! Sets a skin independent font.
/** \param font: New font to set or 0 to use the skin-font. */
virtual void setOverrideFont(IGUIFont* font=0) _IRR_OVERRIDE_;
//! Gets the override font (if any)
/** \return The override font (may be 0) */
virtual IGUIFont* getOverrideFont(void) const _IRR_OVERRIDE_;
//! Get the font which is used for drawing
/** This is the override font when one is set and the
font of the skin otherwise. */
virtual IGUIFont* getActiveFont() const _IRR_OVERRIDE_;
//! Sets the image list which should be used for the image and selected image of every node.
//! The default is 0 (no images).
virtual void setImageList( IGUIImageList* imageList ) _IRR_OVERRIDE_;
//! Returns the image list which is used for the nodes.
virtual IGUIImageList* getImageList() const _IRR_OVERRIDE_
{ return ImageList; }
//! Sets if the image is left of the icon. Default is true.
virtual void setImageLeftOfIcon( bool bLeftOf ) _IRR_OVERRIDE_
{ ImageLeftOfIcon = bLeftOf; }
//! Returns if the Image is left of the icon. Default is true.
virtual bool getImageLeftOfIcon() const _IRR_OVERRIDE_
{ return ImageLeftOfIcon; }
//! Returns the node which is associated to the last event.
virtual IGUITreeViewNode* getLastEventNode() const _IRR_OVERRIDE_
{ return LastEventNode; }
//! Access the vertical scrollbar
virtual IGUIScrollBar* getVerticalScrollBar() const _IRR_OVERRIDE_;
//! Access the horizontal scrollbar
virtual IGUIScrollBar* getHorizontalScrollBar() const _IRR_OVERRIDE_;
private:
//! calculates the heigth of an node and of all visible nodes.
void recalculateItemHeight();
//! Resize scrollbars when their size in the skin has changed
void updateScrollBarSize(s32 size);
//! executes an mouse action (like selectNew of CGUIListBox)
void mouseAction( s32 xpos, s32 ypos, bool onlyHover = false );
CGUITreeViewNode* Root;
IGUITreeViewNode* Selected;
s32 ItemHeight;
s32 IndentWidth;
s32 TotalItemHeight;
s32 TotalItemWidth;
s32 ScrollBarSize;
IGUIFont* Font;
gui::IGUIFont* OverrideFont;
IGUIFont* IconFont;
IGUIScrollBar* ScrollBarH;
IGUIScrollBar* ScrollBarV;
IGUIImageList* ImageList;
IGUITreeViewNode* LastEventNode;
bool LinesVisible;
bool Selecting;
bool Clip;
bool DrawBack;
bool ImageLeftOfIcon;
};
} // end namespace gui
} // end namespace irr
#endif

View File

@ -1,363 +0,0 @@
// Copyright (C) 2002-2012 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#include "CGUIWindow.h"
#ifdef _IRR_COMPILE_WITH_GUI_
#include "IGUISkin.h"
#include "IGUIEnvironment.h"
#include "IVideoDriver.h"
#include "IGUIButton.h"
#include "IGUIFont.h"
#include "IGUIFontBitmap.h"
namespace irr
{
namespace gui
{
//! constructor
CGUIWindow::CGUIWindow(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle)
: IGUIWindow(environment, parent, id, rectangle), Dragging(false), IsDraggable(true), DrawBackground(true), DrawTitlebar(true), IsActive(false)
{
#ifdef _DEBUG
setDebugName("CGUIWindow");
#endif
IGUISkin* skin = 0;
if (environment)
skin = environment->getSkin();
CurrentIconColor = video::SColor(255,255,255,255);
s32 buttonw = 15;
if (skin)
{
buttonw = skin->getSize(EGDS_WINDOW_BUTTON_WIDTH);
}
s32 posx = RelativeRect.getWidth() - buttonw - 4;
CloseButton = Environment->addButton(core::rect<s32>(posx, 3, posx + buttonw, 3 + buttonw), this, -1,
L"", skin ? skin->getDefaultText(EGDT_WINDOW_CLOSE) : L"Close" );
CloseButton->setSubElement(true);
CloseButton->setTabStop(false);
CloseButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT);
posx -= buttonw + 2;
RestoreButton = Environment->addButton(core::rect<s32>(posx, 3, posx + buttonw, 3 + buttonw), this, -1,
L"", skin ? skin->getDefaultText(EGDT_WINDOW_RESTORE) : L"Restore" );
RestoreButton->setVisible(false);
RestoreButton->setSubElement(true);
RestoreButton->setTabStop(false);
RestoreButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT);
posx -= buttonw + 2;
MinButton = Environment->addButton(core::rect<s32>(posx, 3, posx + buttonw, 3 + buttonw), this, -1,
L"", skin ? skin->getDefaultText(EGDT_WINDOW_MINIMIZE) : L"Minimize" );
MinButton->setVisible(false);
MinButton->setSubElement(true);
MinButton->setTabStop(false);
MinButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT);
MinButton->grab();
RestoreButton->grab();
CloseButton->grab();
// this element is a tab group
setTabGroup(true);
setTabStop(true);
setTabOrder(-1);
refreshSprites();
updateClientRect();
}
//! destructor
CGUIWindow::~CGUIWindow()
{
if (MinButton)
MinButton->drop();
if (RestoreButton)
RestoreButton->drop();
if (CloseButton)
CloseButton->drop();
}
void CGUIWindow::refreshSprites()
{
if (!Environment)
return;
IGUISkin* skin = Environment->getSkin();
if ( !skin )
return;
IGUISpriteBank* sprites = skin->getSpriteBank();
if ( !sprites )
return;
CurrentIconColor = skin->getColor(isEnabled() ? EGDC_WINDOW_SYMBOL : EGDC_GRAY_WINDOW_SYMBOL);
if (sprites)
{
CloseButton->setSpriteBank(sprites);
CloseButton->setSprite(EGBS_BUTTON_UP, skin->getIcon(EGDI_WINDOW_CLOSE), CurrentIconColor);
CloseButton->setSprite(EGBS_BUTTON_DOWN, skin->getIcon(EGDI_WINDOW_CLOSE), CurrentIconColor);
RestoreButton->setSpriteBank(sprites);
RestoreButton->setSprite(EGBS_BUTTON_UP, skin->getIcon(EGDI_WINDOW_RESTORE), CurrentIconColor);
RestoreButton->setSprite(EGBS_BUTTON_DOWN, skin->getIcon(EGDI_WINDOW_RESTORE), CurrentIconColor);
MinButton->setSpriteBank(sprites);
MinButton->setSprite(EGBS_BUTTON_UP, skin->getIcon(EGDI_WINDOW_MINIMIZE), CurrentIconColor);
MinButton->setSprite(EGBS_BUTTON_DOWN, skin->getIcon(EGDI_WINDOW_MINIMIZE), CurrentIconColor);
}
}
//! called if an event happened.
bool CGUIWindow::OnEvent(const SEvent& event)
{
if (isEnabled())
{
switch(event.EventType)
{
case EET_GUI_EVENT:
if (event.GUIEvent.EventType == EGET_ELEMENT_FOCUS_LOST)
{
Dragging = false;
IsActive = false;
}
else
if (event.GUIEvent.EventType == EGET_ELEMENT_FOCUSED)
{
if (Parent && ((event.GUIEvent.Caller == this) || isMyChild(event.GUIEvent.Caller)))
{
Parent->bringToFront(this);
IsActive = true;
}
else
{
IsActive = false;
}
}
else
if (event.GUIEvent.EventType == EGET_BUTTON_CLICKED)
{
if (event.GUIEvent.Caller == CloseButton)
{
if (Parent)
{
// send close event to parent
SEvent e;
e.EventType = EET_GUI_EVENT;
e.GUIEvent.Caller = this;
e.GUIEvent.Element = 0;
e.GUIEvent.EventType = EGET_ELEMENT_CLOSED;
// if the event was not absorbed
if (!Parent->OnEvent(e))
remove();
return true;
}
else
{
remove();
return true;
}
}
}
break;
case EET_MOUSE_INPUT_EVENT:
switch(event.MouseInput.Event)
{
case EMIE_LMOUSE_PRESSED_DOWN:
DragStart.X = event.MouseInput.X;
DragStart.Y = event.MouseInput.Y;
Dragging = IsDraggable;
if (Parent)
Parent->bringToFront(this);
return true;
case EMIE_LMOUSE_LEFT_UP:
Dragging = false;
return true;
case EMIE_MOUSE_MOVED:
if (!event.MouseInput.isLeftPressed())
Dragging = false;
if (Dragging)
{
// gui window should not be dragged outside its parent
if (Parent &&
(event.MouseInput.X < Parent->getAbsolutePosition().UpperLeftCorner.X +1 ||
event.MouseInput.Y < Parent->getAbsolutePosition().UpperLeftCorner.Y +1 ||
event.MouseInput.X > Parent->getAbsolutePosition().LowerRightCorner.X -1 ||
event.MouseInput.Y > Parent->getAbsolutePosition().LowerRightCorner.Y -1))
return true;
move(core::position2d<s32>(event.MouseInput.X - DragStart.X, event.MouseInput.Y - DragStart.Y));
DragStart.X = event.MouseInput.X;
DragStart.Y = event.MouseInput.Y;
return true;
}
break;
default:
break;
}
default:
break;
}
}
return IGUIElement::OnEvent(event);
}
//! Updates the absolute position.
void CGUIWindow::updateAbsolutePosition()
{
IGUIElement::updateAbsolutePosition();
}
//! draws the element and its children
void CGUIWindow::draw()
{
if (IsVisible)
{
IGUISkin* skin = Environment->getSkin();
// update each time because the skin is allowed to change this always.
updateClientRect();
if ( CurrentIconColor != skin->getColor(isEnabled() ? EGDC_WINDOW_SYMBOL : EGDC_GRAY_WINDOW_SYMBOL) )
refreshSprites();
core::rect<s32> rect = AbsoluteRect;
// draw body fast
if (DrawBackground)
{
rect = skin->draw3DWindowBackground(this, DrawTitlebar,
skin->getColor(IsActive ? EGDC_ACTIVE_BORDER : EGDC_INACTIVE_BORDER),
AbsoluteRect, &AbsoluteClippingRect);
if (DrawTitlebar && Text.size())
{
rect.UpperLeftCorner.X += skin->getSize(EGDS_TITLEBARTEXT_DISTANCE_X);
rect.UpperLeftCorner.Y += skin->getSize(EGDS_TITLEBARTEXT_DISTANCE_Y);
rect.LowerRightCorner.X -= skin->getSize(EGDS_WINDOW_BUTTON_WIDTH) + 5;
IGUIFont* font = skin->getFont(EGDF_WINDOW);
if (font)
{
font->draw(Text.c_str(), rect,
skin->getColor(IsActive ? EGDC_ACTIVE_CAPTION:EGDC_INACTIVE_CAPTION),
false, true, &AbsoluteClippingRect);
}
}
}
}
IGUIElement::draw();
}
//! Returns pointer to the close button
IGUIButton* CGUIWindow::getCloseButton() const
{
return CloseButton;
}
//! Returns pointer to the minimize button
IGUIButton* CGUIWindow::getMinimizeButton() const
{
return MinButton;
}
//! Returns pointer to the maximize button
IGUIButton* CGUIWindow::getMaximizeButton() const
{
return RestoreButton;
}
//! Returns true if the window is draggable, false if not
bool CGUIWindow::isDraggable() const
{
return IsDraggable;
}
//! Sets whether the window is draggable
void CGUIWindow::setDraggable(bool draggable)
{
IsDraggable = draggable;
if (Dragging && !IsDraggable)
Dragging = false;
}
//! Set if the window background will be drawn
void CGUIWindow::setDrawBackground(bool draw)
{
DrawBackground = draw;
}
//! Get if the window background will be drawn
bool CGUIWindow::getDrawBackground() const
{
return DrawBackground;
}
//! Set if the window titlebar will be drawn
void CGUIWindow::setDrawTitlebar(bool draw)
{
DrawTitlebar = draw;
}
//! Get if the window titlebar will be drawn
bool CGUIWindow::getDrawTitlebar() const
{
return DrawTitlebar;
}
void CGUIWindow::updateClientRect()
{
if (! DrawBackground )
{
ClientRect = core::rect<s32>(0,0, AbsoluteRect.getWidth(), AbsoluteRect.getHeight());
return;
}
IGUISkin* skin = Environment->getSkin();
skin->draw3DWindowBackground(this, DrawTitlebar,
skin->getColor(IsActive ? EGDC_ACTIVE_BORDER : EGDC_INACTIVE_BORDER),
AbsoluteRect, &AbsoluteClippingRect, &ClientRect);
ClientRect -= AbsoluteRect.UpperLeftCorner;
}
//! Returns the rectangle of the drawable area (without border, without titlebar and without scrollbars)
core::rect<s32> CGUIWindow::getClientRect() const
{
return ClientRect;
}
} // end namespace gui
} // end namespace irr
#endif // _IRR_COMPILE_WITH_GUI_

View File

@ -1,93 +0,0 @@
// Copyright (C) 2002-2012 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __C_GUI_WINDOW_H_INCLUDED__
#define __C_GUI_WINDOW_H_INCLUDED__
#include "IrrCompileConfig.h"
#ifdef _IRR_COMPILE_WITH_GUI_
#include "IGUIWindow.h"
namespace irr
{
namespace gui
{
class IGUIButton;
class CGUIWindow : public IGUIWindow
{
public:
//! constructor
CGUIWindow(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle);
//! destructor
virtual ~CGUIWindow();
//! called if an event happened.
virtual bool OnEvent(const SEvent& event) _IRR_OVERRIDE_;
//! update absolute position
virtual void updateAbsolutePosition() _IRR_OVERRIDE_;
//! draws the element and its children
virtual void draw() _IRR_OVERRIDE_;
//! Returns pointer to the close button
virtual IGUIButton* getCloseButton() const _IRR_OVERRIDE_;
//! Returns pointer to the minimize button
virtual IGUIButton* getMinimizeButton() const _IRR_OVERRIDE_;
//! Returns pointer to the maximize button
virtual IGUIButton* getMaximizeButton() const _IRR_OVERRIDE_;
//! Returns true if the window is draggable, false if not
virtual bool isDraggable() const _IRR_OVERRIDE_;
//! Sets whether the window is draggable
virtual void setDraggable(bool draggable) _IRR_OVERRIDE_;
//! Set if the window background will be drawn
virtual void setDrawBackground(bool draw) _IRR_OVERRIDE_;
//! Get if the window background will be drawn
virtual bool getDrawBackground() const _IRR_OVERRIDE_;
//! Set if the window titlebar will be drawn
//! Note: If the background is not drawn, then the titlebar is automatically also not drawn
virtual void setDrawTitlebar(bool draw) _IRR_OVERRIDE_;
//! Get if the window titlebar will be drawn
virtual bool getDrawTitlebar() const _IRR_OVERRIDE_;
//! Returns the rectangle of the drawable area (without border and without titlebar)
virtual core::rect<s32> getClientRect() const _IRR_OVERRIDE_;
protected:
void updateClientRect();
void refreshSprites();
IGUIButton* CloseButton;
IGUIButton* MinButton;
IGUIButton* RestoreButton;
core::rect<s32> ClientRect;
video::SColor CurrentIconColor;
core::position2d<s32> DragStart;
bool Dragging, IsDraggable;
bool DrawBackground;
bool DrawTitlebar;
bool IsActive;
};
} // end namespace gui
} // end namespace irr
#endif // _IRR_COMPILE_WITH_GUI_
#endif

View File

@ -13,7 +13,6 @@
#include "CTimer.h"
#include "CLogger.h"
#include "irrString.h"
#include "IRandomizer.h"
namespace irr
{
@ -21,8 +20,8 @@ namespace irr
CIrrDeviceStub::CIrrDeviceStub(const SIrrlichtCreationParameters& params)
: IrrlichtDevice(), VideoDriver(0), GUIEnvironment(0), SceneManager(0),
Timer(0), CursorControl(0), UserReceiver(params.EventReceiver),
Logger(0), Operator(0), Randomizer(0), FileSystem(0),
InputReceivingSceneManager(0), VideoModeList(0), ContextManager(0),
Logger(0), Operator(0), FileSystem(0),
InputReceivingSceneManager(0), ContextManager(0),
CreationParams(params), Close(false)
{
Timer = new CTimer(params.UsePerformanceTimer);
@ -40,10 +39,8 @@ CIrrDeviceStub::CIrrDeviceStub(const SIrrlichtCreationParameters& params)
Logger->setLogLevel(CreationParams.LoggingLevel);
os::Printer::Logger = Logger;
Randomizer = createDefaultRandomizer();
FileSystem = io::createFileSystem();
VideoModeList = new video::CVideoModeList();
core::stringc s = "Irrlicht Engine version ";
s.append(getVersion());
@ -55,8 +52,6 @@ CIrrDeviceStub::CIrrDeviceStub(const SIrrlichtCreationParameters& params)
CIrrDeviceStub::~CIrrDeviceStub()
{
VideoModeList->drop();
if (GUIEnvironment)
GUIEnvironment->drop();
@ -81,9 +76,6 @@ CIrrDeviceStub::~CIrrDeviceStub()
if (Operator)
Operator->drop();
if (Randomizer)
Randomizer->drop();
CursorControl = 0;
if (Timer)
@ -159,13 +151,6 @@ gui::ICursorControl* CIrrDeviceStub::getCursorControl()
}
//! \return Returns a pointer to a list with all video modes supported
//! by the gfx adapter.
video::IVideoModeList* CIrrDeviceStub::getVideoModeList()
{
return VideoModeList;
}
//! return the context manager
video::IContextManager* CIrrDeviceStub::getContextManager()
{
@ -275,56 +260,6 @@ IOSOperator* CIrrDeviceStub::getOSOperator()
}
//! Provides access to the engine's currently set randomizer.
IRandomizer* CIrrDeviceStub::getRandomizer() const
{
return Randomizer;
}
//! Sets a new randomizer.
void CIrrDeviceStub::setRandomizer(IRandomizer* r)
{
if (r!=Randomizer)
{
if (Randomizer)
Randomizer->drop();
Randomizer=r;
if (Randomizer)
Randomizer->grab();
}
}
namespace
{
struct SDefaultRandomizer : public IRandomizer
{
virtual void reset(s32 value=0x0f0f0f0f) _IRR_OVERRIDE_
{
os::Randomizer::reset(value);
}
virtual s32 rand() const _IRR_OVERRIDE_
{
return os::Randomizer::rand();
}
virtual s32 randMax() const _IRR_OVERRIDE_
{
return os::Randomizer::randMax();
}
};
}
//! Creates a new default randomizer.
IRandomizer* CIrrDeviceStub::createDefaultRandomizer() const
{
IRandomizer* r = new SDefaultRandomizer();
if (r)
r->reset();
return r;
}
//! Sets the input receiving scene manager.
void CIrrDeviceStub::setInputReceivingSceneManager(scene::ISceneManager* sceneManager)
{

View File

@ -8,7 +8,6 @@
#include "IrrlichtDevice.h"
#include "IImagePresenter.h"
#include "SIrrCreationParameters.h"
#include "CVideoModeList.h"
#include "IContextManager.h"
namespace irr
@ -16,7 +15,6 @@ namespace irr
// lots of prototypes:
class ILogger;
class CLogger;
class IRandomizer;
namespace gui
{
@ -74,9 +72,6 @@ namespace irr
//! \return Returns a pointer to the mouse cursor control interface.
virtual gui::ICursorControl* getCursorControl() _IRR_OVERRIDE_;
//! Returns a pointer to a list with all video modes supported by the gfx adapter.
virtual video::IVideoModeList* getVideoModeList() _IRR_OVERRIDE_;
//! return the context manager
virtual video::IContextManager* getContextManager() _IRR_OVERRIDE_;
@ -102,15 +97,6 @@ namespace irr
//! Returns a pointer to the logger.
virtual ILogger* getLogger() _IRR_OVERRIDE_;
//! Provides access to the engine's currently set randomizer.
virtual IRandomizer* getRandomizer() const _IRR_OVERRIDE_;
//! Sets a new randomizer.
virtual void setRandomizer(IRandomizer* r) _IRR_OVERRIDE_;
//! Creates a new default randomizer.
virtual IRandomizer* createDefaultRandomizer() const _IRR_OVERRIDE_;
//! Returns the operation system opertator object.
virtual IOSOperator* getOSOperator() _IRR_OVERRIDE_;
@ -205,7 +191,6 @@ namespace irr
IEventReceiver* UserReceiver;
CLogger* Logger;
IOSOperator* Operator;
IRandomizer* Randomizer;
io::IFileSystem* FileSystem;
scene::ISceneManager* InputReceivingSceneManager;
@ -222,7 +207,6 @@ namespace irr
EMOUSE_INPUT_EVENT LastMouseInputEvent;
};
SMouseMultiClicks MouseMultiClicks;
video::CVideoModeList* VideoModeList;
video::IContextManager* ContextManager;
SIrrlichtCreationParameters CreationParams;
bool Close;

View File

@ -167,7 +167,6 @@ add_library(IRROBJ OBJECT
CSceneCollisionManager.cpp
CSceneManager.cpp
CMeshCache.cpp
CDefaultSceneNodeFactory.cpp
)
set(IRRDRVROBJ
@ -204,7 +203,6 @@ set(IRRIMAGEOBJ
)
add_library(IRRVIDEOOBJ OBJECT
CVideoModeList.cpp
CFPSCounter.cpp
${IRRDRVROBJ}
${IRRIMAGEOBJ}
@ -218,7 +216,6 @@ add_library(IRRIOOBJ OBJECT
CReadFile.cpp
CWriteFile.cpp
CZipReader.cpp
CMountPointReader.cpp
CAttributes.cpp
)
@ -257,32 +254,18 @@ add_library(IRRGUIOBJ OBJECT
CGUIButton.cpp
CGUICheckBox.cpp
CGUIComboBox.cpp
CGUIContextMenu.cpp
CGUIEditBox.cpp
CGUIEnvironment.cpp
CGUIFileOpenDialog.cpp
CGUIFont.cpp
CGUIImage.cpp
CGUIInOutFader.cpp
CGUIListBox.cpp
CGUIMenu.cpp
CGUIMeshViewer.cpp
CGUIMessageBox.cpp
CGUIModalScreen.cpp
CGUIScrollBar.cpp
CGUISpinBox.cpp
CGUISkin.cpp
CGUIStaticText.cpp
CGUITabControl.cpp
CGUITable.cpp
CGUIToolBar.cpp
CGUIWindow.cpp
CGUIColorSelectDialog.cpp
CDefaultGUIElementFactory.cpp
CGUISpriteBank.cpp
CGUIImageList.cpp
CGUITreeView.cpp
CGUIProfiler.cpp
)
# Library

File diff suppressed because it is too large Load Diff

View File

@ -20,11 +20,6 @@ not intended for doing mesh modifications and/or animations during runtime.
class CMeshManipulator : public IMeshManipulator
{
public:
//! Flips the direction of surfaces.
/** Changes backfacing triangles to frontfacing triangles and vice versa.
\param mesh: Mesh on which the operation is performed. */
virtual void flipSurfaces(scene::IMesh* mesh) const _IRR_OVERRIDE_;
//! Recalculates all normals of the mesh.
/** \param mesh: Mesh on which the operation is performed.
\param smooth: Whether to use smoothed normals. */
@ -38,43 +33,6 @@ public:
//! Clones a static IMesh into a modifiable SMesh.
virtual SMesh* createMeshCopy(scene::IMesh* mesh) const _IRR_OVERRIDE_;
//! Creates a planar texture mapping on the mesh
/** \param mesh: Mesh on which the operation is performed.
\param resolution: resolution of the planar mapping. This is the value
specifying which is the relation between world space and
texture coordinate space. */
virtual void makePlanarTextureMapping(scene::IMesh* mesh, f32 resolution=0.001f) const _IRR_OVERRIDE_;
//! Creates a planar texture mapping on the meshbuffer
virtual void makePlanarTextureMapping(scene::IMeshBuffer* meshbuffer, f32 resolution=0.001f) const _IRR_OVERRIDE_;
//! Creates a planar texture mapping on the meshbuffer
void makePlanarTextureMapping(scene::IMeshBuffer* buffer, f32 resolutionS, f32 resolutionT, u8 axis, const core::vector3df& offset) const _IRR_OVERRIDE_;
//! Creates a planar texture mapping on the mesh
void makePlanarTextureMapping(scene::IMesh* mesh, f32 resolutionS, f32 resolutionT, u8 axis, const core::vector3df& offset) const _IRR_OVERRIDE_;
//! Recalculates tangents, requires a tangent mesh buffer
virtual void recalculateTangents(IMeshBuffer* buffer, bool recalculateNormals=false, bool smooth=false, bool angleWeighted=false) const _IRR_OVERRIDE_;
//! Recalculates tangents, requires a tangent mesh
virtual void recalculateTangents(IMesh* mesh, bool recalculateNormals=false, bool smooth=false, bool angleWeighted=false) const _IRR_OVERRIDE_;
//! Creates a copy of the mesh, which will only consist of S3DVertexTangents vertices.
virtual IMesh* createMeshWithTangents(IMesh* mesh, bool recalculateNormals=false, bool smooth=false, bool angleWeighted=false, bool recalculateTangents=true) const _IRR_OVERRIDE_;
//! Creates a copy of the mesh, which will only consist of S3D2TCoords vertices.
virtual IMesh* createMeshWith2TCoords(IMesh* mesh) const _IRR_OVERRIDE_;
//! Creates a copy of the mesh, which will only consist of S3DVertex vertices.
virtual IMesh* createMeshWith1TCoords(IMesh* mesh) const _IRR_OVERRIDE_;
//! Creates a copy of the mesh, which will only consist of unique triangles, i.e. no vertices are shared.
virtual IMesh* createMeshUniquePrimitives(IMesh* mesh) const _IRR_OVERRIDE_;
//! Creates a copy of the mesh, which will have all duplicated vertices removed, i.e. maximal amount of vertices are shared via indexing.
virtual IMesh* createMeshWelded(IMesh *mesh, f32 tolerance=core::ROUNDING_ERROR_f32) const _IRR_OVERRIDE_;
//! Returns amount of polygons in mesh.
virtual s32 getPolyCount(scene::IMesh* mesh) const _IRR_OVERRIDE_;
@ -83,15 +41,6 @@ public:
//! create a new AnimatedMesh and adds the mesh to it
virtual IAnimatedMesh * createAnimatedMesh(scene::IMesh* mesh,scene::E_ANIMATED_MESH_TYPE type) const _IRR_OVERRIDE_;
//! create a mesh optimized for the vertex cache
virtual IMesh* createForsythOptimizedMesh(const scene::IMesh *mesh) const _IRR_OVERRIDE_;
//! Optimizes the mesh using an algorithm tuned for heightmaps
virtual void heightmapOptimizeMesh(IMesh * const m, const f32 tolerance = core::ROUNDING_ERROR_f32) const _IRR_OVERRIDE_;
//! Optimizes the mesh using an algorithm tuned for heightmaps
virtual void heightmapOptimizeMesh(IMeshBuffer * const m, const f32 tolerance = core::ROUNDING_ERROR_f32) const _IRR_OVERRIDE_;
};
} // end namespace scene

View File

@ -1,175 +0,0 @@
// Copyright (C) 2002-2012 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#include "CMountPointReader.h"
#ifdef __IRR_COMPILE_WITH_MOUNT_ARCHIVE_LOADER_
#include "CReadFile.h"
#include "os.h"
namespace irr
{
namespace io
{
//! Constructor
CArchiveLoaderMount::CArchiveLoaderMount( io::IFileSystem* fs)
: FileSystem(fs)
{
#ifdef _DEBUG
setDebugName("CArchiveLoaderMount");
#endif
}
//! returns true if the file maybe is able to be loaded by this class
bool CArchiveLoaderMount::isALoadableFileFormat(const io::path& filename) const
{
io::path fname(filename);
deletePathFromFilename(fname);
if (!fname.size())
return true;
IFileList* list = FileSystem->createFileList();
bool ret = false;
if (list)
{
// check if name is found as directory
if (list->findFile(filename, true))
ret=true;
list->drop();
}
return ret;
}
//! Check to see if the loader can create archives of this type.
bool CArchiveLoaderMount::isALoadableFileFormat(E_FILE_ARCHIVE_TYPE fileType) const
{
return fileType == EFAT_FOLDER;
}
//! Check if the file might be loaded by this class
bool CArchiveLoaderMount::isALoadableFileFormat(io::IReadFile* file) const
{
return false;
}
//! Creates an archive from the filename
IFileArchive* CArchiveLoaderMount::createArchive(const io::path& filename, bool ignoreCase, bool ignorePaths) const
{
IFileArchive *archive = 0;
EFileSystemType current = FileSystem->setFileListSystem(FILESYSTEM_NATIVE);
const io::path save = FileSystem->getWorkingDirectory();
io::path fullPath = FileSystem->getAbsolutePath(filename);
FileSystem->flattenFilename(fullPath);
if (FileSystem->changeWorkingDirectoryTo(fullPath))
{
archive = new CMountPointReader(FileSystem, fullPath, ignoreCase, ignorePaths);
}
FileSystem->changeWorkingDirectoryTo(save);
FileSystem->setFileListSystem(current);
return archive;
}
//! creates/loads an archive from the file.
//! \return Pointer to the created archive. Returns 0 if loading failed.
IFileArchive* CArchiveLoaderMount::createArchive(io::IReadFile* file, bool ignoreCase, bool ignorePaths) const
{
return 0;
}
//! compatible Folder Architecture
CMountPointReader::CMountPointReader(IFileSystem * parent, const io::path& basename, bool ignoreCase, bool ignorePaths)
: CFileList(basename, ignoreCase, ignorePaths), Parent(parent)
{
//! ensure CFileList path ends in a slash
if (Path.lastChar() != '/' )
Path.append('/');
const io::path& work = Parent->getWorkingDirectory();
Parent->changeWorkingDirectoryTo(basename);
buildDirectory();
Parent->changeWorkingDirectoryTo(work);
sort();
}
//! returns the list of files
const IFileList* CMountPointReader::getFileList() const
{
return this;
}
void CMountPointReader::buildDirectory()
{
IFileList * list = Parent->createFileList();
if (!list)
return;
const u32 size = list->getFileCount();
for (u32 i=0; i < size; ++i)
{
io::path full = list->getFullFileName(i);
full = full.subString(Path.size(), full.size() - Path.size());
if (!list->isDirectory(i))
{
addItem(full, list->getFileOffset(i), list->getFileSize(i), false, RealFileNames.size());
RealFileNames.push_back(list->getFullFileName(i));
}
else
{
const io::path rel = list->getFileName(i);
RealFileNames.push_back(list->getFullFileName(i));
io::path pwd = Parent->getWorkingDirectory();
if (pwd.lastChar() != '/')
pwd.append('/');
pwd.append(rel);
if ( rel != "." && rel != ".." )
{
addItem(full, 0, 0, true, 0);
Parent->changeWorkingDirectoryTo(pwd);
buildDirectory();
Parent->changeWorkingDirectoryTo("..");
}
}
}
list->drop();
}
//! opens a file by index
IReadFile* CMountPointReader::createAndOpenFile(u32 index)
{
if (index >= Files.size())
return 0;
return CReadFile::createReadFile(RealFileNames[Files[index].ID]);
}
//! opens a file by file name
IReadFile* CMountPointReader::createAndOpenFile(const io::path& filename)
{
s32 index = findFile(filename, false);
if (index != -1)
return createAndOpenFile(index);
else
return 0;
}
} // io
} // irr
#endif // __IRR_COMPILE_WITH_MOUNT_ARCHIVE_LOADER_

View File

@ -1,92 +0,0 @@
// Copyright (C) 2002-2012 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __C_MOUNT_READER_H_INCLUDED__
#define __C_MOUNT_READER_H_INCLUDED__
#include "IrrCompileConfig.h"
#ifdef __IRR_COMPILE_WITH_MOUNT_ARCHIVE_LOADER_
#include "IFileSystem.h"
#include "CFileList.h"
namespace irr
{
namespace io
{
//! Archiveloader capable of loading MountPoint Archives
class CArchiveLoaderMount : public IArchiveLoader
{
public:
//! Constructor
CArchiveLoaderMount(io::IFileSystem* fs);
//! returns true if the file maybe is able to be loaded by this class
//! based on the file extension (e.g. ".zip")
virtual bool isALoadableFileFormat(const io::path& filename) const _IRR_OVERRIDE_;
//! Check if the file might be loaded by this class
/** Check might look into the file.
\param file File handle to check.
\return True if file seems to be loadable. */
virtual bool isALoadableFileFormat(io::IReadFile* file) const _IRR_OVERRIDE_;
//! Check to see if the loader can create archives of this type.
/** Check based on the archive type.
\param fileType The archive type to check.
\return True if the archile loader supports this type, false if not */
virtual bool isALoadableFileFormat(E_FILE_ARCHIVE_TYPE fileType) const _IRR_OVERRIDE_;
//! Creates an archive from the filename
/** \param file File handle to check.
\return Pointer to newly created archive, or 0 upon error. */
virtual IFileArchive* createArchive(const io::path& filename, bool ignoreCase, bool ignorePaths) const _IRR_OVERRIDE_;
//! creates/loads an archive from the file.
//! \return Pointer to the created archive. Returns 0 if loading failed.
virtual IFileArchive* createArchive(io::IReadFile* file, bool ignoreCase, bool ignorePaths) const _IRR_OVERRIDE_;
private:
io::IFileSystem* FileSystem;
};
//! A File Archive which uses a mountpoint
class CMountPointReader : public virtual IFileArchive, virtual CFileList
{
public:
//! Constructor
CMountPointReader(IFileSystem *parent, const io::path& basename,
bool ignoreCase, bool ignorePaths);
//! opens a file by index
virtual IReadFile* createAndOpenFile(u32 index) _IRR_OVERRIDE_;
//! opens a file by file name
virtual IReadFile* createAndOpenFile(const io::path& filename) _IRR_OVERRIDE_;
//! returns the list of files
virtual const IFileList* getFileList() const _IRR_OVERRIDE_;
//! get the class Type
virtual E_FILE_ARCHIVE_TYPE getType() const _IRR_OVERRIDE_ { return EFAT_FOLDER; }
//! return the name (id) of the file Archive
virtual const io::path& getArchiveName() const _IRR_OVERRIDE_ {return Path;}
private:
core::array<io::path> RealFileNames;
IFileSystem *Parent;
void buildDirectory();
};
} // io
} // irr
#endif // __IRR_COMPILE_WITH_MOUNT_ARCHIVE_LOADER_
#endif // __C_MOUNT_READER_H_INCLUDED__

View File

@ -97,7 +97,6 @@ CNullDriver::CNullDriver(io::IFileSystem* io, const core::dimension2d<u32>& scre
DriverAttributes = new io::CAttributes();
DriverAttributes->addInt("MaxTextures", _IRR_MATERIAL_MAX_TEXTURES_);
DriverAttributes->addInt("MaxSupportedTextures", _IRR_MATERIAL_MAX_TEXTURES_);
DriverAttributes->addInt("MaxLights", getMaximalDynamicLightAmount());
DriverAttributes->addInt("MaxAnisotropy", 1);
// DriverAttributes->addInt("MaxUserClipPlanes", 0);
// DriverAttributes->addInt("MaxAuxBuffers", 0);
@ -1095,61 +1094,6 @@ void CNullDriver::drawStencilShadow(bool clearStencilBuffer,
}
//! deletes all dynamic lights there are
void CNullDriver::deleteAllDynamicLights()
{
Lights.set_used(0);
}
//! adds a dynamic light
s32 CNullDriver::addDynamicLight(const SLight& light)
{
Lights.push_back(light);
return Lights.size() - 1;
}
//! Turns a dynamic light on or off
//! \param lightIndex: the index returned by addDynamicLight
//! \param turnOn: true to turn the light on, false to turn it off
void CNullDriver::turnLightOn(s32 lightIndex, bool turnOn)
{
// Do nothing
}
//! returns the maximal amount of dynamic lights the device can handle
u32 CNullDriver::getMaximalDynamicLightAmount() const
{
return 0;
}
//! Returns current amount of dynamic lights set
//! \return Current amount of dynamic lights set
u32 CNullDriver::getDynamicLightCount() const
{
return Lights.size();
}
//! Returns light data which was previously set by IVideoDriver::addDynamicLight().
//! \param idx: Zero based index of the light. Must be greater than 0 and smaller
//! than IVideoDriver()::getDynamicLightCount.
//! \return Light data.
const SLight& CNullDriver::getDynamicLight(u32 idx) const
{
if ( idx < Lights.size() )
return Lights[idx];
else
{
_IRR_DEBUG_BREAK_IF(true)
static const SLight dummy;
return dummy;
}
}
//! Creates a boolean alpha channel of the texture based of an color key.
void CNullDriver::makeColorKeyTexture(video::ITexture* texture,
video::SColor color,

View File

@ -18,7 +18,6 @@
#include "CFPSCounter.h"
#include "S3DVertex.h"
#include "SVertexIndex.h"
#include "SLight.h"
#include "SExposedVideoData.h"
#include <list>
@ -249,22 +248,6 @@ namespace video
//! very useful method for statistics.
virtual u32 getPrimitiveCountDrawn( u32 param = 0 ) const _IRR_OVERRIDE_;
//! deletes all dynamic lights there are
virtual void deleteAllDynamicLights() _IRR_OVERRIDE_;
//! adds a dynamic light, returning an index to the light
//! \param light: the light data to use to create the light
//! \return An index to the light, or -1 if an error occurs
virtual s32 addDynamicLight(const SLight& light) _IRR_OVERRIDE_;
//! Turns a dynamic light on or off
//! \param lightIndex: the index returned by addDynamicLight
//! \param turnOn: true to turn the light on, false to turn it off
virtual void turnLightOn(s32 lightIndex, bool turnOn) _IRR_OVERRIDE_;
//! returns the maximal amount of dynamic lights the device can handle
virtual u32 getMaximalDynamicLightAmount() const _IRR_OVERRIDE_;
//! \return Returns the name of the video driver. Example: In case of the DIRECT3D8
//! driver, it would return "Direct3D8.1".
virtual const wchar_t* getName() const _IRR_OVERRIDE_;
@ -298,15 +281,6 @@ namespace video
video::SColor leftDownEdge = video::SColor(0,0,0,0),
video::SColor rightDownEdge = video::SColor(0,0,0,0)) _IRR_OVERRIDE_;
//! Returns current amount of dynamic lights set
//! \return Current amount of dynamic lights set
virtual u32 getDynamicLightCount() const _IRR_OVERRIDE_;
//! Returns light data which was previously set with IVideDriver::addDynamicLight().
//! \param idx: Zero based index of the light. Must be greater than 0 and smaller
//! than IVideoDriver()::getDynamicLightCount.
//! \return Light data.
virtual const SLight& getDynamicLight(u32 idx) const _IRR_OVERRIDE_;
//! Removes a texture from the texture cache and deletes it, freeing lot of
//! memory.
@ -819,7 +793,6 @@ namespace video
core::array<video::IImageLoader*> SurfaceLoader;
core::array<video::IImageWriter*> SurfaceWriter;
core::array<SLight> Lights;
core::array<SMaterialRenderer> MaterialRenderers;
std::list<SHWBufferLink*> HWBufferList;

View File

@ -81,8 +81,6 @@ COGLES2Driver::COGLES2Driver(const SIrrlichtCreationParameters& params, io::IFil
COGLES2Driver::~COGLES2Driver()
{
RequestedLights.clear();
deleteMaterialRenders();
CacheHandler->getTextureCache().clear();
@ -2007,46 +2005,6 @@ COGLES2Driver::~COGLES2Driver()
return Name.c_str();
}
//! deletes all dynamic lights there are
void COGLES2Driver::deleteAllDynamicLights()
{
RequestedLights.clear();
CNullDriver::deleteAllDynamicLights();
}
//! adds a dynamic light
s32 COGLES2Driver::addDynamicLight(const SLight& light)
{
CNullDriver::addDynamicLight(light);
RequestedLights.push_back(RequestedLight(light));
u32 newLightIndex = RequestedLights.size() - 1;
return (s32)newLightIndex;
}
//! Turns a dynamic light on or off
//! \param lightIndex: the index returned by addDynamicLight
//! \param turnOn: true to turn the light on, false to turn it off
void COGLES2Driver::turnLightOn(s32 lightIndex, bool turnOn)
{
if (lightIndex < 0 || lightIndex >= (s32)RequestedLights.size())
return;
RequestedLight & requestedLight = RequestedLights[lightIndex];
requestedLight.DesireToBeOn = turnOn;
}
//! returns the maximal amount of dynamic lights the device can handle
u32 COGLES2Driver::getMaximalDynamicLightAmount() const
{
return 8;
}
void COGLES2Driver::setViewPort(const core::rect<s32>& area)
{
core::rect<s32> vp = area;

View File

@ -19,14 +19,6 @@
#include "COGLES2ExtensionHandler.h"
#include "IContextManager.h"
#if defined(_IRR_WINDOWS_API_)
// include windows headers for HWND
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#include <windows.h>
#endif
namespace irr
{
namespace video
@ -158,20 +150,6 @@ namespace video
//! Returns the name of the video driver.
virtual const wchar_t* getName() const _IRR_OVERRIDE_;
//! deletes all dynamic lights there are
virtual void deleteAllDynamicLights() _IRR_OVERRIDE_;
//! adds a dynamic light
virtual s32 addDynamicLight(const SLight& light) _IRR_OVERRIDE_;
//! Turns a dynamic light on or off
/** \param lightIndex: the index returned by addDynamicLight
\param turnOn: true to turn the light on, false to turn it off */
virtual void turnLightOn(s32 lightIndex, bool turnOn) _IRR_OVERRIDE_;
//! returns the maximal amount of dynamic lights the device can handle
virtual u32 getMaximalDynamicLightAmount() const _IRR_OVERRIDE_;
//! Returns the maximum texture size supported.
virtual core::dimension2du getMaxTextureSize() const _IRR_OVERRIDE_;
@ -421,19 +399,6 @@ private:
//! Color buffer format
ECOLOR_FORMAT ColorFormat;
//! All the lights that have been requested; a hardware limited
//! number of them will be used at once.
struct RequestedLight
{
RequestedLight(SLight const & lightData)
: LightData(lightData), DesireToBeOn(true) { }
SLight LightData;
bool DesireToBeOn;
};
core::array<RequestedLight> RequestedLights;
IContextManager* ContextManager;
};

View File

@ -7,7 +7,6 @@
#ifdef _IRR_COMPILE_WITH_OGLES2_
#include "IVideoDriver.h"
#include "SLight.h"
namespace irr
{
@ -17,21 +16,11 @@ namespace video
// Base callback
COGLES2MaterialBaseCB::COGLES2MaterialBaseCB() :
FirstUpdateBase(true), WVPMatrixID(-1), WVMatrixID(-1), NMatrixID(-1), GlobalAmbientID(-1), MaterialAmbientID(-1), MaterialDiffuseID(-1), MaterialEmissiveID(-1), MaterialSpecularID(-1), MaterialShininessID(-1), LightCountID(-1), LightTypeID(-1),
LightPositionID(-1), LightDirectionID(-1), LightAttenuationID(-1), LightAmbientID(-1), LightDiffuseID(-1), LightSpecularID(-1), FogEnableID(-1), FogTypeID(-1), FogColorID(-1), FogStartID(-1),
FirstUpdateBase(true), WVPMatrixID(-1), WVMatrixID(-1), NMatrixID(-1), GlobalAmbientID(-1), MaterialAmbientID(-1), MaterialDiffuseID(-1), MaterialEmissiveID(-1), MaterialSpecularID(-1), MaterialShininessID(-1),
FogEnableID(-1), FogTypeID(-1), FogColorID(-1), FogStartID(-1),
FogEndID(-1), FogDensityID(-1), ThicknessID(-1), LightEnable(false), MaterialAmbient(SColorf(0.f, 0.f, 0.f)), MaterialDiffuse(SColorf(0.f, 0.f, 0.f)), MaterialEmissive(SColorf(0.f, 0.f, 0.f)), MaterialSpecular(SColorf(0.f, 0.f, 0.f)),
MaterialShininess(0.f), FogEnable(0), FogType(1), FogColor(SColorf(0.f, 0.f, 0.f, 1.f)), FogStart(0.f), FogEnd(0.f), FogDensity(0.f), Thickness(1.f)
{
for (u32 i = 0; i < 8; ++i)
{
LightType[i] = 0;
LightPosition[i] = core::vector3df(0.f, 0.f, 0.f);
LightDirection[i] = core::vector3df(0.f, 0.f, 0.f);
LightAttenuation[i] = core::vector3df(0.f, 0.f, 0.f);
LightAmbient[i] = SColorf(0.f, 0.f, 0.f);
LightDiffuse[i] = SColorf(0.f, 0.f, 0.f);
LightSpecular[i] = SColorf(0.f, 0.f, 0.f);
}
}
void COGLES2MaterialBaseCB::OnSetMaterial(const SMaterial& material)
@ -63,14 +52,6 @@ void COGLES2MaterialBaseCB::OnSetConstants(IMaterialRendererServices* services,
MaterialEmissiveID = services->getVertexShaderConstantID("uMaterialEmissive");
MaterialSpecularID = services->getVertexShaderConstantID("uMaterialSpecular");
MaterialShininessID = services->getVertexShaderConstantID("uMaterialShininess");
LightCountID = services->getVertexShaderConstantID("uLightCount");
LightTypeID = services->getVertexShaderConstantID("uLightType");
LightPositionID = services->getVertexShaderConstantID("uLightPosition");
LightDirectionID = services->getVertexShaderConstantID("uLightDirection");
LightAttenuationID = services->getVertexShaderConstantID("uLightAttenuation");
LightAmbientID = services->getVertexShaderConstantID("uLightAmbient");
LightDiffuseID = services->getVertexShaderConstantID("uLightDiffuse");
LightSpecularID = services->getVertexShaderConstantID("uLightSpecular");
FogEnableID = services->getVertexShaderConstantID("uFogEnable");
FogTypeID = services->getVertexShaderConstantID("uFogType");
FogColorID = services->getVertexShaderConstantID("uFogColor");
@ -95,60 +76,6 @@ void COGLES2MaterialBaseCB::OnSetConstants(IMaterialRendererServices* services,
Matrix.makeInverse();
services->setPixelShaderConstant(NMatrixID, Matrix.getTransposed().pointer(), 16);
s32 LightCount = LightEnable ? driver->getDynamicLightCount() : 0;
services->setPixelShaderConstant(LightCountID, &LightCount, 1);
if (LightCount > 0)
{
video::SColorf globalAmbient(driver->getAmbientLight());
services->setVertexShaderConstant(GlobalAmbientID, reinterpret_cast<f32*>(&globalAmbient), 4);
// TODO: this are all vertex shader constants, why are they all set as pixel shader constants? (it currently works so I'm scared to change it...)
services->setPixelShaderConstant(MaterialAmbientID, reinterpret_cast<f32*>(&MaterialAmbient), 4);
services->setPixelShaderConstant(MaterialDiffuseID, reinterpret_cast<f32*>(&MaterialDiffuse), 4);
services->setPixelShaderConstant(MaterialEmissiveID, reinterpret_cast<f32*>(&MaterialEmissive), 4);
services->setPixelShaderConstant(MaterialSpecularID, reinterpret_cast<f32*>(&MaterialSpecular), 4);
services->setPixelShaderConstant(MaterialShininessID, &MaterialShininess, 1);
Matrix = V;
for (s32 i = 0; i < LightCount; ++i)
{
SLight CurrentLight = driver->getDynamicLight(i);
Matrix.transformVect(CurrentLight.Position);
switch (CurrentLight.Type)
{
case ELT_DIRECTIONAL:
LightType[i] = 2;
break;
case ELT_SPOT:
LightType[i] = 1;
break;
default: // ELT_POINT
LightType[i] = 0;
break;
}
LightPosition[i] = CurrentLight.Position;
LightDirection[i] = CurrentLight.Direction;
LightAttenuation[i] = CurrentLight.Attenuation;
LightAmbient[i] = CurrentLight.AmbientColor;
LightDiffuse[i] = CurrentLight.DiffuseColor;
LightSpecular[i] = CurrentLight.SpecularColor;
}
const int MAX_SHADER_LIGHTS = 8; // must be the same as MAX_LIGHTS define in the shader
services->setPixelShaderConstant(LightTypeID, LightType, MAX_SHADER_LIGHTS);
services->setPixelShaderConstant(LightPositionID, reinterpret_cast<f32*>(LightPosition), 3*MAX_SHADER_LIGHTS);
services->setPixelShaderConstant(LightDirectionID, reinterpret_cast<f32*>(LightDirection), 3*MAX_SHADER_LIGHTS);
services->setPixelShaderConstant(LightAttenuationID, reinterpret_cast<f32*>(LightAttenuation), 3*MAX_SHADER_LIGHTS);
services->setPixelShaderConstant(LightAmbientID, reinterpret_cast<f32*>(LightAmbient), 4*MAX_SHADER_LIGHTS);
services->setPixelShaderConstant(LightDiffuseID, reinterpret_cast<f32*>(LightDiffuse), 4*MAX_SHADER_LIGHTS);
services->setPixelShaderConstant(LightSpecularID, reinterpret_cast<f32*>(LightSpecular), 4*MAX_SHADER_LIGHTS);
}
services->setPixelShaderConstant(FogEnableID, &FogEnable, 1);
if (FogEnable)

View File

@ -39,15 +39,6 @@ protected:
s32 MaterialSpecularID;
s32 MaterialShininessID;
s32 LightCountID;
s32 LightTypeID;
s32 LightPositionID;
s32 LightDirectionID;
s32 LightAttenuationID;
s32 LightAmbientID;
s32 LightDiffuseID;
s32 LightSpecularID;
s32 FogEnableID;
s32 FogTypeID;
s32 FogColorID;
@ -65,14 +56,6 @@ protected:
SColorf MaterialSpecular;
f32 MaterialShininess;
s32 LightType[8];
core::vector3df LightPosition[8];
core::vector3df LightDirection[8];
core::vector3df LightAttenuation[8];
SColorf LightAmbient[8];
SColorf LightDiffuse[8];
SColorf LightSpecular[8];
s32 FogEnable;
s32 FogType;
SColorf FogColor;

View File

@ -56,8 +56,6 @@ COGLES1Driver::COGLES1Driver(const SIrrlichtCreationParameters& params, io::IFil
COGLES1Driver::~COGLES1Driver()
{
RequestedLights.clear();
deleteMaterialRenders();
CacheHandler->getTextureCache().clear();
@ -2122,177 +2120,6 @@ const wchar_t* COGLES1Driver::getName() const
}
//! deletes all dynamic lights there are
void COGLES1Driver::deleteAllDynamicLights()
{
for (s32 i=0; i<MaxLights; ++i)
glDisable(GL_LIGHT0 + i);
RequestedLights.clear();
CNullDriver::deleteAllDynamicLights();
}
//! adds a dynamic light
s32 COGLES1Driver::addDynamicLight(const SLight& light)
{
CNullDriver::addDynamicLight(light);
RequestedLights.push_back(RequestedLight(light));
u32 newLightIndex = RequestedLights.size() - 1;
// Try and assign a hardware light just now, but don't worry if I can't
assignHardwareLight(newLightIndex);
return (s32)newLightIndex;
}
void COGLES1Driver::assignHardwareLight(u32 lightIndex)
{
setTransform(ETS_WORLD, core::matrix4());
s32 lidx;
for (lidx=GL_LIGHT0; lidx < GL_LIGHT0 + MaxLights; ++lidx)
{
if(!glIsEnabled(lidx))
{
RequestedLights[lightIndex].HardwareLightIndex = lidx;
break;
}
}
if(lidx == GL_LIGHT0 + MaxLights) // There's no room for it just now
return;
GLfloat data[4];
const SLight & light = RequestedLights[lightIndex].LightData;
switch (light.Type)
{
case video::ELT_SPOT:
data[0] = light.Direction.X;
data[1] = light.Direction.Y;
data[2] = light.Direction.Z;
data[3] = 0.0f;
glLightfv(lidx, GL_SPOT_DIRECTION, data);
// set position
data[0] = light.Position.X;
data[1] = light.Position.Y;
data[2] = light.Position.Z;
data[3] = 1.0f; // 1.0f for positional light
glLightfv(lidx, GL_POSITION, data);
glLightf(lidx, GL_SPOT_EXPONENT, light.Falloff);
glLightf(lidx, GL_SPOT_CUTOFF, light.OuterCone);
break;
case video::ELT_POINT:
// set position
data[0] = light.Position.X;
data[1] = light.Position.Y;
data[2] = light.Position.Z;
data[3] = 1.0f; // 1.0f for positional light
glLightfv(lidx, GL_POSITION, data);
glLightf(lidx, GL_SPOT_EXPONENT, 0.0f);
glLightf(lidx, GL_SPOT_CUTOFF, 180.0f);
break;
case video::ELT_DIRECTIONAL:
// set direction
data[0] = -light.Direction.X;
data[1] = -light.Direction.Y;
data[2] = -light.Direction.Z;
data[3] = 0.0f; // 0.0f for directional light
glLightfv(lidx, GL_POSITION, data);
glLightf(lidx, GL_SPOT_EXPONENT, 0.0f);
glLightf(lidx, GL_SPOT_CUTOFF, 180.0f);
break;
case video::ELT_COUNT:
return;
}
// set diffuse color
data[0] = light.DiffuseColor.r;
data[1] = light.DiffuseColor.g;
data[2] = light.DiffuseColor.b;
data[3] = light.DiffuseColor.a;
glLightfv(lidx, GL_DIFFUSE, data);
// set specular color
data[0] = light.SpecularColor.r;
data[1] = light.SpecularColor.g;
data[2] = light.SpecularColor.b;
data[3] = light.SpecularColor.a;
glLightfv(lidx, GL_SPECULAR, data);
// set ambient color
data[0] = light.AmbientColor.r;
data[1] = light.AmbientColor.g;
data[2] = light.AmbientColor.b;
data[3] = light.AmbientColor.a;
glLightfv(lidx, GL_AMBIENT, data);
// 1.0f / (constant + linear * d + quadratic*(d*d);
// set attenuation
glLightf(lidx, GL_CONSTANT_ATTENUATION, light.Attenuation.X);
glLightf(lidx, GL_LINEAR_ATTENUATION, light.Attenuation.Y);
glLightf(lidx, GL_QUADRATIC_ATTENUATION, light.Attenuation.Z);
glEnable(lidx);
}
//! Turns a dynamic light on or off
//! \param lightIndex: the index returned by addDynamicLight
//! \param turnOn: true to turn the light on, false to turn it off
void COGLES1Driver::turnLightOn(s32 lightIndex, bool turnOn)
{
if(lightIndex < 0 || lightIndex >= (s32)RequestedLights.size())
return;
RequestedLight & requestedLight = RequestedLights[lightIndex];
requestedLight.DesireToBeOn = turnOn;
if(turnOn)
{
if(-1 == requestedLight.HardwareLightIndex)
assignHardwareLight(lightIndex);
}
else
{
if(-1 != requestedLight.HardwareLightIndex)
{
// It's currently assigned, so free up the hardware light
glDisable(requestedLight.HardwareLightIndex);
requestedLight.HardwareLightIndex = -1;
// Now let the first light that's waiting on a free hardware light grab it
for(u32 requested = 0; requested < RequestedLights.size(); ++requested)
if(RequestedLights[requested].DesireToBeOn
&&
-1 == RequestedLights[requested].HardwareLightIndex)
{
assignHardwareLight(requested);
break;
}
}
}
}
//! returns the maximal amount of dynamic lights the device can handle
u32 COGLES1Driver::getMaximalDynamicLightAmount() const
{
return MaxLights;
}
//! Sets the dynamic ambient light color.
void COGLES1Driver::setAmbientLight(const SColorf& color)
{

View File

@ -18,14 +18,6 @@
#include "COGLESExtensionHandler.h"
#include "IContextManager.h"
#if defined(_IRR_WINDOWS_API_)
// include windows headers for HWND
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#include <windows.h>
#endif
namespace irr
{
namespace video
@ -149,20 +141,6 @@ namespace video
//! Returns the name of the video driver.
virtual const wchar_t* getName() const _IRR_OVERRIDE_;
//! deletes all dynamic lights there are
virtual void deleteAllDynamicLights() _IRR_OVERRIDE_;
//! adds a dynamic light
virtual s32 addDynamicLight(const SLight& light) _IRR_OVERRIDE_;
//! Turns a dynamic light on or off
//! \param lightIndex: the index returned by addDynamicLight
//! \param turnOn: true to turn the light on, false to turn it off
virtual void turnLightOn(s32 lightIndex, bool turnOn) _IRR_OVERRIDE_;
//! returns the maximal amount of dynamic lights the device can handle
virtual u32 getMaximalDynamicLightAmount() const _IRR_OVERRIDE_;
//! Sets the dynamic ambient light color.
virtual void setAmbientLight(const SColorf& color) _IRR_OVERRIDE_;
@ -374,19 +352,6 @@ namespace video
SIrrlichtCreationParameters Params;
//! All the lights that have been requested; a hardware limited
//! number of them will be used at once.
struct RequestedLight
{
RequestedLight(SLight const & lightData)
: LightData(lightData), HardwareLightIndex(-1), DesireToBeOn(true) { }
SLight LightData;
s32 HardwareLightIndex; // GL_LIGHT0 - GL_LIGHT7
bool DesireToBeOn;
};
core::array<RequestedLight> RequestedLights;
IContextManager* ContextManager;
};

View File

@ -59,8 +59,6 @@ bool COpenGLDriver::initDriver()
//! destructor
COpenGLDriver::~COpenGLDriver()
{
RequestedLights.clear();
deleteMaterialRenders();
CacheHandler->getTextureCache().clear();
@ -2984,177 +2982,6 @@ const wchar_t* COpenGLDriver::getName() const
}
//! deletes all dynamic lights there are
void COpenGLDriver::deleteAllDynamicLights()
{
for (s32 i=0; i<MaxLights; ++i)
glDisable(GL_LIGHT0 + i);
RequestedLights.clear();
CNullDriver::deleteAllDynamicLights();
}
//! adds a dynamic light
s32 COpenGLDriver::addDynamicLight(const SLight& light)
{
CNullDriver::addDynamicLight(light);
RequestedLights.push_back(RequestedLight(light));
u32 newLightIndex = RequestedLights.size() - 1;
// Try and assign a hardware light just now, but don't worry if I can't
assignHardwareLight(newLightIndex);
return (s32)newLightIndex;
}
void COpenGLDriver::assignHardwareLight(u32 lightIndex)
{
setTransform(ETS_WORLD, core::matrix4());
s32 lidx;
for (lidx=GL_LIGHT0; lidx < GL_LIGHT0 + MaxLights; ++lidx)
{
if(!glIsEnabled(lidx))
{
RequestedLights[lightIndex].HardwareLightIndex = lidx;
break;
}
}
if(lidx == GL_LIGHT0 + MaxLights) // There's no room for it just now
return;
GLfloat data[4];
const SLight & light = RequestedLights[lightIndex].LightData;
switch (light.Type)
{
case video::ELT_SPOT:
data[0] = light.Direction.X;
data[1] = light.Direction.Y;
data[2] = light.Direction.Z;
data[3] = 0.0f;
glLightfv(lidx, GL_SPOT_DIRECTION, data);
// set position
data[0] = light.Position.X;
data[1] = light.Position.Y;
data[2] = light.Position.Z;
data[3] = 1.0f; // 1.0f for positional light
glLightfv(lidx, GL_POSITION, data);
glLightf(lidx, GL_SPOT_EXPONENT, light.Falloff);
glLightf(lidx, GL_SPOT_CUTOFF, light.OuterCone);
break;
case video::ELT_POINT:
// set position
data[0] = light.Position.X;
data[1] = light.Position.Y;
data[2] = light.Position.Z;
data[3] = 1.0f; // 1.0f for positional light
glLightfv(lidx, GL_POSITION, data);
glLightf(lidx, GL_SPOT_EXPONENT, 0.0f);
glLightf(lidx, GL_SPOT_CUTOFF, 180.0f);
break;
case video::ELT_DIRECTIONAL:
// set direction
data[0] = -light.Direction.X;
data[1] = -light.Direction.Y;
data[2] = -light.Direction.Z;
data[3] = 0.0f; // 0.0f for directional light
glLightfv(lidx, GL_POSITION, data);
glLightf(lidx, GL_SPOT_EXPONENT, 0.0f);
glLightf(lidx, GL_SPOT_CUTOFF, 180.0f);
break;
default:
break;
}
// set diffuse color
data[0] = light.DiffuseColor.r;
data[1] = light.DiffuseColor.g;
data[2] = light.DiffuseColor.b;
data[3] = light.DiffuseColor.a;
glLightfv(lidx, GL_DIFFUSE, data);
// set specular color
data[0] = light.SpecularColor.r;
data[1] = light.SpecularColor.g;
data[2] = light.SpecularColor.b;
data[3] = light.SpecularColor.a;
glLightfv(lidx, GL_SPECULAR, data);
// set ambient color
data[0] = light.AmbientColor.r;
data[1] = light.AmbientColor.g;
data[2] = light.AmbientColor.b;
data[3] = light.AmbientColor.a;
glLightfv(lidx, GL_AMBIENT, data);
// 1.0f / (constant + linear * d + quadratic*(d*d);
// set attenuation
glLightf(lidx, GL_CONSTANT_ATTENUATION, light.Attenuation.X);
glLightf(lidx, GL_LINEAR_ATTENUATION, light.Attenuation.Y);
glLightf(lidx, GL_QUADRATIC_ATTENUATION, light.Attenuation.Z);
glEnable(lidx);
}
//! Turns a dynamic light on or off
//! \param lightIndex: the index returned by addDynamicLight
//! \param turnOn: true to turn the light on, false to turn it off
void COpenGLDriver::turnLightOn(s32 lightIndex, bool turnOn)
{
if(lightIndex < 0 || lightIndex >= (s32)RequestedLights.size())
return;
RequestedLight & requestedLight = RequestedLights[lightIndex];
requestedLight.DesireToBeOn = turnOn;
if(turnOn)
{
if(-1 == requestedLight.HardwareLightIndex)
assignHardwareLight(lightIndex);
}
else
{
if(-1 != requestedLight.HardwareLightIndex)
{
// It's currently assigned, so free up the hardware light
glDisable(requestedLight.HardwareLightIndex);
requestedLight.HardwareLightIndex = -1;
// Now let the first light that's waiting on a free hardware light grab it
for(u32 requested = 0; requested < RequestedLights.size(); ++requested)
if(RequestedLights[requested].DesireToBeOn
&&
-1 == RequestedLights[requested].HardwareLightIndex)
{
assignHardwareLight(requested);
break;
}
}
}
}
//! returns the maximal amount of dynamic lights the device can handle
u32 COpenGLDriver::getMaximalDynamicLightAmount() const
{
return MaxLights;
}
//! Sets the dynamic ambient light color. The default color is
//! (0,0,0,0) which means it is dark.
//! \param color: New color of the ambient light.

View File

@ -210,22 +210,6 @@ namespace video
//! driver, it would return "Direct3D8.1".
virtual const wchar_t* getName() const _IRR_OVERRIDE_;
//! deletes all dynamic lights there are
virtual void deleteAllDynamicLights() _IRR_OVERRIDE_;
//! adds a dynamic light, returning an index to the light
//! \param light: the light data to use to create the light
//! \return An index to the light, or -1 if an error occurs
virtual s32 addDynamicLight(const SLight& light) _IRR_OVERRIDE_;
//! Turns a dynamic light on or off
//! \param lightIndex: the index returned by addDynamicLight
//! \param turnOn: true to turn the light on, false to turn it off
virtual void turnLightOn(s32 lightIndex, bool turnOn) _IRR_OVERRIDE_;
//! returns the maximal amount of dynamic lights the device can handle
virtual u32 getMaximalDynamicLightAmount() const _IRR_OVERRIDE_;
//! Sets the dynamic ambient light color. The default color is
//! (0,0,0,0) which means it is dark.
//! \param color: New color of the ambient light.
@ -497,19 +481,6 @@ namespace video
SIrrlichtCreationParameters Params;
//! All the lights that have been requested; a hardware limited
//! number of them will be used at once.
struct RequestedLight
{
RequestedLight(SLight const & lightData)
: LightData(lightData), HardwareLightIndex(-1), DesireToBeOn(true) { }
SLight LightData;
s32 HardwareLightIndex; // GL_LIGHT0 - GL_LIGHT7
bool DesireToBeOn;
};
core::array<RequestedLight> RequestedLights;
//! Built-in 2D quad for 2D rendering.
S3DVertex Quad2DVertices[4];
static const u16 Quad2DIndices[4];

View File

@ -44,8 +44,6 @@
#include "CDummyTransformationSceneNode.h"
#include "CEmptySceneNode.h"
#include "CDefaultSceneNodeFactory.h"
#include "CSceneCollisionManager.h"
namespace irr
@ -110,11 +108,6 @@ CSceneManager::CSceneManager(video::IVideoDriver* driver, io::IFileSystem* fs,
MeshLoaderList.push_back(new CB3DMeshFileLoader(this));
#endif
// factories
ISceneNodeFactory* factory = new CDefaultSceneNodeFactory(this);
registerSceneNodeFactory(factory);
factory->drop();
IRR_PROFILE(
static bool initProfile = false;
if (!initProfile )
@ -173,9 +166,6 @@ CSceneManager::~CSceneManager()
if (Parameters)
Parameters->drop();
for (i=0; i<SceneNodeFactoryList.size(); ++i)
SceneNodeFactoryList[i]->drop();
// remove all nodes before dropping the driver
// as render targets may be destroyed twice
@ -998,62 +988,6 @@ ISceneManager* CSceneManager::createNewSceneManager(bool cloneContent)
}
//! Returns the default scene node factory which can create all built in scene nodes
ISceneNodeFactory* CSceneManager::getDefaultSceneNodeFactory()
{
return getSceneNodeFactory(0);
}
//! Adds a scene node factory to the scene manager.
void CSceneManager::registerSceneNodeFactory(ISceneNodeFactory* factoryToAdd)
{
if (factoryToAdd)
{
factoryToAdd->grab();
SceneNodeFactoryList.push_back(factoryToAdd);
}
}
//! Returns amount of registered scene node factories.
u32 CSceneManager::getRegisteredSceneNodeFactoryCount() const
{
return SceneNodeFactoryList.size();
}
//! Returns a scene node factory by index
ISceneNodeFactory* CSceneManager::getSceneNodeFactory(u32 index)
{
if (index < SceneNodeFactoryList.size())
return SceneNodeFactoryList[index];
return 0;
}
//! Returns a typename from a scene node type or null if not found
const c8* CSceneManager::getSceneNodeTypeName(ESCENE_NODE_TYPE type)
{
const char* name = 0;
for (s32 i=(s32)SceneNodeFactoryList.size()-1; !name && i>=0; --i)
name = SceneNodeFactoryList[i]->getCreateableSceneNodeTypeName(type);
return name;
}
//! Adds a scene node to the scene by name
ISceneNode* CSceneManager::addSceneNode(const char* sceneNodeTypeName, ISceneNode* parent)
{
ISceneNode* node = 0;
for (s32 i=(s32)SceneNodeFactoryList.size()-1; i>=0 && !node; --i)
node = SceneNodeFactoryList[i]->addSceneNode(sceneNodeTypeName, parent);
return node;
}
//! Sets ambient color of the scene
void CSceneManager::setAmbientLight(const video::SColorf &ambientColor)
{

View File

@ -180,26 +180,6 @@ namespace scene
//! Returns type of the scene node
virtual ESCENE_NODE_TYPE getType() const _IRR_OVERRIDE_ { return ESNT_SCENE_MANAGER; }
//! Returns the default scene node factory which can create all built in scene nodes
virtual ISceneNodeFactory* getDefaultSceneNodeFactory() _IRR_OVERRIDE_;
//! Adds a scene node factory to the scene manager.
/** Use this to extend the scene manager with new scene node types which it should be
able to create automatically, for example when loading data from xml files. */
virtual void registerSceneNodeFactory(ISceneNodeFactory* factoryToAdd) _IRR_OVERRIDE_;
//! Returns amount of registered scene node factories.
virtual u32 getRegisteredSceneNodeFactoryCount() const _IRR_OVERRIDE_;
//! Returns a scene node factory by index
virtual ISceneNodeFactory* getSceneNodeFactory(u32 index) _IRR_OVERRIDE_;
//! Returns a typename from a scene node type or null if not found
virtual const c8* getSceneNodeTypeName(ESCENE_NODE_TYPE type) _IRR_OVERRIDE_;
//! Adds a scene node to the scene by name
virtual ISceneNode* addSceneNode(const char* sceneNodeTypeName, ISceneNode* parent=0) _IRR_OVERRIDE_;
//! Returns a mesh writer implementation if available
virtual IMeshWriter* createMeshWriter(EMESH_WRITER_TYPE type) _IRR_OVERRIDE_;
@ -324,7 +304,6 @@ namespace scene
core::array<IMeshLoader*> MeshLoaderList;
core::array<ISceneNode*> DeletionList;
core::array<ISceneNodeFactory*> SceneNodeFactoryList;
//! current active camera
ICameraSceneNode* ActiveCamera;

View File

@ -1,132 +0,0 @@
// Copyright (C) 2002-2012 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#include "CVideoModeList.h"
#include "irrMath.h"
namespace irr
{
namespace video
{
//! constructor
CVideoModeList::CVideoModeList()
{
#ifdef _DEBUG
setDebugName("CVideoModeList");
#endif
Desktop.depth = 0;
Desktop.size = core::dimension2d<u32>(0,0);
}
void CVideoModeList::setDesktop(s32 desktopDepth, const core::dimension2d<u32>& desktopSize)
{
Desktop.depth = desktopDepth;
Desktop.size = desktopSize;
}
//! Gets amount of video modes in the list.
s32 CVideoModeList::getVideoModeCount() const
{
return (s32)VideoModes.size();
}
//! Returns the screen size of a video mode in pixels.
core::dimension2d<u32> CVideoModeList::getVideoModeResolution(s32 modeNumber) const
{
if (modeNumber < 0 || modeNumber > (s32)VideoModes.size())
return core::dimension2d<u32>(0,0);
return VideoModes[modeNumber].size;
}
core::dimension2d<u32> CVideoModeList::getVideoModeResolution(
const core::dimension2d<u32>& minSize,
const core::dimension2d<u32>& maxSize) const
{
u32 best=VideoModes.size();
// if only one or no mode
if (best<2)
return getVideoModeResolution(0);
u32 i;
for (i=0; i<VideoModes.size(); ++i)
{
if (VideoModes[i].size.Width>=minSize.Width &&
VideoModes[i].size.Height>=minSize.Height &&
VideoModes[i].size.Width<=maxSize.Width &&
VideoModes[i].size.Height<=maxSize.Height)
best=i;
}
// we take the last one found, the largest one fitting
if (best<VideoModes.size())
return VideoModes[best].size;
const u32 minArea = minSize.getArea();
const u32 maxArea = maxSize.getArea();
u32 minDist = 0xffffffff;
best=0;
for (i=0; i<VideoModes.size(); ++i)
{
const u32 area = VideoModes[i].size.getArea();
const u32 dist = core::min_(abs(int(minArea-area)), abs(int(maxArea-area)));
if (dist<minDist)
{
minDist=dist;
best=i;
}
}
return VideoModes[best].size;
}
//! Returns the pixel depth of a video mode in bits.
s32 CVideoModeList::getVideoModeDepth(s32 modeNumber) const
{
if (modeNumber < 0 || modeNumber > (s32)VideoModes.size())
return 0;
return VideoModes[modeNumber].depth;
}
//! Returns current desktop screen resolution.
const core::dimension2d<u32>& CVideoModeList::getDesktopResolution() const
{
return Desktop.size;
}
//! Returns the pixel depth of a video mode in bits.
s32 CVideoModeList::getDesktopDepth() const
{
return Desktop.depth;
}
//! adds a new mode to the list
void CVideoModeList::addMode(const core::dimension2d<u32>& size, s32 depth)
{
SVideoMode m;
m.depth = depth;
m.size = size;
for (u32 i=0; i<VideoModes.size(); ++i)
{
if (VideoModes[i] == m)
return;
}
VideoModes.push_back(m);
VideoModes.sort(); // TODO: could be replaced by inserting into right place
}
} // end namespace video
} // end namespace irr

View File

@ -1,79 +0,0 @@
// Copyright (C) 2002-2012 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __IRR_C_VIDEO_MODE_LIST_H_INCLUDED__
#define __IRR_C_VIDEO_MODE_LIST_H_INCLUDED__
#include "IVideoModeList.h"
#include "dimension2d.h"
#include "irrArray.h"
namespace irr
{
namespace video
{
class CVideoModeList : public IVideoModeList
{
public:
//! constructor
CVideoModeList();
//! Gets amount of video modes in the list.
virtual s32 getVideoModeCount() const _IRR_OVERRIDE_;
//! Returns the screen size of a video mode in pixels.
virtual core::dimension2d<u32> getVideoModeResolution(s32 modeNumber) const _IRR_OVERRIDE_;
//! Returns the screen size of an optimal video mode in pixels.
virtual core::dimension2d<u32> getVideoModeResolution(const core::dimension2d<u32>& minSize, const core::dimension2d<u32>& maxSize) const _IRR_OVERRIDE_;
//! Returns the pixel depth of a video mode in bits.
virtual s32 getVideoModeDepth(s32 modeNumber) const _IRR_OVERRIDE_;
//! Returns current desktop screen resolution.
virtual const core::dimension2d<u32>& getDesktopResolution() const _IRR_OVERRIDE_;
//! Returns the pixel depth of a video mode in bits.
virtual s32 getDesktopDepth() const _IRR_OVERRIDE_;
//! adds a new mode to the list
void addMode(const core::dimension2d<u32>& size, s32 depth);
void setDesktop(s32 desktopDepth, const core::dimension2d<u32>& desktopSize);
private:
struct SVideoMode
{
core::dimension2d<u32> size;
s32 depth;
bool operator==(const SVideoMode& other) const
{
return size == other.size && depth == other.depth;
}
bool operator <(const SVideoMode& other) const
{
return (size.Width < other.size.Width ||
(size.Width == other.size.Width &&
size.Height < other.size.Height) ||
(size.Width == other.size.Width &&
size.Height == other.size.Height &&
depth < other.depth));
}
};
core::array<SVideoMode> VideoModes;
SVideoMode Desktop;
};
} // end namespace video
} // end namespace irr
#endif

View File

@ -1,109 +0,0 @@
// Copyright (C) 2002-2012 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#include "IrrCompileConfig.h"
#include "CZBuffer.h"
#include "irrString.h"
#ifdef _IRR_COMPILE_WITH_SOFTWARE_
namespace irr
{
namespace video
{
//! constructor
CZBuffer::CZBuffer(const core::dimension2d<u32>& size)
: Buffer(0), BufferEnd(0), Size(0,0), TotalSize(0)
{
#ifdef _DEBUG
setDebugName("CZBuffer");
#endif
setSize(size);
}
//! destructor
CZBuffer::~CZBuffer()
{
delete [] Buffer;
}
//! clears the zbuffer
void CZBuffer::clear()
{
memset(Buffer, 0, (BufferEnd-Buffer)*sizeof(TZBufferType));
}
//! sets the new size of the zbuffer
void CZBuffer::setSize(const core::dimension2d<u32>& size)
{
if (size == Size)
return;
Size = size;
delete [] Buffer;
TotalSize = size.Width * size.Height;
Buffer = new TZBufferType[TotalSize];
BufferEnd = Buffer + TotalSize;
}
//! returns the size of the zbuffer
const core::dimension2d<u32>& CZBuffer::getSize() const
{
return Size;
}
//! locks the zbuffer
TZBufferType* CZBuffer::lock()
{
return Buffer;
}
//! unlocks the zbuffer
void CZBuffer::unlock()
{
}
} // end namespace video
} // end namespace irr
#endif // _IRR_COMPILE_WITH_SOFTWARE_
namespace irr
{
namespace video
{
//! creates a ZBuffer
IZBuffer* createZBuffer(const core::dimension2d<u32>& size)
{
#ifdef _IRR_COMPILE_WITH_SOFTWARE_
return new CZBuffer(size);
#else
return 0;
#endif // _IRR_COMPILE_WITH_SOFTWARE_
}
} // end namespace video
} // end namespace irr

View File

@ -1,52 +0,0 @@
// Copyright (C) 2002-2012 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __C_Z_BUFFER_H_INCLUDED__
#define __C_Z_BUFFER_H_INCLUDED__
#include "IZBuffer.h"
namespace irr
{
namespace video
{
class CZBuffer : public IZBuffer
{
public:
//! constructor
CZBuffer(const core::dimension2d<u32>& size);
//! destructor
virtual ~CZBuffer();
//! clears the zbuffer
virtual void clear() _IRR_OVERRIDE_;
//! sets the new size of the zbuffer
virtual void setSize(const core::dimension2d<u32>& size) _IRR_OVERRIDE_;
//! returns the size of the zbuffer
virtual const core::dimension2d<u32>& getSize() const _IRR_OVERRIDE_;
//! locks the zbuffer
virtual TZBufferType* lock() _IRR_OVERRIDE_;
//! unlocks the zbuffer
virtual void unlock() _IRR_OVERRIDE_;
private:
TZBufferType* Buffer;
TZBufferType* BufferEnd;
core::dimension2d<u32> Size;
s32 TotalSize;
};
} // end namespace video
} // end namespace irr
#endif

View File

@ -1,68 +0,0 @@
// Copyright (C) 2002-2012 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __I_TRIANGLE_RENDERER_H_INCLUDED__
#define __I_TRIANGLE_RENDERER_H_INCLUDED__
#include "IReferenceCounted.h"
#include "S2DVertex.h"
#include "rect.h"
#include "IZBuffer.h"
namespace irr
{
namespace video
{
class IImage;
enum ETriangleRenderer
{
ETR_FLAT = 0,
ETR_FLAT_WIRE,
ETR_GOURAUD,
ETR_GOURAUD_WIRE,
ETR_TEXTURE_FLAT,
ETR_TEXTURE_FLAT_WIRE,
ETR_TEXTURE_GOURAUD,
ETR_TEXTURE_GOURAUD_WIRE,
ETR_TEXTURE_GOURAUD_NOZ,
ETR_TEXTURE_GOURAUD_ADD,
ETR_COUNT
};
class ITriangleRenderer : public virtual IReferenceCounted
{
public:
//! sets a render target
virtual void setRenderTarget(video::IImage* surface, const core::rect<s32>& viewPort) = 0;
//! en or disables the backface culling
virtual void setBackfaceCulling(bool enabled = true) = 0;
//! sets the Texture
virtual void setTexture(video::IImage* texture) = 0;
//! draws an indexed triangle list
virtual void drawIndexedTriangleList(S2DVertex* vertices, s32 vertexCount, const u16* indexList, s32 triangleCount) = 0;
};
ITriangleRenderer* createTriangleRendererTextureGouraud(IZBuffer* zbuffer);
ITriangleRenderer* createTriangleRendererTextureGouraudWire(IZBuffer* zbuffer);
ITriangleRenderer* createTriangleRendererGouraud(IZBuffer* zbuffer);
ITriangleRenderer* createTriangleRendererGouraudWire(IZBuffer* zbuffer);
ITriangleRenderer* createTriangleRendererTextureFlat(IZBuffer* zbuffer);
ITriangleRenderer* createTriangleRendererTextureFlatWire(IZBuffer* zbuffer);
ITriangleRenderer* createTriangleRendererFlat(IZBuffer* zbuffer);
ITriangleRenderer* createTriangleRendererFlatWire(IZBuffer* zbuffer);
ITriangleRenderer* createTriangleRendererTextureGouraudNoZ();
ITriangleRenderer* createTriangleRendererTextureGouraudAdd(IZBuffer* zbuffer);
} // end namespace video
} // end namespace irr
#endif

View File

@ -1,47 +0,0 @@
// Copyright (C) 2002-2012 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __I_Z_BUFFER_H_INCLUDED__
#define __I_Z_BUFFER_H_INCLUDED__
#include "IReferenceCounted.h"
#include "dimension2d.h"
#include "S2DVertex.h"
namespace irr
{
namespace video
{
class IZBuffer : public virtual IReferenceCounted
{
public:
//! destructor
virtual ~IZBuffer() {};
//! clears the zbuffer
virtual void clear() = 0;
//! sets the new size of the zbuffer
virtual void setSize(const core::dimension2d<u32>& size) = 0;
//! returns the size of the zbuffer
virtual const core::dimension2d<u32>& getSize() const = 0;
//! locks the zbuffer
virtual TZBufferType* lock() = 0;
//! unlocks the zbuffer
virtual void unlock() = 0;
};
//! creates a ZBuffer
IZBuffer* createZBuffer(const core::dimension2d<u32>& size);
} // end namespace video
} // end namespace irr
#endif

View File

@ -289,40 +289,6 @@ namespace os
Logger->log(message, hint.c_str(), ll);
}
// our Randomizer is not really os specific, so we
// code one for all, which should work on every platform the same,
// which is desirable.
s32 Randomizer::seed = 0x0f0f0f0f;
//! generates a pseudo random number
s32 Randomizer::rand()
{
// (a*seed)%m with Schrage's method
seed = a * (seed%q) - r* (seed/q);
if (seed<1)
seed += m;
return seed-1; // -1 because we want it to start at 0
}
s32 Randomizer::randMax()
{
return rMax;
}
//! resets the randomizer
void Randomizer::reset(s32 value)
{
if (value<0)
seed = value+m;
else if ( value == 0 || value == m)
seed = 1;
else
seed = value;
}
// ------------------------------------------------------
// virtual timer implementation

View File

@ -44,37 +44,6 @@ namespace os
static ILogger* Logger;
};
// congruential pseudo-random generator
// numbers identical to std::minstd_rand0
// period is somewhere around m-1
class Randomizer
{
public:
//! resets the randomizer
static void reset(s32 value=0x0f0f0f0f);
//! generates a pseudo random number in the range 0..randMax()
static s32 rand();
//! get maximum number generated by rand()
static s32 randMax();
private:
static s32 seed;
static const s32 m = 2147483647; // a Mersenne prime (2^31-1)
static const s32 a = 16807; // another spectral success story
static const s32 q = m/a;
static const s32 r = m%a; // again less than q
static const s32 rMax = m-2;
};
class Timer
{
public:

View File

@ -1,14 +0,0 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by Irrlicht.rc
// N<>chste Standardwerte f<>r neue Objekte
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 101
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1001
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif