Huge GUITable update by CuteAlien.

Modal screen no longer flashes invisible children.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@1172 dfc29bdd-3216-0410-991c-e03cc46cb475
master
bitplane 2008-01-11 15:56:37 +00:00
parent 678f84e96c
commit 6436ded4e1
5 changed files with 819 additions and 300 deletions

View File

@ -1,6 +1,8 @@
-------------------------------------------
Changes in version 1.5 (... 2008)
- Added volume light scene node
- Better fix for hires timers on dual core machines by RogerBorg
- added Initial Windows Mobile 6 Version. (30.12.2006 TA)
@ -37,7 +39,8 @@ Changes in version 1.5 (... 2008)
Nodes are now solid or transparent. ( but still more states are needed )
- GUI:
Finally added StarSonata/Acki patch with table element and TabControl additions.
Finally added StarSonata patch with table element and TabControl additions.
Table is based on MultiColor listbox by Acki, and has loads of changes by CuteAlien.
-------------------------------------------

View File

@ -15,12 +15,48 @@ namespace irr
namespace gui
{
//! modes for ordering used when a column header is clicked
enum EGUI_COLUMN_ORDERING
{
//! Do not use ordering
EGCO_NONE,
//! Send a EGET_TABLE_HEADER_CHANGED message when a column header is clicked.
EGCO_CUSTOM,
//! Sort it ascending by it's ascii value like: a,b,c,...
EGCO_ASCENDING,
//! Sort it descending by it's ascii value like: z,x,y,...
EGCO_DESCENDING,
//! Sort it ascending on first click, descending on next, etc
EGCO_FLIP_ASCENDING_DESCENDING,
//! Not used as mode, only to get maximum value for this enum
EGCO_COUNT
};
//! Names for EGUI_COLUMN_ORDERING types
const c8* const GUIColumnOrderingNames[] =
{
"none",
"custom",
"ascend",
"descend",
"ascend_descend",
0,
};
enum EGUI_ORDERING_MODE
{
//! Order the elements from the smallest to the largest.
//! No element ordering
EGOM_NONE,
//! Elements are ordered from the smallest to the largest.
EGOM_ASCENDING,
//! Order the elements from the largest to the smallest.
//! Elements are ordered from the largest to the smallest.
EGOM_DESCENDING,
//! this value is not used, it only specifies the amount of default ordering types
@ -28,6 +64,22 @@ namespace gui
EGOM_COUNT
};
const c8* const GUIOrderingModeNames[] =
{
"ascending",
"descending",
0
};
enum EGUI_TABLE_DRAW_FLAGS
{
EGTDF_ROWS = 1,
EGTDF_COLUMNS = 2,
EGTDF_ACTIVE_ROW = 4,
EGTDF_COUNT,
};
class IGUIFont;
//! Default list box GUI element.
@ -39,15 +91,20 @@ namespace gui
: IGUIElement(EGUIET_TABLE, environment, parent, id, rectangle) {}
//! Adds a column
virtual void addColumn(const wchar_t* caption, s32 id=-1) = 0;
//! If columnIndex is outside the current range, do push new colum at the end
virtual void addColumn(const wchar_t* caption, s32 columnIndex=-1) = 0;
//! remove a column from the table
virtual void removeColumn(u32 columnIndex) = 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.
//! \param doOrder: Do also the ordering which depending on mode for active column
\return Returns true if successful. */
virtual bool setActiveColumn(s32 idx) = 0;
virtual bool setActiveColumn(s32 idx, bool doOrder=false) = 0;
//! Returns which header is currently active
virtual s32 getActiveColumn() const = 0;
@ -57,12 +114,19 @@ namespace gui
//! Set the width of a column
virtual void setColumnWidth(u32 columnIndex, u32 width) = 0;
//! columns can be resized by drag 'n drop
virtual void setResizableColumns(bool resizable) = 0;
//! can columns be resized by dran 'n drop?
virtual bool hasResizableColumns() const = 0;
//! This tells the table control whether 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.
//! This tells the table control which ordering mode should be used when
//! a column header is clicked.
/** \param columnIndex: The index of the column header.
\param state: If true, a EGET_TABLE_HEADER_CHANGED message will be sent and you can order the table data as you whish.*/
virtual void setColumnCustomOrdering(u32 columnIndex, bool state) = 0;
//! \param mode: One of the modes defined in EGUI_COLUMN_ORDERING
virtual void setColumnOrdering(u32 columnIndex, EGUI_COLUMN_ORDERING mode) = 0;
//! Returns which row is currently selected
virtual s32 getSelected() const = 0;
@ -90,7 +154,8 @@ namespace gui
//! 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;
//! \param columnIndex: When set to -1 the active column is used.
virtual void orderRows(s32 columnIndex=-1, EGUI_ORDERING_MODE mode=EGOM_NONE) = 0;
//! Set the text of a cell
virtual void setCellText(u32 rowIndex, u32 columnIndex, const wchar_t* text) = 0;
@ -112,6 +177,12 @@ namespace gui
//! clears the table, deletes all items in the table
virtual void clear() = 0;
//! Set flags, as defined in EGUI_TABLE_DRAW_FLAGS, which influence the layout
virtual void setDrawFlags(s32 flags) = 0;
//! Get the flags, as defined in EGUI_TABLE_DRAW_FLAGS, which influence the layout
virtual s32 getDrawFlags() const = 0;
};

View File

@ -93,13 +93,16 @@ void CGUIModalScreen::draw()
for (; it != Children.end(); ++it)
{
r = (*it)->getAbsolutePosition();
r.LowerRightCorner.X += 1;
r.LowerRightCorner.Y += 1;
r.UpperLeftCorner.X -= 1;
r.UpperLeftCorner.Y -= 1;
if ((*it)->isVisible())
{
r = (*it)->getAbsolutePosition();
r.LowerRightCorner.X += 1;
r.LowerRightCorner.Y += 1;
r.UpperLeftCorner.X -= 1;
r.UpperLeftCorner.Y -= 1;
skin->draw2DRectangle(this, c, r, &AbsoluteClippingRect);
skin->draw2DRectangle(this, c, r, &AbsoluteClippingRect);
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -23,7 +23,7 @@ namespace gui
{
public:
//! constructor
CGUITable(IGUIEnvironment* environment, IGUIElement* parent,
CGUITable(IGUIEnvironment* environment, IGUIElement* parent,
s32 id, core::rect<s32> rectangle, bool clip=true,
bool drawBack=false, bool moveOverSelect=true);
@ -31,15 +31,19 @@ namespace gui
~CGUITable();
//! Adds a column
virtual void addColumn(const wchar_t* caption, s32 id=-1);
//! If columnIndex is outside the current range, do push new colum at the end
virtual void addColumn(const wchar_t* caption, s32 columnIndex=-1);
//! remove a column from the table
virtual void removeColumn(u32 columnIndex);
//! 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);
\return Returns true if successful. */
virtual bool setActiveColumn(s32 columnIndex, bool doOrder=false);
//! Returns which header is currently active
virtual s32 getActiveColumn() const;
@ -49,14 +53,20 @@ namespace gui
//! set a column width
virtual void setColumnWidth(u32 columnIndex, u32 width);
//! columns can be resized by drag 'n drop
virtual void setResizableColumns(bool resizable);
//! can columns be resized by dran 'n drop?
virtual bool hasResizableColumns() const;
//! This tells the table control whether is should send an
//! 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.
//! This tells the table control which ordering mode should be used when
//! a column header is clicked.
/** \param columnIndex: The index of the column header.
\param state: If true, an EGET_TABLE_HEADER_CHANGED message will be sent.*/
virtual void setColumnCustomOrdering(u32 columnIndex, bool state);
\param state: If true, a EGET_TABLE_HEADER_CHANGED message will be sent and you can order the table data as you whish.*/
//! \param mode: One of the modes defined in EGUI_COLUMN_ORDERING
virtual void setColumnOrdering(u32 columnIndex, EGUI_COLUMN_ORDERING mode);
//! Returns which row is currently selected
virtual s32 getSelected() const;
@ -87,7 +97,9 @@ namespace gui
//! 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();
//! \param columnIndex: When set to -1 the active column is used.
virtual void orderRows(s32 columnIndex=-1, EGUI_ORDERING_MODE mode=EGOM_NONE);
//! Set the text of a cell
virtual void setCellText(u32 rowIndex, u32 columnIndex, const wchar_t* text);
@ -96,6 +108,7 @@ namespace gui
virtual void setCellText(u32 rowIndex, u32 columnIndex, const wchar_t* text, video::SColor color);
//! Set the data of a cell
//! data will not be serialized.
virtual void setCellData(u32 rowIndex, u32 columnIndex, void *data);
//! Set the color of a cell text
@ -111,11 +124,17 @@ namespace gui
virtual void clear();
//! called if an event happened.
virtual bool OnEvent(const SEvent& event);
virtual bool OnEvent(SEvent event);
//! draws the element and its children
virtual void draw();
//! Set flags, as defined in EGUI_TABLE_DRAW_FLAGS, which influence the layout
virtual void setDrawFlags(s32 flags);
//! Get the flags, as defined in EGUI_TABLE_DRAW_FLAGS, which influence the layout
virtual s32 getDrawFlags() const;
//! Writes attributes of the object.
//! Implement this to expose the attributes of your scene node animator for
//! scripting languages, editors, debuggers or xml serialization purposes.
@ -126,51 +145,66 @@ namespace gui
//! scripting languages, editors, debuggers or xml deserialization purposes.
virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0);
protected:
virtual void refreshControls();
virtual void checkScrollbars();
private:
struct Cell
{
core::stringw text;
Cell() : Data(0) {}
core::stringw Text;
core::stringw BrokenText;
video::SColor color;
void *data;
video::SColor Color;
void *Data;
};
struct Row
{
Row() {}
core::array<Cell> Items;
u32 height;
};
struct Column
{
core::stringw name;
Column() : Width(0), OrderingMode(EGCO_NONE) {}
core::stringw Name;
video::SColor TextColor;
u32 width;
bool useCustomOrdering;
u32 Width;
EGUI_COLUMN_ORDERING OrderingMode;
};
void breakText(core::stringw &text, u32 cellWidth);
void breakText(const core::stringw &text, core::stringw & brokenText, u32 cellWidth);
void selectNew(s32 ypos, bool onlyHover=false);
bool selectColumnHeader(s32 xpos, s32 ypos);
void recalculate();
bool dragColumnStart(s32 xpos, s32 ypos);
bool dragColumnUpdate(s32 xpos);
void recalculateHeights();
void recalculateWidths();
core::array< Column > Columns;
core::array< Row > Rows;
gui::IGUIFont* Font;
gui::IGUIScrollBar* ScrollBar;
gui::IGUIScrollBar* VerticalScrollBar;
gui::IGUIScrollBar* HorizontalScrollBar;
bool Clip;
bool DrawBack;
bool MoveOverSelect;
bool Selecting;
s32 CurrentResizedColumn;
s32 ResizeStart;
bool ResizableColumns;
s32 ItemHeight;
s32 TotalItemHeight;
s32 TotalItemWidth;
s32 Selected;
s32 CellHeightPadding;
s32 CellWidthPadding;
s32 ActiveTab;
EGUI_ORDERING_MODE CurrentOrdering;
s32 DrawFlags;
};
} // end namespace gui