diff --git a/changes.txt b/changes.txt index 4639dd47..cf9ccf20 100644 --- a/changes.txt +++ b/changes.txt @@ -2,9 +2,9 @@ Changes in version 1.5 (... 2008) - Hardware accelerated Vertex and Index Buffer support finally integrated into Irrlicht. Thanks to a ressource handling idea by Klasker and the almost immediate implementation by Luke, Irrlicht now supports VBOs under OpenGL. D3D will follow soon. - Hardware buffers make rendering the same vertices much faster. In some cases this can be more than 10x faster. To sue this feature with a mesh simple set a usage type, e.g. via MeshBuffer->setHardwareMappingHint(scene::EHM_STATIC). The driver will upload the vertices and indices on the next draw and reuse this information without the need to upload it each frame. + Hardware buffers make rendering the same vertices much faster. In some cases this can be more than 10x faster. To use this feature with a mesh simple set a usage type, e.g. via MeshBuffer->setHardwareMappingHint(scene::EHM_STATIC). The driver will upload the vertices and indices on the next draw and reuse this information without the need to upload it each frame. - - MeshBuffers can now access the elements of the S3DVertex base class in all vertex types directly, instead of using teh getVertices() pointer access. This simplifies simple mesh manipulations as it does not require a switch statement over all vertex types. + - MeshBuffers can now access the elements of the S3DVertex base class in all vertex types directly, instead of using the getVertices() pointer access. This simplifies simple mesh manipulations as it does not require a switch statement over all vertex types. - GLSL changes for setting arrays. Also allow for only pixel or vertex shader to be set. @@ -24,6 +24,9 @@ Changes in version 1.5 (... 2008) Removed the seperate rendering states for quake3 Shader Scene Nodes. Nodes are now solid or transparent. ( but still more states are needed ) + - GUI: + Finally added table control and TabControl additions from StarSonata team. + ------------------------------------------- Changes in version 1.4 (30.11.2007) diff --git a/include/EGUIAlignment.h b/include/EGUIAlignment.h new file mode 100644 index 00000000..5a284838 --- /dev/null +++ b/include/EGUIAlignment.h @@ -0,0 +1,37 @@ +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __E_GUI_ALIGNMENT_H_INCLUDED__ +#define __E_GUI_ALIGNMENT_H_INCLUDED__ + +namespace irr +{ +namespace gui +{ +enum EGUI_ALIGNMENT +{ + //! Aligned to parent's top or left side (default) + EGUIA_UPPERLEFT=0, + //! Aligned to parent's bottom or right side + EGUIA_LOWERRIGHT, + //! Aligned to the center of parent + EGUIA_CENTER, + //! Stretched to fit parent + EGUIA_SCALE +}; + +//! Names for alignments +const c8* const GUIAlignmentNames[] = +{ + "upperLeft", + "lowerRight", + "center", + "scale", + 0 +}; + +} // namespace gui +} // namespace irr + +#endif // __E_GUI_ALIGNMENT_H_INCLUDED__ diff --git a/include/EGUIElementTypes.h b/include/EGUIElementTypes.h index 53faa155..39e3b386 100644 --- a/include/EGUIElementTypes.h +++ b/include/EGUIElementTypes.h @@ -59,6 +59,9 @@ enum EGUI_ELEMENT_TYPE //! A scroll bar (IGUIScrollBar) EGUIET_SCROLL_BAR, + //! A spin box (IGUISpinBox) + EGUIET_SPIN_BOX, + //! A static text (IGUIStaticText) EGUIET_STATIC_TEXT, @@ -68,15 +71,15 @@ enum EGUI_ELEMENT_TYPE //! A tab control EGUIET_TAB_CONTROL, + //! A Table + EGUIET_TABLE, + //! A tool bar (IGUIToolBar) EGUIET_TOOL_BAR, //! A window EGUIET_WINDOW, - //! A spin box (IGUISpinBox) - EGUIET_SPIN_BOX, - //! Not an element, amount of elements in there EGUIET_COUNT, @@ -107,12 +110,13 @@ const c8* const GUIElementTypeNames[] = "messageBox", "modalScreen", "scrollBar", + "spinBox", "staticText", "tab", "tabControl", + "table", "toolBar", "window", - "spinBox", 0 }; @@ -121,3 +125,6 @@ const c8* const GUIElementTypeNames[] = #endif + + + diff --git a/include/IEventReceiver.h b/include/IEventReceiver.h index fce37f91..e5f6e39c 100644 --- a/include/IEventReceiver.h +++ b/include/IEventReceiver.h @@ -150,7 +150,12 @@ namespace irr EGET_COMBO_BOX_CHANGED, //! The value of a spin box has changed - EGET_SPINBOX_CHANGED + EGET_SPINBOX_CHANGED, + + //! A table has changed + EGET_TABLE_CHANGED, + EGET_TABLE_HEADER_CHANGED, + EGET_TABLE_SELECTED_AGAIN }; } // end namespace gui @@ -261,3 +266,6 @@ public: #endif + + + diff --git a/include/IGUIElement.h b/include/IGUIElement.h index 548c70dd..96689fab 100644 --- a/include/IGUIElement.h +++ b/include/IGUIElement.h @@ -11,6 +11,7 @@ #include "irrString.h" #include "IEventReceiver.h" #include "EGUIElementTypes.h" +#include "EGUIAlignment.h" #include "IAttributes.h" namespace irr @@ -20,28 +21,6 @@ namespace gui class IGUIEnvironment; -enum EGUI_ALIGNMENT -{ - //! Aligned to parent's top or left side (default) - EGUIA_UPPERLEFT=0, - //! Aligned to parent's bottom or right side - EGUIA_LOWERRIGHT, - //! Aligned to the center of parent - EGUIA_CENTER, - //! Scaled within its parent - EGUIA_SCALE -}; - -//! Names for alignments -const c8* const GUIAlignmentNames[] = -{ - "upperLeft", - "lowerRight", - "center", - "scale", - 0 -}; - //! Base class of all GUI elements. class IGUIElement : public virtual io::IAttributeExchangingObject, public IEventReceiver { diff --git a/include/IGUIEnvironment.h b/include/IGUIEnvironment.h index 6c345389..b62e88f9 100644 --- a/include/IGUIEnvironment.h +++ b/include/IGUIEnvironment.h @@ -49,6 +49,7 @@ class IGUIEditBox; class IGUISpinBox; class IGUITabControl; class IGUITab; +class IGUITable; class IGUIContextMenu; class IGUIComboBox; class IGUIToolBar; @@ -369,6 +370,10 @@ public: virtual IGUIComboBox* addComboBox(const core::rect& rectangle, IGUIElement* parent=0, s32 id=-1) = 0; + //! Adds a table to the environment + virtual IGUITable* addTable(const core::rect& rectangle, + IGUIElement* parent=0, s32 id=-1, bool drawBackground = false) = 0; + //! Returns the default element factory which can create all built in elements virtual IGUIElementFactory* getDefaultGUIElementFactory() const = 0; @@ -426,3 +431,6 @@ public: #endif + + + diff --git a/include/IGUISkin.h b/include/IGUISkin.h index 1ccfded7..1e09b050 100644 --- a/include/IGUISkin.h +++ b/include/IGUISkin.h @@ -6,6 +6,7 @@ #define __I_GUI_SKIN_H_INCLUDED__ #include "IAttributeExchangingObject.h" +#include "EGUIAlignment.h" #include "SColor.h" #include "rect.h" @@ -464,7 +465,7 @@ namespace gui \param rect: Defining area where to draw. \param clip: Clip area. */ virtual void draw3DTabButton(IGUIElement* element, bool active, - const core::rect& rect, const core::rect* clip=0) = 0; + const core::rect& rect, const core::rect* clip=0, gui::EGUI_ALIGNMENT alignment=EGUIA_UPPERLEFT) = 0; //! draws a tab control body /** \param element: Pointer to the element which wishes to draw this. This parameter @@ -475,7 +476,7 @@ namespace gui \param rect: Defining area where to draw. \param clip: Clip area. */ virtual void draw3DTabBody(IGUIElement* element, bool border, bool background, - const core::rect& rect, const core::rect* clip=0) = 0; + const core::rect& rect, const core::rect* clip=0, s32 tabHeight=-1, gui::EGUI_ALIGNMENT alignment=EGUIA_UPPERLEFT ) = 0; //! draws an icon, usually from the skin's sprite bank /** \param element: Pointer to the element which wishes to draw this icon. @@ -513,3 +514,6 @@ namespace gui #endif + + + diff --git a/include/IGUITabControl.h b/include/IGUITabControl.h index a296fd91..4f089fee 100644 --- a/include/IGUITabControl.h +++ b/include/IGUITabControl.h @@ -7,6 +7,7 @@ #include "IGUIElement.h" #include "SColor.h" +#include "IGUISkin.h" namespace irr { @@ -39,6 +40,12 @@ namespace gui //! returns the color of the background virtual video::SColor getBackgroundColor() const = 0; + + //! sets the color of the text + virtual void setTextColor(video::SColor c) = 0; + + //! gets the color of the text + virtual video::SColor getTextColor() const = 0; }; //! A standard tab control @@ -77,6 +84,28 @@ namespace gui //! Returns which tab is currently active virtual s32 getActiveTab() const = 0; + + //! Set the height of the tabs + virtual void setTabHeight( s32 height ) = 0; + + //! Get the height of the tabs + /** return Returns the height of the tabs */ + virtual s32 getTabHeight() const = 0; + + //! Set the alignment of the tabs + //! Use EGUIA_UPPERLEFT or EGUIA_LOWERRIGHT + virtual void setTabVerticalAlignment( gui::EGUI_ALIGNMENT alignment ) = 0; + + //! Get the alignment of the tabs + /** return Returns the alignment of the tabs */ + virtual gui::EGUI_ALIGNMENT getTabVerticalAlignment() const = 0; + + //! Set the extra width added to tabs on each side of the text + virtual void setTabExtraWidth( s32 extraWidth ) = 0; + + //! Get the extra width added to tabs on each side of the text + /** return Returns the extra width of the tabs */ + virtual s32 getTabExtraWidth() const = 0; }; @@ -85,3 +114,7 @@ namespace gui #endif + + + + diff --git a/include/IGUITable.h b/include/IGUITable.h new file mode 100644 index 00000000..5fcc6a5d --- /dev/null +++ b/include/IGUITable.h @@ -0,0 +1,125 @@ +// Copyright (C) 2003-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +// 07.10.2005 - Multicolor-Listbox added by A. Buschhüter (Acki) +// A_Buschhueter@gmx.de + +#ifndef __I_GUI_TABLE_H_INCLUDED__ +#define __I_GUI_TABLE_H_INCLUDED__ + +#include "IGUIElement.h" +#include "irrTypes.h" +#include "SColor.h" +#include "IGUISkin.h" + +namespace irr +{ +namespace gui +{ + + enum EGUI_ORDERING_MODE + { + //! Order the elements from the smallest to the largest. + EGOM_ASCENDING, + + //! Order the elements from the largest to the smallest. + EGOM_DESCENDING, + + //! this value is not used, it only specifies the amount of default ordering types + //! available. + EGOM_COUNT + }; + + class IGUIFont; + + //! Default list box GUI element. + class IGUITable : public IGUIElement + { + public: + //! constructor + IGUITable(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect rectangle) + : IGUIElement(EGUIET_TABLE, environment, parent, id, rectangle) {} + + //! Adds a column + virtual void addColumn(const wchar_t* caption, s32 id=-1) = 0; + + //! Returns the number of columns in the table control + virtual s32 getColumncount() const = 0; + + //! Makes a column active. This will trigger an ordering process. + /** \param idx: The id of the column to make active. + \return Returns true if successful. */ + virtual bool setActiveColumn(s32 idx) = 0; + + //! Returns which header is currently active + virtual s32 getActiveColumn() const = 0; + + //! Returns the ordering used by the currently active column + virtual EGUI_ORDERING_MODE getActiveColumnOrdering() const = 0; + + //! set a column width + virtual void setColumnWidth(u32 columnIndex, u32 width) = 0; + + //! This tells the table control wether is should send a EGET_TABLE_HEADER_CHANGED message or not when + //! a column header is clicked. If set to false, the table control will use a default alphabetical ordering scheme. + /** \param columnIndex: The index of the column header. + \param state: If true, a EGET_TABLE_HEADER_CHANGED message will be sent and you can order the table data as you whish.*/ + virtual void setColumnCustomOrdering(u32 columnIndex, bool state) = 0; + + //! Returns which row is currently selected + virtual s32 getSelected() const = 0; + + //! Returns amount of rows in the tabcontrol + virtual s32 getRowcount() const = 0; + + //! adds a row to the table + /** \param rowIndex: zero based index of rows. The row will be inserted at this + position, if a row already exist there, it will be placed after it. If the row + is larger than the actual number of row by more than one, it won't be created. + Note that if you create a row that's not at the end, there might be performance issues*/ + virtual void addRow(u32 rowIndex) = 0; + + //! Remove a row from the table + virtual void removeRow(u32 rowIndex) = 0; + + //! clears the table rows, but keeps the columns intact + virtual void clearRows() = 0; + + //! Swap two row positions. This is useful for a custom ordering algo. + virtual void swapRows(u32 rowIndexA, u32 rowIndexB) = 0; + + //! This tells the table to start ordering all the rows. You need to explicitly + //! tell the table to re order the rows when a new row is added or the cells data is + //! changed. This makes the system more flexible and doesn't make you pay the cost of + //! ordering when adding a lot of rows. + virtual void orderRows() = 0; + + //! Set the text of a cell + virtual void setCellText(u32 rowIndex, u32 columnIndex, const wchar_t* text) = 0; + + //! Set the text of a cell, and set a color of this cell. + virtual void setCellText(u32 rowIndex, u32 columnIndex, const wchar_t* text, video::SColor color) = 0; + + //! Set the data of a cell + virtual void setCellData(u32 rowIndex, u32 columnIndex, void *data) = 0; + + //! Set the color of a cell text + virtual void setCellColor(u32 rowIndex, u32 columnIndex, video::SColor color) = 0; + + //! Get the text of a cell + virtual const wchar_t* getCellText(u32 rowIndex, u32 columnIndex ) const = 0; + + //! Get the data of a cell + virtual void* getCellData(u32 rowIndex, u32 columnIndex ) const = 0; + + //! clears the table, deletes all items in the table + virtual void clear() = 0; + }; + + +} // end namespace gui +} // end namespace irr + +#endif + diff --git a/include/aabbox3d.h b/include/aabbox3d.h index 2827badb..54a92f0e 100644 --- a/include/aabbox3d.h +++ b/include/aabbox3d.h @@ -274,6 +274,20 @@ class aabbox3d (other.MaxEdge*inv) + (MaxEdge*d)); } + //! returns the volume enclosed by the box in cubed units + T getVolume() const + { + const vector3d e = getExtent(); + return e.X * e.Y * e.Z; + } + + //! returns the surface area of the box in squared units + T getArea() const + { + const vector3d e = getExtent(); + return 2*(e.X*e.Y + e.X*e.Z + e.Y*e.Z); + } + // member variables vector3d MinEdge; diff --git a/include/irrlicht.h b/include/irrlicht.h index 52bf3243..73c2f18c 100644 --- a/include/irrlicht.h +++ b/include/irrlicht.h @@ -78,6 +78,7 @@ #include "IGUISpriteBank.h" #include "IGUIStaticText.h" #include "IGUITabControl.h" +#include "IGUITable.h" #include "IGUIToolbar.h" #include "IGUIWindow.h" #include "IImage.h" @@ -331,3 +332,4 @@ namespace irr #endif + diff --git a/source/Irrlicht/CDefaultGUIElementFactory.cpp b/source/Irrlicht/CDefaultGUIElementFactory.cpp index 534c77a0..40b05318 100644 --- a/source/Irrlicht/CDefaultGUIElementFactory.cpp +++ b/source/Irrlicht/CDefaultGUIElementFactory.cpp @@ -7,26 +7,26 @@ #ifdef _IRR_COMPILE_WITH_GUI_ #include "IGUIEnvironment.h" + #include "IGUIButton.h" #include "IGUICheckBox.h" +#include "IGUIColorSelectDialog.h" #include "IGUIComboBox.h" #include "IGUIContextMenu.h" #include "IGUIEditBox.h" -#include "IGUISpinBox.h" #include "IGUIFileOpenDialog.h" -#include "IGUIColorSelectDialog.h" #include "IGUIInOutFader.h" #include "IGUIImage.h" #include "IGUIListBox.h" #include "IGUIMeshViewer.h" #include "IGUIScrollBar.h" +#include "IGUISpinBox.h" #include "IGUIStaticText.h" #include "IGUITabControl.h" +#include "IGUITable.h" #include "IGUIToolbar.h" #include "IGUIWindow.h" -#include - namespace irr { namespace gui @@ -80,6 +80,8 @@ IGUIElement* CDefaultGUIElementFactory::addGUIElement(EGUI_ELEMENT_TYPE type, IG return Environment->addTab(core::rect(0,0,100,100),parent); case EGUIET_TAB_CONTROL: return Environment->addTabControl(core::rect(0,0,100,100),parent); + case EGUIET_TABLE: + return Environment->addTable(core::rect(0,0,100,100), parent); case EGUIET_TOOL_BAR: return Environment->addToolBar(parent); case EGUIET_WINDOW: diff --git a/source/Irrlicht/CGUIEnvironment.cpp b/source/Irrlicht/CGUIEnvironment.cpp index 7fa62872..d1635aec 100644 --- a/source/Irrlicht/CGUIEnvironment.cpp +++ b/source/Irrlicht/CGUIEnvironment.cpp @@ -32,6 +32,7 @@ #include "CGUIComboBox.h" #include "CGUIMenu.h" #include "CGUIToolBar.h" +#include "CGUITable.h" #include "CDefaultGUIElementFactory.h" #include "IWriteFile.h" @@ -984,6 +985,12 @@ IGUIScrollBar* CGUIEnvironment::addScrollBar(bool horizontal, const core::rect& rectangle, IGUIElement* parent, s32 id, bool drawBackground) +{ + CGUITable* b = new CGUITable(this, parent ? parent : this, id, rectangle, true, drawBackground, false); + b->drop(); + return b; +} //! Adds an image element. IGUIImage* CGUIEnvironment::addImage(video::ITexture* image, core::position2d pos, @@ -1495,3 +1502,4 @@ IGUIEnvironment* createGUIEnvironment(io::IFileSystem* fs, #endif // _IRR_COMPILE_WITH_GUI_ + diff --git a/source/Irrlicht/CGUIEnvironment.h b/source/Irrlicht/CGUIEnvironment.h index aa43a07c..33a3d1e5 100644 --- a/source/Irrlicht/CGUIEnvironment.h +++ b/source/Irrlicht/CGUIEnvironment.h @@ -155,6 +155,10 @@ public: virtual IGUIComboBox* addComboBox(const core::rect& rectangle, IGUIElement* parent=0, s32 id=-1); + //! Adds a table element. + virtual IGUITable* addTable(const core::rect& rectangle, + IGUIElement* parent=0, s32 id=-1, bool drawBackground=false); + //! sets the focus to an element virtual bool setFocus(IGUIElement* element); @@ -292,3 +296,4 @@ private: #endif // __C_GUI_ENVIRNMENT_H_INCLUDED__ + diff --git a/source/Irrlicht/CGUISkin.cpp b/source/Irrlicht/CGUISkin.cpp index f69f6642..8620a52c 100644 --- a/source/Irrlicht/CGUISkin.cpp +++ b/source/Irrlicht/CGUISkin.cpp @@ -680,41 +680,79 @@ implementations to find out how to draw the part exactly. \param rect: Defining area where to draw. \param clip: Clip area. */ void CGUISkin::draw3DTabButton(IGUIElement* element, bool active, - const core::rect& frameRect, - const core::rect* clip) + const core::rect& frameRect, const core::rect* clip, EGUI_ALIGNMENT alignment) { if (!Driver) return; core::rect tr = frameRect; - tr.LowerRightCorner.X -= 2; - tr.LowerRightCorner.Y = tr.UpperLeftCorner.Y + 1; - tr.UpperLeftCorner.X += 1; - Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), tr, clip); + if ( alignment == EGUIA_UPPERLEFT ) + { + tr.LowerRightCorner.X -= 2; + tr.LowerRightCorner.Y = tr.UpperLeftCorner.Y + 1; + tr.UpperLeftCorner.X += 1; + Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), tr, clip); + + // draw left highlight + tr = frameRect; + tr.LowerRightCorner.X = tr.UpperLeftCorner.X + 1; + tr.UpperLeftCorner.Y += 1; + Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), tr, clip); - // draw left highlight - tr = frameRect; - tr.LowerRightCorner.X = tr.UpperLeftCorner.X + 1; - tr.UpperLeftCorner.Y += 1; - Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), tr, clip); + // draw grey background + tr = frameRect; + tr.UpperLeftCorner.X += 1; + tr.UpperLeftCorner.Y += 1; + tr.LowerRightCorner.X -= 2; + Driver->draw2DRectangle(getColor(EGDC_3D_FACE), tr, clip); - // draw grey background - tr = frameRect; - tr.UpperLeftCorner.X += 1; - tr.UpperLeftCorner.Y += 1; - tr.LowerRightCorner.X -= 2; - Driver->draw2DRectangle(getColor(EGDC_3D_FACE), tr, clip); + + // draw right middle gray shadow + tr.LowerRightCorner.X += 1; + tr.UpperLeftCorner.X = tr.LowerRightCorner.X - 1; + Driver->draw2DRectangle(getColor(EGDC_3D_SHADOW), tr, clip); - // draw right middle gray shadow - tr.LowerRightCorner.X += 1; - tr.UpperLeftCorner.X = tr.LowerRightCorner.X - 1; - Driver->draw2DRectangle(getColor(EGDC_3D_SHADOW), tr, clip); + + tr.LowerRightCorner.X += 1; + tr.UpperLeftCorner.X += 1; + tr.UpperLeftCorner.Y += 1; + Driver->draw2DRectangle(getColor(EGDC_3D_DARK_SHADOW), tr, clip); + } + else + { + tr.LowerRightCorner.X -= 2; + tr.UpperLeftCorner.Y = tr.LowerRightCorner.Y - 1; + tr.UpperLeftCorner.X += 1; + Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), tr, clip); + + // draw left highlight + tr = frameRect; + tr.LowerRightCorner.X = tr.UpperLeftCorner.X + 1; + tr.LowerRightCorner.Y -= 1; + Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), tr, clip); + + // draw grey background + tr = frameRect; + tr.UpperLeftCorner.X += 1; + tr.UpperLeftCorner.Y -= 1; + tr.LowerRightCorner.X -= 2; + tr.LowerRightCorner.Y -= 1; + Driver->draw2DRectangle(getColor(EGDC_3D_FACE), tr, clip); + + // draw right middle gray shadow + tr.LowerRightCorner.X += 1; + tr.UpperLeftCorner.X = tr.LowerRightCorner.X - 1; + //tr.LowerRightCorner.Y -= 1; + Driver->draw2DRectangle(getColor(EGDC_3D_SHADOW), tr, clip); + + + tr.LowerRightCorner.X += 1; + tr.UpperLeftCorner.X += 1; + tr.LowerRightCorner.Y -= 1; + Driver->draw2DRectangle(getColor(EGDC_3D_DARK_SHADOW), tr, clip); + } - tr.LowerRightCorner.X += 1; - tr.UpperLeftCorner.X += 1; - tr.UpperLeftCorner.Y += 1; - Driver->draw2DRectangle(getColor(EGDC_3D_DARK_SHADOW), tr, clip); } @@ -727,46 +765,85 @@ implementations to find out how to draw the part exactly. \param rect: Defining area where to draw. \param clip: Clip area. */ void CGUISkin::draw3DTabBody(IGUIElement* element, bool border, bool background, - const core::rect& rect, const core::rect* clip) + const core::rect& rect, const core::rect* clip, s32 tabHeight, EGUI_ALIGNMENT alignment) { if (!Driver) return; core::rect tr = rect; + if ( tabHeight == -1 ) + tabHeight = getSize(gui::EGDS_BUTTON_HEIGHT); + // draw border. if (border) { - // draw left hightlight - tr.UpperLeftCorner.Y += getSize(gui::EGDS_BUTTON_HEIGHT) + 2; - tr.LowerRightCorner.X = tr.UpperLeftCorner.X + 1; - Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), tr, clip); + if ( alignment == EGUIA_UPPERLEFT ) + { + // draw left hightlight + tr.UpperLeftCorner.Y += tabHeight + 2; + tr.LowerRightCorner.X = tr.UpperLeftCorner.X + 1; + Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), tr, clip); - // draw right shadow - tr.UpperLeftCorner.X = rect.LowerRightCorner.X - 1; - tr.LowerRightCorner.X = tr.UpperLeftCorner.X + 1; - Driver->draw2DRectangle(getColor(EGDC_3D_SHADOW), tr, clip); + + // draw right shadow + tr.UpperLeftCorner.X = rect.LowerRightCorner.X - 1; + tr.LowerRightCorner.X = tr.UpperLeftCorner.X + 1; + Driver->draw2DRectangle(getColor(EGDC_3D_SHADOW), tr, clip); - // draw lower shadow - tr = rect; - tr.UpperLeftCorner.Y = tr.LowerRightCorner.Y - 1; - Driver->draw2DRectangle(getColor(EGDC_3D_SHADOW), tr, clip); + // draw lower shadow + tr = rect; + tr.UpperLeftCorner.Y = tr.LowerRightCorner.Y - 1; + Driver->draw2DRectangle(getColor(EGDC_3D_SHADOW), tr, clip); + + } + else + { + // draw left hightlight + tr.LowerRightCorner.Y -= tabHeight + 2; + tr.LowerRightCorner.X = tr.UpperLeftCorner.X + 1; + Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), tr, clip); + + // draw right shadow + tr.UpperLeftCorner.X = rect.LowerRightCorner.X - 1; + tr.LowerRightCorner.X = tr.UpperLeftCorner.X + 1; + Driver->draw2DRectangle(getColor(EGDC_3D_SHADOW), tr, clip); + + // draw lower shadow + tr = rect; + tr.LowerRightCorner.Y = tr.UpperLeftCorner.Y + 1; + Driver->draw2DRectangle(getColor(EGDC_3D_HIGH_LIGHT), tr, clip); + + } } if (background) { - tr = rect; - tr.UpperLeftCorner.Y += getSize(gui::EGDS_BUTTON_HEIGHT) + 2; - tr.LowerRightCorner.X -= 1; - tr.UpperLeftCorner.X += 1; - tr.LowerRightCorner.Y -= 1; + + if ( alignment == EGUIA_UPPERLEFT ) + { + tr = rect; + tr.UpperLeftCorner.Y += tabHeight + 2; + tr.LowerRightCorner.X -= 1; + tr.UpperLeftCorner.X += 1; + tr.LowerRightCorner.Y -= 1; + } + else + { + tr = rect; + tr.UpperLeftCorner.X += 1; + tr.UpperLeftCorner.Y -= 1; + tr.LowerRightCorner.X -= 1; + tr.LowerRightCorner.Y -= tabHeight + 2; + //tr.UpperLeftCorner.X += 1; + } if (!UseGradient) Driver->draw2DRectangle(getColor(EGDC_3D_FACE), tr, clip); else { - const video::SColor c1 = getColor(EGDC_3D_FACE); - const video::SColor c2 = getColor(EGDC_3D_SHADOW); + video::SColor c1 = getColor(EGDC_3D_FACE); + video::SColor c2 = getColor(EGDC_3D_SHADOW); Driver->draw2DRectangle(tr, c1, c1, c2, c2, clip); } } @@ -856,3 +933,4 @@ void CGUISkin::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWrit #endif // _IRR_COMPILE_WITH_GUI_ + diff --git a/source/Irrlicht/CGUISkin.h b/source/Irrlicht/CGUISkin.h index 7a6b955d..bb3e572f 100644 --- a/source/Irrlicht/CGUISkin.h +++ b/source/Irrlicht/CGUISkin.h @@ -164,8 +164,7 @@ namespace gui \param rect: Defining area where to draw. \param clip: Clip area. */ virtual void draw3DTabButton(IGUIElement* element, bool active, - const core::rect& rect, - const core::rect* clip=0); + const core::rect& rect, const core::rect* clip=0, EGUI_ALIGNMENT alignment=EGUIA_UPPERLEFT); //! draws a tab control body /** \param element: Pointer to the element which wishes to draw this. This parameter @@ -175,10 +174,8 @@ namespace gui \param background: Specifies if the background should be drawn. \param rect: Defining area where to draw. \param clip: Clip area. */ - virtual void draw3DTabBody(IGUIElement* element, bool border, - bool background, - const core::rect& rect, - const core::rect* clip=0); + virtual void draw3DTabBody(IGUIElement* element, bool border, bool background, + const core::rect& rect, const core::rect* clip=0, s32 tabHeight=-1, EGUI_ALIGNMENT alignment=EGUIA_UPPERLEFT); //! draws an icon, usually from the skin's sprite bank /** \param element: Pointer to the element which wishes to draw this icon. @@ -244,3 +241,4 @@ namespace gui #endif + diff --git a/source/Irrlicht/CGUITabControl.cpp b/source/Irrlicht/CGUITabControl.cpp index 9b8360a2..48964bd9 100644 --- a/source/Irrlicht/CGUITabControl.cpp +++ b/source/Irrlicht/CGUITabControl.cpp @@ -5,6 +5,7 @@ #include "CGUITabControl.h" #ifdef _IRR_COMPILE_WITH_GUI_ +#include "CGUIButton.h" #include "IGUISkin.h" #include "IGUIEnvironment.h" #include "IGUIFont.h" @@ -31,6 +32,12 @@ CGUITab::CGUITab(s32 number, IGUIEnvironment* environment, #ifdef _DEBUG setDebugName("CGUITab"); #endif + + IGUISkin* skin = environment->getSkin(); + if (skin) + TextColor = skin->getColor(EGDC_BUTTON_TEXT); + else + TextColor.set(255,0,0,0); } @@ -77,6 +84,16 @@ void CGUITab::setBackgroundColor(video::SColor c) BackColor = c; } +//! sets the color of the text +void CGUITab::setTextColor(video::SColor c) +{ + TextColor = c; +} + +video::SColor CGUITab::getTextColor() const +{ + return TextColor; +} //! returns true if the tab is drawing its background, false if not bool CGUITab::isDrawingBackground() const @@ -98,9 +115,10 @@ void CGUITab::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteO { IGUITab::serializeAttributes(out,options); - out->addInt ("TabNumber", Number); + out->addInt ("TabNumber", Number); out->addBool ("DrawBackground", DrawBackground); out->addColor ("BackColor", BackColor); + out->addColor ("TextColor", TextColor); } @@ -113,6 +131,7 @@ void CGUITab::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWrite setNumber(in->getAttributeAsInt("TabNumber")); setDrawBackground(in->getAttributeAsBool("DrawBackground")); setBackgroundColor(in->getAttributeAsColor("BackColor")); + setTextColor(in->getAttributeAsColor("TextColor")); if (Parent && Parent->getType() == EGUIET_TAB_CONTROL) { @@ -127,16 +146,60 @@ void CGUITab::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWrite // Tabcontrol // ------------------------------------------------------------------ -//! destructor +//! constructor CGUITabControl::CGUITabControl(IGUIEnvironment* environment, IGUIElement* parent, const core::rect& rectangle, bool fillbackground, bool border, s32 id) : IGUITabControl(environment, parent, id, rectangle), ActiveTab(-1), - Border(border), FillBackground(fillbackground) + Border(border), FillBackground(fillbackground), ScrollControl(false), TabHeight(0), VerticalAlignment(EGUIA_UPPERLEFT), + UpButton(0), DownButton(0), TabMaxWidth(0), CurrentScrollTabIndex(0), TabExtraWidth(20) { #ifdef _DEBUG setDebugName("CGUITabControl"); - #endif + #endif + + video::SColor color(255,255,255,255); + IGUISkin* skin = Environment->getSkin(); + IGUISpriteBank* sprites = 0; + + TabHeight = 32; + + if (skin) + { + sprites = skin->getSpriteBank(); + color = skin->getColor(EGDC_WINDOW_SYMBOL); + TabHeight = skin->getSize(gui::EGDS_BUTTON_HEIGHT) + 2; + } + + UpButton = Environment->addButton(core::rect(0,0,10,10), this); + + if (UpButton) + { + UpButton->setSpriteBank(sprites); + UpButton->setSprite(EGBS_BUTTON_UP, skin->getIcon(EGDI_CURSOR_LEFT), color); + UpButton->setSprite(EGBS_BUTTON_DOWN, skin->getIcon(EGDI_CURSOR_LEFT), color); + UpButton->setVisible(false); + UpButton->setSubElement(true); + UpButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT); + UpButton->setOverrideFont(Environment->getBuiltInFont()); + UpButton->grab(); + } + + DownButton = Environment->addButton(core::rect(0,0,10,10), this); + + if (DownButton) + { + DownButton->setSpriteBank(sprites); + DownButton->setSprite(EGBS_BUTTON_UP, skin->getIcon(EGDI_CURSOR_RIGHT), color); + DownButton->setSprite(EGBS_BUTTON_DOWN, skin->getIcon(EGDI_CURSOR_RIGHT), color); + DownButton->setVisible(false); + DownButton->setSubElement(true); + DownButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT); + DownButton->setOverrideFont(Environment->getBuiltInFont()); + DownButton->grab(); + } + + setTabVerticalAlignment(EGUIA_UPPERLEFT); } @@ -146,6 +209,12 @@ CGUITabControl::~CGUITabControl() for (s32 i=0; i<(s32)Tabs.size(); ++i) if (Tabs[i]) Tabs[i]->drop(); + + if (UpButton) + UpButton->drop(); + + if (DownButton) + DownButton->drop(); } @@ -156,16 +225,28 @@ IGUITab* CGUITabControl::addTab(const wchar_t* caption, s32 id) if (!skin) return 0; - s32 tabheight = skin->getSize(gui::EGDS_BUTTON_HEIGHT) + 2; - core::rect r(1,tabheight, - AbsoluteRect.getWidth()-1, - AbsoluteRect.getHeight()-1); + core::rect r; + if ( VerticalAlignment == EGUIA_UPPERLEFT ) + { + r.UpperLeftCorner.X = 1; + r.UpperLeftCorner.Y = TabHeight; - CGUITab* tab = new CGUITab(Tabs.size(), Environment, this, - r, id); - tab->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT); + r.LowerRightCorner.X = AbsoluteRect.getWidth()-1; + r.LowerRightCorner.Y = AbsoluteRect.getHeight()-1; + } + else + { + r.UpperLeftCorner.X = 1; + r.UpperLeftCorner.Y = 1; + + r.LowerRightCorner.X = AbsoluteRect.getWidth()-1; + r.LowerRightCorner.Y = AbsoluteRect.getHeight()-TabHeight; + } + + CGUITab* tab = new CGUITab(Tabs.size(), Environment, this, r, id); tab->setText(caption); + tab->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT); tab->setVisible(false); Tabs.push_back(tab); @@ -175,6 +256,8 @@ IGUITab* CGUITabControl::addTab(const wchar_t* caption, s32 id) tab->setVisible(true); } + recalculateScrollBar(); + return tab; } @@ -241,16 +324,34 @@ bool CGUITabControl::OnEvent(const SEvent& event) switch(event.EventType) { + case EET_GUI_EVENT: + switch(event.GUIEvent.EventType) + { + case EGET_BUTTON_CLICKED: + if (event.GUIEvent.Caller == UpButton) + { + scrollLeft(); + return true; + } + else if (event.GUIEvent.Caller == DownButton) + { + scrollRight(); + return true; + } + + break; + } + break; case EET_MOUSE_INPUT_EVENT: switch(event.MouseInput.Event) { - case EMIE_LMOUSE_PRESSED_DOWN: - Environment->setFocus(this); - return true; + //case EMIE_LMOUSE_PRESSED_DOWN: + // Environment->setFocus(this); + // return true; case EMIE_LMOUSE_LEFT_UP: - Environment->removeFocus(this); - selectTab(core::position2d(event.MouseInput.X, event.MouseInput.Y)); - return true; + if (selectTab(core::position2d(event.MouseInput.X, event.MouseInput.Y))) + return true; + break; default: break; } @@ -262,20 +363,48 @@ bool CGUITabControl::OnEvent(const SEvent& event) return Parent ? Parent->OnEvent(event) : false; } - -void CGUITabControl::selectTab(core::position2d p) +void CGUITabControl::scrollLeft() { + if ( CurrentScrollTabIndex > 0 ) + --CurrentScrollTabIndex; + recalculateScrollBar(); +} + +void CGUITabControl::scrollRight() +{ + if ( CurrentScrollTabIndex < (s32)(Tabs.size()) - 1 ) + { + if ( needScrollControl(CurrentScrollTabIndex, true) ) + ++CurrentScrollTabIndex; + } + recalculateScrollBar(); +} + +bool CGUITabControl::needScrollControl(s32 startIndex, bool withScrollControl) +{ + if ( startIndex >= (s32)Tabs.size() ) + startIndex -= 1; + + if ( startIndex < 0 ) + startIndex = 0; + IGUISkin* skin = Environment->getSkin(); + if (!skin) + return false; + IGUIFont* font = skin->getFont(); core::rect frameRect(AbsoluteRect); - s32 tabheight = skin->getSize(gui::EGDS_BUTTON_HEIGHT); - frameRect.UpperLeftCorner.Y += 2; - frameRect.LowerRightCorner.Y = frameRect.UpperLeftCorner.Y + tabheight; + if (Tabs.empty()) + return false; + + if (!font) + return false; + s32 pos = frameRect.UpperLeftCorner.X + 2; - for (u32 i=0; i p) text = Tabs[i]->getText(); // get text length - s32 len = 20; - if (font) - len += font->getDimension(text).Width; + s32 len = font->getDimension(text).Width + TabExtraWidth; + + frameRect.LowerRightCorner.X += len; frameRect.UpperLeftCorner.X = pos; frameRect.LowerRightCorner.X = frameRect.UpperLeftCorner.X + len; pos += len; + if ( withScrollControl && pos > AbsoluteRect.LowerRightCorner.X - TabMaxWidth) + return true; + + if ( !withScrollControl && pos > AbsoluteRect.LowerRightCorner.X ) + return true; + } + + return false; +} + +bool CGUITabControl::selectTab(core::position2d p) +{ + IGUISkin* skin = Environment->getSkin(); + IGUIFont* font = skin->getFont(); + + core::rect frameRect(AbsoluteRect); + + if ( VerticalAlignment == EGUIA_UPPERLEFT ) + { + frameRect.UpperLeftCorner.Y += 2; + frameRect.LowerRightCorner.Y = frameRect.UpperLeftCorner.Y + TabHeight; + } + else + { + frameRect.UpperLeftCorner.Y = frameRect.LowerRightCorner.Y - TabHeight; + } + + s32 pos = frameRect.UpperLeftCorner.X + 2; + + if (!frameRect.isPointInside(p)) + return false; + + for (s32 i=CurrentScrollTabIndex; i<(s32)Tabs.size(); ++i) + { + // get Text + const wchar_t* text = 0; + if (Tabs[i]) + text = Tabs[i]->getText(); + + // get text length + s32 len = font->getDimension(text).Width + TabExtraWidth; + frameRect.UpperLeftCorner.X = pos; + frameRect.LowerRightCorner.X = frameRect.UpperLeftCorner.X + len; + + if ( ScrollControl && pos > AbsoluteRect.LowerRightCorner.X) + return false; + + pos += len; + if (frameRect.isPointInside(p)) { setActiveTab(i); - return; + return true; } } + return false; } @@ -311,28 +490,38 @@ void CGUITabControl::draw() return; IGUIFont* font = skin->getFont(); + video::IVideoDriver* driver = Environment->getVideoDriver(); core::rect frameRect(AbsoluteRect); if (Tabs.empty()) - skin->draw2DRectangle(this, skin->getColor(EGDC_3D_HIGH_LIGHT), - frameRect, &AbsoluteClippingRect); + driver->draw2DRectangle(skin->getColor(EGDC_3D_HIGH_LIGHT), frameRect, &AbsoluteClippingRect); if (!font) return; + + if ( VerticalAlignment == EGUIA_UPPERLEFT ) + { + frameRect.UpperLeftCorner.Y += 2; + frameRect.LowerRightCorner.Y = frameRect.UpperLeftCorner.Y + TabHeight; + } + else + { + frameRect.UpperLeftCorner.Y = frameRect.LowerRightCorner.Y - TabHeight - 1; + frameRect.LowerRightCorner.Y -= 2; + } - s32 tabheight = skin->getSize(gui::EGDS_BUTTON_HEIGHT); - frameRect.UpperLeftCorner.Y += 2; - frameRect.LowerRightCorner.Y = frameRect.UpperLeftCorner.Y + tabheight; core::rect tr; s32 pos = frameRect.UpperLeftCorner.X + 2; // left and right pos of the active tab s32 left = 0; s32 right = 0; - const wchar_t* activetext = 0; - - for (s32 i=0; i<(s32)Tabs.size(); ++i) + + //const wchar_t* activetext = 0; + CGUITab *activeTab = 0; + + for (s32 i=CurrentScrollTabIndex; i<(s32)Tabs.size(); ++i) { // get Text const wchar_t* text = 0; @@ -340,57 +529,208 @@ void CGUITabControl::draw() text = Tabs[i]->getText(); // get text length - s32 len = font->getDimension(text).Width + 20; + s32 len = font->getDimension(text).Width + TabExtraWidth; + + frameRect.LowerRightCorner.X += len; + frameRect.UpperLeftCorner.X = pos; frameRect.LowerRightCorner.X = frameRect.UpperLeftCorner.X + len; + + if ( ScrollControl && pos > frameRect.LowerRightCorner.X ) + break; + pos += len; if (i == ActiveTab) { left = frameRect.UpperLeftCorner.X; right = frameRect.LowerRightCorner.X; - activetext = text; + //activetext = text; + activeTab = Tabs[i]; } else { - skin->draw3DTabButton(this, false, frameRect, &AbsoluteClippingRect); - + skin->draw3DTabButton(this, false, frameRect, &AbsoluteClippingRect, VerticalAlignment); + // draw text - font->draw(text, frameRect, skin->getColor(EGDC_BUTTON_TEXT), + font->draw(text, frameRect, Tabs[i]->getTextColor(), true, true, &AbsoluteClippingRect); } } // draw active tab - if (left != 0 && right != 0) - { - frameRect.UpperLeftCorner.X = left-2; - frameRect.LowerRightCorner.X = right+2; - frameRect.UpperLeftCorner.Y -= 2; - - skin->draw3DTabButton(this, true, frameRect, &AbsoluteClippingRect); - - // draw text - font->draw(activetext, frameRect, skin->getColor(EGDC_BUTTON_TEXT), - true, true, &AbsoluteClippingRect); - + if (left != 0 && right != 0 && activeTab != 0) + { // draw upper highlight frame - tr.UpperLeftCorner.X = AbsoluteRect.UpperLeftCorner.X; - tr.LowerRightCorner.X = left - 1; - tr.UpperLeftCorner.Y = frameRect.LowerRightCorner.Y - 1; - tr.LowerRightCorner.Y = frameRect.LowerRightCorner.Y; - skin->draw2DRectangle(this, skin->getColor(EGDC_3D_HIGH_LIGHT), tr, &AbsoluteClippingRect); + if ( VerticalAlignment == EGUIA_UPPERLEFT ) + { + frameRect.UpperLeftCorner.X = left-2; + frameRect.LowerRightCorner.X = right+2; + frameRect.UpperLeftCorner.Y -= 2; - tr.UpperLeftCorner.X = right; - tr.LowerRightCorner.X = AbsoluteRect.LowerRightCorner.X; - skin->draw2DRectangle(this, skin->getColor(EGDC_3D_HIGH_LIGHT), tr, &AbsoluteClippingRect); + skin->draw3DTabButton(this, true, frameRect, &AbsoluteClippingRect, VerticalAlignment); + + // draw text + font->draw(activeTab->getText(), frameRect, activeTab->getTextColor(), + true, true, &AbsoluteClippingRect); + + tr.UpperLeftCorner.X = AbsoluteRect.UpperLeftCorner.X; + tr.LowerRightCorner.X = left - 1; + tr.UpperLeftCorner.Y = frameRect.LowerRightCorner.Y - 1; + tr.LowerRightCorner.Y = frameRect.LowerRightCorner.Y; + driver->draw2DRectangle(skin->getColor(EGDC_3D_HIGH_LIGHT), tr, &AbsoluteClippingRect); + + tr.UpperLeftCorner.X = right; + tr.LowerRightCorner.X = AbsoluteRect.LowerRightCorner.X; + driver->draw2DRectangle(skin->getColor(EGDC_3D_HIGH_LIGHT), tr, &AbsoluteClippingRect); + } + else + { + + frameRect.UpperLeftCorner.X = left-2; + frameRect.LowerRightCorner.X = right+2; + frameRect.LowerRightCorner.Y += 2; + + skin->draw3DTabButton(this, true, frameRect, &AbsoluteClippingRect, VerticalAlignment); + + // draw text + font->draw(activeTab->getText(), frameRect, activeTab->getTextColor(), + true, true, &AbsoluteClippingRect); + + tr.UpperLeftCorner.X = AbsoluteRect.UpperLeftCorner.X; + tr.LowerRightCorner.X = left - 1; + tr.UpperLeftCorner.Y = frameRect.UpperLeftCorner.Y - 1; + tr.LowerRightCorner.Y = frameRect.UpperLeftCorner.Y; + driver->draw2DRectangle(skin->getColor(EGDC_3D_DARK_SHADOW), tr, &AbsoluteClippingRect); + + tr.UpperLeftCorner.X = right; + tr.LowerRightCorner.X = AbsoluteRect.LowerRightCorner.X; + driver->draw2DRectangle(skin->getColor(EGDC_3D_DARK_SHADOW), tr, &AbsoluteClippingRect); + } + } + else + { + if ( VerticalAlignment == EGUIA_UPPERLEFT ) + { + tr.UpperLeftCorner.X = AbsoluteRect.UpperLeftCorner.X; + tr.LowerRightCorner.X = AbsoluteRect.LowerRightCorner.X; + tr.UpperLeftCorner.Y = frameRect.LowerRightCorner.Y - 1; + tr.LowerRightCorner.Y = frameRect.LowerRightCorner.Y; + driver->draw2DRectangle(skin->getColor(EGDC_3D_HIGH_LIGHT), tr, &AbsoluteClippingRect); + } + else + { + tr.UpperLeftCorner.X = AbsoluteRect.UpperLeftCorner.X; + tr.LowerRightCorner.X = 1000; + tr.UpperLeftCorner.Y = frameRect.UpperLeftCorner.Y - 1; + tr.LowerRightCorner.Y = frameRect.UpperLeftCorner.Y; + driver->draw2DRectangle(skin->getColor(EGDC_3D_DARK_SHADOW), tr, &AbsoluteClippingRect); + } } - skin->draw3DTabBody(this, Border, FillBackground, AbsoluteRect, &AbsoluteClippingRect); + skin->draw3DTabBody(this, Border, FillBackground, AbsoluteRect, &AbsoluteClippingRect, TabHeight, VerticalAlignment); IGUIElement::draw(); } +//! Set the height of the tabs +void CGUITabControl::setTabHeight( s32 height ) +{ + if ( height < 0 ) + height = 0; + + TabHeight = height; + + TabMaxWidth = 2 * TabHeight; + + recalculateScrollBar(); +} + +//! Get the height of the tabs +s32 CGUITabControl::getTabHeight() const +{ + return TabHeight; +} + +//! Set the extra width added to tabs on each side of the text +void CGUITabControl::setTabExtraWidth( s32 extraWidth ) +{ + if ( extraWidth < 0 ) + extraWidth = 0; + + TabExtraWidth = extraWidth; + + recalculateScrollBar(); +} + +//! Get the extra width added to tabs on each side of the text +s32 CGUITabControl::getTabExtraWidth() const +{ + return TabExtraWidth; +} + +void CGUITabControl::recalculateScrollBar() +{ + ScrollControl = needScrollControl() || CurrentScrollTabIndex > 0; + + if (ScrollControl) + { + UpButton->setVisible( true ); + DownButton->setVisible( true ); + } + else + { + UpButton->setVisible( false ); + DownButton->setVisible( false ); + } + + this->bringToFront( UpButton ); + this->bringToFront( DownButton ); +} + +//! Set the alignment of the tabs +void CGUITabControl::setTabVerticalAlignment( EGUI_ALIGNMENT alignment ) +{ + VerticalAlignment = alignment; + + IGUISkin* skin = Environment->getSkin(); + s32 ButtonSize = 16; + if (skin) + { + ButtonSize = skin->getSize(EGDS_WINDOW_BUTTON_WIDTH); + if (ButtonSize > TabHeight) + ButtonSize = TabHeight; + } + + TabMaxWidth = s32(f32(ButtonSize) * 2.5f); + s32 ButtonX = RelativeRect.getWidth() - TabMaxWidth - 1; + s32 ButtonY = 0; + + if (VerticalAlignment == EGUIA_UPPERLEFT) + { + ButtonY = (TabHeight / 2) - (ButtonSize / 2); + UpButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT); + DownButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT); + } + else + { + ButtonY = RelativeRect.getHeight() - (TabHeight / 2) - (ButtonSize / 2); + UpButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT); + DownButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT); + } + + UpButton->setRelativePosition(core::rect(ButtonX, ButtonY, ButtonX+ButtonSize, ButtonY+ButtonSize)); + ButtonX += ButtonSize + 1; + DownButton->setRelativePosition(core::rect(ButtonX, ButtonY, ButtonX+ButtonSize, ButtonY+ButtonSize)); + + recalculateScrollBar(); +} + +//! Get the alignment of the tabs +EGUI_ALIGNMENT CGUITabControl::getTabVerticalAlignment() const +{ + return VerticalAlignment; +} //! Returns which tab is currently active s32 CGUITabControl::getActiveTab() const @@ -398,16 +738,6 @@ s32 CGUITabControl::getActiveTab() const return ActiveTab; } - -bool CGUITabControl::setActiveTab(IGUIElement *tab) -{ - for (s32 i=0; i<(s32)Tabs.size(); ++i) - if (Tabs[i] == tab) - return setActiveTab(i); - return false; -} - - //! Brings a tab to front. bool CGUITabControl::setActiveTab(s32 idx) { @@ -435,6 +765,13 @@ bool CGUITabControl::setActiveTab(s32 idx) return true; } +bool CGUITabControl::setActiveTab(IGUIElement *tab) +{ + for (s32 i=0; i<(s32)Tabs.size(); ++i) + if (Tabs[i] == tab) + return setActiveTab(i); + return false; +} //! Removes a child. void CGUITabControl::removeChild(IGUIElement* child) @@ -465,31 +802,44 @@ void CGUITabControl::removeChild(IGUIElement* child) // remove real element IGUIElement::removeChild(child); + + recalculateScrollBar(); } +//! Update the position of the element, decides scroll button status +void CGUITabControl::updateAbsolutePosition() +{ + IGUIElement::updateAbsolutePosition(); + recalculateScrollBar(); +} //! Writes attributes of the element. void CGUITabControl::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const { IGUITabControl::serializeAttributes(out,options); - out->addInt("ActiveTab", ActiveTab); + out->addInt ("ActiveTab", ActiveTab); out->addBool("Border", Border); out->addBool("FillBackground", FillBackground); + out->addInt ("TabHeight", TabHeight); + out->addEnum("TabVerticalAlignment", s32(VerticalAlignment), GUIAlignmentNames); } //! Reads attributes of the element void CGUITabControl::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0) { - Border = in->getAttributeAsBool("Border"); + Border = in->getAttributeAsBool("Border"); FillBackground = in->getAttributeAsBool("FillBackground"); ActiveTab = -1; + setTabHeight(in->getAttributeAsInt("TabHeight")); + IGUITabControl::deserializeAttributes(in,options); setActiveTab(in->getAttributeAsInt("ActiveTab")); + setTabVerticalAlignment( static_cast(in->getAttributeAsEnumeration("TabVerticalAlignment" , GUIAlignmentNames)) ); } @@ -498,3 +848,4 @@ void CGUITabControl::deserializeAttributes(io::IAttributes* in, io::SAttributeRe #endif // _IRR_COMPILE_WITH_GUI_ + diff --git a/source/Irrlicht/CGUITabControl.h b/source/Irrlicht/CGUITabControl.h index 76375d19..dfa425af 100644 --- a/source/Irrlicht/CGUITabControl.h +++ b/source/Irrlicht/CGUITabControl.h @@ -10,11 +10,15 @@ #include "IGUITabControl.h" #include "irrArray.h" +#include "IGUISkin.h" namespace irr { namespace gui { + class CGUITabControl; + class IGUIButton; + // A tab, onto which other gui elements could be added. class CGUITab : public IGUITab { @@ -25,6 +29,9 @@ namespace gui IGUIElement* parent, const core::rect& rectangle, s32 id); + //! destructor + //virtual ~CGUITab(); + //! Returns number of this tab in tabcontrol. Can be accessed //! later IGUITabControl::getTab() by this number. virtual s32 getNumber() const; @@ -40,6 +47,9 @@ namespace gui //! sets the color of the background, if it should be drawn. virtual void setBackgroundColor(video::SColor c); + + //! sets the color of the text + virtual void setTextColor(video::SColor c); //! returns true if the tab is drawing its background, false if not virtual bool isDrawingBackground() const; @@ -47,6 +57,8 @@ namespace gui //! returns the color of the background virtual video::SColor getBackgroundColor() const; + virtual video::SColor getTextColor() const; + //! Writes attributes of the element. virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const; @@ -59,6 +71,8 @@ namespace gui s32 Number; bool DrawBackground; video::SColor BackColor; + video::SColor TextColor; + }; @@ -108,18 +122,51 @@ namespace gui //! Writes attributes of the element. virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const; + //! Set the height of the tabs + virtual void setTabHeight( s32 height ); //! Reads attributes of the element virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options); + //! Get the height of the tabs + virtual s32 getTabHeight() const; + + //! Set the alignment of the tabs + //! note: EGUIA_CENTER is not an option + virtual void setTabVerticalAlignment( gui::EGUI_ALIGNMENT alignment ); + + //! Get the alignment of the tabs + virtual gui::EGUI_ALIGNMENT getTabVerticalAlignment() const; + + //! Set the extra width added to tabs on each side of the text + virtual void setTabExtraWidth( s32 extraWidth ); + + //! Get the extra width added to tabs on each side of the text + virtual s32 getTabExtraWidth() const; + + //! Update the position of the element, decides scroll button status + virtual void updateAbsolutePosition(); private: - void selectTab(core::position2d p); + bool selectTab(core::position2d p); + void scrollLeft(); + void scrollRight(); + bool needScrollControl( s32 startIndex=0, bool withScrollControl=false ); + + void recalculateScrollBar(); core::array Tabs; s32 ActiveTab; bool Border; bool FillBackground; + bool ScrollControl; + s32 TabHeight; + gui::EGUI_ALIGNMENT VerticalAlignment; + IGUIButton* UpButton; + IGUIButton* DownButton; + s32 TabMaxWidth; + s32 CurrentScrollTabIndex; + s32 TabExtraWidth; }; @@ -130,3 +177,6 @@ namespace gui #endif + + + diff --git a/source/Irrlicht/CGUITable.cpp b/source/Irrlicht/CGUITable.cpp new file mode 100644 index 00000000..7d85481a --- /dev/null +++ b/source/Irrlicht/CGUITable.cpp @@ -0,0 +1,723 @@ +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +// 07.10.2005 - Multicolor-Listbox addet by A. Buschhüter (Acki) +// A_Buschhueter@gmx.de + +#include "CGUITable.h" + +#ifdef _IRR_COMPILE_WITH_GUI_ + +#include "IGUISkin.h" +#include "IGUIEnvironment.h" +#include "IVideoDriver.h" +#include "IGUIFont.h" +#include "CGUIScrollBar.h" +#include "os.h" + +#define ARROW_PAD 15 + +namespace irr +{ +namespace gui +{ + +//! constructor +CGUITable::CGUITable(IGUIEnvironment* environment, IGUIElement* parent, + s32 id, core::rect rectangle, bool clip, + bool drawBack, bool moveOverSelect) +: IGUITable(environment, parent, id, rectangle), ScrollBar(0), + ItemHeight(0), TotalItemHeight(0), Font(0), Selected(-1), + Clip(clip), DrawBack(drawBack), Selecting(false), ActiveTab(-1), + MoveOverSelect(moveOverSelect), CellHeightPadding(2), CellWidthPadding(5), m_CurrentOrdering(EGOM_ASCENDING) +{ + #ifdef _DEBUG + setDebugName("CGUITable"); + #endif + + IGUISkin* skin = Environment->getSkin(); + s32 s = skin->getSize(EGDS_SCROLLBAR_SIZE); + + ScrollBar = new CGUIScrollBar(false, Environment, this, -1, + core::rect(RelativeRect.getWidth() - s, 0, RelativeRect.getWidth(), RelativeRect.getHeight()), + !clip); + + if (ScrollBar) + { + ScrollBar->setPos(0); + ScrollBar->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT); + ScrollBar->setSubElement(true); + ScrollBar->grab(); + } + + recalculate(); +} + + +//! destructor +CGUITable::~CGUITable() +{ + if (ScrollBar) + ScrollBar->drop(); + + if (Font) + Font->drop(); +} + + +void CGUITable::addColumn(const wchar_t* caption, s32 id) +{ + IGUISkin* skin = Environment->getSkin(); + if (!skin) + return; + + Column tabHeader; + tabHeader.name = caption; + tabHeader.width = Font->getDimension(caption).Width + (CellWidthPadding * 2) + ARROW_PAD; + tabHeader.TextColor = skin->getColor(EGDC_BUTTON_TEXT); + tabHeader.useCustomOrdering = false; + + + Columns.push_back(tabHeader); + + if (ActiveTab == -1) + ActiveTab = 0; +} + +s32 CGUITable::getColumncount() const +{ + return Columns.size(); +} + +s32 CGUITable::getRowcount() const +{ + return Rows.size(); +} + +bool CGUITable::setActiveColumn(s32 idx) +{ + if (idx < 0 || idx >= (s32)Columns.size()) + return false; + + bool changed = (ActiveTab != idx); + + ActiveTab = idx; + + m_CurrentOrdering = EGOM_ASCENDING; + + if ( !Columns[idx].useCustomOrdering ) + orderRows(); + + if (changed) + { + SEvent event; + event.EventType = EET_GUI_EVENT; + event.GUIEvent.Caller = this; + event.GUIEvent.EventType = EGET_TABLE_HEADER_CHANGED; + Parent->OnEvent(event); + } + + return true; +} + +s32 CGUITable::getActiveColumn() const +{ + return ActiveTab; +} + +EGUI_ORDERING_MODE CGUITable::getActiveColumnOrdering() const +{ + return m_CurrentOrdering; +} + +void CGUITable::setColumnWidth(u32 columnIndex, u32 width) +{ + if ( columnIndex < Columns.size() ) + { + if ( width < ( Font->getDimension(Columns[columnIndex].name.c_str() ).Width + (u32(CellWidthPadding) * 2) ) ) + width = Font->getDimension(Columns[columnIndex].name.c_str() ).Width + (CellWidthPadding * 2) + ARROW_PAD; + + Columns[columnIndex].width = width; + } +} + +void CGUITable::addRow(u32 rowIndex) +{ + if (!( rowIndex < (Rows.size() + 1) ) ) + return; + + Row row; + + if ( rowIndex == Rows.size() ) + Rows.push_back(row); + else + Rows.insert(row, rowIndex); + + for ( u32 i = 0 ; i < Columns.size() ; ++i ) + { + Cell cell; + cell.data = 0; + Rows[rowIndex].Items.push_back(cell); + } + + recalculate(); +} + +void CGUITable::removeRow(u32 rowIndex) +{ + if (!( rowIndex < Rows.size() ) ) + return; + + Rows.erase( rowIndex ); + + if ( !(Selected < s32(Rows.size())) ) + Selected = Rows.size() - 1; + + recalculate(); +} + +//! adds an list item, returns id of item +void CGUITable::setCellText(u32 rowIndex, u32 columnIndex, const wchar_t* text) +{ + if ( rowIndex < (Rows.size() + 1) && columnIndex < Columns.size() ) + { + Rows[rowIndex].Items[columnIndex].text = text; + breakText( Rows[rowIndex].Items[columnIndex].text, Columns[columnIndex].width ); + + IGUISkin* skin = Environment->getSkin(); + if ( skin ) + Rows[rowIndex].Items[columnIndex].color = skin->getColor(EGDC_BUTTON_TEXT); + } +} + +void CGUITable::setCellText(u32 rowIndex, u32 columnIndex, const wchar_t* text, video::SColor color) +{ + if ( rowIndex < (Rows.size() + 1) && columnIndex < Columns.size() ) + { + Rows[rowIndex].Items[columnIndex].text = text; + breakText( Rows[rowIndex].Items[columnIndex].text, Columns[columnIndex].width ); + Rows[rowIndex].Items[columnIndex].color = color; + } +} + +void CGUITable::setCellColor(u32 rowIndex, u32 columnIndex, video::SColor color) +{ + if ( rowIndex < (Rows.size() + 1) && columnIndex < Columns.size() ) + { + Rows[rowIndex].Items[columnIndex].color = color; + } +} + +void CGUITable::setCellData(u32 rowIndex, u32 columnIndex, void *data) +{ + if ( rowIndex < (Rows.size() + 1) && columnIndex < Columns.size() ) + { + Rows[rowIndex].Items[columnIndex].data = data; + } +} + +const wchar_t* CGUITable::getCellText(u32 rowIndex, u32 columnIndex ) const +{ + if ( rowIndex < (Rows.size() + 1) && columnIndex < Columns.size() ) + { + return Rows[rowIndex].Items[columnIndex].text.c_str(); + } + + return 0; +} + +void* CGUITable::getCellData(u32 rowIndex, u32 columnIndex ) const +{ + if ( rowIndex < (Rows.size() + 1) && columnIndex < Columns.size() ) + { + return Rows[rowIndex].Items[columnIndex].data; + } + + return 0; +} + +//! clears the list +void CGUITable::clear() +{ + Rows.clear(); + Columns.clear(); + + if (ScrollBar) + ScrollBar->setPos(0); + + recalculate(); +} + +void CGUITable::clearRows() +{ + Rows.clear(); + + if (ScrollBar) + ScrollBar->setPos(0); + + recalculate(); +} + +s32 CGUITable::getSelected() const +{ + return Selected; +} + +void CGUITable::recalculate() +{ + + IGUISkin* skin = Environment->getSkin(); + if (Font != skin->getFont()) + { + if (Font) + Font->drop(); + + Font = skin->getFont(); + + ItemHeight = 0; + + if(Font) + { + ItemHeight = Font->getDimension(L"A").Height + (CellHeightPadding * 2); + Font->grab(); + } + } + + ScrollBar->setMax((ItemHeight * Rows.size()) - AbsoluteRect.getHeight() + ItemHeight); + +} + +//! called if an event happened. +bool CGUITable::OnEvent(const SEvent& event) +{ + + switch(event.EventType) + { + case EET_GUI_EVENT: + switch(event.GUIEvent.EventType) + { + case gui::EGET_SCROLL_BAR_CHANGED: + if (event.GUIEvent.Caller == ScrollBar) + { + s32 pos = ((gui::IGUIScrollBar*)event.GUIEvent.Caller)->getPos(); + return true; + } + break; + /*case gui::EGET_ELEMENT_FOCUS_LOST: + { + Selecting = false; + return true; + } + break;*/ + } + break; + case EET_MOUSE_INPUT_EVENT: + { + core::position2d p(event.MouseInput.X, event.MouseInput.Y); + + switch(event.MouseInput.Event) + { + case EMIE_MOUSE_WHEEL: + ScrollBar->setPos(ScrollBar->getPos() + (s32)event.MouseInput.Wheel*-10); + return true; + + case EMIE_LMOUSE_PRESSED_DOWN: + + if (Environment->hasFocus(this) && + ScrollBar->getAbsolutePosition().isPointInside(p) && + ScrollBar->OnEvent(event)) + return true; + + if ( selectColumnHeader( event.MouseInput.X, event.MouseInput.Y ) ) + return true; + + Selecting = true; + Environment->setFocus(this); + return true; + + case EMIE_LMOUSE_LEFT_UP: + + if (Environment->hasFocus(this) && + ScrollBar->getAbsolutePosition().isPointInside(p) && + ScrollBar->OnEvent(event)) + { + return true; + } + + Selecting = false; + Environment->removeFocus(this); + selectNew(event.MouseInput.Y); + return true; + + case EMIE_MOUSE_MOVED: + if (Selecting || MoveOverSelect) + { + if (getAbsolutePosition().isPointInside(p)) + { + selectNew(event.MouseInput.Y); + return true; + } + } + } + } + break; + } + + + return Parent ? Parent->OnEvent(event) : false; +} + +void CGUITable::setColumnCustomOrdering(u32 columnIndex, bool state) +{ + if ( columnIndex < Columns.size() ) + Columns[columnIndex].useCustomOrdering = state; +} + +void CGUITable::swapRows(u32 rowIndexA, u32 rowIndexB) +{ + if ( rowIndexA >= Rows.size() ) + return; + + if ( rowIndexB >= Rows.size() ) + return; + + Row swap = Rows[rowIndexA]; + Rows[rowIndexA] = Rows[rowIndexB]; + Rows[rowIndexB] = swap; + + if ( Selected == s32(rowIndexA) ) + Selected = rowIndexB; + else if( Selected == s32(rowIndexB) ) + Selected = rowIndexA; + +} + +bool CGUITable::selectColumnHeader(s32 xpos, s32 ypos) +{ + if ( ypos > ( AbsoluteRect.UpperLeftCorner.Y + ItemHeight ) ) + return false; + + + core::rect frameRect(AbsoluteRect); + + s32 pos = frameRect.UpperLeftCorner.X;; + u32 colWidth; + + for ( u32 i = 0 ; i < Columns.size() ; ++i ) + { + colWidth = Columns[i].width; + + if ( xpos >= pos && xpos < ( pos + s32(colWidth) ) ) + { + if ( ActiveTab == s32(i) ) + { + if ( m_CurrentOrdering == EGOM_ASCENDING ) + m_CurrentOrdering = EGOM_DESCENDING; + else + m_CurrentOrdering = EGOM_ASCENDING; + } + else + { + ActiveTab = i; + m_CurrentOrdering = EGOM_ASCENDING; + } + + if ( !Columns[i].useCustomOrdering ) + orderRows(); + else + { + if (Parent) + { + SEvent event; + event.EventType = EET_GUI_EVENT; + event.GUIEvent.Caller = this; + event.GUIEvent.EventType = EGET_TABLE_HEADER_CHANGED; + Parent->OnEvent(event); + } + } + + break; + } + + pos += colWidth; + } + + return false; +} + +void CGUITable::orderRows() +{ + Row swap; + s32 columnIndex = getActiveColumn(); + + if ( m_CurrentOrdering == EGOM_ASCENDING ) + { + for ( s32 i = 0 ; i < s32(Rows.size()) - 1 ; ++i ) + { + for ( s32 j = 0 ; j < s32(Rows.size()) - i - 1 ; ++j ) + { + if ( Rows[j+1].Items[columnIndex].text < Rows[j].Items[columnIndex].text ) + { + swap = Rows[j]; + Rows[j] = Rows[j+1]; + Rows[j+1] = swap; + + if ( Selected == j ) + Selected = j+1; + else if( Selected == j+1 ) + Selected = j; + } + } + } + } + else + { + for ( s32 i = 0 ; i < s32(Rows.size()) - 1 ; ++i ) + { + for ( s32 j = 0 ; j < s32(Rows.size()) - i - 1 ; ++j ) + { + if ( Rows[j].Items[columnIndex].text < Rows[j+1].Items[columnIndex].text) + { + swap = Rows[j]; + Rows[j] = Rows[j+1]; + Rows[j+1] = swap; + + if ( Selected == j ) + Selected = j+1; + else if( Selected == j+1 ) + Selected = j; + } + } + } + } +} + + +void CGUITable::selectNew(s32 ypos, bool onlyHover) +{ + IGUISkin* skin = Environment->getSkin(); + if (!skin) + return; + + s32 oldSelected = Selected; + + if ( ypos < ( AbsoluteRect.UpperLeftCorner.Y + ItemHeight ) ) + return; + + // find new selected item. + if (ItemHeight!=0) + Selected = ((ypos - AbsoluteRect.UpperLeftCorner.Y - ItemHeight - 1) + ScrollBar->getPos()) / ItemHeight; + + if (Selected >= (s32)Rows.size()) + Selected = Rows.size() - 1; + else if (Selected<0) + Selected = 0; + + // post the news + if (Parent && !onlyHover) + { + SEvent event; + event.EventType = EET_GUI_EVENT; + event.GUIEvent.Caller = this; + event.GUIEvent.EventType = (Selected != oldSelected) ? EGET_TABLE_CHANGED : EGET_TABLE_SELECTED_AGAIN; + Parent->OnEvent(event); + } +} + +//! draws the element and its children +void CGUITable::draw() +{ + if (!IsVisible) + return; + + irr::video::IVideoDriver* driver = Environment->getVideoDriver(); + + core::rect frameRect(AbsoluteRect); + core::rect columnSeparator(AbsoluteRect); + + IGUISkin* skin = Environment->getSkin(); + if (!skin) + return; + + IGUIFont* font = skin->getFont(); + if (!font) + return; + + s32 headerFinalPosition = frameRect.UpperLeftCorner.Y + ItemHeight; + + + frameRect = AbsoluteRect; + frameRect.UpperLeftCorner.X += 1; + frameRect.UpperLeftCorner.Y = headerFinalPosition; + frameRect.LowerRightCorner.X = AbsoluteRect.LowerRightCorner.X - skin->getSize(EGDS_SCROLLBAR_SIZE); + frameRect.LowerRightCorner.Y = headerFinalPosition + ItemHeight; + + frameRect.UpperLeftCorner.Y -= ScrollBar->getPos(); + frameRect.LowerRightCorner.Y -= ScrollBar->getPos(); + + core::rect clientClip(AbsoluteRect); + clientClip.UpperLeftCorner.Y = headerFinalPosition + 1; + clientClip.UpperLeftCorner.X += 1; + clientClip.LowerRightCorner.X = AbsoluteRect.LowerRightCorner.X - skin->getSize(EGDS_SCROLLBAR_SIZE); + clientClip.LowerRightCorner.Y -= 1; + + u32 pos; + + for ( u32 i = 0 ; i < Rows.size() ; ++i ) + { + + if (frameRect.LowerRightCorner.Y >= AbsoluteRect.UpperLeftCorner.Y && + frameRect.UpperLeftCorner.Y <= AbsoluteRect.LowerRightCorner.Y) + { + + core::rect textRect = frameRect; + + textRect.UpperLeftCorner.Y = textRect.LowerRightCorner.Y - 1; + driver->draw2DRectangle(skin->getColor(EGDC_3D_SHADOW), textRect, &clientClip); + + textRect = frameRect; + + pos = frameRect.UpperLeftCorner.X; + + if (s32(i) == Selected) + driver->draw2DRectangle(skin->getColor(EGDC_HIGH_LIGHT), frameRect, &clientClip); + + for ( u32 j = 0 ; j < Columns.size() ; ++j ) + { + textRect.UpperLeftCorner.X = pos + CellWidthPadding; + textRect.LowerRightCorner.X = pos + Columns[j].width - CellWidthPadding; + + s32 test = font->getDimension(Rows[i].Items[j].text.c_str()).Width; + + if (s32(i) == Selected) + { + font->draw(Rows[i].Items[j].text.c_str(), textRect, skin->getColor(EGDC_HIGH_LIGHT_TEXT), false, true, &clientClip); + } + else + { + font->draw(Rows[i].Items[j].text.c_str(), textRect, Rows[i].Items[j].color, false, true, &clientClip); + } + + pos += Columns[j].width; + } + } + + frameRect.UpperLeftCorner.Y += ItemHeight; + frameRect.LowerRightCorner.Y += ItemHeight; + } + + + frameRect = AbsoluteRect; + columnSeparator.UpperLeftCorner.Y = headerFinalPosition; + + core::rect* clipRect = 0; + if (Clip) + clipRect = &AbsoluteClippingRect; + + const wchar_t* text = 0; + pos = frameRect.UpperLeftCorner.X; + u32 colWidth; + + skin->draw3DSunkenPane(this, skin->getColor(EGDC_3D_HIGH_LIGHT), true, DrawBack, frameRect, clipRect); + + for (u32 i = 0 ; i < Columns.size() ; ++i ) + { + text = Columns[i].name.c_str(); + colWidth = Columns[i].width; + + core::dimension2d dim = font->getDimension(text); + + core::rect columnrect(pos, frameRect.UpperLeftCorner.Y, pos + colWidth, headerFinalPosition); + + skin->draw3DButtonPaneStandard(this, columnrect, &AbsoluteClippingRect); + + columnSeparator.UpperLeftCorner.X = columnrect.LowerRightCorner.X; + columnSeparator.LowerRightCorner.X = columnrect.LowerRightCorner.X + 1; + driver->draw2DRectangle(skin->getColor(EGDC_3D_SHADOW), columnSeparator, &AbsoluteClippingRect); + + columnrect.UpperLeftCorner.X += CellWidthPadding; + font->draw(text, columnrect, skin->getColor(EGDC_BUTTON_TEXT), false, true, &AbsoluteClippingRect); + + if ( s32(i) == ActiveTab ) + { + if ( m_CurrentOrdering == EGOM_ASCENDING ) + { + columnrect.UpperLeftCorner.X = columnrect.LowerRightCorner.X - CellWidthPadding - ARROW_PAD / 2 + 2; + columnrect.UpperLeftCorner.Y += 7; + skin->drawIcon(this,EGDI_CURSOR_UP,columnrect.UpperLeftCorner); + } + else + { + columnrect.UpperLeftCorner.X = columnrect.LowerRightCorner.X - CellWidthPadding - ARROW_PAD / 2 + 2; + columnrect.UpperLeftCorner.Y += 7; + skin->drawIcon(this,EGDI_CURSOR_DOWN,columnrect.UpperLeftCorner); + } + } + + pos += colWidth; + } + + core::rect columnrect(pos, frameRect.UpperLeftCorner.Y, frameRect.LowerRightCorner.X - skin->getSize(EGDS_SCROLLBAR_SIZE), headerFinalPosition); + skin->draw3DButtonPaneStandard(this, columnrect, &AbsoluteClippingRect); + + IGUIElement::draw(); + +} + +void CGUITable::breakText(core::stringw &text, u32 cellWidth ) +{ + IGUISkin* skin = Environment->getSkin(); + + if (!skin) + return; + + if (!Font) + return; + + IGUIFont* font = skin->getFont(); + if (!font) + return; + + + core::stringw line, lineDots, character; + wchar_t c[2]; + c[1] = L'\0'; + + u32 maxLength = cellWidth - (CellWidthPadding * 2); + u32 maxLengthDots = cellWidth - (CellWidthPadding * 2) - font->getDimension(L"...").Width; + u32 size = text.size(); + u32 pos = 0; + + u32 i; + + for (i=0; igetDimension( c ).Width; + if ( pos > maxLength ) + break; + + if ( font->getDimension( (line + c[0]).c_str() ).Width > s32(maxLengthDots) ) + lineDots = line; + + line += c[0]; + } + + if ( i < size ) + line = lineDots + L"..."; + + + text = line; + +} + +} // end namespace gui +} // end namespace irr + +#endif // _IRR_COMPILE_WITH_GUI_ + diff --git a/source/Irrlicht/CGUITable.h b/source/Irrlicht/CGUITable.h new file mode 100644 index 00000000..fe93d948 --- /dev/null +++ b/source/Irrlicht/CGUITable.h @@ -0,0 +1,171 @@ +// Copyright (C) 2002-2005 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +// 07.10.2005 - Multicolor-Listbox addet by A. Buschhüter (Acki) +// A_Buschhueter@gmx.de + +#ifndef __C_GUI_TABLE_BAR_H_INCLUDED__ +#define __C_GUI_TABLE_BAR_H_INCLUDED__ + +#include "IGUITable.h" +#include "irrArray.h" + +namespace irr +{ +namespace gui +{ + + class IGUIFont; + class IGUIScrollBar; + + class CGUITable : public IGUITable + { + public: + //! constructor + CGUITable(IGUIEnvironment* environment, IGUIElement* parent, + s32 id, core::rect rectangle, bool clip=true, + bool drawBack=false, bool moveOverSelect=true); + + //! destructor + ~CGUITable(); + + //! Adds a column + virtual void addColumn(const wchar_t* caption, s32 id=-1); + + //! Returns the number of columns in the table control + virtual s32 getColumncount() const; + + //! Makes a column active. This will trigger an ordering process. + /** \param idx: The id of the column to make active. + \return Returns true if successful. */ + virtual bool setActiveColumn(s32 idx); + + //! Returns which header is currently active + virtual s32 getActiveColumn() const; + + //! Returns the ordering used by the currently active column + virtual EGUI_ORDERING_MODE getActiveColumnOrdering() const; + + //! set a column width + virtual void setColumnWidth(u32 columnIndex, u32 width); + + //! This tells the table control wether is should send a EGET_TABLE_HEADER_CHANGED message or not when + //! a column header is clicked. If set to false, the table control will use a default alphabetical ordering scheme. + /** \param columnIndex: The index of the column header. + \param state: If true, a EGET_TABLE_HEADER_CHANGED message will be sent and you can order the table data as you whish.*/ + virtual void setColumnCustomOrdering(u32 columnIndex, bool state); + + + + //! Returns which row is currently selected + virtual s32 getSelected() const; + + //! Returns amount of rows in the tabcontrol + virtual s32 getRowcount() const; + + //! adds a row to the table + /** \param rowIndex: zero based index of rows. The row will be inserted at this + position, if a row already exist there, it will be placed after it. If the row + is larger than the actual number of row by more than one, it won't be created. + Note that if you create a row that's not at the end, there might be performance issues*/ + virtual void addRow(u32 rowIndex); + + //! Remove a row from the table + virtual void removeRow(u32 rowIndex); + + //! clears the table rows, but keeps the columns intact + virtual void clearRows(); + + //! Swap two row positions. This is useful for a custom ordering algo. + virtual void swapRows(u32 rowIndexA, u32 rowIndexB); + + //! This tells the table to start ordering all the rows. You need to explicitly + //! tell the table to re order the rows when a new row is added or the cells data is + //! changed. This makes the system more flexible and doesn't make you pay the cost of + //! ordering when adding a lot of rows. + virtual void orderRows(); + + + + //! Set the text of a cell + virtual void setCellText(u32 rowIndex, u32 columnIndex, const wchar_t* text); + + //! Set the text of a cell, and set a color of this cell. + virtual void setCellText(u32 rowIndex, u32 columnIndex, const wchar_t* text, video::SColor color); + + //! Set the data of a cell + virtual void setCellData(u32 rowIndex, u32 columnIndex, void *data); + + //! Set the color of a cell text + virtual void setCellColor(u32 rowIndex, u32 columnIndex, video::SColor color); + + //! Get the text of a cell + virtual const wchar_t* getCellText(u32 rowIndex, u32 columnIndex ) const; + + //! Get the data of a cell + virtual void* getCellData(u32 rowIndex, u32 columnIndex ) const; + + + //! clears the table, deletes all items in the table + virtual void clear(); + + + //! called if an event happened. + virtual bool OnEvent(const SEvent& event); + + //! draws the element and its children + virtual void draw(); + + private: + + struct Cell + { + core::stringw text; + core::stringw BrokenText; + video::SColor color; + void *data; + }; + + struct Row + { + core::array Items; + u32 height; + }; + + struct Column + { + core::stringw name; + video::SColor TextColor; + u32 width; + bool useCustomOrdering; + }; + + void breakText(core::stringw &text, u32 cellWidth); + void selectNew(s32 ypos, bool onlyHover=false); + bool selectColumnHeader(s32 xpos, s32 ypos); + void recalculate(); + + core::array< Column > Columns; + core::array< Row > Rows; + s32 ItemHeight; + s32 TotalItemHeight; + gui::IGUIFont* Font; + gui::IGUIScrollBar* ScrollBar; + bool Clip; + bool DrawBack; + bool MoveOverSelect; + + s32 Selected; + s32 CellWidthPadding; + s32 CellHeightPadding; + s32 ActiveTab; + bool Selecting; + EGUI_ORDERING_MODE m_CurrentOrdering; + + }; + +} // end namespace gui +} // end namespace irr + +#endif diff --git a/source/Irrlicht/Irrlicht7.1.vcproj b/source/Irrlicht/Irrlicht7.1.vcproj index 7acd0c05..b2afc7d4 100644 --- a/source/Irrlicht/Irrlicht7.1.vcproj +++ b/source/Irrlicht/Irrlicht7.1.vcproj @@ -619,6 +619,9 @@ + + @@ -630,31 +633,31 @@ + RelativePath="BuiltInFont.h"> + RelativePath="CDefaultGUIElementFactory.cpp"> + RelativePath="CDefaultGUIElementFactory.h"> + RelativePath="CGUIButton.cpp"> + RelativePath="CGUIButton.h"> + RelativePath="CGUICheckbox.cpp"> + RelativePath="CGUICheckbox.h"> + RelativePath="CGUIColorSelectDialog.cpp"> + RelativePath="CGUIColorSelectDialog.h"> @@ -675,28 +678,28 @@ RelativePath="CGUIEditBox.h"> + RelativePath="CGUIEnvironment.cpp"> + RelativePath="CGUIEnvironment.h"> + RelativePath="CGUIFileOpenDialog.cpp"> + RelativePath="CGUIFileOpenDialog.h"> + RelativePath="CGUIFont.cpp"> + RelativePath="CGUIFont.h"> + RelativePath="CGUIImage.cpp"> + RelativePath="CGUIImage.h"> @@ -705,10 +708,10 @@ RelativePath="CGUIInOutFader.h"> + RelativePath="CGUIListBox.cpp"> + RelativePath="CGUIListBox.h"> @@ -717,10 +720,10 @@ RelativePath="CGUIMenu.h"> + RelativePath="CGUIMeshViewer.cpp"> + RelativePath="CGUIMeshViewer.h"> @@ -735,34 +738,34 @@ RelativePath="CGUIModalScreen.h"> + RelativePath="CGUIScrollBar.cpp"> + RelativePath="CGUIScrollBar.h"> + RelativePath="CGUISkin.cpp"> + RelativePath="CGUISkin.h"> + RelativePath="CGUISpinBox.cpp"> + RelativePath="CGUISpinBox.h"> + RelativePath="CGUISpriteBank.cpp"> + RelativePath="CGUISpriteBank.h"> + RelativePath="CGUIStaticText.cpp"> + RelativePath="CGUIStaticText.h"> @@ -770,6 +773,12 @@ + + + + @@ -777,10 +786,10 @@ RelativePath="CGUIToolBar.h"> + RelativePath="CGUIWindow.cpp"> + RelativePath="CGUIWindow.h"> + RelativePath="CSoftwareDriver.cpp"> + RelativePath="CSoftwareDriver.h"> + RelativePath="CSoftwareTexture.cpp"> + RelativePath="CSoftwareTexture.h"> + RelativePath="CTRFlat.cpp"> + RelativePath="CTRFlatWire.cpp"> + RelativePath="CTRGouraud.cpp"> + RelativePath="CTRGouraudWire.cpp"> + RelativePath="CTRTextureFlat.cpp"> + RelativePath="CTRTextureFlatWire.cpp"> + RelativePath="CTRTextureGouraud.cpp"> + RelativePath="CTRTextureGouraud.h"> + RelativePath="CTRTextureGouraudAdd.cpp"> + RelativePath="CTRTextureGouraudNoZ.cpp"> + RelativePath="CTRTextureGouraudWire.cpp"> + RelativePath="CZBuffer.cpp"> + RelativePath="CZBuffer.h"> + RelativePath="ITriangleRenderer.h"> + RelativePath="IZBuffer.h"> + RelativePath="S2DVertex.h"> + RelativePath="COpenGLDriver.cpp"> + RelativePath="COpenGLDriver.h"> + RelativePath="COpenGLExtensionHandler.cpp"> + RelativePath="COpenGLExtensionHandler.h"> + RelativePath="COpenGLMaterialRenderer.h"> + RelativePath="COpenGLNormalMapRenderer.cpp"> + RelativePath="COpenGLNormalMapRenderer.h"> + RelativePath="COpenGLParallaxMapRenderer.cpp"> + RelativePath="COpenGLParallaxMapRenderer.h"> + RelativePath="COpenGLShaderMaterialRenderer.cpp"> + RelativePath="COpenGLShaderMaterialRenderer.h"> + RelativePath="COpenGLSLMaterialRenderer.cpp"> + RelativePath="COpenGLSLMaterialRenderer.h"> + RelativePath="COpenGLTexture.cpp"> + RelativePath="COpenGLTexture.h"> + RelativePath="glext.h"> + RelativePath="CD3D8Driver.cpp"> + RelativePath="CD3D8Driver.h"> + RelativePath="CD3D8MaterialRenderer.h"> + RelativePath="CD3D8NormalMapRenderer.cpp"> + RelativePath="CD3D8NormalMapRenderer.h"> + RelativePath="CD3D8ParallaxMapRenderer.cpp"> + RelativePath="CD3D8ParallaxMapRenderer.h"> + RelativePath="CD3D8ShaderMaterialRenderer.cpp"> + RelativePath="CD3D8ShaderMaterialRenderer.h"> + RelativePath="CD3D8Texture.cpp"> + RelativePath="CD3D8Texture.h"> + RelativePath="CColorConverter.cpp"> + RelativePath="CColorConverter.h"> + RelativePath="CFPSCounter.cpp"> + RelativePath="CFPSCounter.h"> @@ -1010,10 +1019,10 @@ RelativePath="CImageLoaderWAL.h"> + RelativePath="CNullDriver.cpp"> + RelativePath="CNullDriver.h"> @@ -1021,216 +1030,216 @@ + RelativePath="CImageWriterBMP.cpp"> + RelativePath="CImageWriterBMP.h"> + RelativePath="CImageWriterJPG.cpp"> + RelativePath="CImageWriterJPG.h"> + RelativePath="CImageWriterPCX.cpp"> + RelativePath="CImageWriterPCX.h"> + RelativePath="CImageWriterPNG.cpp"> + RelativePath="CImageWriterPNG.h"> + RelativePath="CImageWriterPPM.cpp"> + RelativePath="CImageWriterPPM.h"> + RelativePath="CImageWriterPSD.cpp"> + RelativePath="CImageWriterPSD.h"> + RelativePath="CImageWriterTGA.cpp"> + RelativePath="CImageWriterTGA.h"> + RelativePath="CD3D9Driver.cpp"> + RelativePath="CD3D9Driver.h"> + RelativePath="CD3D9HLSLMaterialRenderer.cpp"> + RelativePath="CD3D9HLSLMaterialRenderer.h"> + RelativePath="CD3D9MaterialRenderer.h"> + RelativePath="CD3D9NormalMapRenderer.cpp"> + RelativePath="CD3D9NormalMapRenderer.h"> + RelativePath="CD3D9ParallaxMapRenderer.cpp"> + RelativePath="CD3D9ParallaxMapRenderer.h"> + RelativePath="CD3D9ShaderMaterialRenderer.cpp"> + RelativePath="CD3D9ShaderMaterialRenderer.h"> + RelativePath="CD3D9Texture.cpp"> + RelativePath="CD3D9Texture.h"> + RelativePath="CBurningShader_Raster_Reference.cpp"> + RelativePath="CDepthBuffer.cpp"> + RelativePath="CDepthBuffer.h"> + RelativePath="CSoftware2MaterialRenderer.h"> + RelativePath="CSoftwareDriver2.cpp"> + RelativePath="CSoftwareDriver2.h"> + RelativePath="CSoftwareTexture2.cpp"> + RelativePath="CSoftwareTexture2.h"> + RelativePath="CTRGouraud2.cpp"> + RelativePath="CTRGouraudAlpha2.cpp"> + RelativePath="CTRGouraudAlphaNoZ2.cpp"> + RelativePath="CTRTextureBlend.cpp"> + RelativePath="CTRTextureDetailMap2.cpp"> + RelativePath="CTRTextureGouraud2.cpp"> + RelativePath="CTRTextureGouraudAdd2.cpp"> + RelativePath="CTRTextureGouraudAddNoZ2.cpp"> + RelativePath="CTRTextureGouraudAlpha.cpp"> + RelativePath="CTRTextureGouraudAlphaNoZ.cpp"> + RelativePath="CTRTextureGouraudNoZ2.cpp"> + RelativePath="CTRTextureGouraudVertexAlpha2.cpp"> + RelativePath="CTRTextureLightMap2_Add.cpp"> + RelativePath="CTRTextureLightMap2_M1.cpp"> + RelativePath="CTRTextureLightMap2_M2.cpp"> + RelativePath="CTRTextureLightMap2_M4.cpp"> + RelativePath="CTRTextureLightMapGouraud2_M4.cpp"> + RelativePath="CTRTextureWire2.cpp"> + RelativePath="IBurningShader.cpp"> + RelativePath="IBurningShader.h"> + RelativePath="IDepthBuffer.h"> + RelativePath="S4DVertex.h"> + RelativePath="SoftwareDriver2_compile_config.h"> + RelativePath="SoftwareDriver2_helper.h"> + RelativePath="CDefaultSceneNodeAnimatorFactory.cpp"> + RelativePath="CDefaultSceneNodeAnimatorFactory.h"> + RelativePath="CDefaultSceneNodeFactory.cpp"> + RelativePath="CDefaultSceneNodeFactory.h"> + RelativePath="CGeometryCreator.cpp"> + RelativePath="CGeometryCreator.h"> + RelativePath="CMeshCache.cpp"> + RelativePath="CMeshCache.h"> @@ -1239,27 +1248,27 @@ RelativePath="CMeshManipulator.h"> + RelativePath="CSceneManager.cpp"> + RelativePath="CSceneManager.h"> + RelativePath="OctTree.h"> + RelativePath="C3DSMeshFileLoader.cpp"> + RelativePath="C3DSMeshFileLoader.h"> + RelativePath="CAnimatedMeshMD2.cpp"> + RelativePath="CAnimatedMeshMD2.h"> diff --git a/source/Irrlicht/Irrlicht8.0.vcproj b/source/Irrlicht/Irrlicht8.0.vcproj index 9c6a254f..5214e4eb 100644 --- a/source/Irrlicht/Irrlicht8.0.vcproj +++ b/source/Irrlicht/Irrlicht8.0.vcproj @@ -1,7 +1,7 @@ + + @@ -1040,6 +1044,14 @@ RelativePath="CGUITabControl.h" > + + + + diff --git a/source/Irrlicht/Irrlicht_Linux-gcc.cbp b/source/Irrlicht/Irrlicht_Linux-gcc.cbp index 9c82202d..9989c93f 100644 --- a/source/Irrlicht/Irrlicht_Linux-gcc.cbp +++ b/source/Irrlicht/Irrlicht_Linux-gcc.cbp @@ -119,6 +119,7 @@ + @@ -346,6 +347,8 @@ + + diff --git a/source/Irrlicht/Irrlicht_Win32-gcc.cbp b/source/Irrlicht/Irrlicht_Win32-gcc.cbp index 257438df..6e6591d3 100644 --- a/source/Irrlicht/Irrlicht_Win32-gcc.cbp +++ b/source/Irrlicht/Irrlicht_Win32-gcc.cbp @@ -153,6 +153,7 @@ + @@ -363,6 +364,8 @@ + + diff --git a/source/Irrlicht/Makefile b/source/Irrlicht/Makefile index 8bef6b41..755613e7 100644 --- a/source/Irrlicht/Makefile +++ b/source/Irrlicht/Makefile @@ -35,7 +35,7 @@ IRRVIDEOOBJ = CVideoModeList.o CFPSCounter.o $(IRRDRVROBJ) $(IRRIMAGEOBJ) IRRSWRENDEROBJ = CSoftwareDriver.o CSoftwareTexture.o CTRFlat.o CTRFlatWire.o CTRGouraud.o CTRGouraudWire.o CTRTextureFlat.o CTRTextureFlatWire.o CTRTextureGouraud.o CTRTextureGouraudAdd.o CTRTextureGouraudNoZ.o CTRTextureGouraudWire.o CZBuffer.o CTRTextureGouraudVertexAlpha2.o CTRTextureGouraudNoZ2.o CTRTextureLightMap2_M2.o CTRTextureLightMap2_M4.o CTRTextureLightMap2_M1.o CSoftwareDriver2.o CSoftwareTexture2.o CTRTextureGouraud2.o CTRGouraud2.o CTRGouraudAlpha2.o CTRGouraudAlphaNoZ2.o CTRTextureDetailMap2.o CTRTextureGouraudAdd2.o CTRTextureGouraudAddNoZ2.o CTRTextureWire2.o CTRTextureLightMap2_Add.o CTRTextureLightMapGouraud2_M4.o IBurningShader.o CTRTextureBlend.o CTRTextureGouraudAlpha.o CTRTextureGouraudAlphaNoZ.o CDepthBuffer.o CBurningShader_Raster_Reference.o IRRIOOBJ = CFileList.o CFileSystem.o CLimitReadFile.o CMemoryReadFile.o CReadFile.o CWriteFile.o CXMLReader.o CXMLWriter.o CZipReader.o CPakReader.o irrXML.o CAttributes.o IRROTHEROBJ = CIrrDeviceSDL.o CIrrDeviceLinux.o CIrrDeviceStub.o CIrrDeviceWin32.o CLogger.o COSOperator.o Irrlicht.o os.o -IRRGUIOBJ = CGUIButton.o CGUICheckBox.o CGUIComboBox.o CGUIContextMenu.o CGUIEditBox.o CGUIEnvironment.o CGUIFileOpenDialog.o CGUIFont.o CGUIImage.o CGUIInOutFader.o CGUIListBox.o CGUIMenu.o CGUIMeshViewer.o CGUIMessageBox.o CGUIModalScreen.o CGUIScrollBar.o CGUISpinBox.o CGUISkin.o CGUIStaticText.o CGUITabControl.o CGUIToolBar.o CGUIWindow.o CGUIColorSelectDialog.o CDefaultGUIElementFactory.o CGUISpriteBank.o +IRRGUIOBJ = CGUIButton.o CGUICheckBox.o CGUIComboBox.o CGUIContextMenu.o CGUIEditBox.o CGUIEnvironment.o CGUIFileOpenDialog.o CGUIFont.o CGUIImage.o CGUIInOutFader.o CGUIListBox.o CGUIMenu.o CGUIMeshViewer.o CGUIMessageBox.o CGUIModalScreen.o CGUIScrollBar.o CGUISpinBox.o CGUISkin.o CGUIStaticText.o CGUITabControl.o CGUITable.o CGUIToolBar.o CGUIWindow.o CGUIColorSelectDialog.o CDefaultGUIElementFactory.o CGUISpriteBank.o ZLIBOBJ = zlib/adler32.o zlib/compress.o zlib/crc32.o zlib/deflate.o zlib/inffast.o zlib/inflate.o zlib/inftrees.o zlib/trees.o zlib/uncompr.o zlib/zutil.o JPEGLIBOBJ = jpeglib/jcapimin.o jpeglib/jcapistd.o jpeglib/jccoefct.o jpeglib/jccolor.o jpeglib/jcdctmgr.o jpeglib/jchuff.o jpeglib/jcinit.o jpeglib/jcmainct.o jpeglib/jcmarker.o jpeglib/jcmaster.o jpeglib/jcomapi.o jpeglib/jcparam.o jpeglib/jcphuff.o jpeglib/jcprepct.o jpeglib/jcsample.o jpeglib/jctrans.o jpeglib/jdapimin.o jpeglib/jdapistd.o jpeglib/jdatadst.o jpeglib/jdatasrc.o jpeglib/jdcoefct.o jpeglib/jdcolor.o jpeglib/jddctmgr.o jpeglib/jdhuff.o jpeglib/jdinput.o jpeglib/jdmainct.o jpeglib/jdmarker.o jpeglib/jdmaster.o jpeglib/jdmerge.o jpeglib/jdphuff.o jpeglib/jdpostct.o jpeglib/jdsample.o jpeglib/jdtrans.o jpeglib/jerror.o jpeglib/jfdctflt.o jpeglib/jfdctfst.o jpeglib/jfdctint.o jpeglib/jidctflt.o jpeglib/jidctfst.o jpeglib/jidctint.o jpeglib/jidctred.o jpeglib/jmemmgr.o jpeglib/jmemnobs.o jpeglib/jquant1.o jpeglib/jquant2.o jpeglib/jutils.o LIBPNGOBJ = libpng/png.o libpng/pngerror.o libpng/pngget.o libpng/pngmem.o libpng/pngpread.o libpng/pngread.o libpng/pngrio.o libpng/pngrtran.o libpng/pngrutil.o libpng/pngset.o libpng/pngtrans.o libpng/pngwio.o libpng/pngwrite.o libpng/pngwtran.o libpng/pngwutil.o diff --git a/tools/GUIEditor/CGUIEditWindow.cpp b/tools/GUIEditor/CGUIEditWindow.cpp index 8bb6648a..b15cc48d 100644 --- a/tools/GUIEditor/CGUIEditWindow.cpp +++ b/tools/GUIEditor/CGUIEditWindow.cpp @@ -54,13 +54,7 @@ CGUIEditWindow::CGUIEditWindow(IGUIEnvironment* environment, core::rect rec //L"Sprite Editor" //Environment->addGUIElement("textureCacheBrowser", this); - IGUITab* OptionsTab = TabControl->addTab(L"Attributes"); - - IGUITabControl *AttribTabControl = environment->addTabControl(core::rect(1,1,100,100), OptionsTab, false, true); - AttribTabControl->setRelativePosition( core::rect(0.0f, 0.0f, 1.0f, 1.0f)); - AttribTabControl->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT); - - IGUITab* EditorTab = AttribTabControl->addTab(L"Editor"); + IGUITab* EditorTab = TabControl->addTab(L"Editor"); OptionEditor = (CGUIAttributeEditor*) environment->addGUIElement("attributeEditor", EditorTab); OptionEditor->grab(); OptionEditor->setID(EGUIEDCE_OPTION_EDITOR); @@ -69,14 +63,14 @@ CGUIEditWindow::CGUIEditWindow(IGUIEnvironment* environment, core::rect rec if (Parent && Parent->getParent() == Environment->getRootGUIElement()) { - IGUITab* EnvTab = AttribTabControl->addTab(L"Env"); + IGUITab* EnvTab = TabControl->addTab(L"Env"); EnvEditor = (CGUIAttributeEditor*) environment->addGUIElement("attributeEditor", EnvTab); EnvEditor->grab(); EnvEditor->setID(EGUIEDCE_ENV_EDITOR); EnvEditor->setRelativePosition(core::rect(0.0f, 0.0f, 1.0f, 1.0f)); EnvEditor->setAlignment(EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT); } - IGUITab* ElementTab = AttribTabControl->addTab(L"Element"); + IGUITab* ElementTab = TabControl->addTab(L"Element"); AttribEditor = (CGUIAttributeEditor*) environment->addGUIElement("attributeEditor", ElementTab); AttribEditor->grab(); diff --git a/tools/GUIEditor/main.cpp b/tools/GUIEditor/main.cpp index af848937..cf7f0852 100644 --- a/tools/GUIEditor/main.cpp +++ b/tools/GUIEditor/main.cpp @@ -70,7 +70,7 @@ int main() now we add the GUI Editor Workspace */ - env->loadGUI("c:\\out.xml"); + env->loadGUI("guiTest.xml"); env->addGUIElement("GUIEditor");