added more controller widget support for QuadTari

added tabbing through controller widgets
This commit is contained in:
Thomas Jentzsch 2020-09-07 15:37:45 +02:00
parent 978ad7c270
commit 500253323a
24 changed files with 257 additions and 155 deletions

View File

@ -20,10 +20,11 @@
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
AtariVoxWidget::AtariVoxWidget(GuiObject* boss, const GUI::Font& font, 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) : FlashWidget(boss, font, x, y, controller)
{ {
init(boss, font, x, y); init(boss, font, x, y, embedded);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -26,7 +26,7 @@ class AtariVoxWidget : public FlashWidget
{ {
public: public:
AtariVoxWidget(GuiObject* boss, const GUI::Font& font, int x, int y, AtariVoxWidget(GuiObject* boss, const GUI::Font& font, int x, int y,
Controller& controller); Controller& controller, bool embedded = false);
~AtariVoxWidget() override = default; ~AtariVoxWidget() override = default;
private: private:

View File

@ -73,6 +73,14 @@ BoosterWidget::BoosterWidget(GuiObject* boss, const GUI::Font& font,
CheckboxWidget::kCheckActionCmd); CheckboxWidget::kCheckActionCmd);
myPins[kJTrigger]->setID(kJTrigger); myPins[kJTrigger]->setID(kJTrigger);
myPins[kJTrigger]->setTarget(this); 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]);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -25,49 +25,56 @@ DrivingWidget::DrivingWidget(GuiObject* boss, const GUI::Font& font,
{ {
const string& label = getHeader(); const string& label = getHeader();
const int fontHeight = font.getFontHeight(), const int lineHeight = font.getLineHeight(),
fontWidth = font.getMaxCharWidth(), bHeight = font.getLineHeight() * 1.25;
bheight = font.getLineHeight() + 4; int xpos = x, ypos = y;
int xpos = x, ypos = y, lwidth = font.getStringWidth("Right (Driving)");
StaticTextWidget* t;
if(embedded) 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); "GC+", kGrayUpCmd);
ypos += myGrayUp->getHeight() + 5; ypos += myGrayUp->getHeight() + bHeight * 0.3;
myGrayDown = new ButtonWidget(boss, font, xpos, ypos, bwidth, bheight, myGrayDown = new ButtonWidget(boss, font, xpos, ypos, bWidth, bHeight,
"GC-", kGrayDownCmd); "GC-", kGrayDownCmd);
xpos += myGrayDown->getWidth() + _fontWidth * 0.75;
} }
else else
{ {
const int bwidth = font.getStringWidth("Gray code +") + 10; const int lwidth = font.getStringWidth("Right (Driving)"),
t = new StaticTextWidget(boss, font, xpos, ypos + 2, lwidth, bWidth = font.getStringWidth("Gray code +") + _fontWidth * 1.25;
fontHeight, label, TextAlign::Left);
ypos += t->getHeight() + 20; StaticTextWidget* t = new StaticTextWidget(boss, font, xpos, ypos + 2, lwidth,
myGrayUp = new ButtonWidget(boss, font, xpos, ypos, bwidth, bheight, lineHeight, label, TextAlign::Left);
ypos = t->getBottom() + _lineHeight * 1.334;
myGrayUp = new ButtonWidget(boss, font, xpos, ypos, bWidth, bHeight,
"Gray code +", kGrayUpCmd); "Gray code +", kGrayUpCmd);
ypos += myGrayUp->getHeight() + 5; ypos += myGrayUp->getHeight() + bHeight * 0.3;
myGrayDown = new ButtonWidget(boss, font, xpos, ypos, bwidth, bheight, myGrayDown = new ButtonWidget(boss, font, xpos, ypos, bWidth, bHeight,
"Gray code -", kGrayDownCmd); "Gray code -", kGrayDownCmd);
xpos += myGrayDown->getWidth() + _fontWidth;
} }
myGrayUp->setTarget(this); ypos -= bHeight * 0.6;
myGrayDown->setTarget(this);
xpos += myGrayDown->getWidth() + fontWidth; ypos -= 10;
myGrayValue = new DataGridWidget(boss, font, xpos, ypos, myGrayValue = new DataGridWidget(boss, font, xpos, ypos,
1, 1, 2, 8, Common::Base::Fmt::_16); 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->setTarget(this);
myGrayValue->setEditable(false); myGrayValue->setEditable(false);
xpos = x + fontWidth*3; ypos += myGrayDown->getHeight() + 20;
myFire = new CheckboxWidget(boss, font, xpos, ypos, "Fire", kFireCmd);
myFire->setTarget(this); myFire->setTarget(this);
addFocusWidget(myGrayUp);
addFocusWidget(myGrayDown);
addFocusWidget(myFire);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -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; int xpos = x, ypos = y;
myEmbedded = embedded;
if(!embedded)
{
new StaticTextWidget(boss, font, xpos, ypos + 2, getHeader()); new StaticTextWidget(boss, font, xpos, ypos + 2, getHeader());
ypos += lineHeight + 6; ypos += _lineHeight * 1.4;
new StaticTextWidget(boss, font, xpos, ypos, "Pages/Ranges used:"); new StaticTextWidget(boss, font, xpos, ypos, "Pages/Ranges used:");
}
else
{
ypos += _lineHeight * 0.4 - (2 + _lineHeight);
new StaticTextWidget(boss, font, xpos, ypos, "Pages:");
}
ypos += lineHeight + 2; ypos += _lineHeight + 2;
xpos += 8; xpos += 8;
for(uInt32 page = 0; page < MAX_PAGES; ++page) for(uInt32 page = 0; page < MAX_PAGES; ++page)
{ {
myPage[page] = new StaticTextWidget(boss, font, xpos, ypos, myPage[page] = new StaticTextWidget(boss, font, xpos, ypos,
page ? " " : "none "); embedded ? page ? " " : "none"
ypos += lineHeight; : page ? " " : "none ");
ypos += _lineHeight;
} }
xpos -= 8; ypos += 2; xpos -= 8; ypos += 2;
myEEPROMEraseCurrent = new ButtonWidget(boss, font, xpos, ypos, myEEPROMEraseCurrent = new ButtonWidget(boss, font, xpos, ypos,
"Erase used pages", kEEPROMEraseCurrent); embedded ? "Erase" : "Erase used pages",
kEEPROMEraseCurrent);
myEEPROMEraseCurrent->setTarget(this); myEEPROMEraseCurrent->setTarget(this);
addFocusWidget(myEEPROMEraseCurrent);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -86,12 +98,14 @@ void FlashWidget::loadConfig()
label.str(""); label.str("");
label << Common::Base::HEX3 << startPage; label << Common::Base::HEX3 << startPage;
if(!myEmbedded)
{
if(int(page) - 1 != startPage) if(int(page) - 1 != startPage)
label << "-" << Common::Base::HEX3 << page - 1; label << "-" << Common::Base::HEX3 << page - 1;
else else
label << " "; label << " ";
label << ": " << Common::Base::HEX4 << from << "-" << Common::Base::HEX4 << to; label << ": " << Common::Base::HEX4 << from << "-" << Common::Base::HEX4 << to;
}
myPage[useCount]->setLabel(label.str()); myPage[useCount]->setLabel(label.str());
startPage = -1; startPage = -1;

View File

@ -31,12 +31,14 @@ class FlashWidget : public ControllerWidget
~FlashWidget() override = default; ~FlashWidget() override = default;
protected: 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: private:
ButtonWidget* myEEPROMEraseCurrent{nullptr};
enum { kEEPROMEraseCurrent = 'eeEC' }; enum { kEEPROMEraseCurrent = 'eeEC' };
bool myEmbedded{false};
ButtonWidget* myEEPROMEraseCurrent{nullptr};
static constexpr uInt32 MAX_PAGES = 5; static constexpr uInt32 MAX_PAGES = 5;
std::array<StaticTextWidget*, MAX_PAGES> myPage{nullptr}; std::array<StaticTextWidget*, MAX_PAGES> myPage{nullptr};

View File

@ -67,6 +67,13 @@ GenesisWidget::GenesisWidget(GuiObject* boss, const GUI::Font& font,
CheckboxWidget::kCheckActionCmd); CheckboxWidget::kCheckActionCmd);
myPins[kJCbtn]->setID(kJCbtn); myPins[kJCbtn]->setID(kJCbtn);
myPins[kJCbtn]->setTarget(this); myPins[kJCbtn]->setTarget(this);
addFocusWidget(myPins[kJUp]);
addFocusWidget(myPins[kJLeft]);
addFocusWidget(myPins[kJRight]);
addFocusWidget(myPins[kJDown]);
addFocusWidget(myPins[kJBbtn]);
addFocusWidget(myPins[kJCbtn]);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -23,17 +23,17 @@ JoystickWidget::JoystickWidget(GuiObject* boss, const GUI::Font& font,
bool embedded) bool embedded)
: ControllerWidget(boss, font, x, y, controller) : ControllerWidget(boss, font, x, y, controller)
{ {
const int fontHeight = font.getFontHeight();
int xpos = x, ypos = y; int xpos = x, ypos = y;
if(!embedded) if(!embedded)
{ {
const string& label = getHeader(); const string& label = getHeader();
const int fontHeight = font.getFontHeight(); const int lwidth = font.getStringWidth("Right (Joystick)");
int lwidth = font.getStringWidth("Right (Joystick)");
StaticTextWidget* t; StaticTextWidget* t;
t = new StaticTextWidget(boss, font, xpos, ypos + 2, lwidth, 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; xpos += t->getWidth() / 2 - 5; ypos = t->getBottom() + fontHeight;
} }
myPins[kJUp] = new CheckboxWidget(boss, font, xpos, ypos, "", myPins[kJUp] = new CheckboxWidget(boss, font, xpos, ypos, "",
@ -61,11 +61,17 @@ JoystickWidget::JoystickWidget(GuiObject* boss, const GUI::Font& font,
myPins[kJRight]->setTarget(this); myPins[kJRight]->setTarget(this);
xpos -= (myPins[kJUp]->getWidth() + 5) * 2; 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", myPins[kJFire] = new CheckboxWidget(boss, font, xpos, ypos, "Fire",
CheckboxWidget::kCheckActionCmd); CheckboxWidget::kCheckActionCmd);
myPins[kJFire]->setID(kJFire); myPins[kJFire]->setID(kJFire);
myPins[kJFire]->setTarget(this); myPins[kJFire]->setTarget(this);
addFocusWidget(myPins[kJUp]);
addFocusWidget(myPins[kJLeft]);
addFocusWidget(myPins[kJRight]);
addFocusWidget(myPins[kJDown]);
addFocusWidget(myPins[kJFire]);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -47,6 +47,7 @@ KeyboardWidget::KeyboardWidget(GuiObject* boss, const GUI::Font& font,
xpos = x + 30; xpos = x + 30;
ypos += myBox[i]->getHeight() + 5; ypos += myBox[i]->getHeight() + 5;
} }
addFocusWidget(myBox[i]);
} }
myEvent = leftport ? ourLeftEvents.data() : ourRightEvents.data(); myEvent = leftport ? ourLeftEvents.data() : ourRightEvents.data();
} }

View File

@ -19,49 +19,90 @@
#include "PaddleWidget.hxx" #include "PaddleWidget.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PaddleWidget::PaddleWidget(GuiObject* boss, const GUI::Font& font, PaddleWidget::PaddleWidget(GuiObject* boss, const GUI::Font& font, int x, int y,
int x, int y, Controller& controller) Controller& controller, bool embedded, bool second)
: ControllerWidget(boss, font, x, y, controller) : ControllerWidget(boss, font, x, y, controller)
{ {
bool leftport = isLeftPort(); bool leftport = isLeftPort();
const string& label = getHeader(); const string& label = getHeader();
const int fontHeight = font.getFontHeight();
const int fontHeight = font.getFontHeight(), int xpos = x, ypos = y,
lineHeight = font.getLineHeight(); lwidth = font.getStringWidth("Right (Paddles)");
int xpos = x, ypos = y, lwidth = font.getStringWidth("Right (Paddles)");
new StaticTextWidget(boss, font, xpos, ypos+2, lwidth, if(!embedded)
fontHeight, label); {
new StaticTextWidget(boss, font, xpos, ypos + 2, lwidth,
_lineHeight, label);
ypos += _lineHeight + fontHeight + 2;
ypos += lineHeight + 20; const string& p0string = leftport ? "P1 pot " : "P3 pot ";
const string& p0string = leftport ? "P0 pot " : "P2 pot "; const string& p1string = leftport ? "P2 pot " : "P4 pot ";
const string& p1string = leftport ? "P1 pot " : "P3 pot ";
myP0Resistance = myP0Resistance =
new SliderWidget(boss, font, xpos, ypos, new SliderWidget(boss, font, xpos, ypos,
p0string, 0, kP0Changed); 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->setMinValue(0);
myP0Resistance->setMaxValue(uInt32(Paddles::MAX_RESISTANCE)); myP0Resistance->setMaxValue(uInt32(Paddles::MAX_RESISTANCE));
myP0Resistance->setStepValue(uInt32(Paddles::MAX_RESISTANCE/100)); myP0Resistance->setStepValue(uInt32(Paddles::MAX_RESISTANCE/100));
myP0Resistance->setTarget(this); myP0Resistance->setTarget(this);
xpos += 20; ypos += myP0Resistance->getHeight() + 4;
myP0Fire = new CheckboxWidget(boss, font, xpos, ypos,
"Fire", kP0Fire);
myP0Fire->setTarget(this); myP0Fire->setTarget(this);
xpos = x; ypos += 2*lineHeight;
myP1Resistance =
new SliderWidget(boss, font, xpos, ypos,
p1string, 0, kP1Changed);
myP1Resistance->setMinValue(0); myP1Resistance->setMinValue(0);
myP1Resistance->setMaxValue(uInt32(Paddles::MAX_RESISTANCE)); myP1Resistance->setMaxValue(uInt32(Paddles::MAX_RESISTANCE));
myP1Resistance->setStepValue(uInt32(Paddles::MAX_RESISTANCE/100)); myP1Resistance->setStepValue(uInt32(Paddles::MAX_RESISTANCE/100));
myP1Resistance->setTarget(this); myP1Resistance->setTarget(this);
xpos += 20; ypos += myP1Resistance->getHeight() + 4;
myP1Fire = new CheckboxWidget(boss, font, xpos, ypos,
"Fire", kP1Fire);
myP1Fire->setTarget(this); myP1Fire->setTarget(this);
addFocusWidget(myP0Resistance);
addFocusWidget(myP0Fire);
addFocusWidget(myP1Resistance);
addFocusWidget(myP1Fire);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -26,7 +26,8 @@ class PaddleWidget : public ControllerWidget
{ {
public: public:
PaddleWidget(GuiObject* boss, const GUI::Font& font, int x, int y, PaddleWidget(GuiObject* boss, const GUI::Font& font, int x, int y,
Controller& controller); Controller& controller,
bool embedded = false, bool second = false);
~PaddleWidget() override = default; ~PaddleWidget() override = default;
private: private:

View File

@ -68,6 +68,12 @@ PointingDeviceWidget::PointingDeviceWidget(GuiObject* boss, const GUI::Font& fon
myFire = new CheckboxWidget(boss, font, xLeft, ypos, "Fire", kTBFire); myFire = new CheckboxWidget(boss, font, xLeft, ypos, "Fire", kTBFire);
myFire->setTarget(this); myFire->setTarget(this);
addFocusWidget(myGrayUp);
addFocusWidget(myGrayLeft);
addFocusWidget(myGrayRight);
addFocusWidget(myGrayDown);
addFocusWidget(myFire);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -19,9 +19,13 @@
#include "Console.hxx" #include "Console.hxx"
#include "TIA.hxx" #include "TIA.hxx"
#include "QuadTari.hxx" #include "QuadTari.hxx"
#include "AtariVoxWidget.hxx"
#include "DrivingWidget.hxx" #include "DrivingWidget.hxx"
#include "JoystickWidget.hxx" #include "JoystickWidget.hxx"
#include "NullControlWidget.hxx" #include "NullControlWidget.hxx"
#include "PaddleWidget.hxx"
#include "SaveKeyWidget.hxx"
#include "QuadTariWidget.hxx" #include "QuadTariWidget.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -29,54 +33,55 @@ QuadTariWidget::QuadTariWidget(GuiObject* boss, const GUI::Font& font,
int x, int y, Controller& controller) int x, int y, Controller& controller)
: ControllerWidget(boss, font, x, y, controller) : ControllerWidget(boss, font, x, y, controller)
{ {
const int fontWidth = font.getMaxCharWidth(),
fontHeight = font.getFontHeight();
string label = (isLeftPort() ? "Left" : "Right") + string(" (QuadTari)"); string label = (isLeftPort() ? "Left" : "Right") + string(" (QuadTari)");
StaticTextWidget* t = new StaticTextWidget(boss, font, x, y + 2, label); StaticTextWidget* t = new StaticTextWidget(boss, font, x, y + 2, label);
QuadTari& qt = static_cast<QuadTari&>(controller); QuadTari& qt = static_cast<QuadTari&>(controller);
// TODO: support multiple controller types y = t->getBottom() + _lineHeight;
switch(qt.myFirstController->type()) addController(boss, x, y, *qt.myFirstController, false);
{ addController(boss, x, y, *qt.mySecondController, true);
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;
}
myPointer = new StaticTextWidget(boss, font, 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);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -35,12 +35,13 @@ class QuadTariWidget: public ControllerWidget
} }
private: private:
ControllerWidget* myFirstControl{nullptr};
ControllerWidget* mySecondControl{nullptr};
StaticTextWidget* myPointer{nullptr}; StaticTextWidget* myPointer{nullptr};
void loadConfig() override; void loadConfig() override;
void addController(GuiObject* boss, int x, int y,
Controller& controller, bool second);
// Following constructors and assignment operators not supported // Following constructors and assignment operators not supported
QuadTariWidget() = delete; QuadTariWidget() = delete;
QuadTariWidget(const QuadTariWidget&) = delete; QuadTariWidget(const QuadTariWidget&) = delete;

View File

@ -141,9 +141,11 @@ RiotWidget::RiotWidget(GuiObject* boss, const GUI::Font& lfont,
xpos = col; ypos = 10; xpos = col; ypos = 10;
myLeftControl = addControlWidget(boss, lfont, xpos, ypos, myLeftControl = addControlWidget(boss, lfont, xpos, ypos,
instance().console().leftController()); instance().console().leftController());
addToFocusList(myLeftControl->getFocusList());
xpos += myLeftControl->getWidth() + 15; xpos += myLeftControl->getWidth() + 15;
myRightControl = addControlWidget(boss, lfont, xpos, ypos, myRightControl = addControlWidget(boss, lfont, xpos, ypos,
instance().console().rightController()); instance().console().rightController());
addToFocusList(myRightControl->getFocusList());
// TIA INPTx registers (R), left port // TIA INPTx registers (R), left port
static constexpr std::array<const char*, 3> contLeftReadNames = { static constexpr std::array<const char*, 3> contLeftReadNames = {

View File

@ -40,7 +40,7 @@ RomListWidget::RomListWidget(GuiObject* boss, const GUI::Font& lfont,
_textcolorhi = kTextColor; _textcolorhi = kTextColor;
_cols = w / _fontWidth; _cols = w / _fontWidth;
_rows = h / _fontHeight; _rows = h / _lineHeight;
// Set real dimensions // Set real dimensions
_w = w - ScrollBarWidget::scrollBarWidth(_font); _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, // rowheight is determined by largest item on a line,
// possibly meaning that number of rows will change // possibly meaning that number of rows will change
_fontHeight = std::max(_fontHeight, CheckboxWidget::boxSize(_font)); _lineHeight = std::max(_lineHeight, CheckboxWidget::boxSize(_font));
_rows = h / _fontHeight; _rows = h / _lineHeight;
// Create a CheckboxWidget for each row in the list // Create a CheckboxWidget for each row in the list
for(int i = 0; i < _rows; ++i) for(int i = 0; i < _rows; ++i)
@ -79,7 +79,7 @@ RomListWidget::RomListWidget(GuiObject* boss, const GUI::Font& lfont,
t->setID(i); t->setID(i);
t->setFill(CheckboxWidget::FillType::Circle); t->setFill(CheckboxWidget::FillType::Circle);
t->setTextColor(kTextColorEm); t->setTextColor(kTextColorEm);
ypos += _fontHeight; ypos += _lineHeight;
myCheckList.push_back(t); myCheckList.push_back(t);
} }
@ -175,7 +175,7 @@ void RomListWidget::setHighlighted(int item)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int RomListWidget::findItem(int x, int y) const 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; codeDisasmW = actualWidth;
xpos = _x + CheckboxWidget::boxSize(_font) + 10; ypos = _y + 2; 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; ColorId bytesColor = textColor;
@ -493,18 +493,18 @@ void RomListWidget::drawWidget(bool hilite)
// Draw highlighted item in a frame // Draw highlighted item in a frame
if (_highlightedItem == pos) 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. // Draw the selected item inverted, on a highlighted background.
if(_selectedItem == pos && _hasFocus) if(_selectedItem == pos && _hasFocus)
{ {
if(!_editMode) 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; bytesColor = kTextColorInv;
} }
else 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 // Draw labels
@ -537,7 +537,7 @@ void RomListWidget::drawWidget(bool hilite)
} }
// Draw separator // 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 // Draw bytes
{ {
@ -567,20 +567,20 @@ void RomListWidget::drawWidget(bool hilite)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Common::Rect RomListWidget::getLineRect() const 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; xoffset = CheckboxWidget::boxSize(_font) + 10;
return Common::Rect(2 + xoffset, 1 + yoffset, return Common::Rect(2 + xoffset, 1 + yoffset,
_w - (xoffset - 15), _fontHeight + yoffset); _w - (xoffset - 15), _lineHeight + yoffset);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Common::Rect RomListWidget::getEditRect() const 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, return Common::Rect(2 + _w - _bytesWidth, 1 + yoffset,
_w, _fontHeight + yoffset); _w, _lineHeight + yoffset);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -20,10 +20,10 @@
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
SaveKeyWidget::SaveKeyWidget(GuiObject* boss, const GUI::Font& font, 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) : FlashWidget(boss, font, x, y, controller)
{ {
init(boss, font, x, y); init(boss, font, x, y, embedded);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -26,7 +26,7 @@ class SaveKeyWidget : public FlashWidget
{ {
public: public:
SaveKeyWidget(GuiObject* boss, const GUI::Font& font, int x, int y, SaveKeyWidget(GuiObject* boss, const GUI::Font& font, int x, int y,
Controller& controller); Controller& controller, bool embedded = false);
~SaveKeyWidget() override = default; ~SaveKeyWidget() override = default;
private: private:

View File

@ -29,8 +29,8 @@ CheckListWidget::CheckListWidget(GuiObject* boss, const GUI::Font& font,
// rowheight is determined by largest item on a line, // rowheight is determined by largest item on a line,
// possibly meaning that number of rows will change // possibly meaning that number of rows will change
_fontHeight = std::max(_fontHeight, CheckboxWidget::boxSize(_font)); _lineHeight = std::max(_lineHeight, CheckboxWidget::boxSize(_font));
_rows = h / _fontHeight; _rows = h / _lineHeight;
// Create a CheckboxWidget for each row in the list // Create a CheckboxWidget for each row in the list
for(int i = 0; i < _rows; ++i) for(int i = 0; i < _rows; ++i)
@ -40,7 +40,7 @@ CheckListWidget::CheckListWidget(GuiObject* boss, const GUI::Font& font,
t->setTextColor(kTextColor); t->setTextColor(kTextColor);
t->setTarget(this); t->setTarget(this);
t->setID(i); t->setID(i);
ypos += _fontHeight; ypos += _lineHeight;
_checkList.push_back(t); _checkList.push_back(t);
} }
@ -110,7 +110,7 @@ void CheckListWidget::drawWidget(bool hilite)
_checkList[i]->setDirty(); _checkList[i]->setDirty();
_checkList[i]->draw(); _checkList[i]->draw();
const int y = _y + 2 + _fontHeight * i + 2; const int y = _y + 2 + _lineHeight * i + 2;
ColorId textColor = kTextColor; ColorId textColor = kTextColor;
Common::Rect r(getEditRect()); Common::Rect r(getEditRect());
@ -120,13 +120,13 @@ void CheckListWidget::drawWidget(bool hilite)
{ {
if(_hasFocus && !_editMode) if(_hasFocus && !_editMode)
{ {
s.fillRect(_x + r.x() - 3, _y + 1 + _fontHeight * i, s.fillRect(_x + r.x() - 3, _y + 1 + _lineHeight * i,
_w - r.x(), _fontHeight, kTextColorHi); _w - r.x(), _lineHeight, kTextColorHi);
textColor = kTextColorInv; textColor = kTextColorInv;
} }
else else
s.frameRect(_x + r.x() - 3, _y + 1 + _fontHeight * i, s.frameRect(_x + r.x() - 3, _y + 1 + _lineHeight * i,
_w - r.x(), _fontHeight, onTop ? kTextColorHi : kColor); _w - r.x(), _lineHeight, onTop ? kTextColorHi : kColor);
} }
if (_selectedItem == pos && _editMode) if (_selectedItem == pos && _editMode)
@ -149,11 +149,11 @@ void CheckListWidget::drawWidget(bool hilite)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Common::Rect CheckListWidget::getEditRect() const Common::Rect CheckListWidget::getEditRect() const
{ {
const int yoffset = (_selectedItem - _currentPos) * _fontHeight, const int yoffset = (_selectedItem - _currentPos) * _lineHeight,
xoffset = CheckboxWidget::boxSize(_font) + 10; xoffset = CheckboxWidget::boxSize(_font) + 10;
return Common::Rect(2 + xoffset, 1 + yoffset, return Common::Rect(2 + xoffset, 1 + yoffset,
_w - (xoffset - 15), _fontHeight + yoffset); _w - (xoffset - 15), _lineHeight + yoffset);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -36,7 +36,7 @@ ListWidget::ListWidget(GuiObject* boss, const GUI::Font& font,
_textcolorhi = kTextColor; _textcolorhi = kTextColor;
_cols = w / _fontWidth; _cols = w / _fontWidth;
_rows = h / _fontHeight; _rows = h / _lineHeight;
// Set real dimensions // Set real dimensions
_w = w - ScrollBarWidget::scrollBarWidth(_font); _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 int ListWidget::findItem(int x, int y) const
{ {
return (y - 1) / _fontHeight + _currentPos; return (y - 1) / _lineHeight + _currentPos;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -79,7 +79,7 @@ void StringListWidget::drawWidget(bool hilite)
// Draw the list items // Draw the list items
for (i = 0, pos = _currentPos; i < _rows && pos < len; i++, pos++) 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; ColorId textColor = onTop ? kTextColor : kShadowColor;
// Draw the selected item inverted, on a highlighted background. // Draw the selected item inverted, on a highlighted background.
@ -87,11 +87,11 @@ void StringListWidget::drawWidget(bool hilite)
{ {
if(_hasFocus && !_editMode) 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; textColor = kTextColorInv;
} }
else 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()); Common::Rect r(getEditRect());
@ -115,6 +115,6 @@ void StringListWidget::drawWidget(bool hilite)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Common::Rect StringListWidget::getEditRect() const Common::Rect StringListWidget::getEditRect() const
{ {
const int offset = std::max(0, (_selectedItem - _currentPos) * _fontHeight); const int offset = std::max(0, (_selectedItem - _currentPos) * _lineHeight);
return Common::Rect(_textOfs, 1 + offset, _w - _textOfs, _fontHeight + offset); return Common::Rect(_textOfs, 1 + offset, _w - _textOfs, _lineHeight + offset);
} }

View File

@ -292,7 +292,7 @@ void TabWidget::drawWidget(bool hilite)
? onTop ? kDlgColor : kBGColorLo ? onTop ? kDlgColor : kBGColorLo
: onTop ? kBGColorHi : kDlgColor); // ? kWidColor : kDlgColor : onTop ? kBGColorHi : kDlgColor); // ? kWidColor : kDlgColor
s.drawString(_font, _tabs[i].title, x + kTabPadding + yOffset, 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); tabWidth - 2 * kTabPadding, fontcolor, TextAlign::Center);
if(i == _activeTab) if(i == _activeTab)
{ {

View File

@ -39,7 +39,7 @@ Widget::Widget(GuiObject* boss, const GUI::Font& font,
_boss->_firstWidget = this; _boss->_firstWidget = this;
_fontWidth = _font.getMaxCharWidth(); _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); s.frameRect(_x, _y, _w, _h, !onTop ? kShadowColor : hilite && isEnabled() ? kBtnBorderColorHi : kBtnBorderColor);
if (!_useBitmap) 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 : !(isEnabled() && onTop) ? _textcolorlo :
hilite ? _textcolorhi : _textcolor, _align); hilite ? _textcolorhi : _textcolor, _align);
else else

View File

@ -139,7 +139,7 @@ class Widget : public GuiObject
uInt32 _flags{0}; uInt32 _flags{0};
bool _hasFocus{false}; bool _hasFocus{false};
int _fontWidth{0}; int _fontWidth{0};
int _fontHeight{0}; int _lineHeight{0};
ColorId _bgcolor{kWidColor}; ColorId _bgcolor{kWidColor};
ColorId _bgcolorhi{kWidColor}; ColorId _bgcolorhi{kWidColor};
ColorId _bgcolorlo{kBGColorLo}; ColorId _bgcolorlo{kBGColorLo};