From 75d485b5cd88de90e50059df0b115a3db7e51a7b Mon Sep 17 00:00:00 2001 From: cutealien Date: Mon, 6 Mar 2023 13:42:05 +0000 Subject: [PATCH] Listbox items can now change individual background colors git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6453 dfc29bdd-3216-0410-991c-e03cc46cb475 --- changes.txt | 1 + include/IGUIListBox.h | 5 +++++ source/Irrlicht/CGUIListBox.cpp | 20 +++++++++++++++++++- 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/changes.txt b/changes.txt index 58b28780..75294839 100644 --- a/changes.txt +++ b/changes.txt @@ -1,6 +1,7 @@ -------------------------- Changes in 1.9 (not yet released) +- Listbox items can now change individual background colors - Fix some bitfield sizes in SMaterial which were chosen too small for enums (PolygonOffsetDirection, ZWriteEnable, BlendOperation) - Add ISceneNode::UpdateAbsolutePosBehavior variable to allow nodes to ignore the scale/rotation parts of their parents transformation. - Add IGUISpinBox functions getValueFor and getOldValue diff --git a/include/IGUIListBox.h b/include/IGUIListBox.h index 466f2866..3a3134ea 100644 --- a/include/IGUIListBox.h +++ b/include/IGUIListBox.h @@ -26,6 +26,11 @@ namespace gui EGUI_LBC_ICON, //! Color of selected icon EGUI_LBC_ICON_HIGHLIGHT, + //! Color of background. + //! Note that this one is drawn over the listbox background and when not used there is no other default + EGUI_LBC_BACKGROUND, + //! Color of selected background + EGUI_LBC_BACKGROUND_HIGHLIGHT, //! Not used, just counts the number of available colors EGUI_LBC_COUNT }; diff --git a/source/Irrlicht/CGUIListBox.cpp b/source/Irrlicht/CGUIListBox.cpp index 7ec18698..ed94541e 100644 --- a/source/Irrlicht/CGUIListBox.cpp +++ b/source/Irrlicht/CGUIListBox.cpp @@ -528,7 +528,13 @@ void CGUIListBox::draw() frameRect.UpperLeftCorner.Y <= AbsoluteRect.LowerRightCorner.Y) { if (i == Selected && hl) - skin->draw2DRectangle(this, skin->getColor(EGDC_HIGH_LIGHT), frameRect, &clientClip); + { + skin->draw2DRectangle(this, hasItemOverrideColor(i, EGUI_LBC_BACKGROUND_HIGHLIGHT) ? getItemOverrideColor(i, EGUI_LBC_BACKGROUND_HIGHLIGHT) : getItemDefaultColor(EGUI_LBC_BACKGROUND_HIGHLIGHT), frameRect, &clientClip); + } + else if ( hasItemOverrideColor(i, EGUI_LBC_BACKGROUND ) ) + { + skin->draw2DRectangle(this, getItemOverrideColor(i, EGUI_LBC_BACKGROUND), frameRect, &clientClip); + } core::rect textRect = frameRect; textRect.UpperLeftCorner.X += 3; @@ -671,6 +677,14 @@ bool CGUIListBox::getSerializationLabels(EGUI_LISTBOX_COLOR colorType, core::str useColorLabel = "UseColIconHl"; colorLabel = "ColIconHl"; break; + case EGUI_LBC_BACKGROUND: + useColorLabel = "UseColBg"; + colorLabel = "ColBg"; + break; + case EGUI_LBC_BACKGROUND_HIGHLIGHT: + useColorLabel = "UseColBgHl"; + colorLabel = "ColBgHl"; + break; default: return false; } @@ -887,6 +901,10 @@ video::SColor CGUIListBox::getItemDefaultColor(EGUI_LISTBOX_COLOR colorType) con return skin->getColor(EGDC_ICON); case EGUI_LBC_ICON_HIGHLIGHT: return skin->getColor(EGDC_ICON_HIGH_LIGHT); + case EGUI_LBC_BACKGROUND: + return skin->getColor(EGDC_3D_HIGH_LIGHT); + case EGUI_LBC_BACKGROUND_HIGHLIGHT: + return skin->getColor(EGDC_HIGH_LIGHT); default: return video::SColor(); }