From 500253323adf35503fb18fb8e5fe4f21f0e52d6f Mon Sep 17 00:00:00 2001 From: Thomas Jentzsch Date: Mon, 7 Sep 2020 15:37:45 +0200 Subject: [PATCH] added more controller widget support for QuadTari added tabbing through controller widgets --- src/debugger/gui/AtariVoxWidget.cxx | 5 +- src/debugger/gui/AtariVoxWidget.hxx | 2 +- src/debugger/gui/BoosterWidget.cxx | 8 ++ src/debugger/gui/DrivingWidget.cxx | 53 ++++++++------ src/debugger/gui/FlashWidget.cxx | 48 +++++++----- src/debugger/gui/FlashWidget.hxx | 6 +- src/debugger/gui/GenesisWidget.cxx | 7 ++ src/debugger/gui/JoystickWidget.cxx | 14 +++- src/debugger/gui/KeyboardWidget.cxx | 1 + src/debugger/gui/PaddleWidget.cxx | 87 ++++++++++++++++------ src/debugger/gui/PaddleWidget.hxx | 3 +- src/debugger/gui/PointingDeviceWidget.cxx | 6 ++ src/debugger/gui/QuadTariWidget.cxx | 89 ++++++++++++----------- src/debugger/gui/QuadTariWidget.hxx | 5 +- src/debugger/gui/RiotWidget.cxx | 2 + src/debugger/gui/RomListWidget.cxx | 28 +++---- src/debugger/gui/SaveKeyWidget.cxx | 4 +- src/debugger/gui/SaveKeyWidget.hxx | 2 +- src/gui/CheckListWidget.cxx | 20 ++--- src/gui/ListWidget.cxx | 4 +- src/gui/StringListWidget.cxx | 10 +-- src/gui/TabWidget.cxx | 2 +- src/gui/Widget.cxx | 4 +- src/gui/Widget.hxx | 2 +- 24 files changed, 257 insertions(+), 155 deletions(-) diff --git a/src/debugger/gui/AtariVoxWidget.cxx b/src/debugger/gui/AtariVoxWidget.cxx index 0a38d2ec5..3d3dfe762 100644 --- a/src/debugger/gui/AtariVoxWidget.cxx +++ b/src/debugger/gui/AtariVoxWidget.cxx @@ -20,10 +20,11 @@ // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - AtariVoxWidget::AtariVoxWidget(GuiObject* boss, const GUI::Font& font, - int x, int y, Controller& controller) + int x, int y, Controller& controller, + bool embedded) : FlashWidget(boss, font, x, y, controller) { - init(boss, font, x, y); + init(boss, font, x, y, embedded); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/debugger/gui/AtariVoxWidget.hxx b/src/debugger/gui/AtariVoxWidget.hxx index cf168173d..ea0345762 100644 --- a/src/debugger/gui/AtariVoxWidget.hxx +++ b/src/debugger/gui/AtariVoxWidget.hxx @@ -26,7 +26,7 @@ class AtariVoxWidget : public FlashWidget { public: AtariVoxWidget(GuiObject* boss, const GUI::Font& font, int x, int y, - Controller& controller); + Controller& controller, bool embedded = false); ~AtariVoxWidget() override = default; private: diff --git a/src/debugger/gui/BoosterWidget.cxx b/src/debugger/gui/BoosterWidget.cxx index 1820919bb..b1056c069 100644 --- a/src/debugger/gui/BoosterWidget.cxx +++ b/src/debugger/gui/BoosterWidget.cxx @@ -73,6 +73,14 @@ BoosterWidget::BoosterWidget(GuiObject* boss, const GUI::Font& font, CheckboxWidget::kCheckActionCmd); myPins[kJTrigger]->setID(kJTrigger); myPins[kJTrigger]->setTarget(this); + + addFocusWidget(myPins[kJUp]); + addFocusWidget(myPins[kJLeft]); + addFocusWidget(myPins[kJRight]); + addFocusWidget(myPins[kJDown]); + addFocusWidget(myPins[kJFire]); + addFocusWidget(myPins[kJBooster]); + addFocusWidget(myPins[kJTrigger]); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/debugger/gui/DrivingWidget.cxx b/src/debugger/gui/DrivingWidget.cxx index 3dadc24b4..5f0b74d95 100644 --- a/src/debugger/gui/DrivingWidget.cxx +++ b/src/debugger/gui/DrivingWidget.cxx @@ -25,49 +25,56 @@ DrivingWidget::DrivingWidget(GuiObject* boss, const GUI::Font& font, { const string& label = getHeader(); - const int fontHeight = font.getFontHeight(), - fontWidth = font.getMaxCharWidth(), - bheight = font.getLineHeight() + 4; - int xpos = x, ypos = y, lwidth = font.getStringWidth("Right (Driving)"); - StaticTextWidget* t; + const int lineHeight = font.getLineHeight(), + bHeight = font.getLineHeight() * 1.25; + int xpos = x, ypos = y; if(embedded) { - const int bwidth = font.getStringWidth("GC+ "); + const int bWidth = font.getStringWidth("GC+ "); - myGrayUp = new ButtonWidget(boss, font, xpos, ypos, bwidth, bheight, + ypos += _lineHeight * 0.334; + myGrayUp = new ButtonWidget(boss, font, xpos, ypos, bWidth, bHeight, "GC+", kGrayUpCmd); - ypos += myGrayUp->getHeight() + 5; - myGrayDown = new ButtonWidget(boss, font, xpos, ypos, bwidth, bheight, + ypos += myGrayUp->getHeight() + bHeight * 0.3; + myGrayDown = new ButtonWidget(boss, font, xpos, ypos, bWidth, bHeight, "GC-", kGrayDownCmd); + xpos += myGrayDown->getWidth() + _fontWidth * 0.75; } else { - const int bwidth = font.getStringWidth("Gray code +") + 10; - t = new StaticTextWidget(boss, font, xpos, ypos + 2, lwidth, - fontHeight, label, TextAlign::Left); + const int lwidth = font.getStringWidth("Right (Driving)"), + bWidth = font.getStringWidth("Gray code +") + _fontWidth * 1.25; - ypos += t->getHeight() + 20; - myGrayUp = new ButtonWidget(boss, font, xpos, ypos, bwidth, bheight, + StaticTextWidget* t = new StaticTextWidget(boss, font, xpos, ypos + 2, lwidth, + lineHeight, label, TextAlign::Left); + + ypos = t->getBottom() + _lineHeight * 1.334; + myGrayUp = new ButtonWidget(boss, font, xpos, ypos, bWidth, bHeight, "Gray code +", kGrayUpCmd); - ypos += myGrayUp->getHeight() + 5; - myGrayDown = new ButtonWidget(boss, font, xpos, ypos, bwidth, bheight, + ypos += myGrayUp->getHeight() + bHeight * 0.3; + myGrayDown = new ButtonWidget(boss, font, xpos, ypos, bWidth, bHeight, "Gray code -", kGrayDownCmd); + xpos += myGrayDown->getWidth() + _fontWidth; } - myGrayUp->setTarget(this); - myGrayDown->setTarget(this); - - xpos += myGrayDown->getWidth() + fontWidth; ypos -= 10; + ypos -= bHeight * 0.6; myGrayValue = new DataGridWidget(boss, font, xpos, ypos, 1, 1, 2, 8, Common::Base::Fmt::_16); + + xpos = x + myGrayDown->getWidth() * 0.25; ypos = myGrayDown->getBottom() + _lineHeight; + myFire = new CheckboxWidget(boss, font, xpos, ypos, "Fire", kFireCmd); + + myGrayUp->setTarget(this); + myGrayDown->setTarget(this); myGrayValue->setTarget(this); myGrayValue->setEditable(false); - - xpos = x + fontWidth*3; ypos += myGrayDown->getHeight() + 20; - myFire = new CheckboxWidget(boss, font, xpos, ypos, "Fire", kFireCmd); myFire->setTarget(this); + + addFocusWidget(myGrayUp); + addFocusWidget(myGrayDown); + addFocusWidget(myFire); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/debugger/gui/FlashWidget.cxx b/src/debugger/gui/FlashWidget.cxx index 3c2614659..c432b16ca 100644 --- a/src/debugger/gui/FlashWidget.cxx +++ b/src/debugger/gui/FlashWidget.cxx @@ -28,31 +28,43 @@ FlashWidget::FlashWidget(GuiObject* boss, const GUI::Font& font, } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void FlashWidget::init(GuiObject* boss, const GUI::Font& font, int x, int y) +void FlashWidget::init(GuiObject* boss, const GUI::Font& font, + int x, int y, bool embedded) { - const int lineHeight = font.getLineHeight(); + const int fontHeight = font.getFontHeight(); int xpos = x, ypos = y; - new StaticTextWidget(boss, font, xpos, ypos + 2, getHeader()); + myEmbedded = embedded; + if(!embedded) + { + new StaticTextWidget(boss, font, xpos, ypos + 2, getHeader()); - ypos += lineHeight + 6; + ypos += _lineHeight * 1.4; + new StaticTextWidget(boss, font, xpos, ypos, "Pages/Ranges used:"); + } + else + { + ypos += _lineHeight * 0.4 - (2 + _lineHeight); + new StaticTextWidget(boss, font, xpos, ypos, "Pages:"); + } - new StaticTextWidget(boss, font, xpos, ypos, "Pages/Ranges used:"); - - ypos += lineHeight + 2; + ypos += _lineHeight + 2; xpos += 8; - for(uInt32 page = 0; page < MAX_PAGES; ++page) { myPage[page] = new StaticTextWidget(boss, font, xpos, ypos, - page ? " " : "none "); - ypos += lineHeight; + embedded ? page ? " " : "none" + : page ? " " : "none "); + ypos += _lineHeight; } xpos -= 8; ypos += 2; myEEPROMEraseCurrent = new ButtonWidget(boss, font, xpos, ypos, - "Erase used pages", kEEPROMEraseCurrent); + embedded ? "Erase" : "Erase used pages", + kEEPROMEraseCurrent); myEEPROMEraseCurrent->setTarget(this); + + addFocusWidget(myEEPROMEraseCurrent); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -86,12 +98,14 @@ void FlashWidget::loadConfig() label.str(""); label << Common::Base::HEX3 << startPage; - if(int(page) - 1 != startPage) - label << "-" << Common::Base::HEX3 << page - 1; - else - label << " "; - label << ": " << Common::Base::HEX4 << from << "-" << Common::Base::HEX4 << to; - + if(!myEmbedded) + { + if(int(page) - 1 != startPage) + label << "-" << Common::Base::HEX3 << page - 1; + else + label << " "; + label << ": " << Common::Base::HEX4 << from << "-" << Common::Base::HEX4 << to; + } myPage[useCount]->setLabel(label.str()); startPage = -1; diff --git a/src/debugger/gui/FlashWidget.hxx b/src/debugger/gui/FlashWidget.hxx index cb085be9d..5db1cae2f 100644 --- a/src/debugger/gui/FlashWidget.hxx +++ b/src/debugger/gui/FlashWidget.hxx @@ -31,12 +31,14 @@ class FlashWidget : public ControllerWidget ~FlashWidget() override = default; protected: - void init(GuiObject* boss, const GUI::Font& font, int x, int y); + void init(GuiObject* boss, const GUI::Font& font, int x, int y, bool embedded); private: - ButtonWidget* myEEPROMEraseCurrent{nullptr}; enum { kEEPROMEraseCurrent = 'eeEC' }; + bool myEmbedded{false}; + ButtonWidget* myEEPROMEraseCurrent{nullptr}; + static constexpr uInt32 MAX_PAGES = 5; std::array myPage{nullptr}; diff --git a/src/debugger/gui/GenesisWidget.cxx b/src/debugger/gui/GenesisWidget.cxx index 70833879a..fcf05ce2f 100644 --- a/src/debugger/gui/GenesisWidget.cxx +++ b/src/debugger/gui/GenesisWidget.cxx @@ -67,6 +67,13 @@ GenesisWidget::GenesisWidget(GuiObject* boss, const GUI::Font& font, CheckboxWidget::kCheckActionCmd); myPins[kJCbtn]->setID(kJCbtn); myPins[kJCbtn]->setTarget(this); + + addFocusWidget(myPins[kJUp]); + addFocusWidget(myPins[kJLeft]); + addFocusWidget(myPins[kJRight]); + addFocusWidget(myPins[kJDown]); + addFocusWidget(myPins[kJBbtn]); + addFocusWidget(myPins[kJCbtn]); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/debugger/gui/JoystickWidget.cxx b/src/debugger/gui/JoystickWidget.cxx index 80455dea0..2581f41ae 100644 --- a/src/debugger/gui/JoystickWidget.cxx +++ b/src/debugger/gui/JoystickWidget.cxx @@ -23,17 +23,17 @@ JoystickWidget::JoystickWidget(GuiObject* boss, const GUI::Font& font, bool embedded) : ControllerWidget(boss, font, x, y, controller) { + const int fontHeight = font.getFontHeight(); int xpos = x, ypos = y; if(!embedded) { const string& label = getHeader(); - const int fontHeight = font.getFontHeight(); - int lwidth = font.getStringWidth("Right (Joystick)"); + const int lwidth = font.getStringWidth("Right (Joystick)"); StaticTextWidget* t; t = new StaticTextWidget(boss, font, xpos, ypos + 2, lwidth, - fontHeight, label, TextAlign::Left); + _lineHeight, label, TextAlign::Left); xpos += t->getWidth() / 2 - 5; ypos = t->getBottom() + fontHeight; } myPins[kJUp] = new CheckboxWidget(boss, font, xpos, ypos, "", @@ -61,11 +61,17 @@ JoystickWidget::JoystickWidget(GuiObject* boss, const GUI::Font& font, myPins[kJRight]->setTarget(this); xpos -= (myPins[kJUp]->getWidth() + 5) * 2; - ypos = myPins[kJDown]->getBottom() + font.getFontHeight() * 0.5 - 1; + ypos = myPins[kJDown]->getBottom() + fontHeight * 0.75; myPins[kJFire] = new CheckboxWidget(boss, font, xpos, ypos, "Fire", CheckboxWidget::kCheckActionCmd); myPins[kJFire]->setID(kJFire); myPins[kJFire]->setTarget(this); + + addFocusWidget(myPins[kJUp]); + addFocusWidget(myPins[kJLeft]); + addFocusWidget(myPins[kJRight]); + addFocusWidget(myPins[kJDown]); + addFocusWidget(myPins[kJFire]); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/debugger/gui/KeyboardWidget.cxx b/src/debugger/gui/KeyboardWidget.cxx index 296217d1e..1496b172c 100644 --- a/src/debugger/gui/KeyboardWidget.cxx +++ b/src/debugger/gui/KeyboardWidget.cxx @@ -47,6 +47,7 @@ KeyboardWidget::KeyboardWidget(GuiObject* boss, const GUI::Font& font, xpos = x + 30; ypos += myBox[i]->getHeight() + 5; } + addFocusWidget(myBox[i]); } myEvent = leftport ? ourLeftEvents.data() : ourRightEvents.data(); } diff --git a/src/debugger/gui/PaddleWidget.cxx b/src/debugger/gui/PaddleWidget.cxx index 87d9fe6ec..d3e31d656 100644 --- a/src/debugger/gui/PaddleWidget.cxx +++ b/src/debugger/gui/PaddleWidget.cxx @@ -19,49 +19,90 @@ #include "PaddleWidget.hxx" // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -PaddleWidget::PaddleWidget(GuiObject* boss, const GUI::Font& font, - int x, int y, Controller& controller) +PaddleWidget::PaddleWidget(GuiObject* boss, const GUI::Font& font, int x, int y, + Controller& controller, bool embedded, bool second) : ControllerWidget(boss, font, x, y, controller) { bool leftport = isLeftPort(); const string& label = getHeader(); + const int fontHeight = font.getFontHeight(); - const int fontHeight = font.getFontHeight(), - lineHeight = font.getLineHeight(); - int xpos = x, ypos = y, lwidth = font.getStringWidth("Right (Paddles)"); + int xpos = x, ypos = y, + lwidth = font.getStringWidth("Right (Paddles)"); - new StaticTextWidget(boss, font, xpos, ypos+2, lwidth, - fontHeight, label); + if(!embedded) + { + new StaticTextWidget(boss, font, xpos, ypos + 2, lwidth, + _lineHeight, label); + ypos += _lineHeight + fontHeight + 2; - ypos += lineHeight + 20; - const string& p0string = leftport ? "P0 pot " : "P2 pot "; - const string& p1string = leftport ? "P1 pot " : "P3 pot "; - myP0Resistance = - new SliderWidget(boss, font, xpos, ypos, - p0string, 0, kP0Changed); + const string& p0string = leftport ? "P1 pot " : "P3 pot "; + const string& p1string = leftport ? "P2 pot " : "P4 pot "; + myP0Resistance = + new SliderWidget(boss, font, xpos, ypos, + p0string, 0, kP0Changed); + + xpos += 20; ypos += myP0Resistance->getHeight() * 1.33; + myP0Fire = new CheckboxWidget(boss, font, xpos, ypos, + "Fire", kP0Fire); + + xpos = x; ypos += _lineHeight * 2.25; + myP1Resistance = + new SliderWidget(boss, font, xpos, ypos, + p1string, 0, kP1Changed); + + xpos += 20; ypos += myP1Resistance->getHeight() * 1.33; + myP1Fire = new CheckboxWidget(boss, font, xpos, ypos, + "Fire", kP1Fire); + } + else + { + const string& p0string = leftport ? second ? "P1b" : "P1a" + : second ? "P3b" : "P3a"; + const string& p1string = leftport ? second ? "P2b" : "P2a" + : second ? "P4b" : "P4a"; + + new StaticTextWidget(boss, font, xpos, ypos + 2, p0string); + + //ypos += lineHeight; + myP0Resistance = new SliderWidget(boss, font, xpos, ypos); + myP0Resistance->setEnabled(false); + myP0Resistance->setFlags(Widget::FLAG_INVISIBLE); + + ypos += _lineHeight * 1.33; + myP0Fire = new CheckboxWidget(boss, font, xpos, ypos, + "Fire", kP0Fire); + + xpos = x; ypos += _lineHeight * 2.25; + new StaticTextWidget(boss, font, xpos, ypos + 2, p1string); + + //ypos += lineHeight; + myP1Resistance = new SliderWidget(boss, font, xpos, ypos); + myP1Resistance->setEnabled(false); + myP1Resistance->setFlags(Widget::FLAG_INVISIBLE); + + ypos += _lineHeight * 1.33; + myP1Fire = new CheckboxWidget(boss, font, xpos, ypos, + "Fire", kP1Fire); + } myP0Resistance->setMinValue(0); myP0Resistance->setMaxValue(uInt32(Paddles::MAX_RESISTANCE)); myP0Resistance->setStepValue(uInt32(Paddles::MAX_RESISTANCE/100)); myP0Resistance->setTarget(this); - xpos += 20; ypos += myP0Resistance->getHeight() + 4; - myP0Fire = new CheckboxWidget(boss, font, xpos, ypos, - "Fire", kP0Fire); myP0Fire->setTarget(this); - xpos = x; ypos += 2*lineHeight; - myP1Resistance = - new SliderWidget(boss, font, xpos, ypos, - p1string, 0, kP1Changed); myP1Resistance->setMinValue(0); myP1Resistance->setMaxValue(uInt32(Paddles::MAX_RESISTANCE)); myP1Resistance->setStepValue(uInt32(Paddles::MAX_RESISTANCE/100)); myP1Resistance->setTarget(this); - xpos += 20; ypos += myP1Resistance->getHeight() + 4; - myP1Fire = new CheckboxWidget(boss, font, xpos, ypos, - "Fire", kP1Fire); myP1Fire->setTarget(this); + + addFocusWidget(myP0Resistance); + addFocusWidget(myP0Fire); + addFocusWidget(myP1Resistance); + addFocusWidget(myP1Fire); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/debugger/gui/PaddleWidget.hxx b/src/debugger/gui/PaddleWidget.hxx index 8773b5a1d..e3034c80c 100644 --- a/src/debugger/gui/PaddleWidget.hxx +++ b/src/debugger/gui/PaddleWidget.hxx @@ -26,7 +26,8 @@ class PaddleWidget : public ControllerWidget { public: PaddleWidget(GuiObject* boss, const GUI::Font& font, int x, int y, - Controller& controller); + Controller& controller, + bool embedded = false, bool second = false); ~PaddleWidget() override = default; private: diff --git a/src/debugger/gui/PointingDeviceWidget.cxx b/src/debugger/gui/PointingDeviceWidget.cxx index 43bbc4ed5..56127c83c 100644 --- a/src/debugger/gui/PointingDeviceWidget.cxx +++ b/src/debugger/gui/PointingDeviceWidget.cxx @@ -68,6 +68,12 @@ PointingDeviceWidget::PointingDeviceWidget(GuiObject* boss, const GUI::Font& fon myFire = new CheckboxWidget(boss, font, xLeft, ypos, "Fire", kTBFire); myFire->setTarget(this); + + addFocusWidget(myGrayUp); + addFocusWidget(myGrayLeft); + addFocusWidget(myGrayRight); + addFocusWidget(myGrayDown); + addFocusWidget(myFire); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/debugger/gui/QuadTariWidget.cxx b/src/debugger/gui/QuadTariWidget.cxx index 23db86995..3ab7c0e78 100644 --- a/src/debugger/gui/QuadTariWidget.cxx +++ b/src/debugger/gui/QuadTariWidget.cxx @@ -19,9 +19,13 @@ #include "Console.hxx" #include "TIA.hxx" #include "QuadTari.hxx" +#include "AtariVoxWidget.hxx" #include "DrivingWidget.hxx" #include "JoystickWidget.hxx" #include "NullControlWidget.hxx" +#include "PaddleWidget.hxx" +#include "SaveKeyWidget.hxx" + #include "QuadTariWidget.hxx" // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -29,54 +33,55 @@ QuadTariWidget::QuadTariWidget(GuiObject* boss, const GUI::Font& font, int x, int y, Controller& controller) : ControllerWidget(boss, font, x, y, controller) { - const int fontWidth = font.getMaxCharWidth(), - fontHeight = font.getFontHeight(); string label = (isLeftPort() ? "Left" : "Right") + string(" (QuadTari)"); StaticTextWidget* t = new StaticTextWidget(boss, font, x, y + 2, label); QuadTari& qt = static_cast(controller); - // TODO: support multiple controller types - switch(qt.myFirstController->type()) - { - case Controller::Type::Joystick: - x += fontWidth * 2; - y = t->getBottom() + fontHeight; - myFirstControl = new JoystickWidget(boss, font, x, y, *qt.myFirstController, true); - break; - - case Controller::Type::Driving: - y = t->getBottom() + font.getFontHeight() * 1; - myFirstControl = new DrivingWidget(boss, font, x, y, *qt.myFirstController, true); - break; - - default: - y = t->getBottom() + font.getFontHeight() * 1.25; - myFirstControl = new NullControlWidget(boss, font, x, y, *qt.myFirstController, true); - break; - } - - x = t->getLeft() + fontWidth * 10; - switch(qt.mySecondController->type()) - { - case Controller::Type::Joystick: - x += fontWidth * 2; - y = t->getBottom() + fontHeight; - mySecondControl = new JoystickWidget(boss, font, x, y, *qt.mySecondController, true); - break; - - case Controller::Type::Driving: - y = t->getBottom() + font.getFontHeight(); - myFirstControl = new DrivingWidget(boss, font, x, y, *qt.mySecondController, true); - break; - - default: - y = t->getBottom() + font.getFontHeight() * 1.25; - mySecondControl = new NullControlWidget(boss, font, x, y, *qt.mySecondController, true); - break; - } + y = t->getBottom() + _lineHeight; + addController(boss, x, y, *qt.myFirstController, false); + addController(boss, x, y, *qt.mySecondController, true); myPointer = new StaticTextWidget(boss, font, - t->getLeft() + font.getMaxCharWidth() * 7, y, " "); + t->getLeft() + _fontWidth * 7, y, " "); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void QuadTariWidget::addController(GuiObject* boss, int x, int y, + Controller& controller, bool second) +{ + ControllerWidget* widget; + + x += second ? _fontWidth * 10 : 0; + switch(controller.type()) + { + case Controller::Type::Joystick: + x += _fontWidth * 2; + widget = new JoystickWidget(boss, _font, x, y, controller, true); + break; + + case Controller::Type::Driving: + widget = new DrivingWidget(boss, _font, x, y, controller, true); + break; + + case Controller::Type::Paddles: + widget = new PaddleWidget(boss, _font, x, y, controller, true, second); + break; + + case Controller::Type::AtariVox: + widget = new AtariVoxWidget(boss, _font, x, y, controller, true); + break; + + case Controller::Type::SaveKey: + widget = new SaveKeyWidget(boss, _font, x, y, controller, true); + break; + + default: + widget = new NullControlWidget(boss, _font, x, y, controller, true); + break; + } + WidgetArray focusList = widget->getFocusList(); + if(!focusList.empty()) + addToFocusList(focusList); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/debugger/gui/QuadTariWidget.hxx b/src/debugger/gui/QuadTariWidget.hxx index cccdf1575..2af39743b 100644 --- a/src/debugger/gui/QuadTariWidget.hxx +++ b/src/debugger/gui/QuadTariWidget.hxx @@ -35,12 +35,13 @@ class QuadTariWidget: public ControllerWidget } private: - ControllerWidget* myFirstControl{nullptr}; - ControllerWidget* mySecondControl{nullptr}; StaticTextWidget* myPointer{nullptr}; void loadConfig() override; + void addController(GuiObject* boss, int x, int y, + Controller& controller, bool second); + // Following constructors and assignment operators not supported QuadTariWidget() = delete; QuadTariWidget(const QuadTariWidget&) = delete; diff --git a/src/debugger/gui/RiotWidget.cxx b/src/debugger/gui/RiotWidget.cxx index 171da0cd6..883772062 100644 --- a/src/debugger/gui/RiotWidget.cxx +++ b/src/debugger/gui/RiotWidget.cxx @@ -141,9 +141,11 @@ RiotWidget::RiotWidget(GuiObject* boss, const GUI::Font& lfont, xpos = col; ypos = 10; myLeftControl = addControlWidget(boss, lfont, xpos, ypos, instance().console().leftController()); + addToFocusList(myLeftControl->getFocusList()); xpos += myLeftControl->getWidth() + 15; myRightControl = addControlWidget(boss, lfont, xpos, ypos, instance().console().rightController()); + addToFocusList(myRightControl->getFocusList()); // TIA INPTx registers (R), left port static constexpr std::array contLeftReadNames = { diff --git a/src/debugger/gui/RomListWidget.cxx b/src/debugger/gui/RomListWidget.cxx index 6e450e334..07bbbf668 100644 --- a/src/debugger/gui/RomListWidget.cxx +++ b/src/debugger/gui/RomListWidget.cxx @@ -40,7 +40,7 @@ RomListWidget::RomListWidget(GuiObject* boss, const GUI::Font& lfont, _textcolorhi = kTextColor; _cols = w / _fontWidth; - _rows = h / _fontHeight; + _rows = h / _lineHeight; // Set real dimensions _w = w - ScrollBarWidget::scrollBarWidth(_font); @@ -67,8 +67,8 @@ RomListWidget::RomListWidget(GuiObject* boss, const GUI::Font& lfont, // rowheight is determined by largest item on a line, // possibly meaning that number of rows will change - _fontHeight = std::max(_fontHeight, CheckboxWidget::boxSize(_font)); - _rows = h / _fontHeight; + _lineHeight = std::max(_lineHeight, CheckboxWidget::boxSize(_font)); + _rows = h / _lineHeight; // Create a CheckboxWidget for each row in the list for(int i = 0; i < _rows; ++i) @@ -79,7 +79,7 @@ RomListWidget::RomListWidget(GuiObject* boss, const GUI::Font& lfont, t->setID(i); t->setFill(CheckboxWidget::FillType::Circle); t->setTextColor(kTextColorEm); - ypos += _fontHeight; + ypos += _lineHeight; myCheckList.push_back(t); } @@ -175,7 +175,7 @@ void RomListWidget::setHighlighted(int item) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - int RomListWidget::findItem(int x, int y) const { - return (y - 1) / _fontHeight + _currentPos; + return (y - 1) / _lineHeight + _currentPos; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -479,7 +479,7 @@ 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 += _fontHeight) + for (i = 0, pos = _currentPos; i < _rows && pos < len; i++, pos++, ypos += _lineHeight) { ColorId bytesColor = textColor; @@ -493,18 +493,18 @@ void RomListWidget::drawWidget(bool hilite) // Draw highlighted item in a frame if (_highlightedItem == pos) - s.frameRect(_x + l.x() - 3, ypos - 1, _w - l.x(), _fontHeight, onTop ? kWidColorHi : kBGColorLo); + s.frameRect(_x + l.x() - 3, ypos - 1, _w - l.x(), _lineHeight, onTop ? kWidColorHi : kBGColorLo); // Draw the selected item inverted, on a highlighted background. if(_selectedItem == pos && _hasFocus) { if(!_editMode) { - s.fillRect(_x + r.x() - 3, ypos - 1, r.w(), _fontHeight, kTextColorHi); + s.fillRect(_x + r.x() - 3, ypos - 1, r.w(), _lineHeight, kTextColorHi); bytesColor = kTextColorInv; } else - s.frameRect(_x + r.x() - 3, ypos - 1, r.w(), _fontHeight, kWidColorHi); + s.frameRect(_x + r.x() - 3, ypos - 1, r.w(), _lineHeight, kWidColorHi); } // Draw labels @@ -537,7 +537,7 @@ void RomListWidget::drawWidget(bool hilite) } // Draw separator - s.vLine(_x + r.x() - 7, ypos, ypos + _fontHeight - 1, kColor); + s.vLine(_x + r.x() - 7, ypos, ypos + _lineHeight - 1, kColor); // Draw bytes { @@ -567,20 +567,20 @@ void RomListWidget::drawWidget(bool hilite) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Common::Rect RomListWidget::getLineRect() const { - const int yoffset = std::max(0, (_selectedItem - _currentPos) * _fontHeight), + const int yoffset = std::max(0, (_selectedItem - _currentPos) * _lineHeight), xoffset = CheckboxWidget::boxSize(_font) + 10; return Common::Rect(2 + xoffset, 1 + yoffset, - _w - (xoffset - 15), _fontHeight + yoffset); + _w - (xoffset - 15), _lineHeight + yoffset); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Common::Rect RomListWidget::getEditRect() const { - const int yoffset = std::max(0, (_selectedItem - _currentPos) * _fontHeight); + const int yoffset = std::max(0, (_selectedItem - _currentPos) * _lineHeight); return Common::Rect(2 + _w - _bytesWidth, 1 + yoffset, - _w, _fontHeight + yoffset); + _w, _lineHeight + yoffset); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/debugger/gui/SaveKeyWidget.cxx b/src/debugger/gui/SaveKeyWidget.cxx index eb6602ad3..92c58329e 100644 --- a/src/debugger/gui/SaveKeyWidget.cxx +++ b/src/debugger/gui/SaveKeyWidget.cxx @@ -20,10 +20,10 @@ // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SaveKeyWidget::SaveKeyWidget(GuiObject* boss, const GUI::Font& font, - int x, int y, Controller& controller) + int x, int y, Controller& controller, bool embedded) : FlashWidget(boss, font, x, y, controller) { - init(boss, font, x, y); + init(boss, font, x, y, embedded); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/debugger/gui/SaveKeyWidget.hxx b/src/debugger/gui/SaveKeyWidget.hxx index 3a646f2d4..e3e6b5213 100644 --- a/src/debugger/gui/SaveKeyWidget.hxx +++ b/src/debugger/gui/SaveKeyWidget.hxx @@ -26,7 +26,7 @@ class SaveKeyWidget : public FlashWidget { public: SaveKeyWidget(GuiObject* boss, const GUI::Font& font, int x, int y, - Controller& controller); + Controller& controller, bool embedded = false); ~SaveKeyWidget() override = default; private: diff --git a/src/gui/CheckListWidget.cxx b/src/gui/CheckListWidget.cxx index 0e5a46d82..1e6db844a 100644 --- a/src/gui/CheckListWidget.cxx +++ b/src/gui/CheckListWidget.cxx @@ -29,8 +29,8 @@ CheckListWidget::CheckListWidget(GuiObject* boss, const GUI::Font& font, // rowheight is determined by largest item on a line, // possibly meaning that number of rows will change - _fontHeight = std::max(_fontHeight, CheckboxWidget::boxSize(_font)); - _rows = h / _fontHeight; + _lineHeight = std::max(_lineHeight, CheckboxWidget::boxSize(_font)); + _rows = h / _lineHeight; // Create a CheckboxWidget for each row in the list for(int i = 0; i < _rows; ++i) @@ -40,7 +40,7 @@ CheckListWidget::CheckListWidget(GuiObject* boss, const GUI::Font& font, t->setTextColor(kTextColor); t->setTarget(this); t->setID(i); - ypos += _fontHeight; + ypos += _lineHeight; _checkList.push_back(t); } @@ -110,7 +110,7 @@ void CheckListWidget::drawWidget(bool hilite) _checkList[i]->setDirty(); _checkList[i]->draw(); - const int y = _y + 2 + _fontHeight * i + 2; + const int y = _y + 2 + _lineHeight * i + 2; ColorId textColor = kTextColor; Common::Rect r(getEditRect()); @@ -120,13 +120,13 @@ void CheckListWidget::drawWidget(bool hilite) { if(_hasFocus && !_editMode) { - s.fillRect(_x + r.x() - 3, _y + 1 + _fontHeight * i, - _w - r.x(), _fontHeight, kTextColorHi); + s.fillRect(_x + r.x() - 3, _y + 1 + _lineHeight * i, + _w - r.x(), _lineHeight, kTextColorHi); textColor = kTextColorInv; } else - s.frameRect(_x + r.x() - 3, _y + 1 + _fontHeight * i, - _w - r.x(), _fontHeight, onTop ? kTextColorHi : kColor); + s.frameRect(_x + r.x() - 3, _y + 1 + _lineHeight * i, + _w - r.x(), _lineHeight, onTop ? kTextColorHi : kColor); } if (_selectedItem == pos && _editMode) @@ -149,11 +149,11 @@ void CheckListWidget::drawWidget(bool hilite) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Common::Rect CheckListWidget::getEditRect() const { - const int yoffset = (_selectedItem - _currentPos) * _fontHeight, + const int yoffset = (_selectedItem - _currentPos) * _lineHeight, xoffset = CheckboxWidget::boxSize(_font) + 10; return Common::Rect(2 + xoffset, 1 + yoffset, - _w - (xoffset - 15), _fontHeight + yoffset); + _w - (xoffset - 15), _lineHeight + yoffset); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/gui/ListWidget.cxx b/src/gui/ListWidget.cxx index aa8ed9455..1ac71eb35 100644 --- a/src/gui/ListWidget.cxx +++ b/src/gui/ListWidget.cxx @@ -36,7 +36,7 @@ ListWidget::ListWidget(GuiObject* boss, const GUI::Font& font, _textcolorhi = kTextColor; _cols = w / _fontWidth; - _rows = h / _fontHeight; + _rows = h / _lineHeight; // Set real dimensions _w = w - ScrollBarWidget::scrollBarWidth(_font); @@ -236,7 +236,7 @@ void ListWidget::handleMouseWheel(int x, int y, int direction) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - int ListWidget::findItem(int x, int y) const { - return (y - 1) / _fontHeight + _currentPos; + return (y - 1) / _lineHeight + _currentPos; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/gui/StringListWidget.cxx b/src/gui/StringListWidget.cxx index 46aed13ba..0c0a8ba08 100644 --- a/src/gui/StringListWidget.cxx +++ b/src/gui/StringListWidget.cxx @@ -79,7 +79,7 @@ void StringListWidget::drawWidget(bool hilite) // Draw the list items for (i = 0, pos = _currentPos; i < _rows && pos < len; i++, pos++) { - const int y = _y + 2 + _fontHeight * i; + const int y = _y + 2 + _lineHeight * i; ColorId textColor = onTop ? kTextColor : kShadowColor; // Draw the selected item inverted, on a highlighted background. @@ -87,11 +87,11 @@ void StringListWidget::drawWidget(bool hilite) { if(_hasFocus && !_editMode) { - s.fillRect(_x + 1, _y + 1 + _fontHeight * i, _w - 1, _fontHeight, kTextColorHi); + s.fillRect(_x + 1, _y + 1 + _lineHeight * i, _w - 1, _lineHeight, kTextColorHi); textColor = kTextColorInv; } else - s.frameRect(_x + 1, _y + 1 + _fontHeight * i, _w - 1, _fontHeight, kWidColorHi); + s.frameRect(_x + 1, _y + 1 + _lineHeight * i, _w - 1, _lineHeight, kWidColorHi); } Common::Rect r(getEditRect()); @@ -115,6 +115,6 @@ void StringListWidget::drawWidget(bool hilite) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Common::Rect StringListWidget::getEditRect() const { - const int offset = std::max(0, (_selectedItem - _currentPos) * _fontHeight); - return Common::Rect(_textOfs, 1 + offset, _w - _textOfs, _fontHeight + offset); + const int offset = std::max(0, (_selectedItem - _currentPos) * _lineHeight); + return Common::Rect(_textOfs, 1 + offset, _w - _textOfs, _lineHeight + offset); } diff --git a/src/gui/TabWidget.cxx b/src/gui/TabWidget.cxx index accd65445..f1b92b876 100644 --- a/src/gui/TabWidget.cxx +++ b/src/gui/TabWidget.cxx @@ -292,7 +292,7 @@ void TabWidget::drawWidget(bool hilite) ? onTop ? kDlgColor : kBGColorLo : onTop ? kBGColorHi : kDlgColor); // ? kWidColor : kDlgColor s.drawString(_font, _tabs[i].title, x + kTabPadding + yOffset, - _y + yOffset + (_tabHeight - _fontHeight - 1), + _y + yOffset + (_tabHeight - _lineHeight - 1), tabWidth - 2 * kTabPadding, fontcolor, TextAlign::Center); if(i == _activeTab) { diff --git a/src/gui/Widget.cxx b/src/gui/Widget.cxx index ed6ba2f02..a54d9e45c 100644 --- a/src/gui/Widget.cxx +++ b/src/gui/Widget.cxx @@ -39,7 +39,7 @@ Widget::Widget(GuiObject* boss, const GUI::Font& font, _boss->_firstWidget = this; _fontWidth = _font.getMaxCharWidth(); - _fontHeight = _font.getLineHeight(); + _lineHeight = _font.getLineHeight(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -466,7 +466,7 @@ void ButtonWidget::drawWidget(bool hilite) s.frameRect(_x, _y, _w, _h, !onTop ? kShadowColor : hilite && isEnabled() ? kBtnBorderColorHi : kBtnBorderColor); if (!_useBitmap) - s.drawString(_font, _label, _x, _y + (_h - _fontHeight)/2 + 1, _w, + s.drawString(_font, _label, _x, _y + (_h - _lineHeight)/2 + 1, _w, !(isEnabled() && onTop) ? _textcolorlo : hilite ? _textcolorhi : _textcolor, _align); else diff --git a/src/gui/Widget.hxx b/src/gui/Widget.hxx index 3add250ba..91fffff04 100644 --- a/src/gui/Widget.hxx +++ b/src/gui/Widget.hxx @@ -139,7 +139,7 @@ class Widget : public GuiObject uInt32 _flags{0}; bool _hasFocus{false}; int _fontWidth{0}; - int _fontHeight{0}; + int _lineHeight{0}; ColorId _bgcolor{kWidColor}; ColorId _bgcolorhi{kWidColor}; ColorId _bgcolorlo{kBGColorLo};