mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-01-19 20:24:49 +00:00
corrects PopupMenu::checkItem() not checking the item. also prepends m to member variables for the MenuItem class to correct a few more locals hiding classvar reports.
This commit is contained in:
parent
bca01fa976
commit
8ec82013ca
|
|
@ -1369,19 +1369,19 @@ void GuiMenuBar::buildWindowAcceleratorMap(WindowInputGenerator &inputGenerator)
|
|||
{
|
||||
for (U32 item = 0; item < mMenuList[i].popupMenu->mMenuItems.size(); item++)
|
||||
{
|
||||
if (!mMenuList[i].popupMenu->mMenuItems[item].accelerator)
|
||||
if (!mMenuList[i].popupMenu->mMenuItems[item].mAccelerator)
|
||||
{
|
||||
mMenuList[i].popupMenu->mMenuItems[item].accelerator = 0;
|
||||
mMenuList[i].popupMenu->mMenuItems[item].mAccelerator = 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
EventDescriptor accelEvent;
|
||||
ActionMap::createEventDescriptor(mMenuList[i].popupMenu->mMenuItems[item].accelerator, &accelEvent);
|
||||
ActionMap::createEventDescriptor(mMenuList[i].popupMenu->mMenuItems[item].mAccelerator, &accelEvent);
|
||||
|
||||
//now we have a modifier, and a key, add them to the canvas
|
||||
inputGenerator.addAcceleratorKey(this, mMenuList[i].popupMenu->mMenuItems[item].cmd, accelEvent.eventCode, accelEvent.flags);
|
||||
inputGenerator.addAcceleratorKey(this, mMenuList[i].popupMenu->mMenuItems[item].mCMD, accelEvent.eventCode, accelEvent.flags);
|
||||
|
||||
mMenuList[i].popupMenu->mMenuItems[item].acceleratorIndex = mCurAcceleratorIndex;
|
||||
mMenuList[i].popupMenu->mMenuItems[item].mAcceleratorIndex = mCurAcceleratorIndex;
|
||||
mCurAcceleratorIndex++;
|
||||
}
|
||||
}
|
||||
|
|
@ -1403,7 +1403,7 @@ void GuiMenuBar::acceleratorKeyPress(U32 index)
|
|||
|
||||
for(U32 item = 0; item < mMenuList[i].popupMenu->mMenuItems.size(); item++)
|
||||
{
|
||||
if(mMenuList[i].popupMenu->mMenuItems[item].acceleratorIndex == index)
|
||||
if(mMenuList[i].popupMenu->mMenuItems[item].mAcceleratorIndex == index)
|
||||
{
|
||||
// first, call the script callback for menu selection:
|
||||
onMenuSelect_callback(mMenuList[i].popupMenu->getId(), mMenuList[i].text);
|
||||
|
|
@ -1454,7 +1454,7 @@ void GuiMenuBar::insert(SimObject* pObject, S32 pos)
|
|||
newMenu.drawBitmapOnly = false;
|
||||
newMenu.drawBorder = true;
|
||||
newMenu.bitmapIndex = -1;
|
||||
newMenu.text = menu->barTitle;
|
||||
newMenu.text = menu->mBarTitle;
|
||||
newMenu.visible = true;
|
||||
newMenu.popupMenu = menu;
|
||||
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ GuiPopupMenuTextListCtrl::GuiPopupMenuTextListCtrl()
|
|||
void GuiPopupMenuTextListCtrl::onRenderCell(Point2I offset, Point2I cell, bool selected, bool mouseOver)
|
||||
{
|
||||
//check if we're a real entry, or if it's a divider
|
||||
if (mPopup->mMenuItems[cell.y].isSpacer)
|
||||
if (mPopup->mMenuItems[cell.y].mIsSpacer)
|
||||
{
|
||||
S32 yp = offset.y + mCellSize.y / 2;
|
||||
GFX->getDrawUtil()->drawLine(offset.x + 5, yp, offset.x + mCellSize.x - 5, yp, ColorI(128, 128, 128));
|
||||
|
|
@ -214,8 +214,8 @@ void GuiPopupMenuTextListCtrl::onMouseUp(const GuiEvent &event)
|
|||
|
||||
if (item)
|
||||
{
|
||||
if (item->enabled)
|
||||
dAtob(Con::executef(mPopup, "onSelectItem", Con::getIntArg(getSelectedCell().y), item->text.isNotEmpty() ? item->text : ""));
|
||||
if (item->mEnabled)
|
||||
dAtob(Con::executef(mPopup, "onSelectItem", Con::getIntArg(getSelectedCell().y), item->mText.isNotEmpty() ? item->mText : ""));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -247,9 +247,9 @@ void GuiPopupMenuTextListCtrl::onCellHighlighted(Point2I cell)
|
|||
{
|
||||
MenuItem *list = &mPopup->mMenuItems[selectionIndex];
|
||||
|
||||
if (list->isSubmenu && list->subMenu != nullptr)
|
||||
if (list->mIsSubmenu && list->mSubMenu != nullptr)
|
||||
{
|
||||
list->subMenu->showPopup(getRoot(), getPosition().x + mCellSize.x, getPosition().y + (selectionIndex * mCellSize.y));
|
||||
list->mSubMenu->showPopup(getRoot(), getPosition().x + mCellSize.x, getPosition().y + (selectionIndex * mCellSize.y));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -46,14 +46,20 @@ public:
|
|||
//-----------------------------------------------------------------------------
|
||||
PopupMenu::PopupMenu()
|
||||
{
|
||||
bitmapIndex = -1;
|
||||
mMenuItems = NULL;
|
||||
mMenuBarCtrl = nullptr;
|
||||
|
||||
barTitle = StringTable->EmptyString();
|
||||
mBarTitle = StringTable->EmptyString();
|
||||
mBounds = RectI(0, 0, 64, 64);
|
||||
mVisible = true;
|
||||
|
||||
mMenuBarCtrl = nullptr;
|
||||
mTextList = nullptr;
|
||||
mBitmapIndex = -1;
|
||||
mDrawBitmapOnly = false;
|
||||
mDrawBorder = false;
|
||||
|
||||
isSubmenu = false;
|
||||
mTextList = nullptr;
|
||||
|
||||
mIsSubmenu = false;
|
||||
}
|
||||
|
||||
PopupMenu::~PopupMenu()
|
||||
|
|
@ -76,7 +82,7 @@ void PopupMenu::initPersistFields()
|
|||
{
|
||||
Parent::initPersistFields();
|
||||
|
||||
addField("barTitle", TypeCaseString, Offset(barTitle, PopupMenu), "");
|
||||
addField("barTitle", TypeCaseString, Offset(mBarTitle, PopupMenu), "");
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
@ -134,28 +140,28 @@ S32 PopupMenu::insertItem(S32 pos, const char *title, const char* accelerator, c
|
|||
String titleString = title;
|
||||
|
||||
MenuItem newItem;
|
||||
newItem.id = pos;
|
||||
newItem.text = titleString;
|
||||
newItem.cmd = cmd;
|
||||
newItem.mID = pos;
|
||||
newItem.mText = titleString;
|
||||
newItem.mCMD = cmd;
|
||||
|
||||
if (titleString.isEmpty() || titleString == String("-"))
|
||||
newItem.isSpacer = true;
|
||||
newItem.mIsSpacer = true;
|
||||
else
|
||||
newItem.isSpacer = false;
|
||||
newItem.mIsSpacer = false;
|
||||
|
||||
if (accelerator[0])
|
||||
newItem.accelerator = dStrdup(accelerator);
|
||||
newItem.mAccelerator = dStrdup(accelerator);
|
||||
else
|
||||
newItem.accelerator = NULL;
|
||||
newItem.mAccelerator = NULL;
|
||||
|
||||
newItem.visible = true;
|
||||
newItem.isChecked = false;
|
||||
newItem.acceleratorIndex = 0;
|
||||
newItem.enabled = !newItem.isSpacer;
|
||||
newItem.mVisible = true;
|
||||
newItem.mIsChecked = false;
|
||||
newItem.mAcceleratorIndex = 0;
|
||||
newItem.mEnabled = !newItem.mIsSpacer;
|
||||
|
||||
newItem.isSubmenu = false;
|
||||
newItem.subMenu = nullptr;
|
||||
newItem.subMenuParentMenu = nullptr;
|
||||
newItem.mIsSubmenu = false;
|
||||
newItem.mSubMenu = nullptr;
|
||||
newItem.mSubMenuParentMenu = nullptr;
|
||||
|
||||
mMenuItems.push_back(newItem);
|
||||
|
||||
|
|
@ -166,11 +172,11 @@ S32 PopupMenu::insertSubMenu(S32 pos, const char *title, PopupMenu *submenu)
|
|||
{
|
||||
S32 itemPos = insertItem(pos, title, "", "");
|
||||
|
||||
mMenuItems[itemPos].isSubmenu = true;
|
||||
mMenuItems[itemPos].subMenu = submenu;
|
||||
mMenuItems[itemPos].subMenuParentMenu = this;
|
||||
mMenuItems[itemPos].mIsSubmenu = true;
|
||||
mMenuItems[itemPos].mSubMenu = submenu;
|
||||
mMenuItems[itemPos].mSubMenuParentMenu = this;
|
||||
|
||||
submenu->isSubmenu = true;
|
||||
submenu->mIsSubmenu = true;
|
||||
|
||||
return itemPos;
|
||||
}
|
||||
|
|
@ -181,15 +187,15 @@ bool PopupMenu::setItem(S32 pos, const char *title, const char* accelerator, con
|
|||
|
||||
for (U32 i = 0; i < mMenuItems.size(); i++)
|
||||
{
|
||||
if (mMenuItems[i].text == titleString)
|
||||
if (mMenuItems[i].mText == titleString)
|
||||
{
|
||||
mMenuItems[i].id = pos;
|
||||
mMenuItems[i].cmd = cmd;
|
||||
mMenuItems[i].mID = pos;
|
||||
mMenuItems[i].mCMD = cmd;
|
||||
|
||||
if (accelerator && accelerator[0])
|
||||
mMenuItems[i].accelerator = dStrdup(accelerator);
|
||||
mMenuItems[i].mAccelerator = dStrdup(accelerator);
|
||||
else
|
||||
mMenuItems[i].accelerator = NULL;
|
||||
mMenuItems[i].mAccelerator = NULL;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -211,7 +217,7 @@ void PopupMenu::enableItem(S32 pos, bool enable)
|
|||
if (mMenuItems.size() < pos || pos < 0)
|
||||
return;
|
||||
|
||||
mMenuItems[pos].enabled = enable;
|
||||
mMenuItems[pos].mEnabled = enable;
|
||||
}
|
||||
|
||||
void PopupMenu::checkItem(S32 pos, bool checked)
|
||||
|
|
@ -219,24 +225,24 @@ void PopupMenu::checkItem(S32 pos, bool checked)
|
|||
if (mMenuItems.size() < pos || pos < 0)
|
||||
return;
|
||||
|
||||
if (checked && mMenuItems[pos].checkGroup != -1)
|
||||
if (checked && mMenuItems[pos].mCheckGroup != -1)
|
||||
{
|
||||
// first, uncheck everything in the group:
|
||||
for (U32 i = 0; i < mMenuItems.size(); i++)
|
||||
if (mMenuItems[i].checkGroup == mMenuItems[pos].checkGroup && mMenuItems[i].isChecked)
|
||||
mMenuItems[i].isChecked = false;
|
||||
if (mMenuItems[i].mCheckGroup == mMenuItems[pos].mCheckGroup && mMenuItems[i].mIsChecked)
|
||||
mMenuItems[i].mIsChecked = false;
|
||||
}
|
||||
|
||||
mMenuItems[pos].isChecked;
|
||||
mMenuItems[pos].mIsChecked = checked;
|
||||
}
|
||||
|
||||
void PopupMenu::checkRadioItem(S32 firstPos, S32 lastPos, S32 checkPos)
|
||||
{
|
||||
for (U32 i = 0; i < mMenuItems.size(); i++)
|
||||
{
|
||||
if (mMenuItems[i].id >= firstPos && mMenuItems[i].id <= lastPos)
|
||||
if (mMenuItems[i].mID >= firstPos && mMenuItems[i].mID <= lastPos)
|
||||
{
|
||||
mMenuItems[i].isChecked = false;
|
||||
mMenuItems[i].mIsChecked = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -246,7 +252,7 @@ bool PopupMenu::isItemChecked(S32 pos)
|
|||
if (mMenuItems.size() < pos || pos < 0)
|
||||
return false;
|
||||
|
||||
return mMenuItems[pos].isChecked;
|
||||
return mMenuItems[pos].mIsChecked;
|
||||
}
|
||||
|
||||
U32 PopupMenu::getItemCount()
|
||||
|
|
@ -305,7 +311,7 @@ void PopupMenu::showPopup(GuiCanvas *owner, S32 x /* = -1 */, S32 y /* = -1 */)
|
|||
if (!backgroundCtrl || !mTextList)
|
||||
return;
|
||||
|
||||
if (!isSubmenu)
|
||||
if (!mIsSubmenu)
|
||||
{
|
||||
//if we're a 'parent' menu, then tell the background to clear out all existing other popups
|
||||
|
||||
|
|
@ -354,11 +360,11 @@ void PopupMenu::showPopup(GuiCanvas *owner, S32 x /* = -1 */, S32 y /* = -1 */)
|
|||
|
||||
for (U32 i = 0; i < mMenuItems.size(); i++)
|
||||
{
|
||||
if (!mMenuItems[i].visible)
|
||||
if (!mMenuItems[i].mVisible)
|
||||
continue;
|
||||
|
||||
S32 iTextWidth = font->getStrWidth(mMenuItems[i].text.c_str());
|
||||
S32 iAcceleratorWidth = mMenuItems[i].accelerator ? font->getStrWidth(mMenuItems[i].accelerator) : 0;
|
||||
S32 iTextWidth = font->getStrWidth(mMenuItems[i].mText.c_str());
|
||||
S32 iAcceleratorWidth = mMenuItems[i].mAccelerator ? font->getStrWidth(mMenuItems[i].mAccelerator) : 0;
|
||||
|
||||
if (iTextWidth > textWidth)
|
||||
textWidth = iTextWidth;
|
||||
|
|
@ -378,7 +384,7 @@ void PopupMenu::showPopup(GuiCanvas *owner, S32 x /* = -1 */, S32 y /* = -1 */)
|
|||
|
||||
for (U32 i = 0; i < mMenuItems.size(); i++)
|
||||
{
|
||||
if (!mMenuItems[i].visible)
|
||||
if (!mMenuItems[i].mVisible)
|
||||
continue;
|
||||
|
||||
char buf[512];
|
||||
|
|
@ -386,17 +392,17 @@ void PopupMenu::showPopup(GuiCanvas *owner, S32 x /* = -1 */, S32 y /* = -1 */)
|
|||
// If this menu item is a submenu, then set the isSubmenu to 2 to indicate
|
||||
// an arrow should be drawn. Otherwise set the isSubmenu normally.
|
||||
char isSubmenu = 1;
|
||||
if (mMenuItems[i].isSubmenu)
|
||||
if (mMenuItems[i].mIsSubmenu)
|
||||
isSubmenu = 2;
|
||||
|
||||
char bitmapIndex = 1;
|
||||
if (mMenuItems[i].bitmapIndex >= 0 && (mMenuItems[i].bitmapIndex * 3 <= profile->mBitmapArrayRects.size()))
|
||||
bitmapIndex = mMenuItems[i].bitmapIndex + 2;
|
||||
if (mMenuItems[i].mBitmapIndex >= 0 && (mMenuItems[i].mBitmapIndex * 3 <= profile->mBitmapArrayRects.size()))
|
||||
bitmapIndex = mMenuItems[i].mBitmapIndex + 2;
|
||||
|
||||
dSprintf(buf, sizeof(buf), "%c%c\t%s\t%s", bitmapIndex, isSubmenu, mMenuItems[i].text.c_str(), mMenuItems[i].accelerator ? mMenuItems[i].accelerator : "");
|
||||
dSprintf(buf, sizeof(buf), "%c%c\t%s\t%s", bitmapIndex, isSubmenu, mMenuItems[i].mText.c_str(), mMenuItems[i].mAccelerator ? mMenuItems[i].mAccelerator : "");
|
||||
mTextList->addEntry(entryCount, buf);
|
||||
|
||||
if (!mMenuItems[i].enabled)
|
||||
if (!mMenuItems[i].mEnabled)
|
||||
mTextList->setEntryActive(entryCount, false);
|
||||
|
||||
entryCount++;
|
||||
|
|
@ -437,8 +443,8 @@ void PopupMenu::hidePopupSubmenus()
|
|||
{
|
||||
for (U32 i = 0; i < mMenuItems.size(); i++)
|
||||
{
|
||||
if (mMenuItems[i].subMenu != nullptr)
|
||||
mMenuItems[i].subMenu->hidePopup();
|
||||
if (mMenuItems[i].mSubMenu != nullptr)
|
||||
mMenuItems[i].mSubMenu->hidePopup();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -34,27 +34,27 @@ class GuiPopupMenuBackgroundCtrl;
|
|||
|
||||
struct MenuItem // an individual item in a pull-down menu
|
||||
{
|
||||
String text; // the text of the menu item
|
||||
U32 id; // a script-assigned identifier
|
||||
char *accelerator; // the keyboard accelerator shortcut for the menu item
|
||||
U32 acceleratorIndex; // index of this accelerator
|
||||
bool enabled; // true if the menu item is selectable
|
||||
bool visible; // true if the menu item is visible
|
||||
S32 bitmapIndex; // index of the bitmap in the bitmap array
|
||||
S32 checkGroup; // the group index of the item visa vi check marks -
|
||||
String mText; // the text of the menu item
|
||||
U32 mID; // a script-assigned identifier
|
||||
char *mAccelerator; // the keyboard accelerator shortcut for the menu item
|
||||
U32 mAcceleratorIndex; // index of this accelerator
|
||||
bool mEnabled; // true if the menu item is selectable
|
||||
bool mVisible; // true if the menu item is visible
|
||||
S32 mBitmapIndex; // index of the bitmap in the bitmap array
|
||||
S32 mCheckGroup; // the group index of the item visa vi check marks -
|
||||
// only one item in the group can be checked.
|
||||
|
||||
bool isSubmenu; // This menu item has a submenu that will be displayed
|
||||
bool mIsSubmenu; // This menu item has a submenu that will be displayed
|
||||
|
||||
bool isChecked;
|
||||
bool mIsChecked;
|
||||
|
||||
bool isSpacer;
|
||||
bool mIsSpacer;
|
||||
|
||||
bool isMenubarEntry;
|
||||
bool mIsMenubarEntry;
|
||||
|
||||
PopupMenu* subMenuParentMenu; // For a submenu, this is the parent menu
|
||||
PopupMenu* subMenu;
|
||||
String cmd;
|
||||
PopupMenu* mSubMenuParentMenu; // For a submenu, this is the parent menu
|
||||
PopupMenu* mSubMenu;
|
||||
String mCMD;
|
||||
};
|
||||
|
||||
// PopupMenu represents a menu.
|
||||
|
|
@ -72,16 +72,16 @@ protected:
|
|||
|
||||
GuiMenuBar* mMenuBarCtrl;
|
||||
|
||||
StringTableEntry barTitle;
|
||||
StringTableEntry mBarTitle;
|
||||
|
||||
RectI bounds;
|
||||
bool visible;
|
||||
RectI mBounds;
|
||||
bool mVisible;
|
||||
|
||||
S32 bitmapIndex; // Index of the bitmap in the bitmap array (-1 = no bitmap)
|
||||
bool drawBitmapOnly; // Draw only the bitmap and not the text
|
||||
bool drawBorder; // Should a border be drawn around this menu (usually if we only have a bitmap, we don't want a border)
|
||||
S32 mBitmapIndex; // Index of the bitmap in the bitmap array (-1 = no bitmap)
|
||||
bool mDrawBitmapOnly; // Draw only the bitmap and not the text
|
||||
bool mDrawBorder; // Should a border be drawn around this menu (usually if we only have a bitmap, we don't want a border)
|
||||
|
||||
bool isSubmenu;
|
||||
bool mIsSubmenu;
|
||||
|
||||
//This is the gui control that renders our popup
|
||||
GuiPopupMenuTextListCtrl *mTextList;
|
||||
|
|
@ -175,8 +175,8 @@ public:
|
|||
virtual bool onMessageReceived(StringTableEntry queue, const char* event, const char* data );
|
||||
virtual bool onMessageObjectReceived(StringTableEntry queue, Message *msg );
|
||||
|
||||
bool isVisible() { return visible; }
|
||||
void setVisible(bool isVis) { visible = isVis; }
|
||||
bool isVisible() { return mVisible; }
|
||||
void setVisible(bool isVis) { mVisible = isVis; }
|
||||
|
||||
GuiMenuBar* getMenuBarCtrl();
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue