fix display of changed PopUpWidget in debugger

allow using IDs with PopUpWidget's ContextMenu
This commit is contained in:
thrust26 2020-04-18 17:51:21 +02:00
parent c0323c572c
commit 7baa759ec9
4 changed files with 20 additions and 6 deletions

View File

@ -181,7 +181,7 @@ bool ContextMenu::sendSelectionUp()
return false; return false;
_selectedItem--; _selectedItem--;
sendCommand(_cmd ? _cmd : ContextMenu::kItemSelectedCmd, _selectedItem, -1); sendCommand(_cmd ? _cmd : ContextMenu::kItemSelectedCmd, _selectedItem, _id);
return true; return true;
} }
@ -192,7 +192,7 @@ bool ContextMenu::sendSelectionDown()
return false; return false;
_selectedItem++; _selectedItem++;
sendCommand(_cmd ? _cmd : ContextMenu::kItemSelectedCmd, _selectedItem, -1); sendCommand(_cmd ? _cmd : ContextMenu::kItemSelectedCmd, _selectedItem, _id);
return true; return true;
} }
@ -203,7 +203,7 @@ bool ContextMenu::sendSelectionFirst()
return false; return false;
_selectedItem = 0; _selectedItem = 0;
sendCommand(_cmd ? _cmd : ContextMenu::kItemSelectedCmd, _selectedItem, -1); sendCommand(_cmd ? _cmd : ContextMenu::kItemSelectedCmd, _selectedItem, _id);
return true; return true;
} }
@ -214,7 +214,7 @@ bool ContextMenu::sendSelectionLast()
return false; return false;
_selectedItem = int(_entries.size()) - 1; _selectedItem = int(_entries.size()) - 1;
sendCommand(_cmd ? _cmd : ContextMenu::kItemSelectedCmd, _selectedItem, -1); sendCommand(_cmd ? _cmd : ContextMenu::kItemSelectedCmd, _selectedItem, _id);
return true; return true;
} }
@ -375,7 +375,7 @@ void ContextMenu::sendSelection()
// Send any command associated with the selection // Send any command associated with the selection
_selectedItem = item; _selectedItem = item;
sendCommand(_cmd ? _cmd : ContextMenu::kItemSelectedCmd, _selectedItem, -1); sendCommand(_cmd ? _cmd : ContextMenu::kItemSelectedCmd, _selectedItem, _id);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -45,6 +45,9 @@ class ContextMenu : public Dialog, public CommandSender
const VariantList& items, int cmd = 0, int width = 0); const VariantList& items, int cmd = 0, int width = 0);
virtual ~ContextMenu() = default; virtual ~ContextMenu() = default;
/** Set the parent widget's ID */
void setID(uInt32 id) { _id = id; }
/** Add the given items to the widget. */ /** Add the given items to the widget. */
void addItems(const VariantList& items); void addItems(const VariantList& items);
@ -121,6 +124,7 @@ class ContextMenu : public Dialog, public CommandSender
ColorId _scrollUpColor{kColor}, _scrollDnColor{kColor}; ColorId _scrollUpColor{kColor}, _scrollDnColor{kColor};
int _cmd{0}; int _cmd{0};
int _id{-1};
uInt32 _xorig{0}, _yorig{0}; uInt32 _xorig{0}, _yorig{0};
uInt32 _maxWidth{0}; uInt32 _maxWidth{0};

View File

@ -50,6 +50,14 @@ PopUpWidget::PopUpWidget(GuiObject* boss, const GUI::Font& font,
myMenu = make_unique<ContextMenu>(this, font, list, cmd, w); 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) void PopUpWidget::addItems(const VariantList& items)
{ {
@ -219,5 +227,5 @@ void PopUpWidget::drawWidget(bool hilite)
TextAlign align = (_font.getStringWidth(name) > w-6) ? TextAlign align = (_font.getStringWidth(name) > w-6) ?
TextAlign::Right : TextAlign::Left; TextAlign::Right : TextAlign::Left;
s.drawString(_font, name, x+2, _y+myTextY, w-6, s.drawString(_font, name, x+2, _y+myTextY, w-6,
!(isEnabled() && onTop) ? kColor : kTextColor, align); !(isEnabled() && onTop) ? kColor : _changed ? kDbgChangedTextColor : kTextColor, align);
} }

View File

@ -41,6 +41,8 @@ class PopUpWidget : public Widget, public CommandSender
const string& label, int labelWidth = 0, int cmd = 0); const string& label, int labelWidth = 0, int cmd = 0);
virtual ~PopUpWidget() = default; virtual ~PopUpWidget() = default;
void setID(uInt32 id);
int getTop() const override { return _y + 1; } int getTop() const override { return _y + 1; }
int getBottom() const override { return _y + 1 + getHeight(); } int getBottom() const override { return _y + 1 + getHeight(); }