diff --git a/src/debugger/gui/RomListWidget.cxx b/src/debugger/gui/RomListWidget.cxx index 20fc53052..3504b2b37 100644 --- a/src/debugger/gui/RomListWidget.cxx +++ b/src/debugger/gui/RomListWidget.cxx @@ -39,6 +39,8 @@ RomListWidget::RomListWidget(GuiObject* boss, const GUI::Font& lfont, _textcolor = kTextColor; _textcolorhi = kTextColor; + _editMode = false; + _cols = w / _fontWidth; _rows = h / _lineHeight; @@ -480,20 +482,18 @@ void RomListWidget::drawWidget(bool hilite) codeDisasmW = actualWidth; xpos = _x + CheckboxWidget::boxSize(_font) + 10; ypos = _y + 2; - for (i = 0, pos = _currentPos; i < _rows && pos < len; i++, pos++, ypos += _lineHeight) + for(i = 0, pos = _currentPos; i < _rows && pos < len; i++, pos++, ypos += _lineHeight) { ColorId bytesColor = textColor; - // Draw checkboxes for correct lines (takes scrolling into account) + // Mark checkboxes dirty for correct lines (takes scrolling into account) myCheckList[i]->setState(instance().debugger(). checkBreakPoint(dlist[pos].address, instance().debugger().cartDebug().getBank(dlist[pos].address))); - myCheckList[i]->setDirty(); - myCheckList[i]->draw(); // Draw highlighted item in a frame - if (_highlightedItem == pos) + if(_highlightedItem == pos) s.frameRect(_x + l.x() - 3, ypos - 1, _w - l.x(), _lineHeight, onTop ? kWidColorHi : kBGColorLo); // Draw the selected item inverted, on a highlighted background. @@ -510,31 +510,31 @@ void RomListWidget::drawWidget(bool hilite) // Draw labels s.drawString(_font, dlist[pos].label, xpos, ypos, _labelWidth, - dlist[pos].hllabel ? textColor : kColor); + dlist[pos].hllabel ? textColor : kColor); // Bytes are only editable if they represent code, graphics, or accessible data // Otherwise, the disassembly should get all remaining space - if(dlist[pos].type & (Device::CODE|Device::GFX|Device::PGFX| - Device::COL|Device::PCOL|Device::BCOL|Device::DATA)) + if(dlist[pos].type & (Device::CODE | Device::GFX | Device::PGFX | + Device::COL | Device::PCOL | Device::BCOL | Device::DATA)) { if(dlist[pos].type == Device::CODE) { // Draw mnemonic s.drawString(_font, dlist[pos].disasm.substr(0, 7), xpos + _labelWidth, ypos, - 7 * _fontWidth, textColor); + 7 * _fontWidth, textColor); // Draw operand - if (dlist[pos].disasm.length() > 8) + if(dlist[pos].disasm.length() > 8) s.drawString(_font, dlist[pos].disasm.substr(8), xpos + _labelWidth + 7 * _fontWidth, ypos, - codeDisasmW - 7 * _fontWidth, textColor); + codeDisasmW - 7 * _fontWidth, textColor); // Draw cycle count s.drawString(_font, dlist[pos].ccount, xpos + _labelWidth + codeDisasmW, ypos, - cycleCountW, textColor); + cycleCountW, textColor); } else { // Draw disassembly only s.drawString(_font, dlist[pos].disasm, xpos + _labelWidth, ypos, - noCodeDisasmW - 4, kTextColor); + noCodeDisasmW - 4, kTextColor); } // Draw separator @@ -542,11 +542,11 @@ void RomListWidget::drawWidget(bool hilite) // Draw bytes { - if (_selectedItem == pos && _editMode) + if(_selectedItem == pos && _editMode) { adjustOffset(); s.drawString(_font, editString(), _x + r.x(), ypos, r.w(), textColor, - TextAlign::Left, -_editScrollOffset, false); + TextAlign::Left, -_editScrollOffset, false); drawCaretSelection(); } @@ -560,7 +560,7 @@ void RomListWidget::drawWidget(bool hilite) { // Draw disassembly, giving it all remaining horizontal space s.drawString(_font, dlist[pos].disasm, xpos + _labelWidth, ypos, - noTypeDisasmW, textColor); + noTypeDisasmW, textColor); } } } diff --git a/src/debugger/gui/RomListWidget.hxx b/src/debugger/gui/RomListWidget.hxx index 40abb0adf..ec557f606 100644 --- a/src/debugger/gui/RomListWidget.hxx +++ b/src/debugger/gui/RomListWidget.hxx @@ -96,7 +96,6 @@ class RomListWidget : public EditableWidget int _currentPos{0}; // position of first line in visible window int _selectedItem{-1}; int _highlightedItem{-1}; - bool _editMode{false}; StellaKey _currentKeyDown{KBDK_UNKNOWN}; Common::Base::Fmt _base{Common::Base::Fmt::_DEFAULT}; // base used during editing diff --git a/src/debugger/gui/RomWidget.cxx b/src/debugger/gui/RomWidget.cxx index 87572d6ed..0454ef16d 100644 --- a/src/debugger/gui/RomWidget.cxx +++ b/src/debugger/gui/RomWidget.cxx @@ -90,10 +90,6 @@ void RomWidget::handleCommand(CommandSender* sender, int cmd, int data, int id) case RomListWidget::kBPointChangedCmd: // 'data' is the line in the disassemblylist to be accessed toggleBreak(data); - // Refresh the romlist, since the breakpoint may not have - // actually changed - myRomList->setDirty(); - myRomList->draw(); break; case RomListWidget::kRomChangedCmd: diff --git a/src/gui/Dialog.cxx b/src/gui/Dialog.cxx index 95379398a..215289771 100644 --- a/src/gui/Dialog.cxx +++ b/src/gui/Dialog.cxx @@ -476,13 +476,17 @@ void Dialog::drawDialog() clearDirty(); } + // Draw all children + drawChain(); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void Dialog::drawChain() +{ Widget* w = _firstWidget; - // Draw all children - w = _firstWidget; while(w) { - // only redraw changed widgets if(w->needsRedraw()) w->draw(); w = w->_next; diff --git a/src/gui/Dialog.hxx b/src/gui/Dialog.hxx index abb22911a..de81b4a1d 100644 --- a/src/gui/Dialog.hxx +++ b/src/gui/Dialog.hxx @@ -65,6 +65,7 @@ class Dialog : public GuiObject void tick() override; bool isChainDirty() const override; void redraw(bool force = false); + void drawChain() override; void render(); void addFocusWidget(Widget* w) override; diff --git a/src/gui/EditableWidget.cxx b/src/gui/EditableWidget.cxx index 4c3928052..8e19cb0a2 100644 --- a/src/gui/EditableWidget.cxx +++ b/src/gui/EditableWidget.cxx @@ -66,7 +66,7 @@ void EditableWidget::setText(const string& str, bool) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void EditableWidget::tick() { - if(_hasFocus && _editable && isVisible() && _boss->isVisible()) + if(_hasFocus && isEditable() && _editMode && isVisible() && _boss->isVisible()) { _caretTimer++; if(_caretTimer > 40) // switch every 2/3rd seconds diff --git a/src/gui/EditableWidget.hxx b/src/gui/EditableWidget.hxx index 345a4c618..8ebf1791c 100644 --- a/src/gui/EditableWidget.hxx +++ b/src/gui/EditableWidget.hxx @@ -123,6 +123,7 @@ class EditableWidget : public Widget, public CommandSender protected: int _editScrollOffset{0}; + bool _editMode{true}; private: TextFilter _filter; diff --git a/src/gui/GuiObject.hxx b/src/gui/GuiObject.hxx index 581d498aa..893686e5f 100644 --- a/src/gui/GuiObject.hxx +++ b/src/gui/GuiObject.hxx @@ -91,16 +91,18 @@ class GuiObject : public CommandReceiver virtual void setHeight(int h) { _h = h; } virtual bool isVisible() const = 0; - virtual void setDirty() { _dirty = true; } - virtual void clearDirty() { _dirty = false; } - virtual void tick() = 0; - virtual bool isDirty() const { return _dirty; } + void setDirty() { _dirty = true; } + void clearDirty() { _dirty = false; } + bool isDirty() const { return _dirty; } virtual bool isChainDirty() const = 0; + // The GUI indicates if its underlying surface needs to be redrawn // and then re-rendered virtual bool needsRedraw() { return isDirty() || isChainDirty(); } + virtual void tick() = 0; + void setFlags(uInt32 flags) { uInt32 oldFlags = _flags; @@ -140,6 +142,7 @@ class GuiObject : public CommandReceiver protected: virtual void releaseFocus() = 0; virtual void draw() = 0; + virtual void drawChain() = 0; private: OSystem& myOSystem; diff --git a/src/gui/Widget.cxx b/src/gui/Widget.cxx index 93331cea1..e04da70d9 100644 --- a/src/gui/Widget.cxx +++ b/src/gui/Widget.cxx @@ -157,7 +157,14 @@ void Widget::draw() clearDirty(); // Draw all children + drawChain(); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void Widget::drawChain() +{ Widget* w = _firstWidget; + while(w) { if(w->needsRedraw()) diff --git a/src/gui/Widget.hxx b/src/gui/Widget.hxx index 13eefdbf7..38f8fecfa 100644 --- a/src/gui/Widget.hxx +++ b/src/gui/Widget.hxx @@ -72,6 +72,7 @@ class Widget : public GuiObject void tick() override; bool isChainDirty() const override; void draw() override; + void drawChain() override; void receivedFocus(); void lostFocus(); void addFocusWidget(Widget* w) override { _focusList.push_back(w); }