From 959831f4ef5a3e797f576c3de08cd65032c997ad Mon Sep 17 00:00:00 2001 From: David Walter Seikel Date: Sun, 13 Jan 2013 18:54:10 +1000 Subject: Remove damned ancient DOS line endings from Irrlicht. Hopefully I did not go overboard. --- .../irrlicht-1.8/tools/GUIEditor/CGUIAttribute.h | 338 ++-- .../tools/GUIEditor/CGUIAttributeEditor.cpp | 240 +-- .../tools/GUIEditor/CGUIAttributeEditor.h | 108 +- .../tools/GUIEditor/CGUIBoolAttribute.h | 136 +- .../tools/GUIEditor/CGUIColorAttribute.h | 358 ++-- .../tools/GUIEditor/CGUIDummyEditorStub.h | 118 +- .../tools/GUIEditor/CGUIEditFactory.cpp | 240 +-- .../irrlicht-1.8/tools/GUIEditor/CGUIEditFactory.h | 106 +- .../tools/GUIEditor/CGUIEditWindow.cpp | 712 ++++---- .../irrlicht-1.8/tools/GUIEditor/CGUIEditWindow.h | 176 +- .../tools/GUIEditor/CGUIEditWorkspace.cpp | 1854 ++++++++++---------- .../tools/GUIEditor/CGUIEditWorkspace.h | 336 ++-- .../tools/GUIEditor/CGUIEnumAttribute.h | 228 +-- .../irrlicht-1.8/tools/GUIEditor/CGUIPanel.cpp | 680 +++---- libraries/irrlicht-1.8/tools/GUIEditor/CGUIPanel.h | 256 +-- .../tools/GUIEditor/CGUIStringAttribute.h | 140 +- .../tools/GUIEditor/CGUITextureAttribute.h | 280 +-- .../tools/GUIEditor/CGUITextureCacheBrowser.cpp | 672 +++---- .../tools/GUIEditor/CGUITextureCacheBrowser.h | 176 +- .../tools/GUIEditor/CMemoryReadWriteFile.cpp | 190 +- .../tools/GUIEditor/CMemoryReadWriteFile.h | 146 +- .../irrlicht-1.8/tools/GUIEditor/EGUIEditTypes.h | 122 +- .../irrlicht-1.8/tools/GUIEditor/GUI Editor_v8.sln | 40 +- .../tools/GUIEditor/GUI Editor_v8.vcproj | 590 +++---- .../irrlicht-1.8/tools/GUIEditor/GUI Editor_v9.sln | 40 +- .../tools/GUIEditor/GUI Editor_v9.vcproj | 586 +++---- .../tools/GUIEditor/GUI Editor_vc10.vcxproj | 424 ++--- .../GUIEditor/GUI Editor_vc10.vcxproj.filters | 174 +- .../tools/GUIEditor/GUI Editor_vc11.vcxproj | 432 ++--- .../GUIEditor/GUI Editor_vc11.vcxproj.filters | 174 +- libraries/irrlicht-1.8/tools/GUIEditor/Makefile | 86 +- libraries/irrlicht-1.8/tools/GUIEditor/main.cpp | 152 +- 32 files changed, 5155 insertions(+), 5155 deletions(-) (limited to 'libraries/irrlicht-1.8/tools/GUIEditor') diff --git a/libraries/irrlicht-1.8/tools/GUIEditor/CGUIAttribute.h b/libraries/irrlicht-1.8/tools/GUIEditor/CGUIAttribute.h index 0585498..1f2b092 100644 --- a/libraries/irrlicht-1.8/tools/GUIEditor/CGUIAttribute.h +++ b/libraries/irrlicht-1.8/tools/GUIEditor/CGUIAttribute.h @@ -1,169 +1,169 @@ -/* - This base class is used by the Attribute editor for making your own attribute types. - - The attribute editor will try and create an attribute called "AttribType_attribute", - and if it fails, it will create a "string_attribute". - -*/ - -#ifndef __C_GUI_ATTRIBUTE_H_INCLUDED__ -#define __C_GUI_ATTRIBUTE_H_INCLUDED__ - -#include "IGUIElement.h" -#include "IGUIEnvironment.h" -#include "IGUIFont.h" -#include "IGUIStaticText.h" -#include "IAttributes.h" -#include "CGUIEditWorkspace.h" - -namespace irr -{ - -namespace gui -{ - - const u32 ATTRIBEDIT_ATTRIB_CHANGED=MAKE_IRR_ID('A','T','T','R'); - - class CGUIAttribute : public IGUIElement - { - public: - //! constructor - CGUIAttribute(IGUIEnvironment* environment, IGUIElement *parent, s32 myParentID) : - IGUIElement(EGUIET_ELEMENT, environment, parent, -1, core::rect(0, 0, 100, 100) ), - AttribName(0), Attribs(0), Index(0), MyParentID(myParentID) - { - - #ifdef _DEBUG - setDebugName("CGUIAttribute"); - #endif - - AttribName = environment->addStaticText(0, - core::rect(0, 0, - 100, Environment->getSkin()->getFont()->getDimension(L"A").Height), - false, false, this, -1, false); - AttribName->grab(); - AttribName->setSubElement(true); - AttribName->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT); - } - - virtual ~CGUIAttribute() - { - if (Attribs) - Attribs->drop(); - if (AttribName) - AttribName->drop(); - } - - virtual bool OnEvent(const SEvent &e) - { - if (IsEnabled) - { - switch (e.EventType) - { - case EET_GUI_EVENT: - switch (e.GUIEvent.EventType) - { - case EGET_ELEMENT_FOCUSED: - if (Parent && isMyChild(e.GUIEvent.Caller)) - Parent->bringToFront(this); - break; - case EGET_ELEMENT_HOVERED: - case EGET_ELEMENT_LEFT: - return IGUIElement::OnEvent(e); - case EGET_ELEMENT_FOCUS_LOST: - updateAttrib(); - return IGUIElement::OnEvent(e); - default: - return updateAttrib(); - } - break; - case EET_KEY_INPUT_EVENT: - return true; - default: - break; - } - } - - return IGUIElement::OnEvent(e); - } - - //! sets the attribute to use - virtual void setAttrib(io::IAttributes *attribs, u32 attribIndex) - { - if (Attribs) - Attribs->drop(); - Attribs = attribs; - if (Attribs) - Attribs->grab(); - Index = attribIndex; - - core::stringw name(attribs->getAttributeName(attribIndex)); - name += L" ("; - name += attribs->getAttributeTypeString(attribIndex); - name += L")"; - AttribName->setText(name.c_str()); - - core::rect r = Parent->getAbsolutePosition(); - core::rect r2(0, 5, - r.getWidth(), Environment->getSkin()->getFont()->getDimension(L"A").Height + 10 ); - - AttribName->setRelativePosition(r2); - - // get minimum height - s32 y=0; - core::list::Iterator it = Children.begin(); - for (; it != Children.end(); ++it) - { - if (y < (*it)->getRelativePosition().LowerRightCorner.Y) - y = (*it)->getRelativePosition().LowerRightCorner.Y; - } - setMinSize( core::dimension2du(0, y+5)); - - updateAttrib(false); - } - - //! sets the parent ID, for identifying where events came from - void setParentID(s32 parentID) - { - MyParentID = parentID; - } - - //! save the attribute and possibly post the event to its parent - virtual bool updateAttrib(bool sendEvent=true) - { - if (Attribs && IsEnabled && sendEvent) - { - // build event and pass to parent - SEvent event; - event.EventType = (EEVENT_TYPE)ATTRIBEDIT_ATTRIB_CHANGED; - event.UserEvent.UserData1 = MyParentID; - event.UserEvent.UserData2 = Index; - return Parent->OnEvent(event); - } - - return true; - } - - virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) - { - IGUIElement::serializeAttributes(out, options); - } - - virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0) - { - IGUIElement::deserializeAttributes(in, options); - if (AttribName) - AttribName->setText(Text.c_str()); - } - - protected: - IGUIStaticText* AttribName; - io::IAttributes* Attribs; - u32 Index; - s32 MyParentID; - }; - -} // namespace gui -} // namespace irr - -#endif +/* + This base class is used by the Attribute editor for making your own attribute types. + + The attribute editor will try and create an attribute called "AttribType_attribute", + and if it fails, it will create a "string_attribute". + +*/ + +#ifndef __C_GUI_ATTRIBUTE_H_INCLUDED__ +#define __C_GUI_ATTRIBUTE_H_INCLUDED__ + +#include "IGUIElement.h" +#include "IGUIEnvironment.h" +#include "IGUIFont.h" +#include "IGUIStaticText.h" +#include "IAttributes.h" +#include "CGUIEditWorkspace.h" + +namespace irr +{ + +namespace gui +{ + + const u32 ATTRIBEDIT_ATTRIB_CHANGED=MAKE_IRR_ID('A','T','T','R'); + + class CGUIAttribute : public IGUIElement + { + public: + //! constructor + CGUIAttribute(IGUIEnvironment* environment, IGUIElement *parent, s32 myParentID) : + IGUIElement(EGUIET_ELEMENT, environment, parent, -1, core::rect(0, 0, 100, 100) ), + AttribName(0), Attribs(0), Index(0), MyParentID(myParentID) + { + + #ifdef _DEBUG + setDebugName("CGUIAttribute"); + #endif + + AttribName = environment->addStaticText(0, + core::rect(0, 0, + 100, Environment->getSkin()->getFont()->getDimension(L"A").Height), + false, false, this, -1, false); + AttribName->grab(); + AttribName->setSubElement(true); + AttribName->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT); + } + + virtual ~CGUIAttribute() + { + if (Attribs) + Attribs->drop(); + if (AttribName) + AttribName->drop(); + } + + virtual bool OnEvent(const SEvent &e) + { + if (IsEnabled) + { + switch (e.EventType) + { + case EET_GUI_EVENT: + switch (e.GUIEvent.EventType) + { + case EGET_ELEMENT_FOCUSED: + if (Parent && isMyChild(e.GUIEvent.Caller)) + Parent->bringToFront(this); + break; + case EGET_ELEMENT_HOVERED: + case EGET_ELEMENT_LEFT: + return IGUIElement::OnEvent(e); + case EGET_ELEMENT_FOCUS_LOST: + updateAttrib(); + return IGUIElement::OnEvent(e); + default: + return updateAttrib(); + } + break; + case EET_KEY_INPUT_EVENT: + return true; + default: + break; + } + } + + return IGUIElement::OnEvent(e); + } + + //! sets the attribute to use + virtual void setAttrib(io::IAttributes *attribs, u32 attribIndex) + { + if (Attribs) + Attribs->drop(); + Attribs = attribs; + if (Attribs) + Attribs->grab(); + Index = attribIndex; + + core::stringw name(attribs->getAttributeName(attribIndex)); + name += L" ("; + name += attribs->getAttributeTypeString(attribIndex); + name += L")"; + AttribName->setText(name.c_str()); + + core::rect r = Parent->getAbsolutePosition(); + core::rect r2(0, 5, + r.getWidth(), Environment->getSkin()->getFont()->getDimension(L"A").Height + 10 ); + + AttribName->setRelativePosition(r2); + + // get minimum height + s32 y=0; + core::list::Iterator it = Children.begin(); + for (; it != Children.end(); ++it) + { + if (y < (*it)->getRelativePosition().LowerRightCorner.Y) + y = (*it)->getRelativePosition().LowerRightCorner.Y; + } + setMinSize( core::dimension2du(0, y+5)); + + updateAttrib(false); + } + + //! sets the parent ID, for identifying where events came from + void setParentID(s32 parentID) + { + MyParentID = parentID; + } + + //! save the attribute and possibly post the event to its parent + virtual bool updateAttrib(bool sendEvent=true) + { + if (Attribs && IsEnabled && sendEvent) + { + // build event and pass to parent + SEvent event; + event.EventType = (EEVENT_TYPE)ATTRIBEDIT_ATTRIB_CHANGED; + event.UserEvent.UserData1 = MyParentID; + event.UserEvent.UserData2 = Index; + return Parent->OnEvent(event); + } + + return true; + } + + virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) + { + IGUIElement::serializeAttributes(out, options); + } + + virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0) + { + IGUIElement::deserializeAttributes(in, options); + if (AttribName) + AttribName->setText(Text.c_str()); + } + + protected: + IGUIStaticText* AttribName; + io::IAttributes* Attribs; + u32 Index; + s32 MyParentID; + }; + +} // namespace gui +} // namespace irr + +#endif diff --git a/libraries/irrlicht-1.8/tools/GUIEditor/CGUIAttributeEditor.cpp b/libraries/irrlicht-1.8/tools/GUIEditor/CGUIAttributeEditor.cpp index 45913b6..6d61f17 100644 --- a/libraries/irrlicht-1.8/tools/GUIEditor/CGUIAttributeEditor.cpp +++ b/libraries/irrlicht-1.8/tools/GUIEditor/CGUIAttributeEditor.cpp @@ -1,120 +1,120 @@ - -#include "CGUIAttributeEditor.h" -#include "IGUIEnvironment.h" -#include "IFileSystem.h" -#include "IVideoDriver.h" -#include "IAttributes.h" -#include "IGUIFont.h" -#include "IGUIScrollBar.h" -#include "CGUIEditWorkspace.h" -#include "CGUIAttribute.h" -#include "CGUIStringAttribute.h" - -namespace irr -{ -namespace gui -{ - -using namespace core; -using namespace io; - -CGUIAttributeEditor::CGUIAttributeEditor(IGUIEnvironment* environment, s32 id, IGUIElement *parent) : - CGUIPanel(environment, parent, id, rect(0, 0, 100, 100)), - Attribs(0), Panel(0) -{ - #ifdef _DEBUG - setDebugName("CGUIAttributeEditor"); - #endif - - // create attributes - Attribs = environment->getFileSystem()->createEmptyAttributes(Environment->getVideoDriver()); - - calculateClientArea(); - resizeInnerPane(); - - // refresh attrib list - refreshAttribs(); - - IGUIScrollBar* sb = getVScrollBar(); - core::rect r = sb->getRelativePosition(); - r.LowerRightCorner.Y -= 16; - sb->setRelativePosition(r); -} - -CGUIAttributeEditor::~CGUIAttributeEditor() -{ - for (u32 i=0; iremove(); - AttribList[i]->drop(); - } - AttribList.clear(); - - Attribs->drop(); -} - - -IAttributes* CGUIAttributeEditor::getAttribs() -{ - return Attribs; -} - -void CGUIAttributeEditor::refreshAttribs() -{ - // clear the attribute list - u32 i; - for (i=0; iremove(); - AttribList[i]->drop(); - } - AttribList.clear(); - - position2di top(10, 5); - rect r(top.X, top.Y, - getClientArea().getWidth() - 10, - 5 + Environment->getSkin()->getFont()->getDimension(L"A").Height); - - // add attribute elements - u32 c = Attribs->getAttributeCount(); - for (i=0; igetAttributeTypeString(i); - str += "_attribute"; - CGUIAttribute* n = (CGUIAttribute*)Environment->addGUIElement(str.c_str(), 0); - - // if this doesn't exist, use a string editor - if (!n) - n = (CGUIAttribute*)Environment->addGUIElement("string_attribute", 0); - - if (n) - { - AttribList.push_back(n); - n->setParentID(getID()); - n->grab(); - } - - // We can't set "this" as parent above as we need functionality - // of the overloaded addChild which isn't called in the constructor. - // (that's a general Irrlicht messup with too fat constructors) - addChild(n); - - AttribList[i]->setSubElement(true); - AttribList[i]->setRelativePosition(r); - AttribList[i]->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT); - AttribList[i]->setAttrib(Attribs, i); - r += position2di(0, AttribList[i]->getRelativePosition().getHeight() + 5); - } -} - -void CGUIAttributeEditor::updateAttribs() -{ - for (u32 i=0; iupdateAttrib(false); -} - -} // namespace gui -} // namespace irr - + +#include "CGUIAttributeEditor.h" +#include "IGUIEnvironment.h" +#include "IFileSystem.h" +#include "IVideoDriver.h" +#include "IAttributes.h" +#include "IGUIFont.h" +#include "IGUIScrollBar.h" +#include "CGUIEditWorkspace.h" +#include "CGUIAttribute.h" +#include "CGUIStringAttribute.h" + +namespace irr +{ +namespace gui +{ + +using namespace core; +using namespace io; + +CGUIAttributeEditor::CGUIAttributeEditor(IGUIEnvironment* environment, s32 id, IGUIElement *parent) : + CGUIPanel(environment, parent, id, rect(0, 0, 100, 100)), + Attribs(0), Panel(0) +{ + #ifdef _DEBUG + setDebugName("CGUIAttributeEditor"); + #endif + + // create attributes + Attribs = environment->getFileSystem()->createEmptyAttributes(Environment->getVideoDriver()); + + calculateClientArea(); + resizeInnerPane(); + + // refresh attrib list + refreshAttribs(); + + IGUIScrollBar* sb = getVScrollBar(); + core::rect r = sb->getRelativePosition(); + r.LowerRightCorner.Y -= 16; + sb->setRelativePosition(r); +} + +CGUIAttributeEditor::~CGUIAttributeEditor() +{ + for (u32 i=0; iremove(); + AttribList[i]->drop(); + } + AttribList.clear(); + + Attribs->drop(); +} + + +IAttributes* CGUIAttributeEditor::getAttribs() +{ + return Attribs; +} + +void CGUIAttributeEditor::refreshAttribs() +{ + // clear the attribute list + u32 i; + for (i=0; iremove(); + AttribList[i]->drop(); + } + AttribList.clear(); + + position2di top(10, 5); + rect r(top.X, top.Y, + getClientArea().getWidth() - 10, + 5 + Environment->getSkin()->getFont()->getDimension(L"A").Height); + + // add attribute elements + u32 c = Attribs->getAttributeCount(); + for (i=0; igetAttributeTypeString(i); + str += "_attribute"; + CGUIAttribute* n = (CGUIAttribute*)Environment->addGUIElement(str.c_str(), 0); + + // if this doesn't exist, use a string editor + if (!n) + n = (CGUIAttribute*)Environment->addGUIElement("string_attribute", 0); + + if (n) + { + AttribList.push_back(n); + n->setParentID(getID()); + n->grab(); + } + + // We can't set "this" as parent above as we need functionality + // of the overloaded addChild which isn't called in the constructor. + // (that's a general Irrlicht messup with too fat constructors) + addChild(n); + + AttribList[i]->setSubElement(true); + AttribList[i]->setRelativePosition(r); + AttribList[i]->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT); + AttribList[i]->setAttrib(Attribs, i); + r += position2di(0, AttribList[i]->getRelativePosition().getHeight() + 5); + } +} + +void CGUIAttributeEditor::updateAttribs() +{ + for (u32 i=0; iupdateAttrib(false); +} + +} // namespace gui +} // namespace irr + diff --git a/libraries/irrlicht-1.8/tools/GUIEditor/CGUIAttributeEditor.h b/libraries/irrlicht-1.8/tools/GUIEditor/CGUIAttributeEditor.h index 0bcdab5..551fdfd 100644 --- a/libraries/irrlicht-1.8/tools/GUIEditor/CGUIAttributeEditor.h +++ b/libraries/irrlicht-1.8/tools/GUIEditor/CGUIAttributeEditor.h @@ -1,54 +1,54 @@ -#ifndef __C_GUI_ATTRIBUTE_EDITOR_H_INCLUDED__ -#define __C_GUI_ATTRIBUTE_EDITOR_H_INCLUDED__ - -#include "IGUIElement.h" -#include "CGUIPanel.h" -#include "irrArray.h" -#include "IAttributes.h" -#include "EGUIEditTypes.h" - -namespace irr -{ -namespace gui -{ - - class CGUIAttribute; - - - class CGUIAttributeEditor : public CGUIPanel - { - public: - - //! constructor - CGUIAttributeEditor(IGUIEnvironment* environment, s32 id, IGUIElement *parent=0); - - //! destructor - ~CGUIAttributeEditor(); - - // gets the current attributes list - virtual io::IAttributes* getAttribs(); - - // update the attribute list after making a change - void refreshAttribs(); - - // save the attributes - void updateAttribs(); - - //! Returns the type name of the gui element. - virtual const c8* getTypeName() const - { - return GUIEditElementTypeNames[EGUIEDIT_ATTRIBUTEEDITOR]; - } - - private: - - core::array AttribList; // attributes editing controls - io::IAttributes* Attribs; // current attributes - CGUIPanel* Panel; - }; - -} // end namespace gui -} // end namespace irr - -#endif // __C_GUI_ATTRIBUTE_EDITOR_H_INCLUDED__ - +#ifndef __C_GUI_ATTRIBUTE_EDITOR_H_INCLUDED__ +#define __C_GUI_ATTRIBUTE_EDITOR_H_INCLUDED__ + +#include "IGUIElement.h" +#include "CGUIPanel.h" +#include "irrArray.h" +#include "IAttributes.h" +#include "EGUIEditTypes.h" + +namespace irr +{ +namespace gui +{ + + class CGUIAttribute; + + + class CGUIAttributeEditor : public CGUIPanel + { + public: + + //! constructor + CGUIAttributeEditor(IGUIEnvironment* environment, s32 id, IGUIElement *parent=0); + + //! destructor + ~CGUIAttributeEditor(); + + // gets the current attributes list + virtual io::IAttributes* getAttribs(); + + // update the attribute list after making a change + void refreshAttribs(); + + // save the attributes + void updateAttribs(); + + //! Returns the type name of the gui element. + virtual const c8* getTypeName() const + { + return GUIEditElementTypeNames[EGUIEDIT_ATTRIBUTEEDITOR]; + } + + private: + + core::array AttribList; // attributes editing controls + io::IAttributes* Attribs; // current attributes + CGUIPanel* Panel; + }; + +} // end namespace gui +} // end namespace irr + +#endif // __C_GUI_ATTRIBUTE_EDITOR_H_INCLUDED__ + diff --git a/libraries/irrlicht-1.8/tools/GUIEditor/CGUIBoolAttribute.h b/libraries/irrlicht-1.8/tools/GUIEditor/CGUIBoolAttribute.h index b0521db..189bd2d 100644 --- a/libraries/irrlicht-1.8/tools/GUIEditor/CGUIBoolAttribute.h +++ b/libraries/irrlicht-1.8/tools/GUIEditor/CGUIBoolAttribute.h @@ -1,68 +1,68 @@ -#ifndef __C_GUI_BOOL_ATTRIBUTE_H_INCLUDED__ -#define __C_GUI_BOOL_ATTRIBUTE_H_INCLUDED__ - -#include "CGUIAttribute.h" -#include "IGUICheckBox.h" -#include "EGUIEditTypes.h" - -namespace irr -{ -namespace gui -{ - - class CGUIBoolAttribute : public CGUIAttribute - { - public: - // - CGUIBoolAttribute(IGUIEnvironment* environment, IGUIElement *parent, s32 myParentID) : - CGUIAttribute(environment, parent, myParentID), AttribCheckBox(0) - { - - core::rect r = getAbsolutePosition(); - core::rect r2(0, Environment->getSkin()->getFont()->getDimension(L"A").Height + 10, - r.getWidth() - 5, - Environment->getSkin()->getFont()->getDimension(L"A").Height*2 + 15 ); - - AttribCheckBox = environment->addCheckBox(false, r2, this); - AttribCheckBox->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT); - AttribCheckBox->setSubElement(true); - AttribCheckBox->grab(); - } - - virtual ~CGUIBoolAttribute() - { - if (AttribCheckBox) - AttribCheckBox->drop(); - } - - virtual void setAttrib(io::IAttributes *attribs, u32 attribIndex) - { - AttribCheckBox->setChecked(attribs->getAttributeAsBool(attribIndex)); - CGUIAttribute::setAttrib(attribs, attribIndex); - } - - // save the attribute and possibly post the event to its parent - virtual bool updateAttrib(bool sendEvent=true) - { - if (!Attribs) - return true; - - Attribs->setAttribute(Index, AttribCheckBox->isChecked()); - - return CGUIAttribute::updateAttrib(sendEvent); - } - - //! Returns the type name of the gui element. - virtual const c8* getTypeName() const - { - return GUIEditElementTypeNames[EGUIEDIT_BOOLATTRIBUTE]; - } - - private: - IGUICheckBox* AttribCheckBox; - }; - -} // namespace gui -} // namespace irr - -#endif +#ifndef __C_GUI_BOOL_ATTRIBUTE_H_INCLUDED__ +#define __C_GUI_BOOL_ATTRIBUTE_H_INCLUDED__ + +#include "CGUIAttribute.h" +#include "IGUICheckBox.h" +#include "EGUIEditTypes.h" + +namespace irr +{ +namespace gui +{ + + class CGUIBoolAttribute : public CGUIAttribute + { + public: + // + CGUIBoolAttribute(IGUIEnvironment* environment, IGUIElement *parent, s32 myParentID) : + CGUIAttribute(environment, parent, myParentID), AttribCheckBox(0) + { + + core::rect r = getAbsolutePosition(); + core::rect r2(0, Environment->getSkin()->getFont()->getDimension(L"A").Height + 10, + r.getWidth() - 5, + Environment->getSkin()->getFont()->getDimension(L"A").Height*2 + 15 ); + + AttribCheckBox = environment->addCheckBox(false, r2, this); + AttribCheckBox->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT); + AttribCheckBox->setSubElement(true); + AttribCheckBox->grab(); + } + + virtual ~CGUIBoolAttribute() + { + if (AttribCheckBox) + AttribCheckBox->drop(); + } + + virtual void setAttrib(io::IAttributes *attribs, u32 attribIndex) + { + AttribCheckBox->setChecked(attribs->getAttributeAsBool(attribIndex)); + CGUIAttribute::setAttrib(attribs, attribIndex); + } + + // save the attribute and possibly post the event to its parent + virtual bool updateAttrib(bool sendEvent=true) + { + if (!Attribs) + return true; + + Attribs->setAttribute(Index, AttribCheckBox->isChecked()); + + return CGUIAttribute::updateAttrib(sendEvent); + } + + //! Returns the type name of the gui element. + virtual const c8* getTypeName() const + { + return GUIEditElementTypeNames[EGUIEDIT_BOOLATTRIBUTE]; + } + + private: + IGUICheckBox* AttribCheckBox; + }; + +} // namespace gui +} // namespace irr + +#endif diff --git a/libraries/irrlicht-1.8/tools/GUIEditor/CGUIColorAttribute.h b/libraries/irrlicht-1.8/tools/GUIEditor/CGUIColorAttribute.h index e0c5212..d14b7a1 100644 --- a/libraries/irrlicht-1.8/tools/GUIEditor/CGUIColorAttribute.h +++ b/libraries/irrlicht-1.8/tools/GUIEditor/CGUIColorAttribute.h @@ -1,179 +1,179 @@ -#ifndef __C_GUI_COLOR_ATTRIBUTE_H_INCLUDED__ -#define __C_GUI_COLOR_ATTRIBUTE_H_INCLUDED__ - -#include "CGUIAttribute.h" -#include "IGUIStaticText.h" -#include "IGUIScrollBar.h" -#include "IGUITabControl.h" -#include "EGUIEditTypes.h" - -namespace irr -{ -namespace gui -{ - class CGUIColorAttribute : public CGUIAttribute - { - public: - // - CGUIColorAttribute(IGUIEnvironment* environment, IGUIElement *parent, s32 myParentID) : - CGUIAttribute(environment, parent, myParentID), - AttribSliderA(0), AttribSliderR(0), AttribSliderG(0), AttribSliderB(0), - AttribEditBox(0), AttribColor(0) - { - s32 fh = Environment->getSkin()->getFont()->getDimension(L"A").Height; - - core::rect r0(getAbsolutePosition()), - r2(0, fh + 5, r0.getWidth() - 5, fh*2 + 10 ), - r3(r2), - r4(r2.getWidth() - 20, 3, r2.getWidth() - 3, r2.getHeight()-3); - - AttribColor = Environment->addTab(r4, this, 0); - AttribColor->grab(); - AttribColor->setDrawBackground(true); - AttribColor->setSubElement(true); - AttribColor->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT); - - s32 h=2; - r2 += core::position2di(0, h*4 + Environment->getSkin()->getSize(EGDS_WINDOW_BUTTON_WIDTH)*2); - r3.LowerRightCorner.Y = r3.UpperLeftCorner.Y + Environment->getSkin()->getSize(EGDS_WINDOW_BUTTON_WIDTH)/2; - - AttribSliderA = environment->addScrollBar(true, r3, this, -1); - AttribSliderA->setMax(255); - AttribSliderA->grab(); - AttribSliderA->setSubElement(true); - AttribSliderA->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT); - r3 += core::position2di(0, r3.getHeight()+h); - AttribSliderR = environment->addScrollBar(true, r3, this, -1); - AttribSliderR->setMax(255); - AttribSliderR->grab(); - AttribSliderR->setSubElement(true); - AttribSliderR->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT); - r3 += core::position2di(0, r3.getHeight()+h); - AttribSliderG = environment->addScrollBar(true, r3, this, -1); - AttribSliderG->setMax(255); - AttribSliderG->grab(); - AttribSliderG->setSubElement(true); - AttribSliderG->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT); - r3 += core::position2di(0, r3.getHeight()+h); - AttribSliderB = environment->addScrollBar(true, r3, this, -1); - AttribSliderB->setMax(255); - AttribSliderB->grab(); - AttribSliderB->setSubElement(true); - AttribSliderB->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT); - - // add editbox - AttribEditBox = environment->addEditBox( - L"", - r2, - true, this, -1); - AttribEditBox->grab(); - AttribEditBox->setSubElement(true); - AttribEditBox->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT); - } - - virtual ~CGUIColorAttribute() - { - if (AttribSliderA) - AttribSliderA->drop(); - if (AttribSliderR) - AttribSliderR->drop(); - if (AttribSliderG) - AttribSliderG->drop(); - if (AttribSliderB) - AttribSliderB->drop(); - if (AttribEditBox) - AttribEditBox->drop(); - if (AttribColor) - AttribColor->drop(); - } - - virtual void setAttrib(io::IAttributes *attribs, u32 attribIndex) - { - video::SColor col = attribs->getAttributeAsColor(attribIndex); - - AttribSliderA->setPos(col.getAlpha()); - AttribSliderR->setPos(col.getRed()); - AttribSliderG->setPos(col.getGreen()); - AttribSliderB->setPos(col.getBlue()); - AttribEditBox->setText( attribs->getAttributeAsStringW(attribIndex).c_str() ); - AttribColor->setBackgroundColor(col); - - CGUIAttribute::setAttrib(attribs, attribIndex); - } - - virtual bool OnEvent(const SEvent &e) - { - switch (e.EventType) - { - - case EET_GUI_EVENT: - switch (e.GUIEvent.EventType) - { - case EGET_EDITBOX_ENTER: - case EGET_ELEMENT_FOCUS_LOST: - if (e.GUIEvent.Caller == AttribEditBox) - { - // update scrollbars from textbox - Attribs->setAttribute(Index, AttribEditBox->getText()); - video::SColor col = Attribs->getAttributeAsColor(Index); - AttribSliderA->setPos(col.getAlpha()); - AttribSliderR->setPos(col.getRed()); - AttribSliderG->setPos(col.getGreen()); - AttribSliderB->setPos(col.getBlue()); - // update colour - AttribColor->setBackgroundColor(col); - } - break; - case EGET_SCROLL_BAR_CHANGED: - { - // update editbox from scrollbars - video::SColor col( AttribSliderA->getPos(), AttribSliderR->getPos(), - AttribSliderG->getPos(), AttribSliderB->getPos()); - - Attribs->setAttribute(Index, col); - AttribEditBox->setText( Attribs->getAttributeAsStringW(Index).c_str()); - // update colour - AttribColor->setBackgroundColor(col); - } - return updateAttrib(); - default: - break; - } - break; - default: - break; - } - return CGUIAttribute::OnEvent(e); - } - - // save the attribute and possibly post the event to its parent - virtual bool updateAttrib(bool sendEvent=true) - { - if (!Attribs) - return true; - - Attribs->setAttribute(Index, AttribEditBox->getText()); - AttribEditBox->setText(Attribs->getAttributeAsStringW(Index).c_str()); - return CGUIAttribute::updateAttrib(sendEvent); - } - - //! Returns the type name of the gui element. - virtual const c8* getTypeName() const - { - return GUIEditElementTypeNames[EGUIEDIT_COLORATTRIBUTE]; - } - - private: - IGUIScrollBar* AttribSliderA; - IGUIScrollBar* AttribSliderR; - IGUIScrollBar* AttribSliderG; - IGUIScrollBar* AttribSliderB; - IGUIEditBox* AttribEditBox; - IGUITab* AttribColor; - }; - -} // namespace gui -} // namespace irr - -#endif - +#ifndef __C_GUI_COLOR_ATTRIBUTE_H_INCLUDED__ +#define __C_GUI_COLOR_ATTRIBUTE_H_INCLUDED__ + +#include "CGUIAttribute.h" +#include "IGUIStaticText.h" +#include "IGUIScrollBar.h" +#include "IGUITabControl.h" +#include "EGUIEditTypes.h" + +namespace irr +{ +namespace gui +{ + class CGUIColorAttribute : public CGUIAttribute + { + public: + // + CGUIColorAttribute(IGUIEnvironment* environment, IGUIElement *parent, s32 myParentID) : + CGUIAttribute(environment, parent, myParentID), + AttribSliderA(0), AttribSliderR(0), AttribSliderG(0), AttribSliderB(0), + AttribEditBox(0), AttribColor(0) + { + s32 fh = Environment->getSkin()->getFont()->getDimension(L"A").Height; + + core::rect r0(getAbsolutePosition()), + r2(0, fh + 5, r0.getWidth() - 5, fh*2 + 10 ), + r3(r2), + r4(r2.getWidth() - 20, 3, r2.getWidth() - 3, r2.getHeight()-3); + + AttribColor = Environment->addTab(r4, this, 0); + AttribColor->grab(); + AttribColor->setDrawBackground(true); + AttribColor->setSubElement(true); + AttribColor->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT); + + s32 h=2; + r2 += core::position2di(0, h*4 + Environment->getSkin()->getSize(EGDS_WINDOW_BUTTON_WIDTH)*2); + r3.LowerRightCorner.Y = r3.UpperLeftCorner.Y + Environment->getSkin()->getSize(EGDS_WINDOW_BUTTON_WIDTH)/2; + + AttribSliderA = environment->addScrollBar(true, r3, this, -1); + AttribSliderA->setMax(255); + AttribSliderA->grab(); + AttribSliderA->setSubElement(true); + AttribSliderA->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT); + r3 += core::position2di(0, r3.getHeight()+h); + AttribSliderR = environment->addScrollBar(true, r3, this, -1); + AttribSliderR->setMax(255); + AttribSliderR->grab(); + AttribSliderR->setSubElement(true); + AttribSliderR->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT); + r3 += core::position2di(0, r3.getHeight()+h); + AttribSliderG = environment->addScrollBar(true, r3, this, -1); + AttribSliderG->setMax(255); + AttribSliderG->grab(); + AttribSliderG->setSubElement(true); + AttribSliderG->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT); + r3 += core::position2di(0, r3.getHeight()+h); + AttribSliderB = environment->addScrollBar(true, r3, this, -1); + AttribSliderB->setMax(255); + AttribSliderB->grab(); + AttribSliderB->setSubElement(true); + AttribSliderB->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT); + + // add editbox + AttribEditBox = environment->addEditBox( + L"", + r2, + true, this, -1); + AttribEditBox->grab(); + AttribEditBox->setSubElement(true); + AttribEditBox->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT); + } + + virtual ~CGUIColorAttribute() + { + if (AttribSliderA) + AttribSliderA->drop(); + if (AttribSliderR) + AttribSliderR->drop(); + if (AttribSliderG) + AttribSliderG->drop(); + if (AttribSliderB) + AttribSliderB->drop(); + if (AttribEditBox) + AttribEditBox->drop(); + if (AttribColor) + AttribColor->drop(); + } + + virtual void setAttrib(io::IAttributes *attribs, u32 attribIndex) + { + video::SColor col = attribs->getAttributeAsColor(attribIndex); + + AttribSliderA->setPos(col.getAlpha()); + AttribSliderR->setPos(col.getRed()); + AttribSliderG->setPos(col.getGreen()); + AttribSliderB->setPos(col.getBlue()); + AttribEditBox->setText( attribs->getAttributeAsStringW(attribIndex).c_str() ); + AttribColor->setBackgroundColor(col); + + CGUIAttribute::setAttrib(attribs, attribIndex); + } + + virtual bool OnEvent(const SEvent &e) + { + switch (e.EventType) + { + + case EET_GUI_EVENT: + switch (e.GUIEvent.EventType) + { + case EGET_EDITBOX_ENTER: + case EGET_ELEMENT_FOCUS_LOST: + if (e.GUIEvent.Caller == AttribEditBox) + { + // update scrollbars from textbox + Attribs->setAttribute(Index, AttribEditBox->getText()); + video::SColor col = Attribs->getAttributeAsColor(Index); + AttribSliderA->setPos(col.getAlpha()); + AttribSliderR->setPos(col.getRed()); + AttribSliderG->setPos(col.getGreen()); + AttribSliderB->setPos(col.getBlue()); + // update colour + AttribColor->setBackgroundColor(col); + } + break; + case EGET_SCROLL_BAR_CHANGED: + { + // update editbox from scrollbars + video::SColor col( AttribSliderA->getPos(), AttribSliderR->getPos(), + AttribSliderG->getPos(), AttribSliderB->getPos()); + + Attribs->setAttribute(Index, col); + AttribEditBox->setText( Attribs->getAttributeAsStringW(Index).c_str()); + // update colour + AttribColor->setBackgroundColor(col); + } + return updateAttrib(); + default: + break; + } + break; + default: + break; + } + return CGUIAttribute::OnEvent(e); + } + + // save the attribute and possibly post the event to its parent + virtual bool updateAttrib(bool sendEvent=true) + { + if (!Attribs) + return true; + + Attribs->setAttribute(Index, AttribEditBox->getText()); + AttribEditBox->setText(Attribs->getAttributeAsStringW(Index).c_str()); + return CGUIAttribute::updateAttrib(sendEvent); + } + + //! Returns the type name of the gui element. + virtual const c8* getTypeName() const + { + return GUIEditElementTypeNames[EGUIEDIT_COLORATTRIBUTE]; + } + + private: + IGUIScrollBar* AttribSliderA; + IGUIScrollBar* AttribSliderR; + IGUIScrollBar* AttribSliderG; + IGUIScrollBar* AttribSliderB; + IGUIEditBox* AttribEditBox; + IGUITab* AttribColor; + }; + +} // namespace gui +} // namespace irr + +#endif + diff --git a/libraries/irrlicht-1.8/tools/GUIEditor/CGUIDummyEditorStub.h b/libraries/irrlicht-1.8/tools/GUIEditor/CGUIDummyEditorStub.h index 635501a..b373b2d 100644 --- a/libraries/irrlicht-1.8/tools/GUIEditor/CGUIDummyEditorStub.h +++ b/libraries/irrlicht-1.8/tools/GUIEditor/CGUIDummyEditorStub.h @@ -1,59 +1,59 @@ -/* - This is a custom editor for stubbing problematic elements out, - for example elements which include modal screens -*/ - -#ifndef __C_GUI_DUMMY_EDITOR_STUB_H_INCLUDED__ -#define __C_GUI_DUMMY_EDITOR_STUB_H_INCLUDED__ - -#include "IGUIElement.h" -#include "IGUIEnvironment.h" -#include "IGUIStaticText.h" - -namespace irr -{ - -namespace gui -{ - class CGUIDummyEditorStub : public IGUIElement - { - public: - //! constructor - CGUIDummyEditorStub(IGUIEnvironment* environment, IGUIElement *parent, const char *text) : - IGUIElement(EGUIET_ELEMENT, environment, parent, -1, core::rect(0, 0, 100, 100) ), - TextBox(0), TypeName(text) - { - - #ifdef _DEBUG - setDebugName("CGUIDummyEditorStub"); - #endif - - core::dimension2du d = Environment->getSkin()->getFont()->getDimension(L"A"); - s32 h = d.Height / 2; - s32 w = d.Width / 2; - - TextBox = environment->addStaticText(core::stringw(text).c_str(), - core::rect(50-w, 50-h, 50+w, 50+h), - false, false, this, -1, false); - TextBox->grab(); - TextBox->setSubElement(true); - TextBox->setAlignment(EGUIA_CENTER, EGUIA_CENTER, EGUIA_CENTER, EGUIA_CENTER); - } - - virtual ~CGUIDummyEditorStub() - { - if (TextBox) - TextBox->drop(); - } - virtual const c8* getTypeName() const { return TypeName.c_str(); } - - protected: - IGUIStaticText* TextBox; - core::stringc TypeName; - - }; - -} // namespace gui -} // namespace irr - -#endif +/* + This is a custom editor for stubbing problematic elements out, + for example elements which include modal screens +*/ + +#ifndef __C_GUI_DUMMY_EDITOR_STUB_H_INCLUDED__ +#define __C_GUI_DUMMY_EDITOR_STUB_H_INCLUDED__ + +#include "IGUIElement.h" +#include "IGUIEnvironment.h" +#include "IGUIStaticText.h" + +namespace irr +{ + +namespace gui +{ + class CGUIDummyEditorStub : public IGUIElement + { + public: + //! constructor + CGUIDummyEditorStub(IGUIEnvironment* environment, IGUIElement *parent, const char *text) : + IGUIElement(EGUIET_ELEMENT, environment, parent, -1, core::rect(0, 0, 100, 100) ), + TextBox(0), TypeName(text) + { + + #ifdef _DEBUG + setDebugName("CGUIDummyEditorStub"); + #endif + + core::dimension2du d = Environment->getSkin()->getFont()->getDimension(L"A"); + s32 h = d.Height / 2; + s32 w = d.Width / 2; + + TextBox = environment->addStaticText(core::stringw(text).c_str(), + core::rect(50-w, 50-h, 50+w, 50+h), + false, false, this, -1, false); + TextBox->grab(); + TextBox->setSubElement(true); + TextBox->setAlignment(EGUIA_CENTER, EGUIA_CENTER, EGUIA_CENTER, EGUIA_CENTER); + } + + virtual ~CGUIDummyEditorStub() + { + if (TextBox) + TextBox->drop(); + } + virtual const c8* getTypeName() const { return TypeName.c_str(); } + + protected: + IGUIStaticText* TextBox; + core::stringc TypeName; + + }; + +} // namespace gui +} // namespace irr + +#endif diff --git a/libraries/irrlicht-1.8/tools/GUIEditor/CGUIEditFactory.cpp b/libraries/irrlicht-1.8/tools/GUIEditor/CGUIEditFactory.cpp index 9552745..0748360 100644 --- a/libraries/irrlicht-1.8/tools/GUIEditor/CGUIEditFactory.cpp +++ b/libraries/irrlicht-1.8/tools/GUIEditor/CGUIEditFactory.cpp @@ -1,120 +1,120 @@ -#include "CGUIEditFactory.h" -#include "IGUIEnvironment.h" -#include "irrString.h" - -#include "EGUIEditTypes.h" - -#include "CGUIEditWorkspace.h" -#include "CGUIEditWindow.h" -#include "CGUIPanel.h" -#include "CGUITextureCacheBrowser.h" -#include "CGUIAttributeEditor.h" -#include "CGUIStringAttribute.h" -#include "CGUIBoolAttribute.h" -#include "CGUIEnumAttribute.h" -#include "CGUIColorAttribute.h" -#include "CGUITextureAttribute.h" -#include "CGUIDummyEditorStub.h" - -namespace irr -{ -namespace gui -{ - -CGUIEditFactory::CGUIEditFactory(IGUIEnvironment* env) -: Environment(env) -{ - #ifdef _DEBUG - setDebugName("CGUIEditFactory"); - #endif - - // don't grab the gui environment here to prevent cyclic references -} - - -CGUIEditFactory::~CGUIEditFactory() -{ -} - - -//! adds an element to the environment based on its type name -IGUIElement* CGUIEditFactory::addGUIElement(const c8* typeName, IGUIElement* parent) -{ - /* - here we create elements, add them to the manager, and then drop them - */ - - core::stringc elementType(typeName); - IGUIElement* ret=0; - if (!parent) - parent = Environment->getRootGUIElement(); - - // editor workspace - if (elementType == core::stringc(GUIEditElementTypeNames[EGUIEDIT_GUIEDIT])) - ret = new CGUIEditWorkspace(Environment, -1, 0); - // editor window - else if (elementType == core::stringc(GUIEditElementTypeNames[EGUIEDIT_GUIEDITWINDOW])) - ret = new CGUIEditWindow(Environment, core::rect(0,0,100,100), 0); - // Klasker's GUI Panel - else if (elementType == core::stringc(GUIEditElementTypeNames[EGUIEDIT_GUIPANEL])) - ret = new CGUIPanel(Environment, 0); - // texture cache browser - else if (elementType == core::stringc(GUIEditElementTypeNames[EGUIEDIT_TEXTUREBROWSER])) - ret = new CGUITextureCacheBrowser(Environment, -1, 0); - // block of attribute editors - else if (elementType == core::stringc(GUIEditElementTypeNames[EGUIEDIT_ATTRIBUTEEDITOR])) - ret = new CGUIAttributeEditor(Environment, -1, 0); - //! single attribute editors - else if (elementType == core::stringc(GUIEditElementTypeNames[EGUIEDIT_STRINGATTRIBUTE])) - ret = new CGUIStringAttribute(Environment, 0, -1); - else if (elementType == core::stringc(GUIEditElementTypeNames[EGUIEDIT_BOOLATTRIBUTE])) - ret = new CGUIBoolAttribute(Environment, 0, -1); - else if (elementType == core::stringc(GUIEditElementTypeNames[EGUIEDIT_ENUMATTRIBUTE])) - ret = new CGUIEnumAttribute(Environment, 0, -1); - else if (elementType == core::stringc(GUIEditElementTypeNames[EGUIEDIT_COLORATTRIBUTE])) - ret = new CGUIColorAttribute(Environment, 0, -1); - else if (elementType == core::stringc(GUIEditElementTypeNames[EGUIEDIT_COLORFATTRIBUTE])) - ret = new CGUIColorAttribute(Environment, 0, -1); - else if (elementType == core::stringc(GUIEditElementTypeNames[EGUIEDIT_TEXTUREATTRIBUTE])) - ret = new CGUITextureAttribute(Environment, 0, -1); - // stubs and custom editors - else if (elementType == core::stringc(GUIEditElementTypeNames[EGUIEDIT_CONTEXTMENUEDITOR]) || - elementType == core::stringc(GUIEditElementTypeNames[EGUIEDIT_MENUEDITOR]) || - elementType == core::stringc(GUIEditElementTypeNames[EGUIEDIT_FILEDIALOGEDITOR]) || - elementType == core::stringc(GUIEditElementTypeNames[EGUIEDIT_COLORDIALOGEDITOR]) || - elementType == core::stringc(GUIEditElementTypeNames[EGUIEDIT_MODALSCREENEDITOR]) ) - ret = new CGUIDummyEditorStub(Environment, 0, typeName); - - // add the element to its parent - if (ret) - parent->addChild(ret); - - // the environment now has the reference, so we can drop the element - if (ret) - ret->drop(); - - return ret; -} - - -//! returns amount of element types this factory is able to create -s32 CGUIEditFactory::getCreatableGUIElementTypeCount() const -{ - return EGUIEDIT_COUNT; -} - - -//! returns type name of a createable element type -const c8* CGUIEditFactory::getCreateableGUIElementTypeName(s32 idx) const -{ - if (idx>=0 && idxgetRootGUIElement(); + + // editor workspace + if (elementType == core::stringc(GUIEditElementTypeNames[EGUIEDIT_GUIEDIT])) + ret = new CGUIEditWorkspace(Environment, -1, 0); + // editor window + else if (elementType == core::stringc(GUIEditElementTypeNames[EGUIEDIT_GUIEDITWINDOW])) + ret = new CGUIEditWindow(Environment, core::rect(0,0,100,100), 0); + // Klasker's GUI Panel + else if (elementType == core::stringc(GUIEditElementTypeNames[EGUIEDIT_GUIPANEL])) + ret = new CGUIPanel(Environment, 0); + // texture cache browser + else if (elementType == core::stringc(GUIEditElementTypeNames[EGUIEDIT_TEXTUREBROWSER])) + ret = new CGUITextureCacheBrowser(Environment, -1, 0); + // block of attribute editors + else if (elementType == core::stringc(GUIEditElementTypeNames[EGUIEDIT_ATTRIBUTEEDITOR])) + ret = new CGUIAttributeEditor(Environment, -1, 0); + //! single attribute editors + else if (elementType == core::stringc(GUIEditElementTypeNames[EGUIEDIT_STRINGATTRIBUTE])) + ret = new CGUIStringAttribute(Environment, 0, -1); + else if (elementType == core::stringc(GUIEditElementTypeNames[EGUIEDIT_BOOLATTRIBUTE])) + ret = new CGUIBoolAttribute(Environment, 0, -1); + else if (elementType == core::stringc(GUIEditElementTypeNames[EGUIEDIT_ENUMATTRIBUTE])) + ret = new CGUIEnumAttribute(Environment, 0, -1); + else if (elementType == core::stringc(GUIEditElementTypeNames[EGUIEDIT_COLORATTRIBUTE])) + ret = new CGUIColorAttribute(Environment, 0, -1); + else if (elementType == core::stringc(GUIEditElementTypeNames[EGUIEDIT_COLORFATTRIBUTE])) + ret = new CGUIColorAttribute(Environment, 0, -1); + else if (elementType == core::stringc(GUIEditElementTypeNames[EGUIEDIT_TEXTUREATTRIBUTE])) + ret = new CGUITextureAttribute(Environment, 0, -1); + // stubs and custom editors + else if (elementType == core::stringc(GUIEditElementTypeNames[EGUIEDIT_CONTEXTMENUEDITOR]) || + elementType == core::stringc(GUIEditElementTypeNames[EGUIEDIT_MENUEDITOR]) || + elementType == core::stringc(GUIEditElementTypeNames[EGUIEDIT_FILEDIALOGEDITOR]) || + elementType == core::stringc(GUIEditElementTypeNames[EGUIEDIT_COLORDIALOGEDITOR]) || + elementType == core::stringc(GUIEditElementTypeNames[EGUIEDIT_MODALSCREENEDITOR]) ) + ret = new CGUIDummyEditorStub(Environment, 0, typeName); + + // add the element to its parent + if (ret) + parent->addChild(ret); + + // the environment now has the reference, so we can drop the element + if (ret) + ret->drop(); + + return ret; +} + + +//! returns amount of element types this factory is able to create +s32 CGUIEditFactory::getCreatableGUIElementTypeCount() const +{ + return EGUIEDIT_COUNT; +} + + +//! returns type name of a createable element type +const c8* CGUIEditFactory::getCreateableGUIElementTypeName(s32 idx) const +{ + if (idx>=0 && idx rectangle, IGUIElement *parent) - : IGUIWindow(environment, parent, -1, rectangle), - Dragging(false), IsDraggable(true), Resizing(false), SelectedElement(0), - AttribEditor(0), OptionEditor(0), EnvEditor(0) -{ - #ifdef _DEBUG - setDebugName("CGUIEditWindow"); - #endif - - // we can't tab out of this window - setTabGroup(true); - // we can ctrl+tab to it - setTabStop(true); - // the tab order number is auto-assigned - setTabOrder(-1); - - // set window text - setText(L"GUI Editor"); - - // return if we have no skin. - IGUISkin *skin = environment->getSkin(); - if (!skin) - return; - - s32 th = skin->getSize(EGDS_WINDOW_BUTTON_WIDTH); - - setRelativePosition(core::rect(50,50,250,500)); - setMinSize(core::dimension2du(200,200)); - - IGUITabControl *TabControl = environment->addTabControl(core::rect(1,th+5,199,449), this, false, true); - TabControl->setSubElement(true); - TabControl->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT); - - TabControl->addTab(L"Tools"); - //L"Texture Cache Browser" - //L"Font Browser" - //L"Font Generator" - //L"Sprite Editor" - //Environment->addGUIElement("textureCacheBrowser", this); - - IGUITab* EditorTab = TabControl->addTab(L"Editor"); - OptionEditor = (CGUIAttributeEditor*) environment->addGUIElement("attributeEditor", EditorTab); - OptionEditor->grab(); - OptionEditor->setID(EGUIEDCE_OPTION_EDITOR); - OptionEditor->setRelativePositionProportional(core::rect(0.0f, 0.0f, 1.0f, 1.0f)); - OptionEditor->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT); - - if (Parent && Parent->getParent() == Environment->getRootGUIElement()) - { - IGUITab* EnvTab = TabControl->addTab(L"Env"); - EnvEditor = (CGUIAttributeEditor*) environment->addGUIElement("attributeEditor", EnvTab); - EnvEditor->grab(); - EnvEditor->setID(EGUIEDCE_ENV_EDITOR); - EnvEditor->setRelativePositionProportional(core::rect(0.0f, 0.0f, 1.0f, 1.0f)); - EnvEditor->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT); - } - IGUITab* ElementTab = TabControl->addTab(L"Element"); - - AttribEditor = (CGUIAttributeEditor*) environment->addGUIElement("attributeEditor", ElementTab); - AttribEditor->grab(); - AttribEditor->setID(EGUIEDCE_ATTRIB_EDITOR); - AttribEditor->setRelativePositionProportional(core::rect(0.0f, 0.0f, 1.0f, 1.0f)); - AttribEditor->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT); - - IGUITab* TreeTab = TabControl->addTab(L"Tree"); - TreeView = environment->addTreeView(core::rect(0,0,0,0), TreeTab); - TreeView->setRelativePositionProportional(core::rect(0.0f, 0.0f, 1.0f, 1.0f)); - TreeView->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT); - IGUITreeViewNode* treenode = TreeView->getRoot(); - //treenode->addChildFront(L"Elements"); - ResizeButton = environment->addButton(core::rect(199-th,449-th,199,449), this); - ResizeButton->setDrawBorder(false); - ResizeButton->setEnabled(false); - ResizeButton->setSpriteBank(skin->getSpriteBank()); - ResizeButton->setSprite(EGBS_BUTTON_UP, skin->getIcon(EGDI_WINDOW_RESIZE), skin->getColor(EGDC_WINDOW_SYMBOL)); - ResizeButton->setSprite(EGBS_BUTTON_DOWN, skin->getIcon(EGDI_WINDOW_RESIZE), skin->getColor(EGDC_WINDOW_SYMBOL)); - ResizeButton->grab(); - ResizeButton->setSubElement(true); - ResizeButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT); - updateTree(); -} - - -//! destructor -CGUIEditWindow::~CGUIEditWindow() -{ - // drop everything - if (AttribEditor) - AttribEditor->drop(); - if (EnvEditor) - EnvEditor->drop(); - if (OptionEditor) - OptionEditor->drop(); - if (ResizeButton) - ResizeButton->drop(); -} - -IGUITreeView* CGUIEditWindow::getTreeView() const -{ - return TreeView; -} -CGUIAttributeEditor* CGUIEditWindow::getEnvironmentEditor() const -{ - return EnvEditor; -} - -CGUIAttributeEditor* CGUIEditWindow::getAttributeEditor() const -{ - return AttribEditor; -} - -CGUIAttributeEditor* CGUIEditWindow::getOptionEditor() const -{ - return OptionEditor; -} - -IGUITreeViewNode* CGUIEditWindow::getTreeNode(IGUIElement* element, IGUITreeViewNode* searchnode) -{ - IGUITreeViewNode* child = searchnode->getFirstChild(); - while (child) - { - if (((IGUIElement*) child->getData()) == element) - return child; - - if (child->hasChildren()) - { - IGUITreeViewNode* foundnode = getTreeNode(element, child); - if (foundnode) - return foundnode; - } - child = child->getNextSibling(); - } - return 0; -} - -void CGUIEditWindow::addChildrenToTree(IGUIElement* parentElement, IGUITreeViewNode* treenode) -{ - core::stringw name = core::stringw(parentElement->getTypeName()); - if (parentElement->getID() != -1) - name += core::stringw(L" [") + core::stringw(parentElement->getID()) + core::stringw(L"]"); - - IGUITreeViewNode* newnode = treenode->addChildBack(name.c_str()); - newnode->setData((void*)parentElement); - core::list children = parentElement->getChildren(); - - for (core::list::Iterator i = children.begin(); i != children.end(); i++ ) - { - if(core::stringc((*i)->getTypeName()) != "GUIEditor" && !(*i)->isSubElement()) - addChildrenToTree(*i, newnode); - } -} - -void CGUIEditWindow::updateTree() -{ - TreeView->getRoot()->clearChildren(); - IGUIElement* root = Environment->getRootGUIElement(); - addChildrenToTree(root, TreeView->getRoot()); - TreeView->getRoot()->getFirstChild()->setExpanded(true); -} - -void CGUIEditWindow::setSelectedElement(IGUIElement *sel) -{ - // save changes - AttribEditor->updateAttribs(); - IGUITreeViewNode* elementTreeNode = getTreeNode(sel, TreeView->getRoot()); - - if (elementTreeNode) - { - elementTreeNode->setSelected(true); - while (elementTreeNode) - { - elementTreeNode->setExpanded(true); - elementTreeNode = elementTreeNode->getParent(); - } - } - - io::IAttributes* Attribs = AttribEditor->getAttribs(); - - if (SelectedElement && sel != SelectedElement) - { - // deserialize attributes - SelectedElement->deserializeAttributes(Attribs); - } - // clear the attributes list - Attribs->clear(); - SelectedElement = sel; - - // get the new attributes - if (SelectedElement) - SelectedElement->serializeAttributes(Attribs); - - AttribEditor->refreshAttribs(); -} - -//! draws the element and its children. -//! same code as for a window -void CGUIEditWindow::draw() -{ - if (!IsVisible) - return; - - IGUISkin* skin = Environment->getSkin(); - - core::rect rect = AbsoluteRect; - - // draw body fast - rect = skin->draw3DWindowBackground(this, true, skin->getColor(EGDC_ACTIVE_BORDER), - AbsoluteRect, &AbsoluteClippingRect); - - if (Text.size()) - { - rect.UpperLeftCorner.X += skin->getSize(EGDS_TEXT_DISTANCE_X); - rect.UpperLeftCorner.Y += skin->getSize(EGDS_TEXT_DISTANCE_Y); - rect.LowerRightCorner.X -= skin->getSize(EGDS_WINDOW_BUTTON_WIDTH) + 5; - - IGUIFont* font = skin->getFont(); - if (font) - font->draw(Text.c_str(), rect, skin->getColor(EGDC_ACTIVE_CAPTION), false, true, &AbsoluteClippingRect); - } - - IGUIElement::draw(); -} - - -//! called if an event happened. -bool CGUIEditWindow::OnEvent(const SEvent &event) -{ - switch(event.EventType) - { - case EET_GUI_EVENT: - switch(event.GUIEvent.EventType) - { - case EGET_ELEMENT_FOCUS_LOST: - if (event.GUIEvent.Caller == this || - event.GUIEvent.Caller == ResizeButton) - { - Dragging = false; - Resizing = false; - } - break; - 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; - - IGUIElement* clickedElement = getElementFromPoint(DragStart); - - if (clickedElement == this) - { - Dragging = IsDraggable; - //Environment->setFocus(this); - if (Parent) - Parent->bringToFront(this); - return true; - } - else if (clickedElement == ResizeButton) - { - Resizing = true; - //Environment->setFocus(this); - if (Parent) - Parent->bringToFront(this); - return true; - } - break; - } - case EMIE_LMOUSE_LEFT_UP: - if (Dragging || Resizing) - { - Dragging = false; - Resizing = false; - return true; - } - break; - case EMIE_MOUSE_MOVED: - if (Dragging || Resizing) - { - // gui window should not be dragged outside of 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; - core::position2di diff(event.MouseInput.X - DragStart.X, event.MouseInput.Y - DragStart.Y); - if (Dragging) - { - move(diff); - DragStart.X = event.MouseInput.X; - DragStart.Y = event.MouseInput.Y; - } - else if (Resizing) - { - core::position2di dp = RelativeRect.LowerRightCorner + diff; - setRelativePosition(core::rect(RelativeRect.UpperLeftCorner, dp)); - DragStart += dp - RelativeRect.LowerRightCorner + diff; - } - - return true; - } - break; - default: - break; - } - default: - break; - } - - return Parent ? Parent->OnEvent(event) : false; -} - -bool CGUIEditWindow::isDraggable() const -{ - return IsDraggable; -} - -void CGUIEditWindow::setDraggable(bool draggable) -{ - IsDraggable = draggable; - - if (Dragging && !IsDraggable) - Dragging = false; -} - - -// we're supposed to supply these if we're creating an IGUIWindow -// but we don't need them so we'll just return null - -//! Returns the rectangle of the drawable area (without border, without titlebar and without scrollbars) -core::rect CGUIEditWindow::getClientRect() const {return core::recti();} -IGUIButton* CGUIEditWindow::getCloseButton() const {return 0;} -IGUIButton* CGUIEditWindow::getMinimizeButton() const {return 0;} -IGUIButton* CGUIEditWindow::getMaximizeButton() const {return 0;} + +#include "CGUIEditWindow.h" +#include "IGUISkin.h" +#include "IGUIEnvironment.h" +#include "IGUIElementFactory.h" +#include "IAttributes.h" +#include "IGUIFont.h" +#include "IGUITabControl.h" +#include "IGUITreeView.h" +#include "CGUIEditWorkspace.h" + +using namespace irr; +using namespace gui; + +//! constructor +CGUIEditWindow::CGUIEditWindow(IGUIEnvironment* environment, core::rect rectangle, IGUIElement *parent) + : IGUIWindow(environment, parent, -1, rectangle), + Dragging(false), IsDraggable(true), Resizing(false), SelectedElement(0), + AttribEditor(0), OptionEditor(0), EnvEditor(0) +{ + #ifdef _DEBUG + setDebugName("CGUIEditWindow"); + #endif + + // we can't tab out of this window + setTabGroup(true); + // we can ctrl+tab to it + setTabStop(true); + // the tab order number is auto-assigned + setTabOrder(-1); + + // set window text + setText(L"GUI Editor"); + + // return if we have no skin. + IGUISkin *skin = environment->getSkin(); + if (!skin) + return; + + s32 th = skin->getSize(EGDS_WINDOW_BUTTON_WIDTH); + + setRelativePosition(core::rect(50,50,250,500)); + setMinSize(core::dimension2du(200,200)); + + IGUITabControl *TabControl = environment->addTabControl(core::rect(1,th+5,199,449), this, false, true); + TabControl->setSubElement(true); + TabControl->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT); + + TabControl->addTab(L"Tools"); + //L"Texture Cache Browser" + //L"Font Browser" + //L"Font Generator" + //L"Sprite Editor" + //Environment->addGUIElement("textureCacheBrowser", this); + + IGUITab* EditorTab = TabControl->addTab(L"Editor"); + OptionEditor = (CGUIAttributeEditor*) environment->addGUIElement("attributeEditor", EditorTab); + OptionEditor->grab(); + OptionEditor->setID(EGUIEDCE_OPTION_EDITOR); + OptionEditor->setRelativePositionProportional(core::rect(0.0f, 0.0f, 1.0f, 1.0f)); + OptionEditor->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT); + + if (Parent && Parent->getParent() == Environment->getRootGUIElement()) + { + IGUITab* EnvTab = TabControl->addTab(L"Env"); + EnvEditor = (CGUIAttributeEditor*) environment->addGUIElement("attributeEditor", EnvTab); + EnvEditor->grab(); + EnvEditor->setID(EGUIEDCE_ENV_EDITOR); + EnvEditor->setRelativePositionProportional(core::rect(0.0f, 0.0f, 1.0f, 1.0f)); + EnvEditor->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT); + } + IGUITab* ElementTab = TabControl->addTab(L"Element"); + + AttribEditor = (CGUIAttributeEditor*) environment->addGUIElement("attributeEditor", ElementTab); + AttribEditor->grab(); + AttribEditor->setID(EGUIEDCE_ATTRIB_EDITOR); + AttribEditor->setRelativePositionProportional(core::rect(0.0f, 0.0f, 1.0f, 1.0f)); + AttribEditor->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT); + + IGUITab* TreeTab = TabControl->addTab(L"Tree"); + TreeView = environment->addTreeView(core::rect(0,0,0,0), TreeTab); + TreeView->setRelativePositionProportional(core::rect(0.0f, 0.0f, 1.0f, 1.0f)); + TreeView->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT); + IGUITreeViewNode* treenode = TreeView->getRoot(); + //treenode->addChildFront(L"Elements"); + ResizeButton = environment->addButton(core::rect(199-th,449-th,199,449), this); + ResizeButton->setDrawBorder(false); + ResizeButton->setEnabled(false); + ResizeButton->setSpriteBank(skin->getSpriteBank()); + ResizeButton->setSprite(EGBS_BUTTON_UP, skin->getIcon(EGDI_WINDOW_RESIZE), skin->getColor(EGDC_WINDOW_SYMBOL)); + ResizeButton->setSprite(EGBS_BUTTON_DOWN, skin->getIcon(EGDI_WINDOW_RESIZE), skin->getColor(EGDC_WINDOW_SYMBOL)); + ResizeButton->grab(); + ResizeButton->setSubElement(true); + ResizeButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT); + updateTree(); +} + + +//! destructor +CGUIEditWindow::~CGUIEditWindow() +{ + // drop everything + if (AttribEditor) + AttribEditor->drop(); + if (EnvEditor) + EnvEditor->drop(); + if (OptionEditor) + OptionEditor->drop(); + if (ResizeButton) + ResizeButton->drop(); +} + +IGUITreeView* CGUIEditWindow::getTreeView() const +{ + return TreeView; +} +CGUIAttributeEditor* CGUIEditWindow::getEnvironmentEditor() const +{ + return EnvEditor; +} + +CGUIAttributeEditor* CGUIEditWindow::getAttributeEditor() const +{ + return AttribEditor; +} + +CGUIAttributeEditor* CGUIEditWindow::getOptionEditor() const +{ + return OptionEditor; +} + +IGUITreeViewNode* CGUIEditWindow::getTreeNode(IGUIElement* element, IGUITreeViewNode* searchnode) +{ + IGUITreeViewNode* child = searchnode->getFirstChild(); + while (child) + { + if (((IGUIElement*) child->getData()) == element) + return child; + + if (child->hasChildren()) + { + IGUITreeViewNode* foundnode = getTreeNode(element, child); + if (foundnode) + return foundnode; + } + child = child->getNextSibling(); + } + return 0; +} + +void CGUIEditWindow::addChildrenToTree(IGUIElement* parentElement, IGUITreeViewNode* treenode) +{ + core::stringw name = core::stringw(parentElement->getTypeName()); + if (parentElement->getID() != -1) + name += core::stringw(L" [") + core::stringw(parentElement->getID()) + core::stringw(L"]"); + + IGUITreeViewNode* newnode = treenode->addChildBack(name.c_str()); + newnode->setData((void*)parentElement); + core::list children = parentElement->getChildren(); + + for (core::list::Iterator i = children.begin(); i != children.end(); i++ ) + { + if(core::stringc((*i)->getTypeName()) != "GUIEditor" && !(*i)->isSubElement()) + addChildrenToTree(*i, newnode); + } +} + +void CGUIEditWindow::updateTree() +{ + TreeView->getRoot()->clearChildren(); + IGUIElement* root = Environment->getRootGUIElement(); + addChildrenToTree(root, TreeView->getRoot()); + TreeView->getRoot()->getFirstChild()->setExpanded(true); +} + +void CGUIEditWindow::setSelectedElement(IGUIElement *sel) +{ + // save changes + AttribEditor->updateAttribs(); + IGUITreeViewNode* elementTreeNode = getTreeNode(sel, TreeView->getRoot()); + + if (elementTreeNode) + { + elementTreeNode->setSelected(true); + while (elementTreeNode) + { + elementTreeNode->setExpanded(true); + elementTreeNode = elementTreeNode->getParent(); + } + } + + io::IAttributes* Attribs = AttribEditor->getAttribs(); + + if (SelectedElement && sel != SelectedElement) + { + // deserialize attributes + SelectedElement->deserializeAttributes(Attribs); + } + // clear the attributes list + Attribs->clear(); + SelectedElement = sel; + + // get the new attributes + if (SelectedElement) + SelectedElement->serializeAttributes(Attribs); + + AttribEditor->refreshAttribs(); +} + +//! draws the element and its children. +//! same code as for a window +void CGUIEditWindow::draw() +{ + if (!IsVisible) + return; + + IGUISkin* skin = Environment->getSkin(); + + core::rect rect = AbsoluteRect; + + // draw body fast + rect = skin->draw3DWindowBackground(this, true, skin->getColor(EGDC_ACTIVE_BORDER), + AbsoluteRect, &AbsoluteClippingRect); + + if (Text.size()) + { + rect.UpperLeftCorner.X += skin->getSize(EGDS_TEXT_DISTANCE_X); + rect.UpperLeftCorner.Y += skin->getSize(EGDS_TEXT_DISTANCE_Y); + rect.LowerRightCorner.X -= skin->getSize(EGDS_WINDOW_BUTTON_WIDTH) + 5; + + IGUIFont* font = skin->getFont(); + if (font) + font->draw(Text.c_str(), rect, skin->getColor(EGDC_ACTIVE_CAPTION), false, true, &AbsoluteClippingRect); + } + + IGUIElement::draw(); +} + + +//! called if an event happened. +bool CGUIEditWindow::OnEvent(const SEvent &event) +{ + switch(event.EventType) + { + case EET_GUI_EVENT: + switch(event.GUIEvent.EventType) + { + case EGET_ELEMENT_FOCUS_LOST: + if (event.GUIEvent.Caller == this || + event.GUIEvent.Caller == ResizeButton) + { + Dragging = false; + Resizing = false; + } + break; + 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; + + IGUIElement* clickedElement = getElementFromPoint(DragStart); + + if (clickedElement == this) + { + Dragging = IsDraggable; + //Environment->setFocus(this); + if (Parent) + Parent->bringToFront(this); + return true; + } + else if (clickedElement == ResizeButton) + { + Resizing = true; + //Environment->setFocus(this); + if (Parent) + Parent->bringToFront(this); + return true; + } + break; + } + case EMIE_LMOUSE_LEFT_UP: + if (Dragging || Resizing) + { + Dragging = false; + Resizing = false; + return true; + } + break; + case EMIE_MOUSE_MOVED: + if (Dragging || Resizing) + { + // gui window should not be dragged outside of 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; + core::position2di diff(event.MouseInput.X - DragStart.X, event.MouseInput.Y - DragStart.Y); + if (Dragging) + { + move(diff); + DragStart.X = event.MouseInput.X; + DragStart.Y = event.MouseInput.Y; + } + else if (Resizing) + { + core::position2di dp = RelativeRect.LowerRightCorner + diff; + setRelativePosition(core::rect(RelativeRect.UpperLeftCorner, dp)); + DragStart += dp - RelativeRect.LowerRightCorner + diff; + } + + return true; + } + break; + default: + break; + } + default: + break; + } + + return Parent ? Parent->OnEvent(event) : false; +} + +bool CGUIEditWindow::isDraggable() const +{ + return IsDraggable; +} + +void CGUIEditWindow::setDraggable(bool draggable) +{ + IsDraggable = draggable; + + if (Dragging && !IsDraggable) + Dragging = false; +} + + +// we're supposed to supply these if we're creating an IGUIWindow +// but we don't need them so we'll just return null + +//! Returns the rectangle of the drawable area (without border, without titlebar and without scrollbars) +core::rect CGUIEditWindow::getClientRect() const {return core::recti();} +IGUIButton* CGUIEditWindow::getCloseButton() const {return 0;} +IGUIButton* CGUIEditWindow::getMinimizeButton() const {return 0;} +IGUIButton* CGUIEditWindow::getMaximizeButton() const {return 0;} diff --git a/libraries/irrlicht-1.8/tools/GUIEditor/CGUIEditWindow.h b/libraries/irrlicht-1.8/tools/GUIEditor/CGUIEditWindow.h index 4b1d72f..07eb28b 100644 --- a/libraries/irrlicht-1.8/tools/GUIEditor/CGUIEditWindow.h +++ b/libraries/irrlicht-1.8/tools/GUIEditor/CGUIEditWindow.h @@ -1,88 +1,88 @@ -#ifndef __C_GUI_EDITOR_H_INCLUDED__ -#define __C_GUI_EDITOR_H_INCLUDED__ - - -#include "IGUIWindow.h" -#include "CGUIAttributeEditor.h" -//#include "IGUIStaticText.h" -#include "IGUIButton.h" -#include "IGUITreeView.h" -#include "irrArray.h" -#include "IAttributes.h" -#include "EGUIEditTypes.h" - -namespace irr -{ -namespace gui -{ - class CGUIEditWindow : public IGUIWindow - { - public: - - //! constructor - CGUIEditWindow(IGUIEnvironment* environment, core::rect rectangle, IGUIElement *parent); - - //! destructor - ~CGUIEditWindow(); - - //! this part draws the window - virtual void draw(); - //! handles events - virtual bool OnEvent(const SEvent &event); - - //! change selection - virtual void setSelectedElement(IGUIElement *sel); - - //! get draggable - virtual bool isDraggable() const; - - //! get draggable - virtual void setDraggable(bool draggable); - - // not used - virtual core::rect getClientRect() const; - virtual IGUIButton* getCloseButton() const; - virtual IGUIButton* getMinimizeButton() const; - virtual IGUIButton* getMaximizeButton() const; - virtual void setDrawBackground(bool draw) { } - virtual bool getDrawBackground() const { return true; } - virtual void setDrawTitlebar(bool draw) { } - virtual bool getDrawTitlebar() const { return true; } - - IGUITreeView* getTreeView() const; - CGUIAttributeEditor* getAttributeEditor() const; - CGUIAttributeEditor* getOptionEditor() const; - CGUIAttributeEditor* getEnvironmentEditor() const; - - //! Returns the type name of the gui element. - virtual const c8* getTypeName() const - { - return GUIEditElementTypeNames[EGUIEDIT_GUIEDITWINDOW]; - } - - void updateTree(); - private: - - void addChildrenToTree(IGUIElement* parentElement, IGUITreeViewNode* treenode); - IGUITreeViewNode* getTreeNode(IGUIElement* element, IGUITreeViewNode* searchnode); - // for dragging the window - bool Dragging; - bool IsDraggable; - bool Resizing; - core::position2d DragStart; - - IGUIElement* SelectedElement; // current selected element - - CGUIAttributeEditor* AttribEditor; // edits the current attribute - CGUIAttributeEditor* OptionEditor; // edits the options for the window - CGUIAttributeEditor* EnvEditor; // edits attributes for the environment - IGUITreeView* TreeView; // tree view of all elements in scene - IGUIButton* ResizeButton; - - }; - -} // end namespace gui -} // end namespace irr - -#endif // __C_GUI_EDITOR_H_INCLUDED__ - +#ifndef __C_GUI_EDITOR_H_INCLUDED__ +#define __C_GUI_EDITOR_H_INCLUDED__ + + +#include "IGUIWindow.h" +#include "CGUIAttributeEditor.h" +//#include "IGUIStaticText.h" +#include "IGUIButton.h" +#include "IGUITreeView.h" +#include "irrArray.h" +#include "IAttributes.h" +#include "EGUIEditTypes.h" + +namespace irr +{ +namespace gui +{ + class CGUIEditWindow : public IGUIWindow + { + public: + + //! constructor + CGUIEditWindow(IGUIEnvironment* environment, core::rect rectangle, IGUIElement *parent); + + //! destructor + ~CGUIEditWindow(); + + //! this part draws the window + virtual void draw(); + //! handles events + virtual bool OnEvent(const SEvent &event); + + //! change selection + virtual void setSelectedElement(IGUIElement *sel); + + //! get draggable + virtual bool isDraggable() const; + + //! get draggable + virtual void setDraggable(bool draggable); + + // not used + virtual core::rect getClientRect() const; + virtual IGUIButton* getCloseButton() const; + virtual IGUIButton* getMinimizeButton() const; + virtual IGUIButton* getMaximizeButton() const; + virtual void setDrawBackground(bool draw) { } + virtual bool getDrawBackground() const { return true; } + virtual void setDrawTitlebar(bool draw) { } + virtual bool getDrawTitlebar() const { return true; } + + IGUITreeView* getTreeView() const; + CGUIAttributeEditor* getAttributeEditor() const; + CGUIAttributeEditor* getOptionEditor() const; + CGUIAttributeEditor* getEnvironmentEditor() const; + + //! Returns the type name of the gui element. + virtual const c8* getTypeName() const + { + return GUIEditElementTypeNames[EGUIEDIT_GUIEDITWINDOW]; + } + + void updateTree(); + private: + + void addChildrenToTree(IGUIElement* parentElement, IGUITreeViewNode* treenode); + IGUITreeViewNode* getTreeNode(IGUIElement* element, IGUITreeViewNode* searchnode); + // for dragging the window + bool Dragging; + bool IsDraggable; + bool Resizing; + core::position2d DragStart; + + IGUIElement* SelectedElement; // current selected element + + CGUIAttributeEditor* AttribEditor; // edits the current attribute + CGUIAttributeEditor* OptionEditor; // edits the options for the window + CGUIAttributeEditor* EnvEditor; // edits attributes for the environment + IGUITreeView* TreeView; // tree view of all elements in scene + IGUIButton* ResizeButton; + + }; + +} // end namespace gui +} // end namespace irr + +#endif // __C_GUI_EDITOR_H_INCLUDED__ + diff --git a/libraries/irrlicht-1.8/tools/GUIEditor/CGUIEditWorkspace.cpp b/libraries/irrlicht-1.8/tools/GUIEditor/CGUIEditWorkspace.cpp index a45e5d3..7b09136 100644 --- a/libraries/irrlicht-1.8/tools/GUIEditor/CGUIEditWorkspace.cpp +++ b/libraries/irrlicht-1.8/tools/GUIEditor/CGUIEditWorkspace.cpp @@ -1,927 +1,927 @@ -// Copyright (C) 2002-2012 Nikolaus Gebhardt / Gaz Davidson -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -// Thanks to Midnight for all his testing, bug fixes and patches :) - -#include "CGUIEditWorkspace.h" -#include "IGUIEnvironment.h" -#include "IVideoDriver.h" -#include "IOSOperator.h" -#include "IReadFile.h" -#include "IFileSystem.h" -#include "IXMLWriter.h" -#include "IGUISkin.h" -#include "IGUIElementFactory.h" -#include "CGUIEditWindow.h" -#include "IGUIContextMenu.h" -#include "IGUIFileOpenDialog.h" -#include "IGUITreeView.h" -#include "CGUIAttribute.h" -#include "CMemoryReadWriteFile.h" - -namespace irr -{ -namespace gui -{ - -//! constructor -CGUIEditWorkspace::CGUIEditWorkspace(IGUIEnvironment* environment, s32 id, IGUIElement *parent) -: IGUIElement(EGUIET_ELEMENT, environment, parent ? parent : environment->getRootGUIElement(), id, environment->getRootGUIElement()->getAbsolutePosition()), - CurrentMode(EGUIEDM_SELECT), MouseOverMode(EGUIEDM_SELECT), - GridSize(10,10), MenuCommandStart(0x3D17), DrawGrid(false), UseGrid(true), - MouseOverElement(0), SelectedElement(0), EditorWindow(0) -{ - #ifdef _DEBUG - setDebugName("CGUIEditWorkspace"); - #endif - - // this element is never saved. - setSubElement(true); - - // it resizes to fit a resizing window - setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT); - - EditorWindow = (CGUIEditWindow*) Environment->addGUIElement("GUIEditWindow", this); - if (EditorWindow) - { - EditorWindow->grab(); - EditorWindow->setSubElement(true); - - Environment->setFocus(EditorWindow); - serializeAttributes(EditorWindow->getOptionEditor()->getAttribs()); - EditorWindow->getOptionEditor()->refreshAttribs(); - - if (EditorWindow->getEnvironmentEditor()) - { - Environment->serializeAttributes(EditorWindow->getEnvironmentEditor()->getAttribs()); - EditorWindow->getEnvironmentEditor()->refreshAttribs(); - } - } -} - - -//! destructor -CGUIEditWorkspace::~CGUIEditWorkspace() -{ - if (EditorWindow) - EditorWindow->drop(); -} - - -void CGUIEditWorkspace::setMenuCommandIDStart(s32 id) -{ - MenuCommandStart = id; -} - -CGUIEditWorkspace::EGUIEDIT_MODE CGUIEditWorkspace::getModeFromPos(core::position2di p) -{ - if (SelectedElement) - { - core::rect r = SelectedElement->getAbsolutePosition(); - - if (TLRect.isPointInside(p)) - return EGUIEDM_RESIZE_TL; - - else if (TRRect.isPointInside(p)) - return EGUIEDM_RESIZE_TR; - - else if (BLRect.isPointInside(p) ) - return EGUIEDM_RESIZE_BL; - - else if (BRRect.isPointInside(p)) - return EGUIEDM_RESIZE_BR; - - else if (TopRect.isPointInside(p)) - return EGUIEDM_RESIZE_T; - - else if (BRect.isPointInside(p)) - return EGUIEDM_RESIZE_B; - - else if (LRect.isPointInside(p)) - return EGUIEDM_RESIZE_L; - - else if (RRect.isPointInside(p)) - return EGUIEDM_RESIZE_R; - - else if (getEditableElementFromPoint(SelectedElement, p) == SelectedElement) - return EGUIEDM_MOVE; - - else - return EGUIEDM_SELECT; - } - - return EGUIEDM_SELECT; - -} - -IGUIElement* CGUIEditWorkspace::getEditableElementFromPoint(IGUIElement *start, const core::position2di &point, s32 index ) -{ - IGUIElement* target = 0; - - // we have to search from back to front. - - core::list::ConstIterator it = start->getChildren().getLast(); - s32 count=0; - while(it != start->getChildren().end()) - { - target = getEditableElementFromPoint((*it),point); - if (target) - { - if (!target->isSubElement() && !isMyChild(target) && target != this) - { - if (index == count) - return target; - else - count++; - } - else - target = 0; - } - --it; - } - - if (start->getAbsolutePosition().isPointInside(point)) - target = start; - - return target; -} - -void CGUIEditWorkspace::setSelectedElement(IGUIElement *sel) -{ - IGUIElement* focus = Environment->getFocus(); - // we only give focus back to children - if (!isMyChild(focus)) - focus = 0; - - if (SelectedElement != Parent) - { - if (SelectedElement != sel && EditorWindow) - { - EditorWindow->setSelectedElement(sel); - SelectedElement = sel; - } - } - else - SelectedElement = 0; - - if (focus) - Environment->setFocus(focus); - else - Environment->setFocus(this); -} - -IGUIElement* CGUIEditWorkspace::getSelectedElement() -{ - return SelectedElement; -} -void CGUIEditWorkspace::selectNextSibling() -{ - IGUIElement* p=0; - - if (SelectedElement && SelectedElement->getParent()) - p = SelectedElement->getParent(); - else - p = Parent; - - core::list::ConstIterator it = p->getChildren().begin(); - // find selected element - if (SelectedElement) - while (*it != SelectedElement) - ++it; - if (it !=p->getChildren().end()) - ++it; - // find next non sub-element - while (it != p->getChildren().end() && (*it)->isSubElement()) - ++it; - - if (it != p->getChildren().end()) - setSelectedElement(*it); -} -void CGUIEditWorkspace::selectPreviousSibling() -{ - IGUIElement* p=0; - - if (SelectedElement && SelectedElement->getParent()) - p = SelectedElement->getParent(); - else - p = Parent; - - core::list::ConstIterator it = p->getChildren().getLast(); - // find selected element - if (SelectedElement) - while (*it != SelectedElement) - --it; - if (it != p->getChildren().end()) - --it; - // find next non sub-element - while (it != p->getChildren().end() && (*it)->isSubElement()) - --it; - - if (it != p->getChildren().end()) - setSelectedElement(*it); -} - -//! called if an event happened. -bool CGUIEditWorkspace::OnEvent(const SEvent &e) -{ - IGUIFileOpenDialog* dialog=0; - switch(e.EventType) - { - case ATTRIBEDIT_ATTRIB_CHANGED: - { - switch (e.UserEvent.UserData1) - { - case EGUIEDCE_ATTRIB_EDITOR: - { - // update selected items attributes - if (SelectedElement) - { - SelectedElement->deserializeAttributes(EditorWindow->getAttributeEditor()->getAttribs()); - EditorWindow->updateTree(); - } - return true; - } - case EGUIEDCE_OPTION_EDITOR: - { - // update editor options - deserializeAttributes(EditorWindow->getOptionEditor()->getAttribs()); - return true; - } - case EGUIEDCE_ENV_EDITOR: - { - // update environment - Environment->deserializeAttributes(EditorWindow->getEnvironmentEditor()->getAttribs()); - return true; - } - } - } - break; - - case EET_KEY_INPUT_EVENT: - if (!e.KeyInput.PressedDown) - { - switch (e.KeyInput.Key) - { - case KEY_DELETE: - if (SelectedElement) - { - IGUIElement* el = SelectedElement; - setSelectedElement(0); - MouseOverElement = 0; - el->remove(); - EditorWindow->updateTree(); - } - break; - case KEY_KEY_X: - if (e.KeyInput.Control && SelectedElement) - { - // cut - CopySelectedElementXML(); - // delete element - IGUIElement *el = SelectedElement; - setSelectedElement(0); - MouseOverElement = 0; - el->remove(); - } - break; - case KEY_KEY_C: - // copy - if (e.KeyInput.Control && SelectedElement) - { - CopySelectedElementXML(); - } - break; - case KEY_KEY_V: - // paste - if (e.KeyInput.Control) - { - PasteXMLToSelectedElement(); - } - break; - default: - break; - } - - return true; - } - break; - - case EET_MOUSE_INPUT_EVENT: - - switch(e.MouseInput.Event) - { - case EMIE_MOUSE_WHEEL: - { - f32 wheel = e.MouseInput.Wheel; - - if (wheel > 0) - selectPreviousSibling(); - else - selectNextSibling(); - } - break; - case EMIE_LMOUSE_PRESSED_DOWN: - { - core::position2di p = core::position2di(e.MouseInput.X,e.MouseInput.Y); - - IGUIElement* newSelection = getElementFromPoint(p); - - if (newSelection != this && isMyChild(newSelection) ) // redirect event - { - Environment->setFocus(newSelection); - return true; - } - - // hide the gui editor - if (EditorWindow) - EditorWindow->setVisible(false); - - if (CurrentMode == EGUIEDM_SELECT) - { - if (SelectedElement) - { - // start moving or dragging - CurrentMode = getModeFromPos(p); - - if (CurrentMode == EGUIEDM_MOVE) - StartMovePos = SelectedElement->getAbsolutePosition().UpperLeftCorner; - - DragStart = p; - SelectedArea = SelectedElement->getAbsolutePosition(); - } - - if (CurrentMode < EGUIEDM_MOVE) - { - // selecting an element... - MouseOverElement = getEditableElementFromPoint(Parent, p); - - if (MouseOverElement == Parent) - MouseOverElement = 0; - - setSelectedElement(MouseOverElement); - } - } - - break; - } - case EMIE_RMOUSE_PRESSED_DOWN: - if (CurrentMode == EGUIEDM_SELECT_NEW_PARENT || CurrentMode >= EGUIEDM_MOVE) - { - // cancel dragging - CurrentMode = EGUIEDM_SELECT; - } - else - { - DragStart = core::position2di(e.MouseInput.X,e.MouseInput.Y); - // root menu - IGUIContextMenu* mnu = Environment->addContextMenu( - core::rect(e.MouseInput.X, e.MouseInput.Y, e.MouseInput.Y+100, e.MouseInput.Y+100),this); - mnu->addItem(L"File",-1,true,true); - mnu->addItem(L"Edit",-1,true,true); - mnu->addItem(L"View",-1,true,true); - mnu->addItem(SelectedElement ? L"Add child" : L"Add" ,-1,true,true); - - // file menu - IGUIContextMenu* sub = mnu->getSubMenu(0); - IGUIContextMenu* sub2 =0; - - sub->addItem(L"New", MenuCommandStart + EGUIEDMC_FILE_NEW ); - sub->addItem(L"Load...",MenuCommandStart + EGUIEDMC_FILE_LOAD); - sub->addItem(L"Save...",MenuCommandStart + EGUIEDMC_FILE_SAVE); - - // edit menu - sub = mnu->getSubMenu(1); - sub->addItem(L"Cut (ctrl+x)", MenuCommandStart + EGUIEDMC_CUT_ELEMENT, (SelectedElement != 0)); - sub->addItem(L"Copy (ctrl+c)", MenuCommandStart + EGUIEDMC_COPY_ELEMENT, (SelectedElement != 0)); - sub->addItem(L"Paste (ctrl+v)", MenuCommandStart + EGUIEDMC_PASTE_ELEMENT, - (core::stringc(Environment->getOSOperator()->getTextFromClipboard()) != "")); - sub->addItem(L"Delete (del)", MenuCommandStart + EGUIEDMC_DELETE_ELEMENT, (SelectedElement != 0)); - sub->addSeparator(); - sub->addItem(L"Set parent", MenuCommandStart + EGUIEDMC_SET_PARENT, (SelectedElement != 0)); - sub->addItem(L"Bring to front", MenuCommandStart + EGUIEDMC_BRING_TO_FRONT, (SelectedElement != 0)); - sub->addSeparator(); - sub->addItem(L"Save to XML...", MenuCommandStart + EGUIEDMC_SAVE_ELEMENT, (SelectedElement != 0)); - - sub = mnu->getSubMenu(2); - // view menu - if (EditorWindow) - sub->addItem(EditorWindow->isVisible() ? L"Hide window" : L"Show window", MenuCommandStart + EGUIEDMC_TOGGLE_EDITOR); - - sub = mnu->getSubMenu(3); - - s32 i,j,c=0; - sub->addItem(L"Default factory",-1,true, true); - - // add elements from each factory - for (i=0; u32(i) < Environment->getRegisteredGUIElementFactoryCount(); ++i) - { - sub2 = sub->getSubMenu(i); - - IGUIElementFactory *f = Environment->getGUIElementFactory(i); - - for (j=0; j< f->getCreatableGUIElementTypeCount(); ++j) - { - sub2->addItem(core::stringw(f->getCreateableGUIElementTypeName(j)).c_str(), MenuCommandStart + EGUIEDMC_COUNT + c); - c++; - } - - if (u32(i+1) < Environment->getRegisteredGUIElementFactoryCount()) - { - core::stringw strFact; - strFact = L"Factory "; - strFact += i+1; - sub->addItem(strFact.c_str(),-1, true, true); - } - } - sub->addSeparator(); - sub->addItem(L"From XML...", MenuCommandStart + EGUIEDMC_INSERT_XML); - - // set focus to menu - Environment->setFocus(mnu); - - } - break; - case EMIE_LMOUSE_LEFT_UP: - - // make window visible again - if (EditorWindow) - EditorWindow->setVisible(true); - if (CurrentMode == EGUIEDM_SELECT_NEW_PARENT) - { - if (SelectedElement) - { - MouseOverElement = getEditableElementFromPoint(Parent, - core::position2di(e.MouseInput.X,e.MouseInput.Y)); - if (MouseOverElement) - { - MouseOverElement->addChild(SelectedElement); - setSelectedElement(0); - setSelectedElement(SelectedElement); - } - } - CurrentMode = EGUIEDM_SELECT; - } - else if (CurrentMode >= EGUIEDM_MOVE) - { - IGUIElement *sel = SelectedElement; - // unselect - setSelectedElement(0); - - // move - core::position2d p(0,0); - if (sel->getParent()) - p = sel->getParent()->getAbsolutePosition().UpperLeftCorner; - - sel->setRelativePosition(SelectedArea - p); - - // select - setSelectedElement(sel); - - // reset selection mode... - CurrentMode = EGUIEDM_SELECT; - } - break; - case EMIE_MOUSE_MOVED: - // always on top - Parent->bringToFront(this); - - // if selecting - if (CurrentMode == EGUIEDM_SELECT || CurrentMode == EGUIEDM_SELECT_NEW_PARENT) - { - - core::position2di p = core::position2di(e.MouseInput.X,e.MouseInput.Y); - - // highlight the element that the mouse is over - MouseOverElement = getEditableElementFromPoint(Parent, p); - if (MouseOverElement == Parent) - { - MouseOverElement = 0; - } - - if (CurrentMode == EGUIEDM_SELECT) - { - MouseOverMode = getModeFromPos(p); - if (MouseOverMode > EGUIEDM_MOVE) - { - MouseOverElement = SelectedElement; - } - } - } - else if (CurrentMode == EGUIEDM_MOVE) - { - // get difference - core::position2di p = core::position2di(e.MouseInput.X,e.MouseInput.Y); - p -= DragStart; - - // apply to top corner - p = StartMovePos + p; - if (UseGrid) - { - p.X = (p.X/GridSize.Width)*GridSize.Width; - p.Y = (p.Y/GridSize.Height)*GridSize.Height; - } - - SelectedArea += p - SelectedArea.UpperLeftCorner; - } - else if (CurrentMode > EGUIEDM_MOVE) - { - // get difference from start position - core::position2di p = core::position2di(e.MouseInput.X,e.MouseInput.Y); - if (UseGrid) - { - p.X = (p.X/GridSize.Width)*GridSize.Width; - p.Y = (p.Y/GridSize.Height)*GridSize.Height; - } - - switch(CurrentMode) - { - case EGUIEDM_RESIZE_T: - SelectedArea.UpperLeftCorner.Y = p.Y; - break; - case EGUIEDM_RESIZE_B: - SelectedArea.LowerRightCorner.Y = p.Y; - break; - case EGUIEDM_RESIZE_L: - SelectedArea.UpperLeftCorner.X = p.X; - break; - case EGUIEDM_RESIZE_R: - SelectedArea.LowerRightCorner.X = p.X; - break; - case EGUIEDM_RESIZE_TL: - SelectedArea.UpperLeftCorner = p; - break; - case EGUIEDM_RESIZE_TR: - SelectedArea.UpperLeftCorner.Y = p.Y; - SelectedArea.LowerRightCorner.X = p.X; - break; - case EGUIEDM_RESIZE_BL: - SelectedArea.UpperLeftCorner.X = p.X; - SelectedArea.LowerRightCorner.Y = p.Y; - break; - case EGUIEDM_RESIZE_BR: - SelectedArea.LowerRightCorner = p; - break; - default: - break; - } - } - - break; - default: - break; - } - break; - - case EET_GUI_EVENT: - switch(e.GUIEvent.EventType) - { - case EGET_TREEVIEW_NODE_SELECT: - { - IGUITreeViewNode* eventnode = ((IGUITreeView*)e.GUIEvent.Caller)->getLastEventNode(); - if(!eventnode->isRoot()) - setSelectedElement((IGUIElement*)(eventnode->getData())); - break; - } - // load a gui file - case EGET_FILE_SELECTED: - dialog = (IGUIFileOpenDialog*)e.GUIEvent.Caller; - Environment->loadGUI(core::stringc(dialog->getFileName()).c_str()); - break; - - case EGET_MENU_ITEM_SELECTED: - { - IGUIContextMenu *menu = (IGUIContextMenu*)e.GUIEvent.Caller; - s32 cmdID = menu->getItemCommandId(menu->getSelectedItem()) - MenuCommandStart; - - IGUIElement* el; - - switch(cmdID) - { - - //! file commands - case EGUIEDMC_FILE_NEW: - // clear all elements belonging to our parent - setSelectedElement(0); - MouseOverElement = 0; - el = Parent; - grab(); - // remove all children - while(Children.end() != el->getChildren().begin()) - el->removeChild(*(el->getChildren().begin())); - // attach to parent again - el->addChild(this); - drop(); - - break; - case EGUIEDMC_FILE_LOAD: - Environment->addFileOpenDialog(L"Please select a GUI file to open", false, this); - break; - case EGUIEDMC_FILE_SAVE: - Environment->saveGUI("guiTest.xml"); - break; - - //! edit menu - case EGUIEDMC_CUT_ELEMENT: - { - CopySelectedElementXML(); - // delete element - el = SelectedElement; - setSelectedElement(0); - MouseOverElement = 0; - el->remove(); - break; - } - case EGUIEDMC_COPY_ELEMENT: - CopySelectedElementXML(); - break; - case EGUIEDMC_PASTE_ELEMENT: - PasteXMLToSelectedElement(); - break; - case EGUIEDMC_DELETE_ELEMENT: - el = SelectedElement; - setSelectedElement(0); - MouseOverElement = 0; - el->remove(); - break; - case EGUIEDMC_SET_PARENT: - CurrentMode = EGUIEDM_SELECT_NEW_PARENT; - break; - case EGUIEDMC_BRING_TO_FRONT: - if (SelectedElement->getParent()) - SelectedElement->getParent()->bringToFront(SelectedElement); - break; - - case EGUIEDMC_SAVE_ELEMENT: - //TODO: add 'save' dialog. - Environment->saveGUI("guiTest.xml", SelectedElement ? SelectedElement : Environment->getRootGUIElement() ); - break; - - //! toggle edit window - case EGUIEDMC_TOGGLE_EDITOR: - break; - - case EGUIEDMC_INSERT_XML: - Environment->loadGUI("guiTest.xml", SelectedElement ? SelectedElement : Environment->getRootGUIElement() ); - break; - - default: - // create element from factory? - if (cmdID >= EGUIEDMC_COUNT) - { - - s32 num = cmdID - EGUIEDMC_COUNT; // get index - // loop through all factories - s32 i, c=Environment->getRegisteredGUIElementFactoryCount(); - for (i=0; i Environment->getGUIElementFactory(i)->getCreatableGUIElementTypeCount(); ++i) - { - num -= Environment->getGUIElementFactory(i)->getCreatableGUIElementTypeCount(); - } - if (num < Environment->getGUIElementFactory(i)->getCreatableGUIElementTypeCount() ) - { - core::stringc name = Environment->getGUIElementFactory(i)->getCreateableGUIElementTypeName(num); - IGUIElement *parentElement = SelectedElement ? SelectedElement : Environment->getRootGUIElement(); - // add it - IGUIElement *newElement = Environment->getGUIElementFactory(i)->addGUIElement(name.c_str(),parentElement); - if (newElement) - { - core::position2di p = DragStart - parentElement->getAbsolutePosition().UpperLeftCorner; - newElement->setRelativePosition(core::rect(p,p+core::position2di(100,100))); - //Environment->removeFocus(newElement); - } - } - } - break; - } - EditorWindow->updateTree(); - } - return true; - default: - break; - } - break; - - default: - break; - } - - // even if we didn't absorb the event, - // we never pass events back to the GUI we're editing! - return false; -} - - -//! draws the element and its children -void CGUIEditWorkspace::draw() -{ - video::IVideoDriver *driver = Environment->getVideoDriver(); - - if (DrawGrid) - { - // draw the grid - - core::rect r = getAbsolutePosition(); - - s32 cy = r.UpperLeftCorner.Y; - while (cy < r.LowerRightCorner.Y) - { - s32 cx = r.UpperLeftCorner.X; - while (cx < r.LowerRightCorner.X) - { - driver->draw2DRectangle(video::SColor(40,0,0,90),core::rect(cx+1,cy+1,GridSize.Width+cx,GridSize.Height+cy)); - cx += GridSize.Width; - } - cy += GridSize.Height; - } - } - if (MouseOverElement && - MouseOverElement != SelectedElement && - MouseOverElement != Parent) - { - core::rect r = MouseOverElement->getAbsolutePosition(); - driver->draw2DRectangle(video::SColor(100,0,0,255), r); - } - if (SelectedElement && CurrentMode == EGUIEDM_SELECT) - { - driver->draw2DRectangle(video::SColor(100,0,255,0),SelectedElement->getAbsolutePosition()); - } - if (CurrentMode >= EGUIEDM_MOVE) - { - driver->draw2DRectangle(video::SColor(100,255,0,0),SelectedArea); - } - - if ( (SelectedElement && CurrentMode >= EGUIEDM_MOVE) || - (SelectedElement && MouseOverElement == SelectedElement && MouseOverMode >= EGUIEDM_MOVE) ) - { - // draw handles for moving - EGUIEDIT_MODE m = CurrentMode; - core::rect r = SelectedArea; - if (m < EGUIEDM_MOVE) - { - m = MouseOverMode; - r = SelectedElement->getAbsolutePosition(); - } - - core::position2di d = core::position2di(4,4); - - TLRect = core::rect(r.UpperLeftCorner, r.UpperLeftCorner + d ); - TRRect = core::rect(r.LowerRightCorner.X-4, r.UpperLeftCorner.Y, r.LowerRightCorner.X, r.UpperLeftCorner.Y+4); - TopRect = core::rect(r.getCenter().X-2, r.UpperLeftCorner.Y,r.getCenter().X+2, r.UpperLeftCorner.Y+4 ); - BLRect = core::rect(r.UpperLeftCorner.X, r.LowerRightCorner.Y-4, r.UpperLeftCorner.X+4, r.LowerRightCorner.Y); - LRect = core::rect(r.UpperLeftCorner.X,r.getCenter().Y-2, r.UpperLeftCorner.X+4, r.getCenter().Y+2 ); - RRect = core::rect(r.LowerRightCorner.X-4,r.getCenter().Y-2, r.LowerRightCorner.X, r.getCenter().Y+2 ); - BRRect = core::rect(r.LowerRightCorner-d, r.LowerRightCorner); - BRect = core::rect(r.getCenter().X-2, r.LowerRightCorner.Y-4,r.getCenter().X+2, r.LowerRightCorner.Y ); - - // top left - if (m == EGUIEDM_RESIZE_T || m == EGUIEDM_RESIZE_L || m == EGUIEDM_RESIZE_TL || m == EGUIEDM_MOVE ) - driver->draw2DRectangle(video::SColor(100,255,255,255), TLRect); - - if (m == EGUIEDM_RESIZE_T || m == EGUIEDM_RESIZE_R || m == EGUIEDM_RESIZE_TR || m == EGUIEDM_MOVE ) - driver->draw2DRectangle(video::SColor(100,255,255,255), TRRect); - - if (m == EGUIEDM_RESIZE_T || m == EGUIEDM_MOVE ) - driver->draw2DRectangle(video::SColor(100,255,255,255), TopRect); - - if (m == EGUIEDM_RESIZE_L || m == EGUIEDM_RESIZE_BL || m == EGUIEDM_RESIZE_B || m == EGUIEDM_MOVE ) - driver->draw2DRectangle(video::SColor(100,255,255,255), BLRect); - - if (m == EGUIEDM_RESIZE_L || m == EGUIEDM_MOVE ) - driver->draw2DRectangle(video::SColor(100,255,255,255), LRect); - - if (m == EGUIEDM_RESIZE_R || m == EGUIEDM_MOVE ) - driver->draw2DRectangle(video::SColor(100,255,255,255), RRect); - - if (m == EGUIEDM_RESIZE_R || m == EGUIEDM_RESIZE_BR || m == EGUIEDM_RESIZE_B || m == EGUIEDM_MOVE ) - driver->draw2DRectangle(video::SColor(100,255,255,255), BRRect ); - - if (m == EGUIEDM_RESIZE_B || m == EGUIEDM_MOVE ) - driver->draw2DRectangle(video::SColor(100,255,255,255), BRect); - - - } - - IGUIElement::draw(); -} - - -void CGUIEditWorkspace::setDrawGrid(bool drawGrid) -{ - DrawGrid = drawGrid; -} - -void CGUIEditWorkspace::setGridSize(const core::dimension2di& gridSize) -{ - GridSize = gridSize; - if (GridSize.Width < 2) - GridSize.Width = 2; - if (GridSize.Height < 2) - GridSize.Height = 2; -} - -void CGUIEditWorkspace::setUseGrid(bool useGrid) -{ - UseGrid = useGrid; -} - - -//! Removes a child. -void CGUIEditWorkspace::removeChild(IGUIElement* child) -{ - IGUIElement::removeChild(child); - - if (Children.empty()) - remove(); -} - - -void CGUIEditWorkspace::updateAbsolutePosition() -{ - core::rect 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(); -} - -void CGUIEditWorkspace::CopySelectedElementXML() -{ - core::stringc XMLText; - core::stringw wXMLText; - // create memory write file - io::CMemoryReadWriteFile* memWrite = new io::CMemoryReadWriteFile("#Clipboard#"); - // save gui to mem file - io::IXMLWriter* xml = Environment->getFileSystem()->createXMLWriter(memWrite); - Environment->writeGUIElement(xml, SelectedElement); - - // copy to clipboard- wide chars not supported yet :( - wXMLText = (wchar_t*)&memWrite->getData()[0]; - u32 i = memWrite->getData().size()/sizeof(wchar_t); - if (wXMLText.size() > i) - wXMLText[i] = L'\0'; - XMLText = wXMLText.c_str(); - memWrite->drop(); - xml->drop(); - Environment->getOSOperator()->copyToClipboard(XMLText.c_str()); -} - -void CGUIEditWorkspace::PasteXMLToSelectedElement() -{ - // get clipboard data - core::stringc XMLText = Environment->getOSOperator()->getTextFromClipboard(); - // convert to stringw - core::stringw wXMLText = XMLText.c_str(); - - io::CMemoryReadWriteFile* memWrite = new io::CMemoryReadWriteFile("#Clipboard#"); - - io::IXMLWriter* xmlw = Environment->getFileSystem()->createXMLWriter(memWrite); - xmlw->writeXMLHeader(); // it needs one of those - xmlw->drop(); - - // write clipboard data - memWrite->write((void*)&wXMLText[0], wXMLText.size() * sizeof(wchar_t)); - - // rewind file - memWrite->seek(0, false); - - // read xml - Environment->loadGUI(memWrite, SelectedElement); - - // reset focus - Environment->setFocus(this); - - // drop the read file - memWrite->drop(); -} - -void CGUIEditWorkspace::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) -{ - out->addBool("DrawGrid", DrawGrid); - out->addBool("UseGrid", UseGrid); - out->addPosition2d("GridSize", core::position2di(GridSize.Width, GridSize.Height)); - out->addInt("MenuCommandStart", MenuCommandStart); -} - -void CGUIEditWorkspace::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options) -{ - setDrawGrid(in->getAttributeAsBool("DrawGrid")); - setUseGrid(in->getAttributeAsBool("UseGrid")); - - core::position2di tmpp = in->getAttributeAsPosition2d("GridSize"); - core::dimension2di tmpd(tmpp.X, tmpp.Y); - setGridSize(tmpd); - setMenuCommandIDStart(in->getAttributeAsInt("MenuCommandStart")); -} - - -} // end namespace gui -} // end namespace irr - - +// Copyright (C) 2002-2012 Nikolaus Gebhardt / Gaz Davidson +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +// Thanks to Midnight for all his testing, bug fixes and patches :) + +#include "CGUIEditWorkspace.h" +#include "IGUIEnvironment.h" +#include "IVideoDriver.h" +#include "IOSOperator.h" +#include "IReadFile.h" +#include "IFileSystem.h" +#include "IXMLWriter.h" +#include "IGUISkin.h" +#include "IGUIElementFactory.h" +#include "CGUIEditWindow.h" +#include "IGUIContextMenu.h" +#include "IGUIFileOpenDialog.h" +#include "IGUITreeView.h" +#include "CGUIAttribute.h" +#include "CMemoryReadWriteFile.h" + +namespace irr +{ +namespace gui +{ + +//! constructor +CGUIEditWorkspace::CGUIEditWorkspace(IGUIEnvironment* environment, s32 id, IGUIElement *parent) +: IGUIElement(EGUIET_ELEMENT, environment, parent ? parent : environment->getRootGUIElement(), id, environment->getRootGUIElement()->getAbsolutePosition()), + CurrentMode(EGUIEDM_SELECT), MouseOverMode(EGUIEDM_SELECT), + GridSize(10,10), MenuCommandStart(0x3D17), DrawGrid(false), UseGrid(true), + MouseOverElement(0), SelectedElement(0), EditorWindow(0) +{ + #ifdef _DEBUG + setDebugName("CGUIEditWorkspace"); + #endif + + // this element is never saved. + setSubElement(true); + + // it resizes to fit a resizing window + setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT); + + EditorWindow = (CGUIEditWindow*) Environment->addGUIElement("GUIEditWindow", this); + if (EditorWindow) + { + EditorWindow->grab(); + EditorWindow->setSubElement(true); + + Environment->setFocus(EditorWindow); + serializeAttributes(EditorWindow->getOptionEditor()->getAttribs()); + EditorWindow->getOptionEditor()->refreshAttribs(); + + if (EditorWindow->getEnvironmentEditor()) + { + Environment->serializeAttributes(EditorWindow->getEnvironmentEditor()->getAttribs()); + EditorWindow->getEnvironmentEditor()->refreshAttribs(); + } + } +} + + +//! destructor +CGUIEditWorkspace::~CGUIEditWorkspace() +{ + if (EditorWindow) + EditorWindow->drop(); +} + + +void CGUIEditWorkspace::setMenuCommandIDStart(s32 id) +{ + MenuCommandStart = id; +} + +CGUIEditWorkspace::EGUIEDIT_MODE CGUIEditWorkspace::getModeFromPos(core::position2di p) +{ + if (SelectedElement) + { + core::rect r = SelectedElement->getAbsolutePosition(); + + if (TLRect.isPointInside(p)) + return EGUIEDM_RESIZE_TL; + + else if (TRRect.isPointInside(p)) + return EGUIEDM_RESIZE_TR; + + else if (BLRect.isPointInside(p) ) + return EGUIEDM_RESIZE_BL; + + else if (BRRect.isPointInside(p)) + return EGUIEDM_RESIZE_BR; + + else if (TopRect.isPointInside(p)) + return EGUIEDM_RESIZE_T; + + else if (BRect.isPointInside(p)) + return EGUIEDM_RESIZE_B; + + else if (LRect.isPointInside(p)) + return EGUIEDM_RESIZE_L; + + else if (RRect.isPointInside(p)) + return EGUIEDM_RESIZE_R; + + else if (getEditableElementFromPoint(SelectedElement, p) == SelectedElement) + return EGUIEDM_MOVE; + + else + return EGUIEDM_SELECT; + } + + return EGUIEDM_SELECT; + +} + +IGUIElement* CGUIEditWorkspace::getEditableElementFromPoint(IGUIElement *start, const core::position2di &point, s32 index ) +{ + IGUIElement* target = 0; + + // we have to search from back to front. + + core::list::ConstIterator it = start->getChildren().getLast(); + s32 count=0; + while(it != start->getChildren().end()) + { + target = getEditableElementFromPoint((*it),point); + if (target) + { + if (!target->isSubElement() && !isMyChild(target) && target != this) + { + if (index == count) + return target; + else + count++; + } + else + target = 0; + } + --it; + } + + if (start->getAbsolutePosition().isPointInside(point)) + target = start; + + return target; +} + +void CGUIEditWorkspace::setSelectedElement(IGUIElement *sel) +{ + IGUIElement* focus = Environment->getFocus(); + // we only give focus back to children + if (!isMyChild(focus)) + focus = 0; + + if (SelectedElement != Parent) + { + if (SelectedElement != sel && EditorWindow) + { + EditorWindow->setSelectedElement(sel); + SelectedElement = sel; + } + } + else + SelectedElement = 0; + + if (focus) + Environment->setFocus(focus); + else + Environment->setFocus(this); +} + +IGUIElement* CGUIEditWorkspace::getSelectedElement() +{ + return SelectedElement; +} +void CGUIEditWorkspace::selectNextSibling() +{ + IGUIElement* p=0; + + if (SelectedElement && SelectedElement->getParent()) + p = SelectedElement->getParent(); + else + p = Parent; + + core::list::ConstIterator it = p->getChildren().begin(); + // find selected element + if (SelectedElement) + while (*it != SelectedElement) + ++it; + if (it !=p->getChildren().end()) + ++it; + // find next non sub-element + while (it != p->getChildren().end() && (*it)->isSubElement()) + ++it; + + if (it != p->getChildren().end()) + setSelectedElement(*it); +} +void CGUIEditWorkspace::selectPreviousSibling() +{ + IGUIElement* p=0; + + if (SelectedElement && SelectedElement->getParent()) + p = SelectedElement->getParent(); + else + p = Parent; + + core::list::ConstIterator it = p->getChildren().getLast(); + // find selected element + if (SelectedElement) + while (*it != SelectedElement) + --it; + if (it != p->getChildren().end()) + --it; + // find next non sub-element + while (it != p->getChildren().end() && (*it)->isSubElement()) + --it; + + if (it != p->getChildren().end()) + setSelectedElement(*it); +} + +//! called if an event happened. +bool CGUIEditWorkspace::OnEvent(const SEvent &e) +{ + IGUIFileOpenDialog* dialog=0; + switch(e.EventType) + { + case ATTRIBEDIT_ATTRIB_CHANGED: + { + switch (e.UserEvent.UserData1) + { + case EGUIEDCE_ATTRIB_EDITOR: + { + // update selected items attributes + if (SelectedElement) + { + SelectedElement->deserializeAttributes(EditorWindow->getAttributeEditor()->getAttribs()); + EditorWindow->updateTree(); + } + return true; + } + case EGUIEDCE_OPTION_EDITOR: + { + // update editor options + deserializeAttributes(EditorWindow->getOptionEditor()->getAttribs()); + return true; + } + case EGUIEDCE_ENV_EDITOR: + { + // update environment + Environment->deserializeAttributes(EditorWindow->getEnvironmentEditor()->getAttribs()); + return true; + } + } + } + break; + + case EET_KEY_INPUT_EVENT: + if (!e.KeyInput.PressedDown) + { + switch (e.KeyInput.Key) + { + case KEY_DELETE: + if (SelectedElement) + { + IGUIElement* el = SelectedElement; + setSelectedElement(0); + MouseOverElement = 0; + el->remove(); + EditorWindow->updateTree(); + } + break; + case KEY_KEY_X: + if (e.KeyInput.Control && SelectedElement) + { + // cut + CopySelectedElementXML(); + // delete element + IGUIElement *el = SelectedElement; + setSelectedElement(0); + MouseOverElement = 0; + el->remove(); + } + break; + case KEY_KEY_C: + // copy + if (e.KeyInput.Control && SelectedElement) + { + CopySelectedElementXML(); + } + break; + case KEY_KEY_V: + // paste + if (e.KeyInput.Control) + { + PasteXMLToSelectedElement(); + } + break; + default: + break; + } + + return true; + } + break; + + case EET_MOUSE_INPUT_EVENT: + + switch(e.MouseInput.Event) + { + case EMIE_MOUSE_WHEEL: + { + f32 wheel = e.MouseInput.Wheel; + + if (wheel > 0) + selectPreviousSibling(); + else + selectNextSibling(); + } + break; + case EMIE_LMOUSE_PRESSED_DOWN: + { + core::position2di p = core::position2di(e.MouseInput.X,e.MouseInput.Y); + + IGUIElement* newSelection = getElementFromPoint(p); + + if (newSelection != this && isMyChild(newSelection) ) // redirect event + { + Environment->setFocus(newSelection); + return true; + } + + // hide the gui editor + if (EditorWindow) + EditorWindow->setVisible(false); + + if (CurrentMode == EGUIEDM_SELECT) + { + if (SelectedElement) + { + // start moving or dragging + CurrentMode = getModeFromPos(p); + + if (CurrentMode == EGUIEDM_MOVE) + StartMovePos = SelectedElement->getAbsolutePosition().UpperLeftCorner; + + DragStart = p; + SelectedArea = SelectedElement->getAbsolutePosition(); + } + + if (CurrentMode < EGUIEDM_MOVE) + { + // selecting an element... + MouseOverElement = getEditableElementFromPoint(Parent, p); + + if (MouseOverElement == Parent) + MouseOverElement = 0; + + setSelectedElement(MouseOverElement); + } + } + + break; + } + case EMIE_RMOUSE_PRESSED_DOWN: + if (CurrentMode == EGUIEDM_SELECT_NEW_PARENT || CurrentMode >= EGUIEDM_MOVE) + { + // cancel dragging + CurrentMode = EGUIEDM_SELECT; + } + else + { + DragStart = core::position2di(e.MouseInput.X,e.MouseInput.Y); + // root menu + IGUIContextMenu* mnu = Environment->addContextMenu( + core::rect(e.MouseInput.X, e.MouseInput.Y, e.MouseInput.Y+100, e.MouseInput.Y+100),this); + mnu->addItem(L"File",-1,true,true); + mnu->addItem(L"Edit",-1,true,true); + mnu->addItem(L"View",-1,true,true); + mnu->addItem(SelectedElement ? L"Add child" : L"Add" ,-1,true,true); + + // file menu + IGUIContextMenu* sub = mnu->getSubMenu(0); + IGUIContextMenu* sub2 =0; + + sub->addItem(L"New", MenuCommandStart + EGUIEDMC_FILE_NEW ); + sub->addItem(L"Load...",MenuCommandStart + EGUIEDMC_FILE_LOAD); + sub->addItem(L"Save...",MenuCommandStart + EGUIEDMC_FILE_SAVE); + + // edit menu + sub = mnu->getSubMenu(1); + sub->addItem(L"Cut (ctrl+x)", MenuCommandStart + EGUIEDMC_CUT_ELEMENT, (SelectedElement != 0)); + sub->addItem(L"Copy (ctrl+c)", MenuCommandStart + EGUIEDMC_COPY_ELEMENT, (SelectedElement != 0)); + sub->addItem(L"Paste (ctrl+v)", MenuCommandStart + EGUIEDMC_PASTE_ELEMENT, + (core::stringc(Environment->getOSOperator()->getTextFromClipboard()) != "")); + sub->addItem(L"Delete (del)", MenuCommandStart + EGUIEDMC_DELETE_ELEMENT, (SelectedElement != 0)); + sub->addSeparator(); + sub->addItem(L"Set parent", MenuCommandStart + EGUIEDMC_SET_PARENT, (SelectedElement != 0)); + sub->addItem(L"Bring to front", MenuCommandStart + EGUIEDMC_BRING_TO_FRONT, (SelectedElement != 0)); + sub->addSeparator(); + sub->addItem(L"Save to XML...", MenuCommandStart + EGUIEDMC_SAVE_ELEMENT, (SelectedElement != 0)); + + sub = mnu->getSubMenu(2); + // view menu + if (EditorWindow) + sub->addItem(EditorWindow->isVisible() ? L"Hide window" : L"Show window", MenuCommandStart + EGUIEDMC_TOGGLE_EDITOR); + + sub = mnu->getSubMenu(3); + + s32 i,j,c=0; + sub->addItem(L"Default factory",-1,true, true); + + // add elements from each factory + for (i=0; u32(i) < Environment->getRegisteredGUIElementFactoryCount(); ++i) + { + sub2 = sub->getSubMenu(i); + + IGUIElementFactory *f = Environment->getGUIElementFactory(i); + + for (j=0; j< f->getCreatableGUIElementTypeCount(); ++j) + { + sub2->addItem(core::stringw(f->getCreateableGUIElementTypeName(j)).c_str(), MenuCommandStart + EGUIEDMC_COUNT + c); + c++; + } + + if (u32(i+1) < Environment->getRegisteredGUIElementFactoryCount()) + { + core::stringw strFact; + strFact = L"Factory "; + strFact += i+1; + sub->addItem(strFact.c_str(),-1, true, true); + } + } + sub->addSeparator(); + sub->addItem(L"From XML...", MenuCommandStart + EGUIEDMC_INSERT_XML); + + // set focus to menu + Environment->setFocus(mnu); + + } + break; + case EMIE_LMOUSE_LEFT_UP: + + // make window visible again + if (EditorWindow) + EditorWindow->setVisible(true); + if (CurrentMode == EGUIEDM_SELECT_NEW_PARENT) + { + if (SelectedElement) + { + MouseOverElement = getEditableElementFromPoint(Parent, + core::position2di(e.MouseInput.X,e.MouseInput.Y)); + if (MouseOverElement) + { + MouseOverElement->addChild(SelectedElement); + setSelectedElement(0); + setSelectedElement(SelectedElement); + } + } + CurrentMode = EGUIEDM_SELECT; + } + else if (CurrentMode >= EGUIEDM_MOVE) + { + IGUIElement *sel = SelectedElement; + // unselect + setSelectedElement(0); + + // move + core::position2d p(0,0); + if (sel->getParent()) + p = sel->getParent()->getAbsolutePosition().UpperLeftCorner; + + sel->setRelativePosition(SelectedArea - p); + + // select + setSelectedElement(sel); + + // reset selection mode... + CurrentMode = EGUIEDM_SELECT; + } + break; + case EMIE_MOUSE_MOVED: + // always on top + Parent->bringToFront(this); + + // if selecting + if (CurrentMode == EGUIEDM_SELECT || CurrentMode == EGUIEDM_SELECT_NEW_PARENT) + { + + core::position2di p = core::position2di(e.MouseInput.X,e.MouseInput.Y); + + // highlight the element that the mouse is over + MouseOverElement = getEditableElementFromPoint(Parent, p); + if (MouseOverElement == Parent) + { + MouseOverElement = 0; + } + + if (CurrentMode == EGUIEDM_SELECT) + { + MouseOverMode = getModeFromPos(p); + if (MouseOverMode > EGUIEDM_MOVE) + { + MouseOverElement = SelectedElement; + } + } + } + else if (CurrentMode == EGUIEDM_MOVE) + { + // get difference + core::position2di p = core::position2di(e.MouseInput.X,e.MouseInput.Y); + p -= DragStart; + + // apply to top corner + p = StartMovePos + p; + if (UseGrid) + { + p.X = (p.X/GridSize.Width)*GridSize.Width; + p.Y = (p.Y/GridSize.Height)*GridSize.Height; + } + + SelectedArea += p - SelectedArea.UpperLeftCorner; + } + else if (CurrentMode > EGUIEDM_MOVE) + { + // get difference from start position + core::position2di p = core::position2di(e.MouseInput.X,e.MouseInput.Y); + if (UseGrid) + { + p.X = (p.X/GridSize.Width)*GridSize.Width; + p.Y = (p.Y/GridSize.Height)*GridSize.Height; + } + + switch(CurrentMode) + { + case EGUIEDM_RESIZE_T: + SelectedArea.UpperLeftCorner.Y = p.Y; + break; + case EGUIEDM_RESIZE_B: + SelectedArea.LowerRightCorner.Y = p.Y; + break; + case EGUIEDM_RESIZE_L: + SelectedArea.UpperLeftCorner.X = p.X; + break; + case EGUIEDM_RESIZE_R: + SelectedArea.LowerRightCorner.X = p.X; + break; + case EGUIEDM_RESIZE_TL: + SelectedArea.UpperLeftCorner = p; + break; + case EGUIEDM_RESIZE_TR: + SelectedArea.UpperLeftCorner.Y = p.Y; + SelectedArea.LowerRightCorner.X = p.X; + break; + case EGUIEDM_RESIZE_BL: + SelectedArea.UpperLeftCorner.X = p.X; + SelectedArea.LowerRightCorner.Y = p.Y; + break; + case EGUIEDM_RESIZE_BR: + SelectedArea.LowerRightCorner = p; + break; + default: + break; + } + } + + break; + default: + break; + } + break; + + case EET_GUI_EVENT: + switch(e.GUIEvent.EventType) + { + case EGET_TREEVIEW_NODE_SELECT: + { + IGUITreeViewNode* eventnode = ((IGUITreeView*)e.GUIEvent.Caller)->getLastEventNode(); + if(!eventnode->isRoot()) + setSelectedElement((IGUIElement*)(eventnode->getData())); + break; + } + // load a gui file + case EGET_FILE_SELECTED: + dialog = (IGUIFileOpenDialog*)e.GUIEvent.Caller; + Environment->loadGUI(core::stringc(dialog->getFileName()).c_str()); + break; + + case EGET_MENU_ITEM_SELECTED: + { + IGUIContextMenu *menu = (IGUIContextMenu*)e.GUIEvent.Caller; + s32 cmdID = menu->getItemCommandId(menu->getSelectedItem()) - MenuCommandStart; + + IGUIElement* el; + + switch(cmdID) + { + + //! file commands + case EGUIEDMC_FILE_NEW: + // clear all elements belonging to our parent + setSelectedElement(0); + MouseOverElement = 0; + el = Parent; + grab(); + // remove all children + while(Children.end() != el->getChildren().begin()) + el->removeChild(*(el->getChildren().begin())); + // attach to parent again + el->addChild(this); + drop(); + + break; + case EGUIEDMC_FILE_LOAD: + Environment->addFileOpenDialog(L"Please select a GUI file to open", false, this); + break; + case EGUIEDMC_FILE_SAVE: + Environment->saveGUI("guiTest.xml"); + break; + + //! edit menu + case EGUIEDMC_CUT_ELEMENT: + { + CopySelectedElementXML(); + // delete element + el = SelectedElement; + setSelectedElement(0); + MouseOverElement = 0; + el->remove(); + break; + } + case EGUIEDMC_COPY_ELEMENT: + CopySelectedElementXML(); + break; + case EGUIEDMC_PASTE_ELEMENT: + PasteXMLToSelectedElement(); + break; + case EGUIEDMC_DELETE_ELEMENT: + el = SelectedElement; + setSelectedElement(0); + MouseOverElement = 0; + el->remove(); + break; + case EGUIEDMC_SET_PARENT: + CurrentMode = EGUIEDM_SELECT_NEW_PARENT; + break; + case EGUIEDMC_BRING_TO_FRONT: + if (SelectedElement->getParent()) + SelectedElement->getParent()->bringToFront(SelectedElement); + break; + + case EGUIEDMC_SAVE_ELEMENT: + //TODO: add 'save' dialog. + Environment->saveGUI("guiTest.xml", SelectedElement ? SelectedElement : Environment->getRootGUIElement() ); + break; + + //! toggle edit window + case EGUIEDMC_TOGGLE_EDITOR: + break; + + case EGUIEDMC_INSERT_XML: + Environment->loadGUI("guiTest.xml", SelectedElement ? SelectedElement : Environment->getRootGUIElement() ); + break; + + default: + // create element from factory? + if (cmdID >= EGUIEDMC_COUNT) + { + + s32 num = cmdID - EGUIEDMC_COUNT; // get index + // loop through all factories + s32 i, c=Environment->getRegisteredGUIElementFactoryCount(); + for (i=0; i Environment->getGUIElementFactory(i)->getCreatableGUIElementTypeCount(); ++i) + { + num -= Environment->getGUIElementFactory(i)->getCreatableGUIElementTypeCount(); + } + if (num < Environment->getGUIElementFactory(i)->getCreatableGUIElementTypeCount() ) + { + core::stringc name = Environment->getGUIElementFactory(i)->getCreateableGUIElementTypeName(num); + IGUIElement *parentElement = SelectedElement ? SelectedElement : Environment->getRootGUIElement(); + // add it + IGUIElement *newElement = Environment->getGUIElementFactory(i)->addGUIElement(name.c_str(),parentElement); + if (newElement) + { + core::position2di p = DragStart - parentElement->getAbsolutePosition().UpperLeftCorner; + newElement->setRelativePosition(core::rect(p,p+core::position2di(100,100))); + //Environment->removeFocus(newElement); + } + } + } + break; + } + EditorWindow->updateTree(); + } + return true; + default: + break; + } + break; + + default: + break; + } + + // even if we didn't absorb the event, + // we never pass events back to the GUI we're editing! + return false; +} + + +//! draws the element and its children +void CGUIEditWorkspace::draw() +{ + video::IVideoDriver *driver = Environment->getVideoDriver(); + + if (DrawGrid) + { + // draw the grid + + core::rect r = getAbsolutePosition(); + + s32 cy = r.UpperLeftCorner.Y; + while (cy < r.LowerRightCorner.Y) + { + s32 cx = r.UpperLeftCorner.X; + while (cx < r.LowerRightCorner.X) + { + driver->draw2DRectangle(video::SColor(40,0,0,90),core::rect(cx+1,cy+1,GridSize.Width+cx,GridSize.Height+cy)); + cx += GridSize.Width; + } + cy += GridSize.Height; + } + } + if (MouseOverElement && + MouseOverElement != SelectedElement && + MouseOverElement != Parent) + { + core::rect r = MouseOverElement->getAbsolutePosition(); + driver->draw2DRectangle(video::SColor(100,0,0,255), r); + } + if (SelectedElement && CurrentMode == EGUIEDM_SELECT) + { + driver->draw2DRectangle(video::SColor(100,0,255,0),SelectedElement->getAbsolutePosition()); + } + if (CurrentMode >= EGUIEDM_MOVE) + { + driver->draw2DRectangle(video::SColor(100,255,0,0),SelectedArea); + } + + if ( (SelectedElement && CurrentMode >= EGUIEDM_MOVE) || + (SelectedElement && MouseOverElement == SelectedElement && MouseOverMode >= EGUIEDM_MOVE) ) + { + // draw handles for moving + EGUIEDIT_MODE m = CurrentMode; + core::rect r = SelectedArea; + if (m < EGUIEDM_MOVE) + { + m = MouseOverMode; + r = SelectedElement->getAbsolutePosition(); + } + + core::position2di d = core::position2di(4,4); + + TLRect = core::rect(r.UpperLeftCorner, r.UpperLeftCorner + d ); + TRRect = core::rect(r.LowerRightCorner.X-4, r.UpperLeftCorner.Y, r.LowerRightCorner.X, r.UpperLeftCorner.Y+4); + TopRect = core::rect(r.getCenter().X-2, r.UpperLeftCorner.Y,r.getCenter().X+2, r.UpperLeftCorner.Y+4 ); + BLRect = core::rect(r.UpperLeftCorner.X, r.LowerRightCorner.Y-4, r.UpperLeftCorner.X+4, r.LowerRightCorner.Y); + LRect = core::rect(r.UpperLeftCorner.X,r.getCenter().Y-2, r.UpperLeftCorner.X+4, r.getCenter().Y+2 ); + RRect = core::rect(r.LowerRightCorner.X-4,r.getCenter().Y-2, r.LowerRightCorner.X, r.getCenter().Y+2 ); + BRRect = core::rect(r.LowerRightCorner-d, r.LowerRightCorner); + BRect = core::rect(r.getCenter().X-2, r.LowerRightCorner.Y-4,r.getCenter().X+2, r.LowerRightCorner.Y ); + + // top left + if (m == EGUIEDM_RESIZE_T || m == EGUIEDM_RESIZE_L || m == EGUIEDM_RESIZE_TL || m == EGUIEDM_MOVE ) + driver->draw2DRectangle(video::SColor(100,255,255,255), TLRect); + + if (m == EGUIEDM_RESIZE_T || m == EGUIEDM_RESIZE_R || m == EGUIEDM_RESIZE_TR || m == EGUIEDM_MOVE ) + driver->draw2DRectangle(video::SColor(100,255,255,255), TRRect); + + if (m == EGUIEDM_RESIZE_T || m == EGUIEDM_MOVE ) + driver->draw2DRectangle(video::SColor(100,255,255,255), TopRect); + + if (m == EGUIEDM_RESIZE_L || m == EGUIEDM_RESIZE_BL || m == EGUIEDM_RESIZE_B || m == EGUIEDM_MOVE ) + driver->draw2DRectangle(video::SColor(100,255,255,255), BLRect); + + if (m == EGUIEDM_RESIZE_L || m == EGUIEDM_MOVE ) + driver->draw2DRectangle(video::SColor(100,255,255,255), LRect); + + if (m == EGUIEDM_RESIZE_R || m == EGUIEDM_MOVE ) + driver->draw2DRectangle(video::SColor(100,255,255,255), RRect); + + if (m == EGUIEDM_RESIZE_R || m == EGUIEDM_RESIZE_BR || m == EGUIEDM_RESIZE_B || m == EGUIEDM_MOVE ) + driver->draw2DRectangle(video::SColor(100,255,255,255), BRRect ); + + if (m == EGUIEDM_RESIZE_B || m == EGUIEDM_MOVE ) + driver->draw2DRectangle(video::SColor(100,255,255,255), BRect); + + + } + + IGUIElement::draw(); +} + + +void CGUIEditWorkspace::setDrawGrid(bool drawGrid) +{ + DrawGrid = drawGrid; +} + +void CGUIEditWorkspace::setGridSize(const core::dimension2di& gridSize) +{ + GridSize = gridSize; + if (GridSize.Width < 2) + GridSize.Width = 2; + if (GridSize.Height < 2) + GridSize.Height = 2; +} + +void CGUIEditWorkspace::setUseGrid(bool useGrid) +{ + UseGrid = useGrid; +} + + +//! Removes a child. +void CGUIEditWorkspace::removeChild(IGUIElement* child) +{ + IGUIElement::removeChild(child); + + if (Children.empty()) + remove(); +} + + +void CGUIEditWorkspace::updateAbsolutePosition() +{ + core::rect 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(); +} + +void CGUIEditWorkspace::CopySelectedElementXML() +{ + core::stringc XMLText; + core::stringw wXMLText; + // create memory write file + io::CMemoryReadWriteFile* memWrite = new io::CMemoryReadWriteFile("#Clipboard#"); + // save gui to mem file + io::IXMLWriter* xml = Environment->getFileSystem()->createXMLWriter(memWrite); + Environment->writeGUIElement(xml, SelectedElement); + + // copy to clipboard- wide chars not supported yet :( + wXMLText = (wchar_t*)&memWrite->getData()[0]; + u32 i = memWrite->getData().size()/sizeof(wchar_t); + if (wXMLText.size() > i) + wXMLText[i] = L'\0'; + XMLText = wXMLText.c_str(); + memWrite->drop(); + xml->drop(); + Environment->getOSOperator()->copyToClipboard(XMLText.c_str()); +} + +void CGUIEditWorkspace::PasteXMLToSelectedElement() +{ + // get clipboard data + core::stringc XMLText = Environment->getOSOperator()->getTextFromClipboard(); + // convert to stringw + core::stringw wXMLText = XMLText.c_str(); + + io::CMemoryReadWriteFile* memWrite = new io::CMemoryReadWriteFile("#Clipboard#"); + + io::IXMLWriter* xmlw = Environment->getFileSystem()->createXMLWriter(memWrite); + xmlw->writeXMLHeader(); // it needs one of those + xmlw->drop(); + + // write clipboard data + memWrite->write((void*)&wXMLText[0], wXMLText.size() * sizeof(wchar_t)); + + // rewind file + memWrite->seek(0, false); + + // read xml + Environment->loadGUI(memWrite, SelectedElement); + + // reset focus + Environment->setFocus(this); + + // drop the read file + memWrite->drop(); +} + +void CGUIEditWorkspace::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) +{ + out->addBool("DrawGrid", DrawGrid); + out->addBool("UseGrid", UseGrid); + out->addPosition2d("GridSize", core::position2di(GridSize.Width, GridSize.Height)); + out->addInt("MenuCommandStart", MenuCommandStart); +} + +void CGUIEditWorkspace::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options) +{ + setDrawGrid(in->getAttributeAsBool("DrawGrid")); + setUseGrid(in->getAttributeAsBool("UseGrid")); + + core::position2di tmpp = in->getAttributeAsPosition2d("GridSize"); + core::dimension2di tmpd(tmpp.X, tmpp.Y); + setGridSize(tmpd); + setMenuCommandIDStart(in->getAttributeAsInt("MenuCommandStart")); +} + + +} // end namespace gui +} // end namespace irr + + diff --git a/libraries/irrlicht-1.8/tools/GUIEditor/CGUIEditWorkspace.h b/libraries/irrlicht-1.8/tools/GUIEditor/CGUIEditWorkspace.h index 3f21258..c9ccd14 100644 --- a/libraries/irrlicht-1.8/tools/GUIEditor/CGUIEditWorkspace.h +++ b/libraries/irrlicht-1.8/tools/GUIEditor/CGUIEditWorkspace.h @@ -1,168 +1,168 @@ -// Copyright (C) 2002-2012 Nikolaus Gebhardt / Gaz Davidson -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_GUIEDIT_WORKSPACE_H_INCLUDED__ -#define __C_GUIEDIT_WORKSPACE_H_INCLUDED__ - -#include "IGUIElement.h" -#include "CGUIEditWindow.h" -#include "EGUIEditTypes.h" - -namespace irr -{ -namespace gui -{ - - //! Adding the GUI Editor Workspace to an element allows you - /** to create, edit, load and save any elements supported - by any loaded factories. - When you add it without a parent (to the root element) - it will also allow you to edit, load and save settings in - the current skin. - */ - - // custom events - enum EGUIEDIT_CUSTOM_EVENTS - { - EGUIEDCE_ATTRIB_EDITOR = MAKE_IRR_ID('g','A','t','t'), - EGUIEDCE_OPTION_EDITOR = MAKE_IRR_ID('g','O','p','t'), - EGUIEDCE_ENV_EDITOR = MAKE_IRR_ID('g','E','n','v') - }; - - class CGUIEditWorkspace : public IGUIElement - { - public: - - //! constructor - CGUIEditWorkspace(IGUIEnvironment* environment, s32 id=-1, IGUIElement *parent=0); - - //! destructor - ~CGUIEditWorkspace(); - - //! called if an event happened. - virtual bool OnEvent(const SEvent &event); - - //! Removes a child. - virtual void removeChild(IGUIElement* child); - - //! draws the element and its children - virtual void draw(); - - //! Updates the absolute position. - virtual void updateAbsolutePosition(); - - //! Sets the menu command id's - /** The GUI editor defaults to command ID's from 0xED17 to 0xED17+EGUIEDMC_COUNT - In the rare case that these are already in use and you wish to use menus - while the editor is present you can set a new offset here. - */ - virtual void setMenuCommandIDStart(s32 id); - - //! grid drawing... - virtual void setDrawGrid(bool drawGrid); - virtual void setGridSize(const core::dimension2di& gridSize); - virtual void setUseGrid(bool useGrid); - - //! returns the first editable element under the mouse - virtual IGUIElement* getEditableElementFromPoint(IGUIElement *start, const core::position2di &point, s32 index=0 ); - - //! selecting elements - virtual void setSelectedElement(IGUIElement *sel); - virtual void selectNextSibling(); - virtual void selectPreviousSibling(); - - //! returns the selected element - virtual IGUIElement* getSelectedElement(); - - //! copies the xml of the selected element and all children to the clipboard - virtual void CopySelectedElementXML(); - - //! copies the xml of the selected element and all children to the clipboard - virtual void PasteXMLToSelectedElement(); - - virtual const c8* getTypeName() const - { - return GUIEditElementTypeNames[EGUIEDIT_GUIEDIT]; - } - - virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0); - virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0); - - private: - - enum EGUIEDIT_MODE - { - // when we are currently selecting an element - EGUIEDM_SELECT=0, - // selecting a new parent for the selected element - EGUIEDM_SELECT_NEW_PARENT, - - // moving the selected element - EGUIEDM_MOVE, - // resizing the selected element - EGUIEDM_RESIZE_TL, - EGUIEDM_RESIZE_T, - EGUIEDM_RESIZE_TR, - EGUIEDM_RESIZE_R, - EGUIEDM_RESIZE_BR, - EGUIEDM_RESIZE_B, - EGUIEDM_RESIZE_BL, - EGUIEDM_RESIZE_L - }; - - enum EGUIEDIT_MENUCOMMANDS - { - //! file commands - EGUIEDMC_FILE_NEW, - EGUIEDMC_FILE_LOAD, - EGUIEDMC_FILE_SAVE, - //! edit menu - EGUIEDMC_CUT_ELEMENT, - EGUIEDMC_COPY_ELEMENT, - EGUIEDMC_PASTE_ELEMENT, - EGUIEDMC_DELETE_ELEMENT, - EGUIEDMC_SET_PARENT, - EGUIEDMC_BRING_TO_FRONT, - EGUIEDMC_SAVE_ELEMENT, - //! grid - EGUIEDMC_TOGGLE_EDITOR, - - EGUIEDMC_INSERT_XML, - - //! number of menu options - EGUIEDMC_COUNT - }; - - EGUIEDIT_MODE getModeFromPos(core::position2di p); - - EGUIEDIT_MODE CurrentMode; - EGUIEDIT_MODE MouseOverMode; - core::position2di DragStart; - core::position2di StartMovePos; - core::rect SelectedArea; - - core::dimension2di GridSize; - s32 MenuCommandStart; - bool DrawGrid, UseGrid; - - IGUIElement *MouseOverElement, - *SelectedElement; - CGUIEditWindow *EditorWindow; - - core::rect TLRect; - core::rect TRRect; - core::rect TopRect; - core::rect BLRect; - core::rect LRect; - core::rect RRect; - core::rect BRRect; - core::rect BRect; - }; - - -} // end namespace gui -} // end namespace irr - -#endif - +// Copyright (C) 2002-2012 Nikolaus Gebhardt / Gaz Davidson +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_GUIEDIT_WORKSPACE_H_INCLUDED__ +#define __C_GUIEDIT_WORKSPACE_H_INCLUDED__ + +#include "IGUIElement.h" +#include "CGUIEditWindow.h" +#include "EGUIEditTypes.h" + +namespace irr +{ +namespace gui +{ + + //! Adding the GUI Editor Workspace to an element allows you + /** to create, edit, load and save any elements supported + by any loaded factories. + When you add it without a parent (to the root element) + it will also allow you to edit, load and save settings in + the current skin. + */ + + // custom events + enum EGUIEDIT_CUSTOM_EVENTS + { + EGUIEDCE_ATTRIB_EDITOR = MAKE_IRR_ID('g','A','t','t'), + EGUIEDCE_OPTION_EDITOR = MAKE_IRR_ID('g','O','p','t'), + EGUIEDCE_ENV_EDITOR = MAKE_IRR_ID('g','E','n','v') + }; + + class CGUIEditWorkspace : public IGUIElement + { + public: + + //! constructor + CGUIEditWorkspace(IGUIEnvironment* environment, s32 id=-1, IGUIElement *parent=0); + + //! destructor + ~CGUIEditWorkspace(); + + //! called if an event happened. + virtual bool OnEvent(const SEvent &event); + + //! Removes a child. + virtual void removeChild(IGUIElement* child); + + //! draws the element and its children + virtual void draw(); + + //! Updates the absolute position. + virtual void updateAbsolutePosition(); + + //! Sets the menu command id's + /** The GUI editor defaults to command ID's from 0xED17 to 0xED17+EGUIEDMC_COUNT + In the rare case that these are already in use and you wish to use menus + while the editor is present you can set a new offset here. + */ + virtual void setMenuCommandIDStart(s32 id); + + //! grid drawing... + virtual void setDrawGrid(bool drawGrid); + virtual void setGridSize(const core::dimension2di& gridSize); + virtual void setUseGrid(bool useGrid); + + //! returns the first editable element under the mouse + virtual IGUIElement* getEditableElementFromPoint(IGUIElement *start, const core::position2di &point, s32 index=0 ); + + //! selecting elements + virtual void setSelectedElement(IGUIElement *sel); + virtual void selectNextSibling(); + virtual void selectPreviousSibling(); + + //! returns the selected element + virtual IGUIElement* getSelectedElement(); + + //! copies the xml of the selected element and all children to the clipboard + virtual void CopySelectedElementXML(); + + //! copies the xml of the selected element and all children to the clipboard + virtual void PasteXMLToSelectedElement(); + + virtual const c8* getTypeName() const + { + return GUIEditElementTypeNames[EGUIEDIT_GUIEDIT]; + } + + virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0); + virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0); + + private: + + enum EGUIEDIT_MODE + { + // when we are currently selecting an element + EGUIEDM_SELECT=0, + // selecting a new parent for the selected element + EGUIEDM_SELECT_NEW_PARENT, + + // moving the selected element + EGUIEDM_MOVE, + // resizing the selected element + EGUIEDM_RESIZE_TL, + EGUIEDM_RESIZE_T, + EGUIEDM_RESIZE_TR, + EGUIEDM_RESIZE_R, + EGUIEDM_RESIZE_BR, + EGUIEDM_RESIZE_B, + EGUIEDM_RESIZE_BL, + EGUIEDM_RESIZE_L + }; + + enum EGUIEDIT_MENUCOMMANDS + { + //! file commands + EGUIEDMC_FILE_NEW, + EGUIEDMC_FILE_LOAD, + EGUIEDMC_FILE_SAVE, + //! edit menu + EGUIEDMC_CUT_ELEMENT, + EGUIEDMC_COPY_ELEMENT, + EGUIEDMC_PASTE_ELEMENT, + EGUIEDMC_DELETE_ELEMENT, + EGUIEDMC_SET_PARENT, + EGUIEDMC_BRING_TO_FRONT, + EGUIEDMC_SAVE_ELEMENT, + //! grid + EGUIEDMC_TOGGLE_EDITOR, + + EGUIEDMC_INSERT_XML, + + //! number of menu options + EGUIEDMC_COUNT + }; + + EGUIEDIT_MODE getModeFromPos(core::position2di p); + + EGUIEDIT_MODE CurrentMode; + EGUIEDIT_MODE MouseOverMode; + core::position2di DragStart; + core::position2di StartMovePos; + core::rect SelectedArea; + + core::dimension2di GridSize; + s32 MenuCommandStart; + bool DrawGrid, UseGrid; + + IGUIElement *MouseOverElement, + *SelectedElement; + CGUIEditWindow *EditorWindow; + + core::rect TLRect; + core::rect TRRect; + core::rect TopRect; + core::rect BLRect; + core::rect LRect; + core::rect RRect; + core::rect BRRect; + core::rect BRect; + }; + + +} // end namespace gui +} // end namespace irr + +#endif + diff --git a/libraries/irrlicht-1.8/tools/GUIEditor/CGUIEnumAttribute.h b/libraries/irrlicht-1.8/tools/GUIEditor/CGUIEnumAttribute.h index 9e3958d..31951e5 100644 --- a/libraries/irrlicht-1.8/tools/GUIEditor/CGUIEnumAttribute.h +++ b/libraries/irrlicht-1.8/tools/GUIEditor/CGUIEnumAttribute.h @@ -1,114 +1,114 @@ -#ifndef __C_GUI_ENUM_ATTRIBUTE_H_INCLUDED__ -#define __C_GUI_ENUM_ATTRIBUTE_H_INCLUDED__ - -#include "CGUIAttribute.h" -#include "IGUIComboBox.h" -#include "IGUIEditBox.h" -#include "EGUIEditTypes.h" - -namespace irr -{ -namespace gui -{ - - class CGUIEnumAttribute : public CGUIAttribute - { - public: - // - CGUIEnumAttribute(IGUIEnvironment* environment, IGUIElement *parent, s32 myParentID) : - CGUIAttribute(environment, parent, myParentID), - AttribComboBox(0), AttribEditBox(0) - { - - } - - virtual ~CGUIEnumAttribute() - { - if (AttribComboBox) - AttribComboBox->drop(); - if (AttribEditBox) - AttribEditBox->drop(); - } - - // save the attribute and possibly post the event to its parent - virtual void setAttrib(io::IAttributes *attribs, u32 attribIndex) - { - - if (AttribComboBox) - { - AttribComboBox->remove(); - AttribComboBox->drop(); - AttribComboBox = 0; - } - - if (AttribEditBox) - { - AttribEditBox->remove(); - AttribEditBox->drop(); - AttribEditBox = 0; - } - - core::array outLiterals; - attribs->getAttributeEnumerationLiteralsOfEnumeration(attribIndex, outLiterals); - - core::rect r = getAbsolutePosition(); - core::rect r2(0, Environment->getSkin()->getFont()->getDimension(L"A").Height + 10, - r.getWidth() - 5, - Environment->getSkin()->getFont()->getDimension(L"A").Height*2 + 20 ); - - if (outLiterals.size() > 0) - { - AttribComboBox = Environment->addComboBox(r2, this, -1); - for (u32 i=0; iaddItem( core::stringw(outLiterals[i].c_str()).c_str()); - - AttribComboBox->setSelected( attribs->getAttributeAsInt(attribIndex) ); - - AttribComboBox->grab(); - AttribComboBox->setSubElement(true); - AttribComboBox->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT); - } - else - { - - AttribEditBox = Environment->addEditBox( - attribs->getAttributeAsStringW(attribIndex).c_str(), - r2, true, this, -1); - AttribEditBox->grab(); - AttribEditBox->setSubElement(true); - AttribEditBox->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT); - } - - CGUIAttribute::setAttrib(attribs, attribIndex); - } - - //! save the attribute and possibly post the event to its parent - virtual bool updateAttrib(bool sendEvent=true) - { - if (!Attribs) - return true; - - if (AttribComboBox) - Attribs->setAttribute(Index, AttribComboBox->getText()); - else if (AttribEditBox) - Attribs->setAttribute(Index, AttribEditBox->getText()); - - return CGUIAttribute::updateAttrib(sendEvent); - } - - //! Returns the type name of the gui element. - virtual const c8* getTypeName() const - { - return GUIEditElementTypeNames[EGUIEDIT_ENUMATTRIBUTE]; - } - - private: - IGUIComboBox* AttribComboBox; - IGUIEditBox* AttribEditBox; - }; - -} // namespace gui -} // namespace irr - -#endif - +#ifndef __C_GUI_ENUM_ATTRIBUTE_H_INCLUDED__ +#define __C_GUI_ENUM_ATTRIBUTE_H_INCLUDED__ + +#include "CGUIAttribute.h" +#include "IGUIComboBox.h" +#include "IGUIEditBox.h" +#include "EGUIEditTypes.h" + +namespace irr +{ +namespace gui +{ + + class CGUIEnumAttribute : public CGUIAttribute + { + public: + // + CGUIEnumAttribute(IGUIEnvironment* environment, IGUIElement *parent, s32 myParentID) : + CGUIAttribute(environment, parent, myParentID), + AttribComboBox(0), AttribEditBox(0) + { + + } + + virtual ~CGUIEnumAttribute() + { + if (AttribComboBox) + AttribComboBox->drop(); + if (AttribEditBox) + AttribEditBox->drop(); + } + + // save the attribute and possibly post the event to its parent + virtual void setAttrib(io::IAttributes *attribs, u32 attribIndex) + { + + if (AttribComboBox) + { + AttribComboBox->remove(); + AttribComboBox->drop(); + AttribComboBox = 0; + } + + if (AttribEditBox) + { + AttribEditBox->remove(); + AttribEditBox->drop(); + AttribEditBox = 0; + } + + core::array outLiterals; + attribs->getAttributeEnumerationLiteralsOfEnumeration(attribIndex, outLiterals); + + core::rect r = getAbsolutePosition(); + core::rect r2(0, Environment->getSkin()->getFont()->getDimension(L"A").Height + 10, + r.getWidth() - 5, + Environment->getSkin()->getFont()->getDimension(L"A").Height*2 + 20 ); + + if (outLiterals.size() > 0) + { + AttribComboBox = Environment->addComboBox(r2, this, -1); + for (u32 i=0; iaddItem( core::stringw(outLiterals[i].c_str()).c_str()); + + AttribComboBox->setSelected( attribs->getAttributeAsInt(attribIndex) ); + + AttribComboBox->grab(); + AttribComboBox->setSubElement(true); + AttribComboBox->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT); + } + else + { + + AttribEditBox = Environment->addEditBox( + attribs->getAttributeAsStringW(attribIndex).c_str(), + r2, true, this, -1); + AttribEditBox->grab(); + AttribEditBox->setSubElement(true); + AttribEditBox->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT); + } + + CGUIAttribute::setAttrib(attribs, attribIndex); + } + + //! save the attribute and possibly post the event to its parent + virtual bool updateAttrib(bool sendEvent=true) + { + if (!Attribs) + return true; + + if (AttribComboBox) + Attribs->setAttribute(Index, AttribComboBox->getText()); + else if (AttribEditBox) + Attribs->setAttribute(Index, AttribEditBox->getText()); + + return CGUIAttribute::updateAttrib(sendEvent); + } + + //! Returns the type name of the gui element. + virtual const c8* getTypeName() const + { + return GUIEditElementTypeNames[EGUIEDIT_ENUMATTRIBUTE]; + } + + private: + IGUIComboBox* AttribComboBox; + IGUIEditBox* AttribEditBox; + }; + +} // namespace gui +} // namespace irr + +#endif + diff --git a/libraries/irrlicht-1.8/tools/GUIEditor/CGUIPanel.cpp b/libraries/irrlicht-1.8/tools/GUIEditor/CGUIPanel.cpp index 4135b7a..0ef1f36 100644 --- a/libraries/irrlicht-1.8/tools/GUIEditor/CGUIPanel.cpp +++ b/libraries/irrlicht-1.8/tools/GUIEditor/CGUIPanel.cpp @@ -1,340 +1,340 @@ -// Copyright 2006-2012 Asger Feldthaus -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -/* - Originally Klasker's but I've messed around with it lots - Gaz -*/ - -#include "CGUIPanel.h" -#include "IGUIEnvironment.h" -#include "IGUIScrollBar.h" -#include "IGUITabControl.h" -#include "IVideoDriver.h" - -const int SCROLL_BAR_SIZE = 16; // Scroll bars are 16 pixels wide -const int BORDER_WIDTH = 2; - -namespace irr -{ -namespace gui -{ - -CGUIPanel::CGUIPanel(IGUIEnvironment* environment, IGUIElement* parent, s32 id, const core::rect& rectangle, - bool border, E_SCROLL_BAR_MODE vMode, E_SCROLL_BAR_MODE hMode) - : IGUIElement(EGUIET_ELEMENT, environment, parent, id, rectangle), - VScrollBar(0), HScrollBar(0), ClipPane(0), InnerPane(0), - VScrollBarMode(vMode), HScrollBarMode(hMode), NeedsUpdate(true), Border(border) -{ - #ifdef _DEBUG - setDebugName("CGUIPanel"); - #endif - - s32 width = rectangle.getWidth(); - s32 height = rectangle.getHeight(); - - core::rect rct = core::rect(width - SCROLL_BAR_SIZE,0, width, height); - - VScrollBar = environment->addScrollBar(false, rct, 0, id); - VScrollBar->setSubElement(true); - VScrollBar->setTabStop(false); - VScrollBar->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT); - VScrollBar->grab(); - IGUIElement::addChild(VScrollBar); - - rct = core::rect(0, height - SCROLL_BAR_SIZE, width - SCROLL_BAR_SIZE,height ); - - HScrollBar = environment->addScrollBar(true, rct, 0, id); - HScrollBar->setSubElement(true); - HScrollBar->setTabStop(false); - HScrollBar->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT); - HScrollBar->grab(); - IGUIElement::addChild(HScrollBar); - - rct = core::rect(0,0, width - SCROLL_BAR_SIZE, height - SCROLL_BAR_SIZE); - - ClipPane = environment->addTab( rct, 0, -1); - ClipPane->setSubElement(true); - ClipPane->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT); - ClipPane->grab(); - IGUIElement::addChild(ClipPane); - - InnerPane = environment->addTab(rct, ClipPane, -1); - InnerPane->setSubElement(true); - InnerPane->grab(); - - calculateClientArea(); - resizeInnerPane(); -} - -CGUIPanel::~CGUIPanel() -{ - // because the inner pane has the list of children, we need to remove the outer ones manually - IGUIElement::removeChild(VScrollBar); - IGUIElement::removeChild(HScrollBar); - IGUIElement::removeChild(ClipPane); - - // now we can drop the others - VScrollBar->drop(); - HScrollBar->drop(); - ClipPane->drop(); - InnerPane->drop(); -} - - -void CGUIPanel::draw() -{ - if (NeedsUpdate) - { - calculateClientArea(); - resizeInnerPane(); - NeedsUpdate = false; - } - - IGUISkin* skin = Environment->getSkin(); - if (Border && skin) - { - skin->draw3DSunkenPane( this, skin->getColor( EGDC_APP_WORKSPACE), false, true, AbsoluteRect, &AbsoluteClippingRect ); - } - - IGUIElement::draw(); -} - -void CGUIPanel::addChild(IGUIElement *child) -{ - // add the child to the inner pane - InnerPane->addChild(child); - - NeedsUpdate = true; -} - -void CGUIPanel::removeChild(IGUIElement *child) -{ - InnerPane->removeChild(child); - - NeedsUpdate = true; -} - -//! returns children of the inner pane -const core::list& CGUIPanel::getChildren() -{ - return InnerPane->getChildren(); -} - -bool CGUIPanel::hasBorder() const -{ - return Border; -} - -void CGUIPanel::setBorder( bool enabled ) -{ - Border = enabled; -} - -IGUIScrollBar* CGUIPanel::getVScrollBar() const -{ - return VScrollBar; -} - -IGUIScrollBar* CGUIPanel::getHScrollBar() const -{ - return HScrollBar; -} - -E_SCROLL_BAR_MODE CGUIPanel::getVScrollBarMode() const -{ - return VScrollBarMode; -} - -void CGUIPanel::setVScrollBarMode( E_SCROLL_BAR_MODE mode ) -{ - VScrollBarMode = mode; - NeedsUpdate = true; -} - -E_SCROLL_BAR_MODE CGUIPanel::getHScrollBarMode() const -{ - return HScrollBarMode; -} - -void CGUIPanel::setHScrollBarMode(E_SCROLL_BAR_MODE mode) -{ - HScrollBarMode = mode; - NeedsUpdate = true; -} - -bool CGUIPanel::OnEvent(const SEvent &event) -{ - // Redirect mouse wheel to scrollbar - if (event.EventType == EET_MOUSE_INPUT_EVENT && event.MouseInput.Event == EMIE_MOUSE_WHEEL) - { - if (VScrollBar->isVisible()) - { - Environment->setFocus(VScrollBar); - VScrollBar->OnEvent(event); - return true; - } - else if (VScrollBar->isVisible()) - { - Environment->setFocus(HScrollBar); - HScrollBar->OnEvent(event); - return true; - } - } - else - { - if (event.EventType == EET_GUI_EVENT && event.GUIEvent.EventType == EGET_SCROLL_BAR_CHANGED && - (event.GUIEvent.Caller == HScrollBar || event.GUIEvent.Caller == VScrollBar) ) - { - moveInnerPane(); - - return true; - } - } - - return IGUIElement::OnEvent(event); -} - -void CGUIPanel::moveInnerPane() -{ - core::dimension2d dim = InnerPane->getAbsolutePosition().getSize(); - core::position2d newpos(HScrollBar->isVisible() ? -HScrollBar->getPos() : 0 , VScrollBar->isVisible() ? -VScrollBar->getPos() : 0); - core::rect r(newpos, newpos + dim); - InnerPane->setRelativePosition(r); -} - - -void CGUIPanel::updateAbsolutePosition() -{ - IGUIElement::updateAbsolutePosition(); - calculateClientArea(); - resizeInnerPane(); -} - - -void CGUIPanel::resizeInnerPane() -{ - if (!HScrollBar || !VScrollBar || !InnerPane || !ClipPane) - return; - - // get outer pane size - core::rect outerRect = ClipPane->getRelativePosition(); - - // resize flexible children depending on outer pane - InnerPane->setRelativePosition(outerRect); - - // get desired size (total size of all children) - core::rect totalRect(0, 0, 0, 0); - - core::list::ConstIterator it; - - for (it = InnerPane->getChildren().begin(); - it != InnerPane->getChildren().end(); ++it) - { - core::rect rct = (*it)->getRelativePosition(); - totalRect.addInternalPoint(rct.UpperLeftCorner); - totalRect.addInternalPoint(rct.LowerRightCorner); - } - - // move children if pane needs to grow - core::position2di adjustedMovement(0,0); - - if (totalRect.UpperLeftCorner.X < 0) - adjustedMovement.X = -totalRect.UpperLeftCorner.X; - if (totalRect.UpperLeftCorner.Y < 0) - adjustedMovement.Y = -totalRect.UpperLeftCorner.Y; - - if (adjustedMovement.X > 0 || adjustedMovement.Y > 0) - { - totalRect += adjustedMovement; - - for (it = InnerPane->getChildren().begin(); - it != InnerPane->getChildren().end(); ++it ) - { - (*it)->move(adjustedMovement); - } - } - - // make sure the inner pane is at least as big as the outer - if (totalRect.getWidth() < outerRect.getWidth()) - { - totalRect.UpperLeftCorner.X = 0; - totalRect.LowerRightCorner.X = outerRect.getWidth(); - } - if (totalRect.getHeight() < outerRect.getHeight()) - { - totalRect.UpperLeftCorner.Y = 0; - totalRect.LowerRightCorner.Y = outerRect.getHeight(); - } - - InnerPane->setRelativePosition(totalRect); - - // scrollbars - if ( HScrollBarMode != ESBM_ALWAYS_INVISIBLE && - (totalRect.getWidth() > outerRect.getWidth() || HScrollBarMode == ESBM_ALWAYS_VISIBLE) ) - { - HScrollBar->setVisible(true); - HScrollBar->setMax(totalRect.getWidth() - outerRect.getWidth()); - bringToFront(HScrollBar); - } - else - HScrollBar->setVisible(false); - - if ( VScrollBarMode != ESBM_ALWAYS_INVISIBLE && - (totalRect.getHeight() > outerRect.getHeight() || VScrollBarMode == ESBM_ALWAYS_VISIBLE) ) - { - VScrollBar->setVisible(true); - VScrollBar->setMax(totalRect.getHeight() - outerRect.getHeight()); - bringToFront(VScrollBar); - } - else - VScrollBar->setVisible(false); - - // move to adjust for scrollbar pos - moveInnerPane(); -} - -void CGUIPanel::calculateClientArea() -{ - core::rect ClientArea(0,0, AbsoluteRect.getWidth(),AbsoluteRect.getHeight()); - - if (VScrollBar->isVisible()) - ClientArea.LowerRightCorner.X -= VScrollBar->getRelativePosition().getWidth(); - - if (HScrollBar->isVisible()) - ClientArea.LowerRightCorner.Y -= HScrollBar->getRelativePosition().getHeight(); - - if (Border) - { - ClientArea.UpperLeftCorner += core::position2d( BORDER_WIDTH, BORDER_WIDTH ); - ClientArea.LowerRightCorner -= core::position2d( BORDER_WIDTH, BORDER_WIDTH ); - } - - ClipPane->setRelativePosition(ClientArea); -} - -core::rect CGUIPanel::getClientArea() const -{ - return ClipPane->getRelativePosition(); -} - -void CGUIPanel::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) -{ - IGUIElement::serializeAttributes(out, options); - - out->addBool("border", Border); - out->addEnum("horizontalScrollBar", HScrollBarMode, GUIScrollBarModeNames ); - out->addEnum("verticalScrollBar", VScrollBarMode, GUIScrollBarModeNames ); -} - -void CGUIPanel::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options) -{ - IGUIElement::deserializeAttributes(in, options); - - setBorder(in->getAttributeAsBool("border")); - setHScrollBarMode((E_SCROLL_BAR_MODE)in->getAttributeAsEnumeration("horizontalScrollBar", GUIScrollBarModeNames)); - setVScrollBarMode((E_SCROLL_BAR_MODE)in->getAttributeAsEnumeration("verticalScrollBar", GUIScrollBarModeNames)); -} - -} // namespace gui -} // namespace irr +// Copyright 2006-2012 Asger Feldthaus +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +/* + Originally Klasker's but I've messed around with it lots - Gaz +*/ + +#include "CGUIPanel.h" +#include "IGUIEnvironment.h" +#include "IGUIScrollBar.h" +#include "IGUITabControl.h" +#include "IVideoDriver.h" + +const int SCROLL_BAR_SIZE = 16; // Scroll bars are 16 pixels wide +const int BORDER_WIDTH = 2; + +namespace irr +{ +namespace gui +{ + +CGUIPanel::CGUIPanel(IGUIEnvironment* environment, IGUIElement* parent, s32 id, const core::rect& rectangle, + bool border, E_SCROLL_BAR_MODE vMode, E_SCROLL_BAR_MODE hMode) + : IGUIElement(EGUIET_ELEMENT, environment, parent, id, rectangle), + VScrollBar(0), HScrollBar(0), ClipPane(0), InnerPane(0), + VScrollBarMode(vMode), HScrollBarMode(hMode), NeedsUpdate(true), Border(border) +{ + #ifdef _DEBUG + setDebugName("CGUIPanel"); + #endif + + s32 width = rectangle.getWidth(); + s32 height = rectangle.getHeight(); + + core::rect rct = core::rect(width - SCROLL_BAR_SIZE,0, width, height); + + VScrollBar = environment->addScrollBar(false, rct, 0, id); + VScrollBar->setSubElement(true); + VScrollBar->setTabStop(false); + VScrollBar->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT); + VScrollBar->grab(); + IGUIElement::addChild(VScrollBar); + + rct = core::rect(0, height - SCROLL_BAR_SIZE, width - SCROLL_BAR_SIZE,height ); + + HScrollBar = environment->addScrollBar(true, rct, 0, id); + HScrollBar->setSubElement(true); + HScrollBar->setTabStop(false); + HScrollBar->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT); + HScrollBar->grab(); + IGUIElement::addChild(HScrollBar); + + rct = core::rect(0,0, width - SCROLL_BAR_SIZE, height - SCROLL_BAR_SIZE); + + ClipPane = environment->addTab( rct, 0, -1); + ClipPane->setSubElement(true); + ClipPane->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT); + ClipPane->grab(); + IGUIElement::addChild(ClipPane); + + InnerPane = environment->addTab(rct, ClipPane, -1); + InnerPane->setSubElement(true); + InnerPane->grab(); + + calculateClientArea(); + resizeInnerPane(); +} + +CGUIPanel::~CGUIPanel() +{ + // because the inner pane has the list of children, we need to remove the outer ones manually + IGUIElement::removeChild(VScrollBar); + IGUIElement::removeChild(HScrollBar); + IGUIElement::removeChild(ClipPane); + + // now we can drop the others + VScrollBar->drop(); + HScrollBar->drop(); + ClipPane->drop(); + InnerPane->drop(); +} + + +void CGUIPanel::draw() +{ + if (NeedsUpdate) + { + calculateClientArea(); + resizeInnerPane(); + NeedsUpdate = false; + } + + IGUISkin* skin = Environment->getSkin(); + if (Border && skin) + { + skin->draw3DSunkenPane( this, skin->getColor( EGDC_APP_WORKSPACE), false, true, AbsoluteRect, &AbsoluteClippingRect ); + } + + IGUIElement::draw(); +} + +void CGUIPanel::addChild(IGUIElement *child) +{ + // add the child to the inner pane + InnerPane->addChild(child); + + NeedsUpdate = true; +} + +void CGUIPanel::removeChild(IGUIElement *child) +{ + InnerPane->removeChild(child); + + NeedsUpdate = true; +} + +//! returns children of the inner pane +const core::list& CGUIPanel::getChildren() +{ + return InnerPane->getChildren(); +} + +bool CGUIPanel::hasBorder() const +{ + return Border; +} + +void CGUIPanel::setBorder( bool enabled ) +{ + Border = enabled; +} + +IGUIScrollBar* CGUIPanel::getVScrollBar() const +{ + return VScrollBar; +} + +IGUIScrollBar* CGUIPanel::getHScrollBar() const +{ + return HScrollBar; +} + +E_SCROLL_BAR_MODE CGUIPanel::getVScrollBarMode() const +{ + return VScrollBarMode; +} + +void CGUIPanel::setVScrollBarMode( E_SCROLL_BAR_MODE mode ) +{ + VScrollBarMode = mode; + NeedsUpdate = true; +} + +E_SCROLL_BAR_MODE CGUIPanel::getHScrollBarMode() const +{ + return HScrollBarMode; +} + +void CGUIPanel::setHScrollBarMode(E_SCROLL_BAR_MODE mode) +{ + HScrollBarMode = mode; + NeedsUpdate = true; +} + +bool CGUIPanel::OnEvent(const SEvent &event) +{ + // Redirect mouse wheel to scrollbar + if (event.EventType == EET_MOUSE_INPUT_EVENT && event.MouseInput.Event == EMIE_MOUSE_WHEEL) + { + if (VScrollBar->isVisible()) + { + Environment->setFocus(VScrollBar); + VScrollBar->OnEvent(event); + return true; + } + else if (VScrollBar->isVisible()) + { + Environment->setFocus(HScrollBar); + HScrollBar->OnEvent(event); + return true; + } + } + else + { + if (event.EventType == EET_GUI_EVENT && event.GUIEvent.EventType == EGET_SCROLL_BAR_CHANGED && + (event.GUIEvent.Caller == HScrollBar || event.GUIEvent.Caller == VScrollBar) ) + { + moveInnerPane(); + + return true; + } + } + + return IGUIElement::OnEvent(event); +} + +void CGUIPanel::moveInnerPane() +{ + core::dimension2d dim = InnerPane->getAbsolutePosition().getSize(); + core::position2d newpos(HScrollBar->isVisible() ? -HScrollBar->getPos() : 0 , VScrollBar->isVisible() ? -VScrollBar->getPos() : 0); + core::rect r(newpos, newpos + dim); + InnerPane->setRelativePosition(r); +} + + +void CGUIPanel::updateAbsolutePosition() +{ + IGUIElement::updateAbsolutePosition(); + calculateClientArea(); + resizeInnerPane(); +} + + +void CGUIPanel::resizeInnerPane() +{ + if (!HScrollBar || !VScrollBar || !InnerPane || !ClipPane) + return; + + // get outer pane size + core::rect outerRect = ClipPane->getRelativePosition(); + + // resize flexible children depending on outer pane + InnerPane->setRelativePosition(outerRect); + + // get desired size (total size of all children) + core::rect totalRect(0, 0, 0, 0); + + core::list::ConstIterator it; + + for (it = InnerPane->getChildren().begin(); + it != InnerPane->getChildren().end(); ++it) + { + core::rect rct = (*it)->getRelativePosition(); + totalRect.addInternalPoint(rct.UpperLeftCorner); + totalRect.addInternalPoint(rct.LowerRightCorner); + } + + // move children if pane needs to grow + core::position2di adjustedMovement(0,0); + + if (totalRect.UpperLeftCorner.X < 0) + adjustedMovement.X = -totalRect.UpperLeftCorner.X; + if (totalRect.UpperLeftCorner.Y < 0) + adjustedMovement.Y = -totalRect.UpperLeftCorner.Y; + + if (adjustedMovement.X > 0 || adjustedMovement.Y > 0) + { + totalRect += adjustedMovement; + + for (it = InnerPane->getChildren().begin(); + it != InnerPane->getChildren().end(); ++it ) + { + (*it)->move(adjustedMovement); + } + } + + // make sure the inner pane is at least as big as the outer + if (totalRect.getWidth() < outerRect.getWidth()) + { + totalRect.UpperLeftCorner.X = 0; + totalRect.LowerRightCorner.X = outerRect.getWidth(); + } + if (totalRect.getHeight() < outerRect.getHeight()) + { + totalRect.UpperLeftCorner.Y = 0; + totalRect.LowerRightCorner.Y = outerRect.getHeight(); + } + + InnerPane->setRelativePosition(totalRect); + + // scrollbars + if ( HScrollBarMode != ESBM_ALWAYS_INVISIBLE && + (totalRect.getWidth() > outerRect.getWidth() || HScrollBarMode == ESBM_ALWAYS_VISIBLE) ) + { + HScrollBar->setVisible(true); + HScrollBar->setMax(totalRect.getWidth() - outerRect.getWidth()); + bringToFront(HScrollBar); + } + else + HScrollBar->setVisible(false); + + if ( VScrollBarMode != ESBM_ALWAYS_INVISIBLE && + (totalRect.getHeight() > outerRect.getHeight() || VScrollBarMode == ESBM_ALWAYS_VISIBLE) ) + { + VScrollBar->setVisible(true); + VScrollBar->setMax(totalRect.getHeight() - outerRect.getHeight()); + bringToFront(VScrollBar); + } + else + VScrollBar->setVisible(false); + + // move to adjust for scrollbar pos + moveInnerPane(); +} + +void CGUIPanel::calculateClientArea() +{ + core::rect ClientArea(0,0, AbsoluteRect.getWidth(),AbsoluteRect.getHeight()); + + if (VScrollBar->isVisible()) + ClientArea.LowerRightCorner.X -= VScrollBar->getRelativePosition().getWidth(); + + if (HScrollBar->isVisible()) + ClientArea.LowerRightCorner.Y -= HScrollBar->getRelativePosition().getHeight(); + + if (Border) + { + ClientArea.UpperLeftCorner += core::position2d( BORDER_WIDTH, BORDER_WIDTH ); + ClientArea.LowerRightCorner -= core::position2d( BORDER_WIDTH, BORDER_WIDTH ); + } + + ClipPane->setRelativePosition(ClientArea); +} + +core::rect CGUIPanel::getClientArea() const +{ + return ClipPane->getRelativePosition(); +} + +void CGUIPanel::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) +{ + IGUIElement::serializeAttributes(out, options); + + out->addBool("border", Border); + out->addEnum("horizontalScrollBar", HScrollBarMode, GUIScrollBarModeNames ); + out->addEnum("verticalScrollBar", VScrollBarMode, GUIScrollBarModeNames ); +} + +void CGUIPanel::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options) +{ + IGUIElement::deserializeAttributes(in, options); + + setBorder(in->getAttributeAsBool("border")); + setHScrollBarMode((E_SCROLL_BAR_MODE)in->getAttributeAsEnumeration("horizontalScrollBar", GUIScrollBarModeNames)); + setVScrollBarMode((E_SCROLL_BAR_MODE)in->getAttributeAsEnumeration("verticalScrollBar", GUIScrollBarModeNames)); +} + +} // namespace gui +} // namespace irr diff --git a/libraries/irrlicht-1.8/tools/GUIEditor/CGUIPanel.h b/libraries/irrlicht-1.8/tools/GUIEditor/CGUIPanel.h index cb6f79a..87609c9 100644 --- a/libraries/irrlicht-1.8/tools/GUIEditor/CGUIPanel.h +++ b/libraries/irrlicht-1.8/tools/GUIEditor/CGUIPanel.h @@ -1,128 +1,128 @@ -// Copyright 2006-2012 Asger Feldthaus -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef _C_GUI_PANEL_H_ -#define _C_GUI_PANEL_H_ - -#include "IGUIElement.h" -#include "EGUIEditTypes.h" - -namespace irr -{ -namespace gui -{ - -class IGUIScrollBar; -class IGUITab; - -enum E_SCROLL_BAR_MODE -{ - //! The scrollbar will only show up when needed. - ESBM_AUTOMATIC = 0, - - //! The scrollbar will never be visible. - ESBM_ALWAYS_INVISIBLE, - - //! The scrollbar will always the visible. - ESBM_ALWAYS_VISIBLE, - - //! just a count of how many are in this enum - ESBM_COUNT -}; - -const c8* const GUIScrollBarModeNames[] = -{ - "automatic", - "alwaysInvisible", - "alwaysVisible", - 0 -}; - -class CGUIPanel : public IGUIElement -{ -public: - CGUIPanel( IGUIEnvironment* environment, IGUIElement* parent, s32 id=-1, - const core::rect& rectangle = core::rect(0,0,100,100), - bool border=false, - E_SCROLL_BAR_MODE vMode=ESBM_AUTOMATIC, - E_SCROLL_BAR_MODE hMode=ESBM_ALWAYS_INVISIBLE ); - - virtual ~CGUIPanel(); - - //! draws the panel and its children - virtual void draw(); - - //! returns true if it has a border, false if not - bool hasBorder() const; - - //! sets whether the element draws a border - void setBorder(bool enabled); - - //! returns a pointer to the vertical scrollbar - IGUIScrollBar* getVScrollBar() const; - - //! returns a pointer to the horizontal scrollbar - IGUIScrollBar* getHScrollBar() const; - - //! returns the vertical scrollbar visibility rule - E_SCROLL_BAR_MODE getVScrollBarMode() const; - - //! sets the vertical scrollbar visibility rule - void setVScrollBarMode(E_SCROLL_BAR_MODE mode); - - //! returns the horizontal scrollbar visibility rule - E_SCROLL_BAR_MODE getHScrollBarMode() const; - - //! sets the horizontal scrollbar visibility rule - void setHScrollBarMode(E_SCROLL_BAR_MODE mode); - - //! returns the visible area inside the panel, excluding scrollbar and border - core::rect getClientArea() const; - - virtual bool OnEvent(const SEvent &event); - - //! adds a child to the panel - virtual void addChild(IGUIElement* child); - - //! removes a child from the panel - virtual void removeChild(IGUIElement* child); - - //! updates the absolute position - virtual void updateAbsolutePosition(); - - //! returns children of the inner pane - virtual const core::list& getChildren(); - - //! Returns the type name of the gui element. - virtual const c8* getTypeName() const - { - return GUIEditElementTypeNames[EGUIEDIT_GUIPANEL]; - } - - virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0); - virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0); - -protected: - void moveInnerPane(); - void resizeInnerPane(); - void calculateClientArea(); - -private: - - IGUIScrollBar* VScrollBar; - IGUIScrollBar* HScrollBar; - IGUITab* ClipPane; - IGUITab* InnerPane; - - E_SCROLL_BAR_MODE VScrollBarMode; - E_SCROLL_BAR_MODE HScrollBarMode; - - bool NeedsUpdate; - bool Border; -}; - -} // namespace gui -} // namespace irr - -#endif +// Copyright 2006-2012 Asger Feldthaus +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef _C_GUI_PANEL_H_ +#define _C_GUI_PANEL_H_ + +#include "IGUIElement.h" +#include "EGUIEditTypes.h" + +namespace irr +{ +namespace gui +{ + +class IGUIScrollBar; +class IGUITab; + +enum E_SCROLL_BAR_MODE +{ + //! The scrollbar will only show up when needed. + ESBM_AUTOMATIC = 0, + + //! The scrollbar will never be visible. + ESBM_ALWAYS_INVISIBLE, + + //! The scrollbar will always the visible. + ESBM_ALWAYS_VISIBLE, + + //! just a count of how many are in this enum + ESBM_COUNT +}; + +const c8* const GUIScrollBarModeNames[] = +{ + "automatic", + "alwaysInvisible", + "alwaysVisible", + 0 +}; + +class CGUIPanel : public IGUIElement +{ +public: + CGUIPanel( IGUIEnvironment* environment, IGUIElement* parent, s32 id=-1, + const core::rect& rectangle = core::rect(0,0,100,100), + bool border=false, + E_SCROLL_BAR_MODE vMode=ESBM_AUTOMATIC, + E_SCROLL_BAR_MODE hMode=ESBM_ALWAYS_INVISIBLE ); + + virtual ~CGUIPanel(); + + //! draws the panel and its children + virtual void draw(); + + //! returns true if it has a border, false if not + bool hasBorder() const; + + //! sets whether the element draws a border + void setBorder(bool enabled); + + //! returns a pointer to the vertical scrollbar + IGUIScrollBar* getVScrollBar() const; + + //! returns a pointer to the horizontal scrollbar + IGUIScrollBar* getHScrollBar() const; + + //! returns the vertical scrollbar visibility rule + E_SCROLL_BAR_MODE getVScrollBarMode() const; + + //! sets the vertical scrollbar visibility rule + void setVScrollBarMode(E_SCROLL_BAR_MODE mode); + + //! returns the horizontal scrollbar visibility rule + E_SCROLL_BAR_MODE getHScrollBarMode() const; + + //! sets the horizontal scrollbar visibility rule + void setHScrollBarMode(E_SCROLL_BAR_MODE mode); + + //! returns the visible area inside the panel, excluding scrollbar and border + core::rect getClientArea() const; + + virtual bool OnEvent(const SEvent &event); + + //! adds a child to the panel + virtual void addChild(IGUIElement* child); + + //! removes a child from the panel + virtual void removeChild(IGUIElement* child); + + //! updates the absolute position + virtual void updateAbsolutePosition(); + + //! returns children of the inner pane + virtual const core::list& getChildren(); + + //! Returns the type name of the gui element. + virtual const c8* getTypeName() const + { + return GUIEditElementTypeNames[EGUIEDIT_GUIPANEL]; + } + + virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0); + virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0); + +protected: + void moveInnerPane(); + void resizeInnerPane(); + void calculateClientArea(); + +private: + + IGUIScrollBar* VScrollBar; + IGUIScrollBar* HScrollBar; + IGUITab* ClipPane; + IGUITab* InnerPane; + + E_SCROLL_BAR_MODE VScrollBarMode; + E_SCROLL_BAR_MODE HScrollBarMode; + + bool NeedsUpdate; + bool Border; +}; + +} // namespace gui +} // namespace irr + +#endif diff --git a/libraries/irrlicht-1.8/tools/GUIEditor/CGUIStringAttribute.h b/libraries/irrlicht-1.8/tools/GUIEditor/CGUIStringAttribute.h index af9ac03..36cac56 100644 --- a/libraries/irrlicht-1.8/tools/GUIEditor/CGUIStringAttribute.h +++ b/libraries/irrlicht-1.8/tools/GUIEditor/CGUIStringAttribute.h @@ -1,70 +1,70 @@ -#ifndef __C_GUI_STRING_ATTRIBUTE_H_INCLUDED__ -#define __C_GUI_STRING_ATTRIBUTE_H_INCLUDED__ - -#include "CGUIAttribute.h" -#include "IGUIEditBox.h" -#include "EGUIEditTypes.h" - -namespace irr -{ -namespace gui -{ - - class CGUIStringAttribute : public CGUIAttribute - { - public: - // - CGUIStringAttribute(IGUIEnvironment* environment, IGUIElement *parent, s32 myParentID) : - CGUIAttribute(environment, parent, myParentID), - AttribEditBox(0) - { - core::rect r = getAbsolutePosition(); - core::rect r2(0, Environment->getSkin()->getFont()->getDimension(L"A").Height + 10, - r.getWidth() - 5, - Environment->getSkin()->getFont()->getDimension(L"A").Height*2 + 15 ); - - AttribEditBox = environment->addEditBox(0, r2, true, this, -1); - AttribEditBox->grab(); - AttribEditBox->setSubElement(true); - AttribEditBox->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT); - - } - - virtual ~CGUIStringAttribute() - { - if (AttribEditBox) - AttribEditBox->drop(); - } - - virtual void setAttrib(io::IAttributes *attribs, u32 attribIndex) - { - AttribEditBox->setText(attribs->getAttributeAsStringW(attribIndex).c_str()); - CGUIAttribute::setAttrib(attribs, attribIndex); - } - - //! save the attribute and possibly post the event to its parent - virtual bool updateAttrib(bool sendEvent=true) - { - if (!Attribs) - return true; - - Attribs->setAttribute(Index, AttribEditBox->getText()); - AttribEditBox->setText(Attribs->getAttributeAsStringW(Index).c_str()); - - return CGUIAttribute::updateAttrib(sendEvent); - } - - //! Returns the type name of the gui element. - virtual const c8* getTypeName() const - { - return GUIEditElementTypeNames[EGUIEDIT_STRINGATTRIBUTE]; - } - - private: - IGUIEditBox* AttribEditBox; - }; - -} // namespace gui -} // namespace irr - -#endif +#ifndef __C_GUI_STRING_ATTRIBUTE_H_INCLUDED__ +#define __C_GUI_STRING_ATTRIBUTE_H_INCLUDED__ + +#include "CGUIAttribute.h" +#include "IGUIEditBox.h" +#include "EGUIEditTypes.h" + +namespace irr +{ +namespace gui +{ + + class CGUIStringAttribute : public CGUIAttribute + { + public: + // + CGUIStringAttribute(IGUIEnvironment* environment, IGUIElement *parent, s32 myParentID) : + CGUIAttribute(environment, parent, myParentID), + AttribEditBox(0) + { + core::rect r = getAbsolutePosition(); + core::rect r2(0, Environment->getSkin()->getFont()->getDimension(L"A").Height + 10, + r.getWidth() - 5, + Environment->getSkin()->getFont()->getDimension(L"A").Height*2 + 15 ); + + AttribEditBox = environment->addEditBox(0, r2, true, this, -1); + AttribEditBox->grab(); + AttribEditBox->setSubElement(true); + AttribEditBox->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT); + + } + + virtual ~CGUIStringAttribute() + { + if (AttribEditBox) + AttribEditBox->drop(); + } + + virtual void setAttrib(io::IAttributes *attribs, u32 attribIndex) + { + AttribEditBox->setText(attribs->getAttributeAsStringW(attribIndex).c_str()); + CGUIAttribute::setAttrib(attribs, attribIndex); + } + + //! save the attribute and possibly post the event to its parent + virtual bool updateAttrib(bool sendEvent=true) + { + if (!Attribs) + return true; + + Attribs->setAttribute(Index, AttribEditBox->getText()); + AttribEditBox->setText(Attribs->getAttributeAsStringW(Index).c_str()); + + return CGUIAttribute::updateAttrib(sendEvent); + } + + //! Returns the type name of the gui element. + virtual const c8* getTypeName() const + { + return GUIEditElementTypeNames[EGUIEDIT_STRINGATTRIBUTE]; + } + + private: + IGUIEditBox* AttribEditBox; + }; + +} // namespace gui +} // namespace irr + +#endif diff --git a/libraries/irrlicht-1.8/tools/GUIEditor/CGUITextureAttribute.h b/libraries/irrlicht-1.8/tools/GUIEditor/CGUITextureAttribute.h index 6a4fef2..bee43a9 100644 --- a/libraries/irrlicht-1.8/tools/GUIEditor/CGUITextureAttribute.h +++ b/libraries/irrlicht-1.8/tools/GUIEditor/CGUITextureAttribute.h @@ -1,140 +1,140 @@ -#ifndef __C_GUI_TEXTURE_ATTRIBUTE_H_INCLUDED__ -#define __C_GUI_TEXTURE_ATTRIBUTE_H_INCLUDED__ - -#include "CGUIAttribute.h" -#include "IGUIEditBox.h" -#include "IGUIImage.h" -#include "IGUIButton.h" -#include "EGUIEditTypes.h" - -namespace irr -{ -namespace gui -{ - - class CGUITextureAttribute : public CGUIAttribute - { - public: - // - CGUITextureAttribute(IGUIEnvironment* environment, IGUIElement *parent, s32 myParentID) : - CGUIAttribute(environment, parent, myParentID), - AttribEditBox(0), AttribImage(0), AttribButton(0) - { - IGUISkin* skin = Environment->getSkin(); - - core::rect r = getAbsolutePosition(); - s32 topy = skin->getFont()->getDimension(L"A").Height + 10; - s32 h = skin->getFont()->getDimension(L"A").Height + 5; - - AttribImage = environment->addImage(0, core::position2di(0, topy), false, this); - AttribImage->setRelativePosition( core::rect(0,topy, r.getWidth() - 5, 100+topy)); - AttribImage->grab(); - AttribImage->setSubElement(true); - AttribImage->setScaleImage(true); - AttribImage->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT); - - topy += 105; - - core::rect r2(0, topy, r.getWidth() - 15 - skin->getSize(EGDS_CHECK_BOX_WIDTH), topy + h); - core::rect br(r.getWidth() - 10 - skin->getSize(EGDS_CHECK_BOX_WIDTH), topy, r.getWidth(), topy + h); - - AttribEditBox = environment->addEditBox(0, r2, true, this, -1); - AttribEditBox->grab(); - AttribEditBox->setSubElement(true); - AttribEditBox->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT); - - AttribButton = environment->addButton(br, this, -1, L"..."); - AttribButton->grab(); - AttribButton->setSubElement(true); - AttribButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT); - //AttribButton->setSpriteBank(skin->getSpriteBank()); - //AttribButton->setSprite(EGBS_BUTTON_UP, skin->getIcon(EGDI_FILE), skin->getColor(EGDC_WINDOW_SYMBOL)); - //AttribButton->setSprite(EGBS_BUTTON_DOWN, skin->getIcon(EGDI_FILE), skin->getColor(EGDC_WINDOW_SYMBOL), true); - } - - virtual ~CGUITextureAttribute() - { - if (AttribEditBox) - AttribEditBox->drop(); - if (AttribImage) - AttribImage->drop(); - if (AttribButton) - AttribButton->drop(); - } - - virtual bool OnEvent(const SEvent &e) - { - - if (IsEnabled) - { - switch (e.EventType) - { - case EET_GUI_EVENT: - switch (e.GUIEvent.EventType) - { - case EGET_BUTTON_CLICKED: - // button click: open file dialog - if (e.GUIEvent.Caller == AttribButton) - { - //Environment->addGUIElement("textureBrowser", Environment->getRootGUIElement()); - return true; - } - break; - case EGET_FILE_SELECTED: - // file selected: change editbox value and set event - - return true; - case EGET_FILE_CHOOSE_DIALOG_CANCELLED: - - return true; - default: - break; - } - break; - case EET_KEY_INPUT_EVENT: - return true; - default: - break; - } - } - return CGUIAttribute::OnEvent(e); - } - - virtual void setAttrib(io::IAttributes *attribs, u32 attribIndex) - { - AttribEditBox->setText(attribs->getAttributeAsStringW(attribIndex).c_str()); - AttribImage->setImage(attribs->getAttributeAsTexture(Index)); - - CGUIAttribute::setAttrib(attribs, attribIndex); - } - - //! save the attribute and possibly post the event to its parent - virtual bool updateAttrib(bool sendEvent=true) - { - if (!Attribs) - return true; - - Attribs->setAttribute(Index, AttribEditBox->getText()); - core::stringw tmp = Attribs->getAttributeAsStringW(Index); - AttribEditBox->setText(Attribs->getAttributeAsStringW(Index).c_str()); - AttribImage->setImage(Attribs->getAttributeAsTexture(Index)); - - return CGUIAttribute::updateAttrib(sendEvent); - } - - //! Returns the type name of the gui element. - virtual const c8* getTypeName() const - { - return GUIEditElementTypeNames[EGUIEDIT_TEXTUREATTRIBUTE]; - } - - private: - IGUIEditBox* AttribEditBox; - IGUIImage* AttribImage; - IGUIButton* AttribButton; - }; - -} // namespace gui -} // namespace irr - -#endif +#ifndef __C_GUI_TEXTURE_ATTRIBUTE_H_INCLUDED__ +#define __C_GUI_TEXTURE_ATTRIBUTE_H_INCLUDED__ + +#include "CGUIAttribute.h" +#include "IGUIEditBox.h" +#include "IGUIImage.h" +#include "IGUIButton.h" +#include "EGUIEditTypes.h" + +namespace irr +{ +namespace gui +{ + + class CGUITextureAttribute : public CGUIAttribute + { + public: + // + CGUITextureAttribute(IGUIEnvironment* environment, IGUIElement *parent, s32 myParentID) : + CGUIAttribute(environment, parent, myParentID), + AttribEditBox(0), AttribImage(0), AttribButton(0) + { + IGUISkin* skin = Environment->getSkin(); + + core::rect r = getAbsolutePosition(); + s32 topy = skin->getFont()->getDimension(L"A").Height + 10; + s32 h = skin->getFont()->getDimension(L"A").Height + 5; + + AttribImage = environment->addImage(0, core::position2di(0, topy), false, this); + AttribImage->setRelativePosition( core::rect(0,topy, r.getWidth() - 5, 100+topy)); + AttribImage->grab(); + AttribImage->setSubElement(true); + AttribImage->setScaleImage(true); + AttribImage->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT); + + topy += 105; + + core::rect r2(0, topy, r.getWidth() - 15 - skin->getSize(EGDS_CHECK_BOX_WIDTH), topy + h); + core::rect br(r.getWidth() - 10 - skin->getSize(EGDS_CHECK_BOX_WIDTH), topy, r.getWidth(), topy + h); + + AttribEditBox = environment->addEditBox(0, r2, true, this, -1); + AttribEditBox->grab(); + AttribEditBox->setSubElement(true); + AttribEditBox->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT); + + AttribButton = environment->addButton(br, this, -1, L"..."); + AttribButton->grab(); + AttribButton->setSubElement(true); + AttribButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT); + //AttribButton->setSpriteBank(skin->getSpriteBank()); + //AttribButton->setSprite(EGBS_BUTTON_UP, skin->getIcon(EGDI_FILE), skin->getColor(EGDC_WINDOW_SYMBOL)); + //AttribButton->setSprite(EGBS_BUTTON_DOWN, skin->getIcon(EGDI_FILE), skin->getColor(EGDC_WINDOW_SYMBOL), true); + } + + virtual ~CGUITextureAttribute() + { + if (AttribEditBox) + AttribEditBox->drop(); + if (AttribImage) + AttribImage->drop(); + if (AttribButton) + AttribButton->drop(); + } + + virtual bool OnEvent(const SEvent &e) + { + + if (IsEnabled) + { + switch (e.EventType) + { + case EET_GUI_EVENT: + switch (e.GUIEvent.EventType) + { + case EGET_BUTTON_CLICKED: + // button click: open file dialog + if (e.GUIEvent.Caller == AttribButton) + { + //Environment->addGUIElement("textureBrowser", Environment->getRootGUIElement()); + return true; + } + break; + case EGET_FILE_SELECTED: + // file selected: change editbox value and set event + + return true; + case EGET_FILE_CHOOSE_DIALOG_CANCELLED: + + return true; + default: + break; + } + break; + case EET_KEY_INPUT_EVENT: + return true; + default: + break; + } + } + return CGUIAttribute::OnEvent(e); + } + + virtual void setAttrib(io::IAttributes *attribs, u32 attribIndex) + { + AttribEditBox->setText(attribs->getAttributeAsStringW(attribIndex).c_str()); + AttribImage->setImage(attribs->getAttributeAsTexture(Index)); + + CGUIAttribute::setAttrib(attribs, attribIndex); + } + + //! save the attribute and possibly post the event to its parent + virtual bool updateAttrib(bool sendEvent=true) + { + if (!Attribs) + return true; + + Attribs->setAttribute(Index, AttribEditBox->getText()); + core::stringw tmp = Attribs->getAttributeAsStringW(Index); + AttribEditBox->setText(Attribs->getAttributeAsStringW(Index).c_str()); + AttribImage->setImage(Attribs->getAttributeAsTexture(Index)); + + return CGUIAttribute::updateAttrib(sendEvent); + } + + //! Returns the type name of the gui element. + virtual const c8* getTypeName() const + { + return GUIEditElementTypeNames[EGUIEDIT_TEXTUREATTRIBUTE]; + } + + private: + IGUIEditBox* AttribEditBox; + IGUIImage* AttribImage; + IGUIButton* AttribButton; + }; + +} // namespace gui +} // namespace irr + +#endif diff --git a/libraries/irrlicht-1.8/tools/GUIEditor/CGUITextureCacheBrowser.cpp b/libraries/irrlicht-1.8/tools/GUIEditor/CGUITextureCacheBrowser.cpp index bac5233..6c80626 100644 --- a/libraries/irrlicht-1.8/tools/GUIEditor/CGUITextureCacheBrowser.cpp +++ b/libraries/irrlicht-1.8/tools/GUIEditor/CGUITextureCacheBrowser.cpp @@ -1,336 +1,336 @@ -// Copyright (C) 2002-2012 Nikolaus Gebhardt / Gaz Davidson -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "CGUITextureCacheBrowser.h" -#include "IGUIEnvironment.h" -#include "IGUIButton.h" -#include "IGUISkin.h" -#include "IGUIFont.h" -#include "IVideoDriver.h" - -namespace irr -{ -namespace gui -{ - -CGUITextureCacheBrowser::CGUITextureCacheBrowser(IGUIEnvironment* environment, s32 id, IGUIElement *parent) -: IGUIWindow(environment, parent, id, core::rect(0,0,300,200)), - CloseButton(0), Panel(0), SelectedTexture(-1), Dragging(false), IsDraggable(true) -{ - #ifdef _DEBUG - setDebugName("CGUITextureCacheBrowser"); - #endif - - IGUISkin* skin = 0; - IGUISpriteBank* sprites = 0; - video::SColor color(255,255,255,255); - - if (environment) - skin = environment->getSkin(); - - s32 buttonw = 15; - if (skin) - { - buttonw = skin->getSize(EGDS_WINDOW_BUTTON_WIDTH); - sprites = skin->getSpriteBank(); - color = skin->getColor(EGDC_WINDOW_SYMBOL); - } - s32 posx = RelativeRect.getWidth() - buttonw - 4; - - CloseButton = Environment->addButton(core::rect(posx, 3, posx + buttonw, 3 + buttonw), this, -1, - L"", skin ? skin->getDefaultText(EGDT_WINDOW_CLOSE) : L"Close" ); - CloseButton->setSubElement(true); - CloseButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT); - if (sprites) - { - CloseButton->setSpriteBank(sprites); - CloseButton->setSprite(EGBS_BUTTON_UP, skin->getIcon(EGDI_WINDOW_CLOSE), color); - CloseButton->setSprite(EGBS_BUTTON_DOWN, skin->getIcon(EGDI_WINDOW_CLOSE), color); - } - - CloseButton->grab(); - - // window title - Text = L"Texture Browser"; - - // panel element - Panel = new CGUIPanel(environment, this); - Panel->setRelativePosition( core::rect(1, buttonw + 5, 151, RelativeRect.getHeight() - 1)); - Panel->setAlignment(EGUIA_UPPERLEFT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT); - Panel->setBorder(true); - Panel->setSubElement(true); - - // some buttons - - - // add images from texture cache - updateImageList(); - -} - -CGUITextureCacheBrowser::~CGUITextureCacheBrowser() -{ - if (CloseButton) - CloseButton->drop(); - if (Panel) - Panel->drop(); - - // drop images - u32 i; - for (i=0; idrop(); - Images[i]->remove(); - } - Images.clear(); -} -void CGUITextureCacheBrowser::updateImageList() -{ - if (!Panel) - return; - - video::IVideoDriver* Driver = Environment->getVideoDriver(); - - // clear images - u32 i; - for (i=0; idrop(); - Images[i]->remove(); - } - Images.clear(); - - u32 count = (u32)Driver->getTextureCount(); - - s32 h = Panel->getClientArea().getWidth()-10; - s32 hw = h/2; - core::rect pos(Panel->getClientArea().getCenter().X - Panel->getAbsolutePosition().UpperLeftCorner.X - hw, 5, - Panel->getClientArea().getCenter().X - Panel->getAbsolutePosition().UpperLeftCorner.X + hw, h+5); - - core::position2di moveDist(0, h+5); - - for (u32 i=0; igetTextureByIndex(i); - details = L"File name: "; - details += tex->getName(); - details += L"\nFormat: "; - video::ECOLOR_FORMAT cf = tex->getColorFormat(); - - bool alpha = false; - - switch (cf) - { - case video::ECF_A1R5G5B5: - details += L"A1R5G5B5 (16-bit with 1-bit alpha channel)\n"; - alpha = true; - break; - case video::ECF_R5G6B5: - details += L"R5G6B5 (16-bit, no alpha channel)\n"; - break; - case video::ECF_R8G8B8: - details += L"R8G8B8 (16-bit, no alpha channel)\n"; - break; - case video::ECF_A8R8G8B8: - details += L"R8G8B8 (32-bit with 8-bit alpha channel)\n"; - alpha = true; - break; - default: - details += L"Unknown\n"; - } - - core::dimension2du osize = tex->getOriginalSize(); - core::dimension2du size = tex->getOriginalSize(); - - details += "Size: "; - details += size.Width; - details += "x"; - details += size.Height; - - if (osize != size) - { - details += "\nOriginal Size: "; - details += osize.Width; - details += "x"; - details += osize.Height; - } - - details += L"\nMip-maps: "; - - if (tex->hasMipMaps()) - details += L"Yes\n"; - else - details += L"No\n"; - - IGUIImage* img = Environment->addImage(tex, core::position2di(1,1), alpha, Panel, i); - img->grab(); - Images.push_back(img); - img->setRelativePosition(pos); - img->setToolTipText(details.c_str()); - img->setScaleImage(true); - img->setColor( SelectedTexture == (s32)i ? video::SColor(255,255,255,255) : video::SColor(128,128,128,128) ); - - pos = pos + moveDist; - } -} - -void CGUITextureCacheBrowser::updateAbsolutePosition() -{ - IGUIWindow::updateAbsolutePosition(); - updateImageList(); -} - -//! called if an event happened. -bool CGUITextureCacheBrowser::OnEvent(const SEvent &event) -{ - switch(event.EventType) - { - case EET_GUI_EVENT: - if (event.GUIEvent.EventType == EGET_ELEMENT_FOCUS_LOST) - { - if (event.GUIEvent.Caller == (IGUIElement*)this) - Dragging = false; - return true; - } - else - if (event.GUIEvent.EventType == EGET_BUTTON_CLICKED) - { - if (event.GUIEvent.Caller == CloseButton) - { - 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; - - if (getElementFromPoint(DragStart) == this) - { - if (!Environment->hasFocus(this)) - { - Dragging = IsDraggable; - //Environment->setFocus(this); - if (Parent) - Parent->bringToFront(this); - } - return true; - } - else - { - if (Panel->getAbsolutePosition().isPointInside(DragStart)) - { - // select an image - IGUIElement* el = Panel->getElementFromPoint(DragStart); - if (el && el != Panel) - { - if (el->getType() == EGUIET_IMAGE) - { - setSelected(el->getID()); - } - } - else - { - setSelected(); - } - } - } - break; - case EMIE_LMOUSE_LEFT_UP: - Dragging = false; - //Environment->removeFocus(this); - 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(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 Parent ? Parent->OnEvent(event) : false; -} - -void CGUITextureCacheBrowser::setSelected(s32 index) -{ - SelectedTexture = index; - updateImageList(); - printf("Texture %d selected\n", index); -} - -void CGUITextureCacheBrowser::draw() -{ - if (!IsVisible) - return; - - IGUISkin* skin = Environment->getSkin(); - - core::rect rect = AbsoluteRect; - core::rect *cl = &AbsoluteClippingRect; - - // draw body fast - rect = skin->draw3DWindowBackground(this, true, skin->getColor(EGDC_ACTIVE_BORDER), - AbsoluteRect, &AbsoluteClippingRect); - - // draw window text - if (Text.size()) - { - rect.UpperLeftCorner.X += skin->getSize(EGDS_TEXT_DISTANCE_X); - rect.UpperLeftCorner.Y += skin->getSize(EGDS_TEXT_DISTANCE_Y); - rect.LowerRightCorner.X -= skin->getSize(EGDS_WINDOW_BUTTON_WIDTH) + 5; - - IGUIFont* font = skin->getFont(); - if (font) - font->draw(Text.c_str(), rect, skin->getColor(EGDC_ACTIVE_CAPTION), false, true, cl); - } - - IGUIElement::draw(); -} - - -bool CGUITextureCacheBrowser::isDraggable() const -{ - return IsDraggable; -} - -void CGUITextureCacheBrowser::setDraggable(bool draggable) -{ - IsDraggable = draggable; - - if (Dragging && !IsDraggable) - Dragging = false; -} - - -//! Returns the rectangle of the drawable area (without border, without titlebar and without scrollbars) -core::rect CGUITextureCacheBrowser::getClientRect() const -{ - return core::recti(); -} - -} // namespace gui -} // namespace irr +// Copyright (C) 2002-2012 Nikolaus Gebhardt / Gaz Davidson +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CGUITextureCacheBrowser.h" +#include "IGUIEnvironment.h" +#include "IGUIButton.h" +#include "IGUISkin.h" +#include "IGUIFont.h" +#include "IVideoDriver.h" + +namespace irr +{ +namespace gui +{ + +CGUITextureCacheBrowser::CGUITextureCacheBrowser(IGUIEnvironment* environment, s32 id, IGUIElement *parent) +: IGUIWindow(environment, parent, id, core::rect(0,0,300,200)), + CloseButton(0), Panel(0), SelectedTexture(-1), Dragging(false), IsDraggable(true) +{ + #ifdef _DEBUG + setDebugName("CGUITextureCacheBrowser"); + #endif + + IGUISkin* skin = 0; + IGUISpriteBank* sprites = 0; + video::SColor color(255,255,255,255); + + if (environment) + skin = environment->getSkin(); + + s32 buttonw = 15; + if (skin) + { + buttonw = skin->getSize(EGDS_WINDOW_BUTTON_WIDTH); + sprites = skin->getSpriteBank(); + color = skin->getColor(EGDC_WINDOW_SYMBOL); + } + s32 posx = RelativeRect.getWidth() - buttonw - 4; + + CloseButton = Environment->addButton(core::rect(posx, 3, posx + buttonw, 3 + buttonw), this, -1, + L"", skin ? skin->getDefaultText(EGDT_WINDOW_CLOSE) : L"Close" ); + CloseButton->setSubElement(true); + CloseButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT); + if (sprites) + { + CloseButton->setSpriteBank(sprites); + CloseButton->setSprite(EGBS_BUTTON_UP, skin->getIcon(EGDI_WINDOW_CLOSE), color); + CloseButton->setSprite(EGBS_BUTTON_DOWN, skin->getIcon(EGDI_WINDOW_CLOSE), color); + } + + CloseButton->grab(); + + // window title + Text = L"Texture Browser"; + + // panel element + Panel = new CGUIPanel(environment, this); + Panel->setRelativePosition( core::rect(1, buttonw + 5, 151, RelativeRect.getHeight() - 1)); + Panel->setAlignment(EGUIA_UPPERLEFT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT); + Panel->setBorder(true); + Panel->setSubElement(true); + + // some buttons + + + // add images from texture cache + updateImageList(); + +} + +CGUITextureCacheBrowser::~CGUITextureCacheBrowser() +{ + if (CloseButton) + CloseButton->drop(); + if (Panel) + Panel->drop(); + + // drop images + u32 i; + for (i=0; idrop(); + Images[i]->remove(); + } + Images.clear(); +} +void CGUITextureCacheBrowser::updateImageList() +{ + if (!Panel) + return; + + video::IVideoDriver* Driver = Environment->getVideoDriver(); + + // clear images + u32 i; + for (i=0; idrop(); + Images[i]->remove(); + } + Images.clear(); + + u32 count = (u32)Driver->getTextureCount(); + + s32 h = Panel->getClientArea().getWidth()-10; + s32 hw = h/2; + core::rect pos(Panel->getClientArea().getCenter().X - Panel->getAbsolutePosition().UpperLeftCorner.X - hw, 5, + Panel->getClientArea().getCenter().X - Panel->getAbsolutePosition().UpperLeftCorner.X + hw, h+5); + + core::position2di moveDist(0, h+5); + + for (u32 i=0; igetTextureByIndex(i); + details = L"File name: "; + details += tex->getName(); + details += L"\nFormat: "; + video::ECOLOR_FORMAT cf = tex->getColorFormat(); + + bool alpha = false; + + switch (cf) + { + case video::ECF_A1R5G5B5: + details += L"A1R5G5B5 (16-bit with 1-bit alpha channel)\n"; + alpha = true; + break; + case video::ECF_R5G6B5: + details += L"R5G6B5 (16-bit, no alpha channel)\n"; + break; + case video::ECF_R8G8B8: + details += L"R8G8B8 (16-bit, no alpha channel)\n"; + break; + case video::ECF_A8R8G8B8: + details += L"R8G8B8 (32-bit with 8-bit alpha channel)\n"; + alpha = true; + break; + default: + details += L"Unknown\n"; + } + + core::dimension2du osize = tex->getOriginalSize(); + core::dimension2du size = tex->getOriginalSize(); + + details += "Size: "; + details += size.Width; + details += "x"; + details += size.Height; + + if (osize != size) + { + details += "\nOriginal Size: "; + details += osize.Width; + details += "x"; + details += osize.Height; + } + + details += L"\nMip-maps: "; + + if (tex->hasMipMaps()) + details += L"Yes\n"; + else + details += L"No\n"; + + IGUIImage* img = Environment->addImage(tex, core::position2di(1,1), alpha, Panel, i); + img->grab(); + Images.push_back(img); + img->setRelativePosition(pos); + img->setToolTipText(details.c_str()); + img->setScaleImage(true); + img->setColor( SelectedTexture == (s32)i ? video::SColor(255,255,255,255) : video::SColor(128,128,128,128) ); + + pos = pos + moveDist; + } +} + +void CGUITextureCacheBrowser::updateAbsolutePosition() +{ + IGUIWindow::updateAbsolutePosition(); + updateImageList(); +} + +//! called if an event happened. +bool CGUITextureCacheBrowser::OnEvent(const SEvent &event) +{ + switch(event.EventType) + { + case EET_GUI_EVENT: + if (event.GUIEvent.EventType == EGET_ELEMENT_FOCUS_LOST) + { + if (event.GUIEvent.Caller == (IGUIElement*)this) + Dragging = false; + return true; + } + else + if (event.GUIEvent.EventType == EGET_BUTTON_CLICKED) + { + if (event.GUIEvent.Caller == CloseButton) + { + 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; + + if (getElementFromPoint(DragStart) == this) + { + if (!Environment->hasFocus(this)) + { + Dragging = IsDraggable; + //Environment->setFocus(this); + if (Parent) + Parent->bringToFront(this); + } + return true; + } + else + { + if (Panel->getAbsolutePosition().isPointInside(DragStart)) + { + // select an image + IGUIElement* el = Panel->getElementFromPoint(DragStart); + if (el && el != Panel) + { + if (el->getType() == EGUIET_IMAGE) + { + setSelected(el->getID()); + } + } + else + { + setSelected(); + } + } + } + break; + case EMIE_LMOUSE_LEFT_UP: + Dragging = false; + //Environment->removeFocus(this); + 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(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 Parent ? Parent->OnEvent(event) : false; +} + +void CGUITextureCacheBrowser::setSelected(s32 index) +{ + SelectedTexture = index; + updateImageList(); + printf("Texture %d selected\n", index); +} + +void CGUITextureCacheBrowser::draw() +{ + if (!IsVisible) + return; + + IGUISkin* skin = Environment->getSkin(); + + core::rect rect = AbsoluteRect; + core::rect *cl = &AbsoluteClippingRect; + + // draw body fast + rect = skin->draw3DWindowBackground(this, true, skin->getColor(EGDC_ACTIVE_BORDER), + AbsoluteRect, &AbsoluteClippingRect); + + // draw window text + if (Text.size()) + { + rect.UpperLeftCorner.X += skin->getSize(EGDS_TEXT_DISTANCE_X); + rect.UpperLeftCorner.Y += skin->getSize(EGDS_TEXT_DISTANCE_Y); + rect.LowerRightCorner.X -= skin->getSize(EGDS_WINDOW_BUTTON_WIDTH) + 5; + + IGUIFont* font = skin->getFont(); + if (font) + font->draw(Text.c_str(), rect, skin->getColor(EGDC_ACTIVE_CAPTION), false, true, cl); + } + + IGUIElement::draw(); +} + + +bool CGUITextureCacheBrowser::isDraggable() const +{ + return IsDraggable; +} + +void CGUITextureCacheBrowser::setDraggable(bool draggable) +{ + IsDraggable = draggable; + + if (Dragging && !IsDraggable) + Dragging = false; +} + + +//! Returns the rectangle of the drawable area (without border, without titlebar and without scrollbars) +core::rect CGUITextureCacheBrowser::getClientRect() const +{ + return core::recti(); +} + +} // namespace gui +} // namespace irr diff --git a/libraries/irrlicht-1.8/tools/GUIEditor/CGUITextureCacheBrowser.h b/libraries/irrlicht-1.8/tools/GUIEditor/CGUITextureCacheBrowser.h index 108d4d6..afe84f1 100644 --- a/libraries/irrlicht-1.8/tools/GUIEditor/CGUITextureCacheBrowser.h +++ b/libraries/irrlicht-1.8/tools/GUIEditor/CGUITextureCacheBrowser.h @@ -1,88 +1,88 @@ -// Copyright (C) 2002-2012 Nikolaus Gebhardt / Gaz Davidson -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_GUI_TEXTURE_CACHE_BROWSER_H_INCLUDED__ -#define __C_GUI_TEXTURE_CACHE_BROWSER_H_INCLUDED__ - -#include "IGUIWindow.h" -#include "CGUIPanel.h" -#include "IGUIImage.h" -#include "EGUIEditTypes.h" - -namespace irr -{ -namespace gui -{ - - //! Texture cache browser - - const u32 TEXTURE_BROWSER_TEXTURE_SELECTED = 0x5E1EC7ED; // custom event number for texture selected - - class CGUITextureCacheBrowser : public IGUIWindow - { - public: - - //! constructor - CGUITextureCacheBrowser(IGUIEnvironment* environment, s32 id=-1, IGUIElement *parent=0); - - //! destructor - ~CGUITextureCacheBrowser(); - - //! event handler - virtual bool OnEvent(const SEvent &event); - - //! draws the element - virtual void draw(); - - //! update absolute position - virtual void updateAbsolutePosition(); - - //! this shoudln't be serialized, but this is included as it's an example - virtual const c8* getTypeName() const { return "textureCacheBrowser"; } - - //! Returns pointer to the close button - virtual IGUIButton* getCloseButton() const { return CloseButton; } - - //! Returns pointer to the minimize button - virtual IGUIButton* getMinimizeButton() const { return 0;} - - //! Returns pointer to the maximize button - virtual IGUIButton* getMaximizeButton() const { return 0;} - - //! get draggable - virtual bool isDraggable() const; - - //! get draggable - virtual void setDraggable(bool draggable); - - //! not used - virtual core::rect getClientRect() const; - virtual void setDrawBackground(bool draw) { } - virtual bool getDrawBackground() const { return true; } - virtual void setDrawTitlebar(bool draw) { } - virtual bool getDrawTitlebar() const { return true; } - - - void setSelected(s32 index=-1); - - private: - - void updateImageList(); - - core::array Images; - core::position2d DragStart; - - IGUIButton* CloseButton; - CGUIPanel* Panel; - s32 SelectedTexture; - bool Dragging; - bool IsDraggable; - }; - - -} // end namespace gui -} // end namespace irr - -#endif - +// Copyright (C) 2002-2012 Nikolaus Gebhardt / Gaz Davidson +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_GUI_TEXTURE_CACHE_BROWSER_H_INCLUDED__ +#define __C_GUI_TEXTURE_CACHE_BROWSER_H_INCLUDED__ + +#include "IGUIWindow.h" +#include "CGUIPanel.h" +#include "IGUIImage.h" +#include "EGUIEditTypes.h" + +namespace irr +{ +namespace gui +{ + + //! Texture cache browser + + const u32 TEXTURE_BROWSER_TEXTURE_SELECTED = 0x5E1EC7ED; // custom event number for texture selected + + class CGUITextureCacheBrowser : public IGUIWindow + { + public: + + //! constructor + CGUITextureCacheBrowser(IGUIEnvironment* environment, s32 id=-1, IGUIElement *parent=0); + + //! destructor + ~CGUITextureCacheBrowser(); + + //! event handler + virtual bool OnEvent(const SEvent &event); + + //! draws the element + virtual void draw(); + + //! update absolute position + virtual void updateAbsolutePosition(); + + //! this shoudln't be serialized, but this is included as it's an example + virtual const c8* getTypeName() const { return "textureCacheBrowser"; } + + //! Returns pointer to the close button + virtual IGUIButton* getCloseButton() const { return CloseButton; } + + //! Returns pointer to the minimize button + virtual IGUIButton* getMinimizeButton() const { return 0;} + + //! Returns pointer to the maximize button + virtual IGUIButton* getMaximizeButton() const { return 0;} + + //! get draggable + virtual bool isDraggable() const; + + //! get draggable + virtual void setDraggable(bool draggable); + + //! not used + virtual core::rect getClientRect() const; + virtual void setDrawBackground(bool draw) { } + virtual bool getDrawBackground() const { return true; } + virtual void setDrawTitlebar(bool draw) { } + virtual bool getDrawTitlebar() const { return true; } + + + void setSelected(s32 index=-1); + + private: + + void updateImageList(); + + core::array Images; + core::position2d DragStart; + + IGUIButton* CloseButton; + CGUIPanel* Panel; + s32 SelectedTexture; + bool Dragging; + bool IsDraggable; + }; + + +} // end namespace gui +} // end namespace irr + +#endif + diff --git a/libraries/irrlicht-1.8/tools/GUIEditor/CMemoryReadWriteFile.cpp b/libraries/irrlicht-1.8/tools/GUIEditor/CMemoryReadWriteFile.cpp index 0a69587..af46b15 100644 --- a/libraries/irrlicht-1.8/tools/GUIEditor/CMemoryReadWriteFile.cpp +++ b/libraries/irrlicht-1.8/tools/GUIEditor/CMemoryReadWriteFile.cpp @@ -1,95 +1,95 @@ -// 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 "CMemoryReadWriteFile.h" - -using namespace irr; -using namespace io; - -CMemoryReadWriteFile::CMemoryReadWriteFile(const c8* filename) -: Data(), FileName(filename), Pos(0) -{ -} - - -s32 CMemoryReadWriteFile::write(const void* buffer, u32 sizeToWrite) -{ - // no point in writing 0 bytes - if (sizeToWrite < 1) - return 0; - - // expand size - if (Pos + sizeToWrite > Data.size()) - Data.set_used(Pos+sizeToWrite); - - // copy data - memcpy( (void*) &Data[Pos], buffer, (size_t) sizeToWrite); - - Pos += sizeToWrite; - - return sizeToWrite; - -} - -bool CMemoryReadWriteFile::seek(long finalPos, bool relativeMovement) -{ - if (relativeMovement) - { - if (finalPos + Pos < 0) - return 0; - else - Pos += finalPos; - } - else - { - Pos = finalPos; - } - - if (Pos > (s32)Data.size()) - Data.set_used(Pos+1); - - return true; - -} - -const io::path& CMemoryReadWriteFile::getFileName() const -{ - return FileName; -} - -long CMemoryReadWriteFile::getPos() const -{ - return Pos; -} - -core::array& CMemoryReadWriteFile::getData() -{ - return Data; -} - - -long CMemoryReadWriteFile::getSize() const -{ - return Data.size(); -} - - -s32 CMemoryReadWriteFile::read(void* buffer, u32 sizeToRead) -{ - // cant read past the end - if (Pos + sizeToRead >= Data.size()) - sizeToRead = Data.size() - Pos; - - // cant read 0 bytes - if (!sizeToRead) - return 0; - - // copy data - memcpy( buffer, (void*) &Data[Pos], (size_t) sizeToRead); - - Pos += sizeToRead; - - return sizeToRead; -} - +// 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 "CMemoryReadWriteFile.h" + +using namespace irr; +using namespace io; + +CMemoryReadWriteFile::CMemoryReadWriteFile(const c8* filename) +: Data(), FileName(filename), Pos(0) +{ +} + + +s32 CMemoryReadWriteFile::write(const void* buffer, u32 sizeToWrite) +{ + // no point in writing 0 bytes + if (sizeToWrite < 1) + return 0; + + // expand size + if (Pos + sizeToWrite > Data.size()) + Data.set_used(Pos+sizeToWrite); + + // copy data + memcpy( (void*) &Data[Pos], buffer, (size_t) sizeToWrite); + + Pos += sizeToWrite; + + return sizeToWrite; + +} + +bool CMemoryReadWriteFile::seek(long finalPos, bool relativeMovement) +{ + if (relativeMovement) + { + if (finalPos + Pos < 0) + return 0; + else + Pos += finalPos; + } + else + { + Pos = finalPos; + } + + if (Pos > (s32)Data.size()) + Data.set_used(Pos+1); + + return true; + +} + +const io::path& CMemoryReadWriteFile::getFileName() const +{ + return FileName; +} + +long CMemoryReadWriteFile::getPos() const +{ + return Pos; +} + +core::array& CMemoryReadWriteFile::getData() +{ + return Data; +} + + +long CMemoryReadWriteFile::getSize() const +{ + return Data.size(); +} + + +s32 CMemoryReadWriteFile::read(void* buffer, u32 sizeToRead) +{ + // cant read past the end + if (Pos + sizeToRead >= Data.size()) + sizeToRead = Data.size() - Pos; + + // cant read 0 bytes + if (!sizeToRead) + return 0; + + // copy data + memcpy( buffer, (void*) &Data[Pos], (size_t) sizeToRead); + + Pos += sizeToRead; + + return sizeToRead; +} + diff --git a/libraries/irrlicht-1.8/tools/GUIEditor/CMemoryReadWriteFile.h b/libraries/irrlicht-1.8/tools/GUIEditor/CMemoryReadWriteFile.h index de20ae7..e0fa06e 100644 --- a/libraries/irrlicht-1.8/tools/GUIEditor/CMemoryReadWriteFile.h +++ b/libraries/irrlicht-1.8/tools/GUIEditor/CMemoryReadWriteFile.h @@ -1,73 +1,73 @@ -// 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_MEMORY_READ_WRITE_FILE_H_INCLUDED__ -#define __C_MEMORY_READ_WRITE_FILE_H_INCLUDED__ - -#include "IWriteFile.h" -#include "IReadFile.h" -#include "irrArray.h" -#include "irrString.h" -#include "memory.h" - -namespace irr -{ -namespace io -{ - - //! Provides write acess to an array as if it is a file. - class CMemoryReadWriteFile : public virtual IWriteFile, public virtual IReadFile - { - public: - - CMemoryReadWriteFile(const c8* filename=0); - - //! Reads an amount of bytes from the file. - //! \param buffer: Pointer to buffer of bytes to write. - //! \param sizeToWrite: Amount of bytes to wrtie to the file. - //! \return Returns how much bytes were written. - virtual s32 write(const void* buffer, u32 sizeToWrite); - - //! Changes position in file, returns true if successful. - //! \param finalPos: Destination position in the file. - //! \param relativeMovement: If set to true, the position in the file is - //! changed relative to current position. Otherwise the position is changed - //! from begin of file. - //! \return Returns true if successful, otherwise false. - virtual bool seek(long finalPos, bool relativeMovement = false); - - //! Returns size of file. - //! \return Returns the size of the file in bytes. - virtual long getSize() const; - - //! Reads an amount of bytes from the file. - //! \param buffer: Pointer to buffer where to read bytes will be written to. - //! \param sizeToRead: Amount of bytes to read from the file. - //! \return Returns how much bytes were read. - virtual s32 read(void* buffer, u32 sizeToRead); - - //! Returns the current position in the file. - //! \return Returns the current position in the file in bytes. - virtual long getPos() const; - - //! Returns name of file. - //! \return Returns the file name as zero terminated character string. - virtual const io::path& getFileName() const; - - //! Returns file data as an array - core::array& getData(); - - private: - - core::array Data; - io::path FileName; - long Pos; - }; - - - -} // end namespace io -} // end namespace irr - -#endif // __C_MEMORY_READ_WRITE_FILE_H_INCLUDED__ +// 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_MEMORY_READ_WRITE_FILE_H_INCLUDED__ +#define __C_MEMORY_READ_WRITE_FILE_H_INCLUDED__ + +#include "IWriteFile.h" +#include "IReadFile.h" +#include "irrArray.h" +#include "irrString.h" +#include "memory.h" + +namespace irr +{ +namespace io +{ + + //! Provides write acess to an array as if it is a file. + class CMemoryReadWriteFile : public virtual IWriteFile, public virtual IReadFile + { + public: + + CMemoryReadWriteFile(const c8* filename=0); + + //! Reads an amount of bytes from the file. + //! \param buffer: Pointer to buffer of bytes to write. + //! \param sizeToWrite: Amount of bytes to wrtie to the file. + //! \return Returns how much bytes were written. + virtual s32 write(const void* buffer, u32 sizeToWrite); + + //! Changes position in file, returns true if successful. + //! \param finalPos: Destination position in the file. + //! \param relativeMovement: If set to true, the position in the file is + //! changed relative to current position. Otherwise the position is changed + //! from begin of file. + //! \return Returns true if successful, otherwise false. + virtual bool seek(long finalPos, bool relativeMovement = false); + + //! Returns size of file. + //! \return Returns the size of the file in bytes. + virtual long getSize() const; + + //! Reads an amount of bytes from the file. + //! \param buffer: Pointer to buffer where to read bytes will be written to. + //! \param sizeToRead: Amount of bytes to read from the file. + //! \return Returns how much bytes were read. + virtual s32 read(void* buffer, u32 sizeToRead); + + //! Returns the current position in the file. + //! \return Returns the current position in the file in bytes. + virtual long getPos() const; + + //! Returns name of file. + //! \return Returns the file name as zero terminated character string. + virtual const io::path& getFileName() const; + + //! Returns file data as an array + core::array& getData(); + + private: + + core::array Data; + io::path FileName; + long Pos; + }; + + + +} // end namespace io +} // end namespace irr + +#endif // __C_MEMORY_READ_WRITE_FILE_H_INCLUDED__ diff --git a/libraries/irrlicht-1.8/tools/GUIEditor/EGUIEditTypes.h b/libraries/irrlicht-1.8/tools/GUIEditor/EGUIEditTypes.h index 88d119e..fe56726 100644 --- a/libraries/irrlicht-1.8/tools/GUIEditor/EGUIEditTypes.h +++ b/libraries/irrlicht-1.8/tools/GUIEditor/EGUIEditTypes.h @@ -1,61 +1,61 @@ -#ifndef __C_GUIEDIT_TYPES_H_INCLUDED__ -#define __C_GUIEDIT_TYPES_H_INCLUDED__ - -#include "irrTypes.h" - -namespace irr { -namespace gui { - -enum EGUIEDIT_ELEMENT_TYPES -{ - // GUI Editor - EGUIEDIT_GUIEDIT=0, - EGUIEDIT_GUIEDITWINDOW, - // Generic - EGUIEDIT_GUIPANEL, - EGUIEDIT_TEXTUREBROWSER, - // Attribute editors - EGUIEDIT_ATTRIBUTEEDITOR, - EGUIEDIT_STRINGATTRIBUTE, - EGUIEDIT_BOOLATTRIBUTE, - EGUIEDIT_ENUMATTRIBUTE, - EGUIEDIT_COLORATTRIBUTE, - EGUIEDIT_COLORFATTRIBUTE, - EGUIEDIT_TEXTUREATTRIBUTE, - // Dummy editor stubs - EGUIEDIT_CONTEXTMENUEDITOR, - EGUIEDIT_MENUEDITOR, - EGUIEDIT_FILEDIALOGEDITOR, - EGUIEDIT_COLORDIALOGEDITOR, - EGUIEDIT_MODALSCREENEDITOR, - // Count - EGUIEDIT_COUNT -}; - -const c8* const GUIEditElementTypeNames[] = -{ - "GUIEditor", - "GUIEditWindow", - "panel", - "textureCacheBrowser", - "attributeEditor", - "string_attribute", - "bool_attribute", - "enum_attribute", - "color_attribute", - "colorf_attribute", - "texture_attribute", - // dummy editors - "contextMenu_editor", - "menu_editor", - "fileOpenDialog_editor", - "colorSelectDialog_editor", - "modalScreen_editor", - 0 -}; - -} // gui -} // irr - -#endif - +#ifndef __C_GUIEDIT_TYPES_H_INCLUDED__ +#define __C_GUIEDIT_TYPES_H_INCLUDED__ + +#include "irrTypes.h" + +namespace irr { +namespace gui { + +enum EGUIEDIT_ELEMENT_TYPES +{ + // GUI Editor + EGUIEDIT_GUIEDIT=0, + EGUIEDIT_GUIEDITWINDOW, + // Generic + EGUIEDIT_GUIPANEL, + EGUIEDIT_TEXTUREBROWSER, + // Attribute editors + EGUIEDIT_ATTRIBUTEEDITOR, + EGUIEDIT_STRINGATTRIBUTE, + EGUIEDIT_BOOLATTRIBUTE, + EGUIEDIT_ENUMATTRIBUTE, + EGUIEDIT_COLORATTRIBUTE, + EGUIEDIT_COLORFATTRIBUTE, + EGUIEDIT_TEXTUREATTRIBUTE, + // Dummy editor stubs + EGUIEDIT_CONTEXTMENUEDITOR, + EGUIEDIT_MENUEDITOR, + EGUIEDIT_FILEDIALOGEDITOR, + EGUIEDIT_COLORDIALOGEDITOR, + EGUIEDIT_MODALSCREENEDITOR, + // Count + EGUIEDIT_COUNT +}; + +const c8* const GUIEditElementTypeNames[] = +{ + "GUIEditor", + "GUIEditWindow", + "panel", + "textureCacheBrowser", + "attributeEditor", + "string_attribute", + "bool_attribute", + "enum_attribute", + "color_attribute", + "colorf_attribute", + "texture_attribute", + // dummy editors + "contextMenu_editor", + "menu_editor", + "fileOpenDialog_editor", + "colorSelectDialog_editor", + "modalScreen_editor", + 0 +}; + +} // gui +} // irr + +#endif + diff --git a/libraries/irrlicht-1.8/tools/GUIEditor/GUI Editor_v8.sln b/libraries/irrlicht-1.8/tools/GUIEditor/GUI Editor_v8.sln index 6f76269..659854d 100644 --- a/libraries/irrlicht-1.8/tools/GUIEditor/GUI Editor_v8.sln +++ b/libraries/irrlicht-1.8/tools/GUIEditor/GUI Editor_v8.sln @@ -1,20 +1,20 @@ - -Microsoft Visual Studio Solution File, Format Version 9.00 -# Visual C++ Express 2005 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GUI Editor", "GUI Editor.vcproj", "{853A396E-C031-4C26-A716-5B4E176BE11D}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {853A396E-C031-4C26-A716-5B4E176BE11D}.Debug|Win32.ActiveCfg = Debug|Win32 - {853A396E-C031-4C26-A716-5B4E176BE11D}.Debug|Win32.Build.0 = Debug|Win32 - {853A396E-C031-4C26-A716-5B4E176BE11D}.Release|Win32.ActiveCfg = Release|Win32 - {853A396E-C031-4C26-A716-5B4E176BE11D}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual C++ Express 2005 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GUI Editor", "GUI Editor.vcproj", "{853A396E-C031-4C26-A716-5B4E176BE11D}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {853A396E-C031-4C26-A716-5B4E176BE11D}.Debug|Win32.ActiveCfg = Debug|Win32 + {853A396E-C031-4C26-A716-5B4E176BE11D}.Debug|Win32.Build.0 = Debug|Win32 + {853A396E-C031-4C26-A716-5B4E176BE11D}.Release|Win32.ActiveCfg = Release|Win32 + {853A396E-C031-4C26-A716-5B4E176BE11D}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/libraries/irrlicht-1.8/tools/GUIEditor/GUI Editor_v8.vcproj b/libraries/irrlicht-1.8/tools/GUIEditor/GUI Editor_v8.vcproj index 81c6fa9..e28c5fa 100644 --- a/libraries/irrlicht-1.8/tools/GUIEditor/GUI Editor_v8.vcproj +++ b/libraries/irrlicht-1.8/tools/GUIEditor/GUI Editor_v8.vcproj @@ -1,295 +1,295 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/libraries/irrlicht-1.8/tools/GUIEditor/GUI Editor_v9.sln b/libraries/irrlicht-1.8/tools/GUIEditor/GUI Editor_v9.sln index 0acf300..82a8b56 100644 --- a/libraries/irrlicht-1.8/tools/GUIEditor/GUI Editor_v9.sln +++ b/libraries/irrlicht-1.8/tools/GUIEditor/GUI Editor_v9.sln @@ -1,20 +1,20 @@ - -Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual C++ Express 2008 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GUI Editor_v9", "GUI Editor_v9.vcproj", "{853A396E-C031-4C26-A716-5B4E176BE11D}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {853A396E-C031-4C26-A716-5B4E176BE11D}.Debug|Win32.ActiveCfg = Debug|Win32 - {853A396E-C031-4C26-A716-5B4E176BE11D}.Debug|Win32.Build.0 = Debug|Win32 - {853A396E-C031-4C26-A716-5B4E176BE11D}.Release|Win32.ActiveCfg = Release|Win32 - {853A396E-C031-4C26-A716-5B4E176BE11D}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual C++ Express 2008 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GUI Editor_v9", "GUI Editor_v9.vcproj", "{853A396E-C031-4C26-A716-5B4E176BE11D}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {853A396E-C031-4C26-A716-5B4E176BE11D}.Debug|Win32.ActiveCfg = Debug|Win32 + {853A396E-C031-4C26-A716-5B4E176BE11D}.Debug|Win32.Build.0 = Debug|Win32 + {853A396E-C031-4C26-A716-5B4E176BE11D}.Release|Win32.ActiveCfg = Release|Win32 + {853A396E-C031-4C26-A716-5B4E176BE11D}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/libraries/irrlicht-1.8/tools/GUIEditor/GUI Editor_v9.vcproj b/libraries/irrlicht-1.8/tools/GUIEditor/GUI Editor_v9.vcproj index 6d73d03..79ba177 100644 --- a/libraries/irrlicht-1.8/tools/GUIEditor/GUI Editor_v9.vcproj +++ b/libraries/irrlicht-1.8/tools/GUIEditor/GUI Editor_v9.vcproj @@ -1,293 +1,293 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/libraries/irrlicht-1.8/tools/GUIEditor/GUI Editor_vc10.vcxproj b/libraries/irrlicht-1.8/tools/GUIEditor/GUI Editor_vc10.vcxproj index 7022876..5c85f4b 100644 --- a/libraries/irrlicht-1.8/tools/GUIEditor/GUI Editor_vc10.vcxproj +++ b/libraries/irrlicht-1.8/tools/GUIEditor/GUI Editor_vc10.vcxproj @@ -1,213 +1,213 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {853A396E-C031-4C26-A716-5B4E176BE11D} - GUI Editor - Win32Proj - GUIEditor - - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - ..\..\bin\Win32-VisualStudio\ - ..\..\bin\Win64-VisualStudio\ - true - true - ..\..\bin\Win32-VisualStudio\ - ..\..\bin\Win64-VisualStudio\ - false - false - AllRules.ruleset - AllRules.ruleset - - - - - AllRules.ruleset - AllRules.ruleset - - - - - - - - Disabled - Neither - false - ..\..\include;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - - - Level3 - EditAndContinue - - - kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib glu32.lib opengl32.lib %(AdditionalOptions) - ..\..\lib\Win32-visualstudio;%(AdditionalLibraryDirectories) - true - Console - - - - - - - Disabled - Neither - false - ..\..\include;%(AdditionalIncludeDirectories) - WIN32;WIN64;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - EnableFastChecks - MultiThreadedDebug - - - Level3 - ProgramDatabase - - - kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib glu32.lib opengl32.lib %(AdditionalOptions) - ..\..\lib\Win64-visualstudio;%(AdditionalLibraryDirectories) - true - Console - - - - - - - Full - ..\..\include;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreaded - - - Level3 - ProgramDatabase - - - ../../bin/Win32-visualstudio/GUIEditor.exe - ..\..\lib\Win32-visualstudio;%(AdditionalLibraryDirectories) - true - Console - true - true - - - - - - - Full - ..\..\include;%(AdditionalIncludeDirectories) - WIN32;WIN64;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreaded - - - Level3 - ProgramDatabase - - - ../../bin/Win32-visualstudio/GUIEditor.exe - ..\..\lib\Win64-visualstudio;%(AdditionalLibraryDirectories) - true - Console - true - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {e08e042a-6c45-411b-92be-3cc31331019f} - false - - - - - + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {853A396E-C031-4C26-A716-5B4E176BE11D} + GUI Editor + Win32Proj + GUIEditor + + + + Application + MultiByte + + + Application + MultiByte + + + Application + MultiByte + + + Application + MultiByte + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + ..\..\bin\Win32-VisualStudio\ + ..\..\bin\Win64-VisualStudio\ + true + true + ..\..\bin\Win32-VisualStudio\ + ..\..\bin\Win64-VisualStudio\ + false + false + AllRules.ruleset + AllRules.ruleset + + + + + AllRules.ruleset + AllRules.ruleset + + + + + + + + Disabled + Neither + false + ..\..\include;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebug + + + Level3 + EditAndContinue + + + kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib glu32.lib opengl32.lib %(AdditionalOptions) + ..\..\lib\Win32-visualstudio;%(AdditionalLibraryDirectories) + true + Console + + + + + + + Disabled + Neither + false + ..\..\include;%(AdditionalIncludeDirectories) + WIN32;WIN64;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + EnableFastChecks + MultiThreadedDebug + + + Level3 + ProgramDatabase + + + kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib glu32.lib opengl32.lib %(AdditionalOptions) + ..\..\lib\Win64-visualstudio;%(AdditionalLibraryDirectories) + true + Console + + + + + + + Full + ..\..\include;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + MultiThreaded + + + Level3 + ProgramDatabase + + + ../../bin/Win32-visualstudio/GUIEditor.exe + ..\..\lib\Win32-visualstudio;%(AdditionalLibraryDirectories) + true + Console + true + true + + + + + + + Full + ..\..\include;%(AdditionalIncludeDirectories) + WIN32;WIN64;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + MultiThreaded + + + Level3 + ProgramDatabase + + + ../../bin/Win32-visualstudio/GUIEditor.exe + ..\..\lib\Win64-visualstudio;%(AdditionalLibraryDirectories) + true + Console + true + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {e08e042a-6c45-411b-92be-3cc31331019f} + false + + + + + \ No newline at end of file diff --git a/libraries/irrlicht-1.8/tools/GUIEditor/GUI Editor_vc10.vcxproj.filters b/libraries/irrlicht-1.8/tools/GUIEditor/GUI Editor_vc10.vcxproj.filters index 1d06fa4..3644f98 100644 --- a/libraries/irrlicht-1.8/tools/GUIEditor/GUI Editor_vc10.vcxproj.filters +++ b/libraries/irrlicht-1.8/tools/GUIEditor/GUI Editor_vc10.vcxproj.filters @@ -1,88 +1,88 @@ - - - - - {f6ad9df9-ebaa-4c0f-997b-c8101c1fc669} - - - {7fd14cb1-d2e7-4fd0-85c1-68fc9d1249f7} - - - {ab2c3f3a-1d99-4619-b5df-47fdd9449f3f} - - - {740a4255-37cc-4ac4-94e9-f2f0970491a8} - - - {a28a0b21-3336-432f-9759-ff2dc064874a} - - - - - gui - - - gui - - - gui - - - gui - - - gui\GUIAttributes - - - gui\Useful GUI Elements - - - io - - - - - - gui - - - gui - - - gui - - - gui - - - gui\GUIAttributes - - - gui\GUIAttributes - - - gui\GUIAttributes - - - gui\GUIAttributes - - - gui\GUIAttributes - - - gui\GUIAttributes - - - gui\GUIAttributes - - - gui\Useful GUI Elements - - - gui\Element Editors - - - io - - + + + + + {f6ad9df9-ebaa-4c0f-997b-c8101c1fc669} + + + {7fd14cb1-d2e7-4fd0-85c1-68fc9d1249f7} + + + {ab2c3f3a-1d99-4619-b5df-47fdd9449f3f} + + + {740a4255-37cc-4ac4-94e9-f2f0970491a8} + + + {a28a0b21-3336-432f-9759-ff2dc064874a} + + + + + gui + + + gui + + + gui + + + gui + + + gui\GUIAttributes + + + gui\Useful GUI Elements + + + io + + + + + + gui + + + gui + + + gui + + + gui + + + gui\GUIAttributes + + + gui\GUIAttributes + + + gui\GUIAttributes + + + gui\GUIAttributes + + + gui\GUIAttributes + + + gui\GUIAttributes + + + gui\GUIAttributes + + + gui\Useful GUI Elements + + + gui\Element Editors + + + io + + \ No newline at end of file diff --git a/libraries/irrlicht-1.8/tools/GUIEditor/GUI Editor_vc11.vcxproj b/libraries/irrlicht-1.8/tools/GUIEditor/GUI Editor_vc11.vcxproj index 6c6f28b..d2dc2e3 100644 --- a/libraries/irrlicht-1.8/tools/GUIEditor/GUI Editor_vc11.vcxproj +++ b/libraries/irrlicht-1.8/tools/GUIEditor/GUI Editor_vc11.vcxproj @@ -1,217 +1,217 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {853A396E-C031-4C26-A716-5B4E176BE11D} - GUI Editor - Win32Proj - GUIEditor - - - - Application - MultiByte - v110 - - - Application - MultiByte - v110 - - - Application - MultiByte - v110 - - - Application - MultiByte - v110 - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - ..\..\bin\Win32-VisualStudio\ - ..\..\bin\Win64-VisualStudio\ - true - true - ..\..\bin\Win32-VisualStudio\ - ..\..\bin\Win64-VisualStudio\ - false - false - AllRules.ruleset - AllRules.ruleset - - - - - AllRules.ruleset - AllRules.ruleset - - - - - - - - Disabled - Neither - false - ..\..\include;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - - - Level3 - EditAndContinue - - - kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib glu32.lib opengl32.lib %(AdditionalOptions) - ..\..\lib\Win32-visualstudio;%(AdditionalLibraryDirectories) - true - Console - - - - - - - Disabled - Neither - false - ..\..\include;%(AdditionalIncludeDirectories) - WIN32;WIN64;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - EnableFastChecks - MultiThreadedDebug - - - Level3 - ProgramDatabase - - - kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib glu32.lib opengl32.lib %(AdditionalOptions) - ..\..\lib\Win64-visualstudio;%(AdditionalLibraryDirectories) - true - Console - - - - - - - Full - ..\..\include;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreaded - - - Level3 - ProgramDatabase - - - ../../bin/Win32-visualstudio/GUIEditor.exe - ..\..\lib\Win32-visualstudio;%(AdditionalLibraryDirectories) - true - Console - true - true - - - - - - - Full - ..\..\include;%(AdditionalIncludeDirectories) - WIN32;WIN64;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreaded - - - Level3 - ProgramDatabase - - - ../../bin/Win32-visualstudio/GUIEditor.exe - ..\..\lib\Win64-visualstudio;%(AdditionalLibraryDirectories) - true - Console - true - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {e08e042a-6c45-411b-92be-3cc31331019f} - false - - - - - + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {853A396E-C031-4C26-A716-5B4E176BE11D} + GUI Editor + Win32Proj + GUIEditor + + + + Application + MultiByte + v110 + + + Application + MultiByte + v110 + + + Application + MultiByte + v110 + + + Application + MultiByte + v110 + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + ..\..\bin\Win32-VisualStudio\ + ..\..\bin\Win64-VisualStudio\ + true + true + ..\..\bin\Win32-VisualStudio\ + ..\..\bin\Win64-VisualStudio\ + false + false + AllRules.ruleset + AllRules.ruleset + + + + + AllRules.ruleset + AllRules.ruleset + + + + + + + + Disabled + Neither + false + ..\..\include;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebug + + + Level3 + EditAndContinue + + + kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib glu32.lib opengl32.lib %(AdditionalOptions) + ..\..\lib\Win32-visualstudio;%(AdditionalLibraryDirectories) + true + Console + + + + + + + Disabled + Neither + false + ..\..\include;%(AdditionalIncludeDirectories) + WIN32;WIN64;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + EnableFastChecks + MultiThreadedDebug + + + Level3 + ProgramDatabase + + + kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib glu32.lib opengl32.lib %(AdditionalOptions) + ..\..\lib\Win64-visualstudio;%(AdditionalLibraryDirectories) + true + Console + + + + + + + Full + ..\..\include;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + MultiThreaded + + + Level3 + ProgramDatabase + + + ../../bin/Win32-visualstudio/GUIEditor.exe + ..\..\lib\Win32-visualstudio;%(AdditionalLibraryDirectories) + true + Console + true + true + + + + + + + Full + ..\..\include;%(AdditionalIncludeDirectories) + WIN32;WIN64;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + MultiThreaded + + + Level3 + ProgramDatabase + + + ../../bin/Win32-visualstudio/GUIEditor.exe + ..\..\lib\Win64-visualstudio;%(AdditionalLibraryDirectories) + true + Console + true + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {e08e042a-6c45-411b-92be-3cc31331019f} + false + + + + + \ No newline at end of file diff --git a/libraries/irrlicht-1.8/tools/GUIEditor/GUI Editor_vc11.vcxproj.filters b/libraries/irrlicht-1.8/tools/GUIEditor/GUI Editor_vc11.vcxproj.filters index 1d06fa4..3644f98 100644 --- a/libraries/irrlicht-1.8/tools/GUIEditor/GUI Editor_vc11.vcxproj.filters +++ b/libraries/irrlicht-1.8/tools/GUIEditor/GUI Editor_vc11.vcxproj.filters @@ -1,88 +1,88 @@ - - - - - {f6ad9df9-ebaa-4c0f-997b-c8101c1fc669} - - - {7fd14cb1-d2e7-4fd0-85c1-68fc9d1249f7} - - - {ab2c3f3a-1d99-4619-b5df-47fdd9449f3f} - - - {740a4255-37cc-4ac4-94e9-f2f0970491a8} - - - {a28a0b21-3336-432f-9759-ff2dc064874a} - - - - - gui - - - gui - - - gui - - - gui - - - gui\GUIAttributes - - - gui\Useful GUI Elements - - - io - - - - - - gui - - - gui - - - gui - - - gui - - - gui\GUIAttributes - - - gui\GUIAttributes - - - gui\GUIAttributes - - - gui\GUIAttributes - - - gui\GUIAttributes - - - gui\GUIAttributes - - - gui\GUIAttributes - - - gui\Useful GUI Elements - - - gui\Element Editors - - - io - - + + + + + {f6ad9df9-ebaa-4c0f-997b-c8101c1fc669} + + + {7fd14cb1-d2e7-4fd0-85c1-68fc9d1249f7} + + + {ab2c3f3a-1d99-4619-b5df-47fdd9449f3f} + + + {740a4255-37cc-4ac4-94e9-f2f0970491a8} + + + {a28a0b21-3336-432f-9759-ff2dc064874a} + + + + + gui + + + gui + + + gui + + + gui + + + gui\GUIAttributes + + + gui\Useful GUI Elements + + + io + + + + + + gui + + + gui + + + gui + + + gui + + + gui\GUIAttributes + + + gui\GUIAttributes + + + gui\GUIAttributes + + + gui\GUIAttributes + + + gui\GUIAttributes + + + gui\GUIAttributes + + + gui\GUIAttributes + + + gui\Useful GUI Elements + + + gui\Element Editors + + + io + + \ No newline at end of file diff --git a/libraries/irrlicht-1.8/tools/GUIEditor/Makefile b/libraries/irrlicht-1.8/tools/GUIEditor/Makefile index 02f8189..6010a2d 100644 --- a/libraries/irrlicht-1.8/tools/GUIEditor/Makefile +++ b/libraries/irrlicht-1.8/tools/GUIEditor/Makefile @@ -1,43 +1,43 @@ -# Irrlicht Engine GUIEditor Makefile -Target = GUIEditor -Sources = CGUIAttributeEditor.cpp CGUIEditFactory.cpp CGUIEditWindow.cpp CGUIEditWorkspace.cpp CGUIPanel.cpp CGUITextureCacheBrowser.cpp CMemoryReadWriteFile.cpp main.cpp - -CPPFLAGS = -I../../include -I/usr/X11R6/include -CXXFLAGS = -Wall -O3 -ffast-math - -ifeq ($(HOSTTYPE), x86_64) -LIBSELECT=64 -endif - -all: all_linux - -# target specific settings -all_linux: SYSTEM=Linux -all_linux: LDFLAGS = -L/usr/X11R6/lib$(LIBSELECT) -L../../lib/$(SYSTEM) -lIrrlicht -lGL -lXxf86vm -lXext -lX11 - -all_win32 clean_win32: SYSTEM=Win32-gcc -all_win32: LDFLAGS = -L../../lib/$(SYSTEM) -lIrrlicht -lopengl32 -lm - -# if you enable sound add the proper library for linking -#LDFLAGS += -lIrrKlang -#LDFLAGS += -laudiere -#LDFLAGS += -lSDL_mixer -lSDL - -all_win32 clean_win32: SUF=.exe -# name of the binary - only valid for targets which set SYSTEM -DESTPATH = ../../bin/$(SYSTEM)/$(Target)$(SUF) - -OBJ = $(Sources:.cpp=.o) - -all_linux all_win32: $(OBJ) - $(warning Building...) - $(CXX) $(CPPFLAGS) $(CXXFLAGS) $^ -o $(DESTPATH) $(LDFLAGS) - -clean: clean_linux clean_win32 - $(warning Cleaning...) - @$(RM) $(OBJ) - -clean_linux clean_win32: - @$(RM) $(DESTPATH) - -.PHONY: all all_win32 clean clean_linux clean_win32 +# Irrlicht Engine GUIEditor Makefile +Target = GUIEditor +Sources = CGUIAttributeEditor.cpp CGUIEditFactory.cpp CGUIEditWindow.cpp CGUIEditWorkspace.cpp CGUIPanel.cpp CGUITextureCacheBrowser.cpp CMemoryReadWriteFile.cpp main.cpp + +CPPFLAGS = -I../../include -I/usr/X11R6/include +CXXFLAGS = -Wall -O3 -ffast-math + +ifeq ($(HOSTTYPE), x86_64) +LIBSELECT=64 +endif + +all: all_linux + +# target specific settings +all_linux: SYSTEM=Linux +all_linux: LDFLAGS = -L/usr/X11R6/lib$(LIBSELECT) -L../../lib/$(SYSTEM) -lIrrlicht -lGL -lXxf86vm -lXext -lX11 + +all_win32 clean_win32: SYSTEM=Win32-gcc +all_win32: LDFLAGS = -L../../lib/$(SYSTEM) -lIrrlicht -lopengl32 -lm + +# if you enable sound add the proper library for linking +#LDFLAGS += -lIrrKlang +#LDFLAGS += -laudiere +#LDFLAGS += -lSDL_mixer -lSDL + +all_win32 clean_win32: SUF=.exe +# name of the binary - only valid for targets which set SYSTEM +DESTPATH = ../../bin/$(SYSTEM)/$(Target)$(SUF) + +OBJ = $(Sources:.cpp=.o) + +all_linux all_win32: $(OBJ) + $(warning Building...) + $(CXX) $(CPPFLAGS) $(CXXFLAGS) $^ -o $(DESTPATH) $(LDFLAGS) + +clean: clean_linux clean_win32 + $(warning Cleaning...) + @$(RM) $(OBJ) + +clean_linux clean_win32: + @$(RM) $(DESTPATH) + +.PHONY: all all_win32 clean clean_linux clean_win32 diff --git a/libraries/irrlicht-1.8/tools/GUIEditor/main.cpp b/libraries/irrlicht-1.8/tools/GUIEditor/main.cpp index e8434b2..1d917d3 100644 --- a/libraries/irrlicht-1.8/tools/GUIEditor/main.cpp +++ b/libraries/irrlicht-1.8/tools/GUIEditor/main.cpp @@ -1,76 +1,76 @@ -#include -#include "driverChoice.h" - -// include the gui creator element factory -#include "CGUIEditFactory.h" - -using namespace irr; -using namespace gui; - -#ifdef _MSC_VER -#pragma comment(lib, "Irrlicht.lib") -#endif - -int main() -{ - // ask user for driver - video::E_DRIVER_TYPE driverType=driverChoiceConsole(); - if (driverType==video::EDT_COUNT) - return 1; - - IrrlichtDevice *device = createDevice(driverType, core::dimension2du(800, 600)); - video::IVideoDriver* driver = device->getVideoDriver(); - scene::ISceneManager* smgr = device->getSceneManager(); - gui::IGUIEnvironment *env = device->getGUIEnvironment(); - - device->setResizable(true); - - /* - first we create the factory which can make new GUI elements - and register it with the gui environment. - */ - - IGUIElementFactory* factory = new CGUIEditFactory(env); - env->registerGUIElementFactory(factory); - // remember to drop since we created with a create call - factory->drop(); - - IGUISkin *skin = env->createSkin(EGST_WINDOWS_METALLIC); - env->setSkin(skin); - - IGUIFont *font = env->getFont("../../media/lucida.xml"); - if (font) - skin->setFont(font); - skin->drop(); - - // change transparency of skin - for (s32 i=0; igetSkin()->getColor((gui::EGUI_DEFAULT_COLOR)i); - col.setAlpha(250); - env->getSkin()->setColor((gui::EGUI_DEFAULT_COLOR)i, col); - } - - /* - now we add the GUI Editor Workspace - */ - - env->addGUIElement("GUIEditor"); - - while(device->run()) - { - device->sleep(10); - - if (device->isWindowActive()) - { - driver->beginScene(true, true, video::SColor(0,200,200,200)); - smgr->drawAll(); - env->drawAll(); - driver->endScene(); - } - } - - device->drop(); - - return 0; -} +#include +#include "driverChoice.h" + +// include the gui creator element factory +#include "CGUIEditFactory.h" + +using namespace irr; +using namespace gui; + +#ifdef _MSC_VER +#pragma comment(lib, "Irrlicht.lib") +#endif + +int main() +{ + // ask user for driver + video::E_DRIVER_TYPE driverType=driverChoiceConsole(); + if (driverType==video::EDT_COUNT) + return 1; + + IrrlichtDevice *device = createDevice(driverType, core::dimension2du(800, 600)); + video::IVideoDriver* driver = device->getVideoDriver(); + scene::ISceneManager* smgr = device->getSceneManager(); + gui::IGUIEnvironment *env = device->getGUIEnvironment(); + + device->setResizable(true); + + /* + first we create the factory which can make new GUI elements + and register it with the gui environment. + */ + + IGUIElementFactory* factory = new CGUIEditFactory(env); + env->registerGUIElementFactory(factory); + // remember to drop since we created with a create call + factory->drop(); + + IGUISkin *skin = env->createSkin(EGST_WINDOWS_METALLIC); + env->setSkin(skin); + + IGUIFont *font = env->getFont("../../media/lucida.xml"); + if (font) + skin->setFont(font); + skin->drop(); + + // change transparency of skin + for (s32 i=0; igetSkin()->getColor((gui::EGUI_DEFAULT_COLOR)i); + col.setAlpha(250); + env->getSkin()->setColor((gui::EGUI_DEFAULT_COLOR)i, col); + } + + /* + now we add the GUI Editor Workspace + */ + + env->addGUIElement("GUIEditor"); + + while(device->run()) + { + device->sleep(10); + + if (device->isWindowActive()) + { + driver->beginScene(true, true, video::SColor(0,200,200,200)); + smgr->drawAll(); + env->drawAll(); + driver->endScene(); + } + } + + device->drop(); + + return 0; +} -- cgit v1.1