Merge pull request #1192 from Areloch/EditorPopupEXFieldExpansion

Usability improvements for editor fields utilizing popup menus
This commit is contained in:
Brian Roberts 2024-02-07 19:29:07 -06:00 committed by GitHub
commit 600a6b8ebc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 206 additions and 35 deletions

View file

@ -855,7 +855,7 @@ void GuiPopUpMenuCtrlEx::sortID()
}
//------------------------------------------------------------------------------
void GuiPopUpMenuCtrlEx::addEntry(const char *buf, S32 id, U32 scheme)
void GuiPopUpMenuCtrlEx::addEntry(const char *buf, S32 id, U32 scheme, const bool& intented)
{
if( !buf )
{
@ -882,6 +882,7 @@ void GuiPopUpMenuCtrlEx::addEntry(const char *buf, S32 id, U32 scheme)
dStrcpy( e.buf, buf, 256 );
e.id = id;
e.scheme = scheme;
e.indented = intented;
// see if there is a shortcut key
char * cp = dStrchr( e.buf, '~' );
@ -1326,8 +1327,8 @@ void GuiPopUpMenuCtrlEx::closePopUp()
mSelIndex = ( mRevNum >= mSelIndex && mSelIndex != -1 ) ? mRevNum - mSelIndex : mSelIndex;
if ( mSelIndex != -1 )
{
if ( mReplaceText )
setText(mTl->mList[mSelIndex].text);
if (mReplaceText)
setText(mEntries[mSelIndex].buf);
for(U32 i=0; i < mEntries.size(); i++)
{
@ -1465,7 +1466,12 @@ void GuiPopUpMenuCtrlEx::onAction()
}
else
{
mTl->addEntry(mEntries[j].id, mEntries[j].buf);
String entryText = mEntries[j].buf;
if(mEntries[j].indented)
entryText = String(" ") + entryText;
mTl->addEntry(mEntries[j].id, entryText.c_str());
}
}

View file

@ -86,8 +86,9 @@ class GuiPopUpMenuCtrlEx : public GuiTextCtrl
S32 id;
U16 ascii;
U16 scheme;
bool usesColorBox; // Added
ColorI colorbox; // Added
bool usesColorBox; // Added
ColorI colorbox; // Added
bool indented; // Added
};
struct Scheme
@ -156,7 +157,11 @@ class GuiPopUpMenuCtrlEx : public GuiTextCtrl
void setBitmap(const char *name); // Added
void sort();
void sortID(); // Added
void addEntry(const char *buf, S32 id = -1, U32 scheme = 0);
void addEntry(const char *buf, S32 id = -1, U32 scheme = 0, const bool& indented = false);
void addCategory(const char *buf)
{
addEntry(buf, -2, 0);
}
void addScheme(U32 id, ColorI fontColor, ColorI fontColorHL, ColorI fontColorSEL);
void onRender(Point2I offset, const RectI &updateRect);
void onAction();
@ -184,6 +189,7 @@ class GuiPopUpMenuCtrlEx : public GuiTextCtrl
S32 getNumEntries() { return( mEntries.size() ); }
void replaceText(S32);
void setCanSearch(const bool& canSearch) { mTextSearchItems = canSearch; }
void setSearchText(String searchTxt) { mSearchText = String::ToLower(searchTxt); onAction(); }
DECLARE_CONOBJECT(GuiPopUpMenuCtrlEx);