Added few new constructors to some widgets which make creating dialogs a bit easier. There still is room for improvement here.

This commit is contained in:
thrust26 2017-09-30 12:07:56 +02:00
parent ecd8d0ff22
commit 01449ddeec
5 changed files with 88 additions and 58 deletions

View File

@ -104,8 +104,8 @@ void InputDialog::addDevicePortTab(const GUI::Font& font)
tabID = myTab->addTab("Devices & Ports");
// Stelladaptor mappings
xpos = 5; ypos = 5;
lwidth = font.getStringWidth("Use mouse as a controller ");
xpos = 5+3; ypos = 5;
lwidth = font.getStringWidth("Digital paddle sensitivity "); // was: "Use mouse as a controller "
pwidth = font.getStringWidth("-UI, -Emulation");
VarList::push_back(items, "Left / Right", "lr");
@ -138,16 +138,6 @@ void InputDialog::addDevicePortTab(const GUI::Font& font)
myCursorState->clearFlags(WIDGET_ENABLED);
#endif
// Add AtariVox serial port
ypos += lineHeight + 5;
lwidth = font.getStringWidth("AVox serial port ");
int fwidth = _w - xpos - lwidth - 20;
new StaticTextWidget(myTab, font, xpos, ypos, lwidth, fontHeight,
"AVox serial port ", kTextAlignLeft);
myAVoxPort = new EditTextWidget(myTab, font, xpos+lwidth, ypos,
fwidth, fontHeight, "");
wid.push_back(myAVoxPort);
lwidth = font.getStringWidth("Digital paddle sensitivity ");
pwidth = font.getMaxCharWidth() * 8;
@ -163,7 +153,7 @@ void InputDialog::addDevicePortTab(const GUI::Font& font)
wid.push_back(myDeadzone);
// Add paddle speed (digital emulation)
xpos = 5; ypos += lineHeight + 4;
xpos = 5+3; ypos += lineHeight + 4;
myDPaddleSpeed = new SliderWidget(myTab, font, xpos, ypos, pwidth, lineHeight,
"Digital paddle sensitivity ",
lwidth, kDPSpeedChanged);
@ -175,7 +165,7 @@ void InputDialog::addDevicePortTab(const GUI::Font& font)
wid.push_back(myDPaddleSpeed);
// Add paddle speed (mouse emulation)
xpos = 5; ypos += lineHeight + 4;
xpos = 5+3; ypos += lineHeight + 4;
myMPaddleSpeed = new SliderWidget(myTab, font, xpos, ypos, pwidth, lineHeight,
"Mouse paddle sensitivity ",
lwidth, kMPSpeedChanged);
@ -187,7 +177,7 @@ void InputDialog::addDevicePortTab(const GUI::Font& font)
wid.push_back(myMPaddleSpeed);
// Add trackball speed
xpos = 5; ypos += lineHeight + 4;
xpos = 5+3; ypos += lineHeight + 4;
myTrackBallSpeed = new SliderWidget(myTab, font, xpos, ypos, pwidth, lineHeight,
"Trackball sensitivity ",
lwidth, kTBSpeedChanged);
@ -199,7 +189,7 @@ void InputDialog::addDevicePortTab(const GUI::Font& font)
wid.push_back(myTrackBallSpeed);
// Add 'allow all 4 directions' for joystick
xpos = 10; ypos += lineHeight + 12;
xpos = 10-2; ypos += lineHeight + 12;
myAllowAll4 = new CheckboxWidget(myTab, font, xpos, ypos,
"Allow all 4 directions on joystick");
wid.push_back(myAllowAll4);
@ -219,13 +209,33 @@ void InputDialog::addDevicePortTab(const GUI::Font& font)
"Use Control key combos");
wid.push_back(myCtrlCombo);
int fwidth;
// Add EEPROM erase (part 1/2)
/*fwidth = font.getStringWidth("Erase EEPROM") + 20;
lwidth = font.getStringWidth("AVox/SaveKey");
new StaticTextWidget(myTab, font, _w - 10 - (fwidth + lwidth) / 2, ypos + 1+8, "AVox/SaveKey");*/
// Show joystick database
xpos += 20; ypos += lineHeight + 8;
myJoyDlgButton = new ButtonWidget(myTab, font, xpos, ypos,
font.getStringWidth("Show Joystick Database") + 20, font.getLineHeight() + 4,
myJoyDlgButton = new ButtonWidget(myTab, font, xpos, ypos, 20,
"Show Joystick Database", kDBButtonPressed);
wid.push_back(myJoyDlgButton);
// Add EEPROM erase (part 1/2)
/*myEraseEEPROMButton = new ButtonWidget(myTab, font, _w - 14 - fwidth, ypos,
"Erase EEPROM", kEEButtonPressed);*/
// Add AtariVox serial port
xpos -= 20; ypos += lineHeight + 12;
lwidth = font.getStringWidth("AVox serial port ");
fwidth = _w - 14 - xpos - lwidth;
new StaticTextWidget(myTab, font, xpos, ypos, "AVox serial port ");
myAVoxPort = new EditTextWidget(myTab, font, xpos + lwidth, ypos,
fwidth, fontHeight, "");
wid.push_back(myAVoxPort);
// Add items for virtual device ports
addToFocusList(wid, myTab, tabID);
}
@ -468,6 +478,10 @@ void InputDialog::handleCommand(CommandSender* sender, int cmd,
myJoyDialog->show();
break;
/*case kEEButtonPressed:
// TODO
break;*/
default:
Dialog::handleCommand(sender, cmd, data, 0);
}

View File

@ -58,7 +58,8 @@ class InputDialog : public Dialog
kDPSpeedChanged = 'PDch',
kMPSpeedChanged = 'PMch',
kTBSpeedChanged = 'TBch',
kDBButtonPressed = 'DBbp'
kDBButtonPressed = 'DBbp',
//kEEButtonPressed = 'EEbp'
};
TabWidget* myTab;
@ -85,6 +86,7 @@ class InputDialog : public Dialog
CheckboxWidget* myCtrlCombo;
ButtonWidget* myJoyDlgButton;
//ButtonWidget* myEraseEEPROMButton;
// Show the list of joysticks that the eventhandler knows about
unique_ptr<JoystickDialog> myJoyDialog;

View File

@ -306,6 +306,13 @@ StaticTextWidget::StaticTextWidget(GuiObject* boss, const GUI::Font& font,
_editable = false;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
StaticTextWidget::StaticTextWidget(GuiObject* boss, const GUI::Font& font,
int x, int y,
const string& text, TextAlignment align)
: StaticTextWidget(boss, font, x, y, font.getStringWidth(text), font.getLineHeight(), text, align)
{}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void StaticTextWidget::setValue(int value)
{
@ -349,6 +356,20 @@ ButtonWidget::ButtonWidget(GuiObject* boss, const GUI::Font& font,
_editable = false;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ButtonWidget::ButtonWidget(GuiObject* boss, const GUI::Font& font,
int x, int y, int dw,
const string& label, int cmd)
: ButtonWidget(boss, font, x, y, font.getStringWidth(label) + dw, font.getLineHeight() + 4, label, cmd)
{}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ButtonWidget::ButtonWidget(GuiObject* boss, const GUI::Font& font,
int x, int y,
const string& label, int cmd)
: ButtonWidget(boss, font, x, y, 20, label, cmd)
{}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void ButtonWidget::handleMouseEntered(int button)
{

View File

@ -174,7 +174,10 @@ class StaticTextWidget : public Widget
public:
StaticTextWidget(GuiObject* boss, const GUI::Font& font,
int x, int y, int w, int h,
const string& text, TextAlignment align);
const string& text, TextAlignment align = kTextAlignLeft);
StaticTextWidget(GuiObject* boss, const GUI::Font& font,
int x, int y,
const string& text, TextAlignment align = kTextAlignLeft);
void setValue(int value);
void setLabel(const string& label);
void setAlign(TextAlignment align) { _align = align; }
@ -205,6 +208,12 @@ class ButtonWidget : public StaticTextWidget, public CommandSender
ButtonWidget(GuiObject* boss, const GUI::Font& font,
int x, int y, int w, int h,
const string& label, int cmd = 0);
ButtonWidget(GuiObject* boss, const GUI::Font& font,
int x, int y, int dw,
const string& label, int cmd = 0);
ButtonWidget(GuiObject* boss, const GUI::Font& font,
int x, int y,
const string& label, int cmd = 0);
void setCmd(int cmd) { _cmd = cmd; }
int getCmd() const { return _cmd; }

View File

@ -25,50 +25,34 @@ FlashWidget::FlashWidget(GuiObject* boss, const GUI::Font& font,
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FlashWidget::init(GuiObject* boss, const GUI::Font& font, int x, int y)
{
bool leftport = myController.jack() == Controller::Left;
const string& label = (leftport ? "Left (" : "Right (") + getName() + ")";
const int fontHeight = font.getFontHeight(),
lineHeight = font.getLineHeight(),
bwidth = font.getStringWidth("Erase EEPROM area") + 20,
bheight = lineHeight + 4;
int xpos = x, ypos = y, lwidth = font.getStringWidth("Right (" + getName() + ")");
StaticTextWidget* t;
t = new StaticTextWidget(boss, font, xpos, ypos + 2, lwidth,
fontHeight, label, kTextAlignLeft);
ypos += t->getHeight() + 8;
myEEPROMEraseCurrent =
new ButtonWidget(boss, font, xpos, ypos, bwidth, bheight,
"Erase EEPROM range", kEEPROMEraseCurrent);
myEEPROMEraseCurrent->setTarget(this);
ypos += lineHeight + 8;
const GUI::Font& ifont = instance().frameBuffer().infoFont();
lwidth = ifont.getMaxCharWidth() * 20;
const int lineHeight = font.getLineHeight();
const int iLineHeight = ifont.getLineHeight();
int xpos = x, ypos = y;
bool leftport = myController.jack() == Controller::Left;
new StaticTextWidget(boss, font, xpos, ypos + 2, (leftport ? "Left (" : "Right (") + getName() + ")");
new StaticTextWidget(boss, ifont, xpos, ypos, lwidth,
fontHeight, "(*) Erases only the", kTextAlignLeft);
ypos += lineHeight + 2;
new StaticTextWidget(boss, ifont, xpos, ypos, lwidth,
fontHeight, "current ROM's range", kTextAlignLeft);
ypos += lineHeight + 8;
myEEPROMEraseAll =
new ButtonWidget(boss, font, xpos, ypos, bwidth, bheight,
"Erase EEPROM", kEEPROMEraseAll);
myEEPROMEraseCurrent = new ButtonWidget(boss, font, xpos, ypos,
"Erase EEPROM range", kEEPROMEraseCurrent);
myEEPROMEraseCurrent->setTarget(this);
ypos += lineHeight + 8;
new StaticTextWidget(boss, ifont, xpos, ypos, "(*) Erases only the");
ypos += iLineHeight;
new StaticTextWidget(boss, ifont, xpos, ypos, "current ROM's range");
ypos += iLineHeight + 8;
myEEPROMEraseAll = new ButtonWidget(boss, font, xpos, ypos,
myEEPROMEraseCurrent->getWidth(), myEEPROMEraseCurrent->getHeight(),
"Erase EEPROM", kEEPROMEraseAll);
myEEPROMEraseAll->setTarget(this);
ypos += lineHeight + 8;
new StaticTextWidget(boss, ifont, xpos, ypos, lwidth,
fontHeight, "(*) This will erase", kTextAlignLeft);
ypos += lineHeight + 2;
new StaticTextWidget(boss, ifont, xpos, ypos, lwidth,
fontHeight, "all EEPROM data!", kTextAlignLeft);
new StaticTextWidget(boss, ifont, xpos, ypos, "(*) This will erase");
ypos += iLineHeight;
new StaticTextWidget(boss, ifont, xpos, ypos, "all EEPROM data!");
updateButtonState();
}