mirror of https://github.com/stella-emu/stella.git
fix display of changed PopUpWidget in debugger
allow using IDs with PopUpWidget's ContextMenu
This commit is contained in:
parent
c0323c572c
commit
7baa759ec9
|
@ -181,7 +181,7 @@ bool ContextMenu::sendSelectionUp()
|
|||
return false;
|
||||
|
||||
_selectedItem--;
|
||||
sendCommand(_cmd ? _cmd : ContextMenu::kItemSelectedCmd, _selectedItem, -1);
|
||||
sendCommand(_cmd ? _cmd : ContextMenu::kItemSelectedCmd, _selectedItem, _id);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -192,7 +192,7 @@ bool ContextMenu::sendSelectionDown()
|
|||
return false;
|
||||
|
||||
_selectedItem++;
|
||||
sendCommand(_cmd ? _cmd : ContextMenu::kItemSelectedCmd, _selectedItem, -1);
|
||||
sendCommand(_cmd ? _cmd : ContextMenu::kItemSelectedCmd, _selectedItem, _id);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -203,7 +203,7 @@ bool ContextMenu::sendSelectionFirst()
|
|||
return false;
|
||||
|
||||
_selectedItem = 0;
|
||||
sendCommand(_cmd ? _cmd : ContextMenu::kItemSelectedCmd, _selectedItem, -1);
|
||||
sendCommand(_cmd ? _cmd : ContextMenu::kItemSelectedCmd, _selectedItem, _id);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -214,7 +214,7 @@ bool ContextMenu::sendSelectionLast()
|
|||
return false;
|
||||
|
||||
_selectedItem = int(_entries.size()) - 1;
|
||||
sendCommand(_cmd ? _cmd : ContextMenu::kItemSelectedCmd, _selectedItem, -1);
|
||||
sendCommand(_cmd ? _cmd : ContextMenu::kItemSelectedCmd, _selectedItem, _id);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -375,7 +375,7 @@ void ContextMenu::sendSelection()
|
|||
|
||||
// Send any command associated with the selection
|
||||
_selectedItem = item;
|
||||
sendCommand(_cmd ? _cmd : ContextMenu::kItemSelectedCmd, _selectedItem, -1);
|
||||
sendCommand(_cmd ? _cmd : ContextMenu::kItemSelectedCmd, _selectedItem, _id);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
|
|
@ -45,6 +45,9 @@ class ContextMenu : public Dialog, public CommandSender
|
|||
const VariantList& items, int cmd = 0, int width = 0);
|
||||
virtual ~ContextMenu() = default;
|
||||
|
||||
/** Set the parent widget's ID */
|
||||
void setID(uInt32 id) { _id = id; }
|
||||
|
||||
/** Add the given items to the widget. */
|
||||
void addItems(const VariantList& items);
|
||||
|
||||
|
@ -121,6 +124,7 @@ class ContextMenu : public Dialog, public CommandSender
|
|||
ColorId _scrollUpColor{kColor}, _scrollDnColor{kColor};
|
||||
|
||||
int _cmd{0};
|
||||
int _id{-1};
|
||||
|
||||
uInt32 _xorig{0}, _yorig{0};
|
||||
uInt32 _maxWidth{0};
|
||||
|
|
|
@ -50,6 +50,14 @@ PopUpWidget::PopUpWidget(GuiObject* boss, const GUI::Font& font,
|
|||
myMenu = make_unique<ContextMenu>(this, font, list, cmd, w);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void PopUpWidget::setID(uInt32 id)
|
||||
{
|
||||
myMenu->setID(id);
|
||||
|
||||
Widget::setID(id);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void PopUpWidget::addItems(const VariantList& items)
|
||||
{
|
||||
|
@ -219,5 +227,5 @@ void PopUpWidget::drawWidget(bool hilite)
|
|||
TextAlign align = (_font.getStringWidth(name) > w-6) ?
|
||||
TextAlign::Right : TextAlign::Left;
|
||||
s.drawString(_font, name, x+2, _y+myTextY, w-6,
|
||||
!(isEnabled() && onTop) ? kColor : kTextColor, align);
|
||||
!(isEnabled() && onTop) ? kColor : _changed ? kDbgChangedTextColor : kTextColor, align);
|
||||
}
|
||||
|
|
|
@ -41,6 +41,8 @@ class PopUpWidget : public Widget, public CommandSender
|
|||
const string& label, int labelWidth = 0, int cmd = 0);
|
||||
virtual ~PopUpWidget() = default;
|
||||
|
||||
void setID(uInt32 id);
|
||||
|
||||
int getTop() const override { return _y + 1; }
|
||||
int getBottom() const override { return _y + 1 + getHeight(); }
|
||||
|
||||
|
|
Loading…
Reference in New Issue