mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-12 15:14:35 +00:00
Merge pull request #245 from Areloch/PopupMenuBitmapArrays
Minor additions to popup menus
This commit is contained in:
commit
fbb11027b6
3 changed files with 30 additions and 8 deletions
|
|
@ -125,11 +125,13 @@ void GuiPopupMenuTextListCtrl::onRenderCell(Point2I offset, Point2I cell, bool s
|
||||||
if (idx != 1)
|
if (idx != 1)
|
||||||
{
|
{
|
||||||
// there's a bitmap...
|
// there's a bitmap...
|
||||||
U32 index = U32(idx - 2) * 3;
|
U32 index = U32(idx - 2) * 4;
|
||||||
if (!mList[cell.y].active)
|
if (!mList[cell.y].active)
|
||||||
index += 2;
|
index += 3;
|
||||||
else if (selected || mouseOver)
|
else if (selected)
|
||||||
index++;
|
index++;
|
||||||
|
else if (mouseOver)
|
||||||
|
index += 2;
|
||||||
|
|
||||||
if (mProfile->mBitmapArrayRects.size() > index)
|
if (mProfile->mBitmapArrayRects.size() > index)
|
||||||
{
|
{
|
||||||
|
|
@ -137,8 +139,10 @@ void GuiPopupMenuTextListCtrl::onRenderCell(Point2I offset, Point2I cell, bool s
|
||||||
Point2I off = maxBitmapSize - rect.extent;
|
Point2I off = maxBitmapSize - rect.extent;
|
||||||
off /= 2;
|
off /= 2;
|
||||||
|
|
||||||
|
Point2I bitPos = Point2I(offset.x + mCellSize.y / 2, offset.y + mCellSize.y / 2);
|
||||||
|
|
||||||
GFX->getDrawUtil()->clearBitmapModulation();
|
GFX->getDrawUtil()->clearBitmapModulation();
|
||||||
GFX->getDrawUtil()->drawBitmapSR(mProfile->mTextureObject, offset + off, rect);
|
GFX->getDrawUtil()->drawBitmapSR(mProfile->mTextureObject, bitPos + off, rect);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -139,7 +139,7 @@ GuiMenuBar* PopupMenu::getMenuBarCtrl()
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
// Public Methods
|
// Public Methods
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
S32 PopupMenu::insertItem(S32 pos, const char *title, const char* accelerator, const char* cmd)
|
S32 PopupMenu::insertItem(S32 pos, const char *title, const char* accelerator, const char* cmd, S32 bitmapIndex)
|
||||||
{
|
{
|
||||||
String titleString = title;
|
String titleString = title;
|
||||||
|
|
||||||
|
|
@ -147,6 +147,7 @@ S32 PopupMenu::insertItem(S32 pos, const char *title, const char* accelerator, c
|
||||||
newItem.mID = pos;
|
newItem.mID = pos;
|
||||||
newItem.mText = titleString;
|
newItem.mText = titleString;
|
||||||
newItem.mCMD = cmd;
|
newItem.mCMD = cmd;
|
||||||
|
newItem.mBitmapIndex = bitmapIndex;
|
||||||
|
|
||||||
if (titleString.isEmpty() || titleString == String("-"))
|
if (titleString.isEmpty() || titleString == String("-"))
|
||||||
newItem.mIsSpacer = true;
|
newItem.mIsSpacer = true;
|
||||||
|
|
@ -269,6 +270,14 @@ void PopupMenu::clearItems()
|
||||||
mMenuItems.clear();
|
mMenuItems.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String PopupMenu::getItemText(S32 pos)
|
||||||
|
{
|
||||||
|
if (mMenuItems.empty() || mMenuItems.size() < pos || pos < 0)
|
||||||
|
return String::EmptyString;
|
||||||
|
|
||||||
|
return mMenuItems[pos].mText;
|
||||||
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
bool PopupMenu::canHandleID(U32 id)
|
bool PopupMenu::canHandleID(U32 id)
|
||||||
{
|
{
|
||||||
|
|
@ -468,9 +477,9 @@ void PopupMenu::hidePopupSubmenus()
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Console Methods
|
// Console Methods
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
DefineEngineMethod(PopupMenu, insertItem, S32, (S32 pos, const char * title, const char * accelerator, const char* cmd), ("", "", ""), "(pos[, title][, accelerator][, cmd])")
|
DefineEngineMethod(PopupMenu, insertItem, S32, (S32 pos, const char * title, const char * accelerator, const char* cmd, S32 bitmapIndex), ("", "", "", -1), "(pos[, title][, accelerator][, cmd][, bitmapIndex])")
|
||||||
{
|
{
|
||||||
return object->insertItem(pos, title, accelerator, cmd);
|
return object->insertItem(pos, title, accelerator, cmd, bitmapIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
DefineEngineMethod(PopupMenu, removeItem, void, (S32 pos), , "(pos)")
|
DefineEngineMethod(PopupMenu, removeItem, void, (S32 pos), , "(pos)")
|
||||||
|
|
@ -506,6 +515,12 @@ DefineEngineMethod(PopupMenu, checkItem, void, (S32 pos, bool checked), , "(pos,
|
||||||
object->checkItem(pos, checked);
|
object->checkItem(pos, checked);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DefineEngineMethod(PopupMenu, getItemText, const char*, (S32 pos), , "(pos)")
|
||||||
|
{
|
||||||
|
return object->getItemText(pos).c_str();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
DefineEngineMethod(PopupMenu, checkRadioItem, void, (S32 firstPos, S32 lastPos, S32 checkPos), , "(firstPos, lastPos, checkPos)")
|
DefineEngineMethod(PopupMenu, checkRadioItem, void, (S32 firstPos, S32 lastPos, S32 checkPos), , "(firstPos, lastPos, checkPos)")
|
||||||
{
|
{
|
||||||
object->checkRadioItem(firstPos, lastPos, checkPos);
|
object->checkRadioItem(firstPos, lastPos, checkPos);
|
||||||
|
|
|
||||||
|
|
@ -107,7 +107,7 @@ public:
|
||||||
/// returns the menu item's ID, or -1 on failure.
|
/// returns the menu item's ID, or -1 on failure.
|
||||||
/// implementd on a per-platform basis.
|
/// implementd on a per-platform basis.
|
||||||
/// TODO: factor out common code
|
/// TODO: factor out common code
|
||||||
S32 insertItem(S32 pos, const char *title, const char* accelerator, const char* cmd);
|
S32 insertItem(S32 pos, const char *title, const char* accelerator, const char* cmd, S32 bitmapIndex = -1);
|
||||||
|
|
||||||
/// Sets the name title and accelerator for
|
/// Sets the name title and accelerator for
|
||||||
/// an existing item.
|
/// an existing item.
|
||||||
|
|
@ -143,6 +143,9 @@ public:
|
||||||
///Clears all items
|
///Clears all items
|
||||||
void clearItems();
|
void clearItems();
|
||||||
|
|
||||||
|
///Gets the text of a given item
|
||||||
|
String getItemText(S32 pos);
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
/// Displays this menu as a popup menu and blocks until the user has selected
|
/// Displays this menu as a popup menu and blocks until the user has selected
|
||||||
/// an item.
|
/// an item.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue