add force sign option to SliderWidget

This commit is contained in:
thrust26 2020-01-11 11:59:09 +01:00
parent 096227ff54
commit a97cf0ba89
5 changed files with 25 additions and 13 deletions

View File

@ -14,7 +14,7 @@
6.0.2 to 6.1: (MM dd, 2020) 6.0.2 to 6.1: (MM dd, 2020)
* Note: because of major event remapping changes, all remappings will be * Note: Because of major event remapping changes, all remappings will be
reset to defaults; if you had custom mappings, they will need to reset to defaults; if you had custom mappings, they will need to
be re-entered again. be re-entered again.
@ -99,6 +99,9 @@
* Added option to change pitch of Pitfall II music. * Added option to change pitch of Pitfall II music.
* ROM Info Launcher can now display multiple lines per property and
bank switching type.
* In file listings, you can now select directories by holding 'Shift' on * In file listings, you can now select directories by holding 'Shift' on
the first character entered. Entering characters in lowercase still the first character entered. Entering characters in lowercase still
selects files, as before. selects files, as before.

View File

@ -136,8 +136,9 @@ GameInfoDialog::GameInfoDialog(
ypos += lineHeight + VGAP; ypos += lineHeight + VGAP;
t = new StaticTextWidget(myTab, font, HBORDER, ypos + 1, "V-Center "); t = new StaticTextWidget(myTab, font, HBORDER, ypos + 1, "V-Center ");
myVCenter = new SliderWidget(myTab, font, t->getRight() + 2, ypos, myVCenter = new SliderWidget(myTab, font, t->getRight() + 2, ypos, "",
"", 0, kVCenterChanged, 7 * fontWidth, "px"); 0, kVCenterChanged, 7 * fontWidth, "px",
SliderWidget::DEF_LBL_GAP, true);
myVCenter->setMinValue(TIAConstants::minVcenter); myVCenter->setMinValue(TIAConstants::minVcenter);
myVCenter->setMaxValue(TIAConstants::maxVcenter); myVCenter->setMaxValue(TIAConstants::maxVcenter);
@ -222,7 +223,7 @@ GameInfoDialog::GameInfoDialog(
VarList::push_back(ctrls, "KidVid", "KIDVID"); VarList::push_back(ctrls, "KidVid", "KIDVID");
VarList::push_back(ctrls, "Lightgun", "LIGHTGUN"); VarList::push_back(ctrls, "Lightgun", "LIGHTGUN");
VarList::push_back(ctrls, "MindLink", "MINDLINK"); VarList::push_back(ctrls, "MindLink", "MINDLINK");
ypos = VBORDER; ypos = VBORDER;
pwidth = font.getStringWidth("Paddles_IAxis"); pwidth = font.getStringWidth("Paddles_IAxis");
myLeftPortLabel = new StaticTextWidget(myTab, font, HBORDER, ypos+1, "Left port "); myLeftPortLabel = new StaticTextWidget(myTab, font, HBORDER, ypos+1, "Left port ");

View File

@ -139,7 +139,7 @@ VideoDialog::VideoDialog(OSystem& osystem, DialogContainer& parent,
myAdjustScanlinesNTSC = myAdjustScanlinesNTSC =
new SliderWidget(myTab, font, xpos, ypos-1, swidth, lineHeight, new SliderWidget(myTab, font, xpos, ypos-1, swidth, lineHeight,
"NTSC scanlines adjust ", lwidth, 0, "NTSC scanlines adjust ", lwidth, 0,
fontWidth * 4, ""); fontWidth * 4, "", SliderWidget::DEF_LBL_GAP, true);
myAdjustScanlinesNTSC->setMinValue(-25); myAdjustScanlinesNTSC->setMaxValue(25); myAdjustScanlinesNTSC->setMinValue(-25); myAdjustScanlinesNTSC->setMaxValue(25);
myAdjustScanlinesNTSC->setTickmarkIntervals(2); myAdjustScanlinesNTSC->setTickmarkIntervals(2);
wid.push_back(myAdjustScanlinesNTSC); wid.push_back(myAdjustScanlinesNTSC);
@ -149,7 +149,7 @@ VideoDialog::VideoDialog(OSystem& osystem, DialogContainer& parent,
myAdjustScanlinesPAL = myAdjustScanlinesPAL =
new SliderWidget(myTab, font, xpos, ypos-1, swidth, lineHeight, new SliderWidget(myTab, font, xpos, ypos-1, swidth, lineHeight,
"PAL scanlines adjust ", lwidth, 0, "PAL scanlines adjust ", lwidth, 0,
fontWidth * 4, ""); fontWidth * 4, "", SliderWidget::DEF_LBL_GAP, true);
myAdjustScanlinesPAL->setMinValue(-25); myAdjustScanlinesPAL->setMaxValue(25); myAdjustScanlinesPAL->setMinValue(-25); myAdjustScanlinesPAL->setMaxValue(25);
myAdjustScanlinesPAL->setTickmarkIntervals(2); myAdjustScanlinesPAL->setTickmarkIntervals(2);
wid.push_back(myAdjustScanlinesPAL); wid.push_back(myAdjustScanlinesPAL);

View File

@ -621,12 +621,14 @@ void CheckboxWidget::drawWidget(bool hilite)
SliderWidget::SliderWidget(GuiObject* boss, const GUI::Font& font, SliderWidget::SliderWidget(GuiObject* boss, const GUI::Font& font,
int x, int y, int w, int h, int x, int y, int w, int h,
const string& label, int labelWidth, int cmd, const string& label, int labelWidth, int cmd,
int valueLabelWidth, const string& valueUnit, int valueLabelGap) int valueLabelWidth, const string& valueUnit, int valueLabelGap,
bool forceLabelSign)
: ButtonWidget(boss, font, x, y, w, h, label, cmd), : ButtonWidget(boss, font, x, y, w, h, label, cmd),
_labelWidth(labelWidth), _labelWidth(labelWidth),
_valueUnit(valueUnit), _valueUnit(valueUnit),
_valueLabelGap(valueLabelGap), _valueLabelGap(valueLabelGap),
_valueLabelWidth(valueLabelWidth) _valueLabelWidth(valueLabelWidth),
_forceLabelSign(forceLabelSign)
{ {
_flags = Widget::FLAG_ENABLED | Widget::FLAG_TRACK_MOUSE; _flags = Widget::FLAG_ENABLED | Widget::FLAG_TRACK_MOUSE;
_bgcolor = kDlgColor; _bgcolor = kDlgColor;
@ -645,9 +647,11 @@ SliderWidget::SliderWidget(GuiObject* boss, const GUI::Font& font,
SliderWidget::SliderWidget(GuiObject* boss, const GUI::Font& font, SliderWidget::SliderWidget(GuiObject* boss, const GUI::Font& font,
int x, int y, int x, int y,
const string& label, int labelWidth, int cmd, const string& label, int labelWidth, int cmd,
int valueLabelWidth, const string& valueUnit, int valueLabelGap) int valueLabelWidth, const string& valueUnit, int valueLabelGap,
bool forceLabelSign)
: SliderWidget(boss, font, x, y, font.getMaxCharWidth() * 10, font.getLineHeight(), : SliderWidget(boss, font, x, y, font.getMaxCharWidth() * 10, font.getLineHeight(),
label, labelWidth, cmd, valueLabelWidth, valueUnit, valueLabelGap) label, labelWidth, cmd, valueLabelWidth, valueUnit, valueLabelGap,
forceLabelSign)
{ {
} }
@ -698,7 +702,7 @@ void SliderWidget::setValueLabel(const string& valueLabel)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void SliderWidget::setValueLabel(int value) void SliderWidget::setValueLabel(int value)
{ {
_valueLabel = std::to_string(value); _valueLabel = (_forceLabelSign && value > 0 ? "+" : "") + std::to_string(value);
setDirty(); setDirty();
} }

View File

@ -314,16 +314,19 @@ class CheckboxWidget : public ButtonWidget
class SliderWidget : public ButtonWidget class SliderWidget : public ButtonWidget
{ {
public: public:
static const int DEF_LBL_GAP = 4;
SliderWidget(GuiObject* boss, const GUI::Font& font, SliderWidget(GuiObject* boss, const GUI::Font& font,
int x, int y, int w, int h, int x, int y, int w, int h,
const string& label = "", int labelWidth = 0, int cmd = 0, const string& label = "", int labelWidth = 0, int cmd = 0,
int valueLabelWidth = 0, const string& valueUnit = "", int valueLabelWidth = 0, const string& valueUnit = "",
int valueLabelGap = 4); int valueLabelGap = DEF_LBL_GAP, bool forceLabelSign = false);
SliderWidget(GuiObject* boss, const GUI::Font& font, SliderWidget(GuiObject* boss, const GUI::Font& font,
int x, int y, int x, int y,
const string& label = "", int labelWidth = 0, int cmd = 0, const string& label = "", int labelWidth = 0, int cmd = 0,
int valueLabelWidth = 0, const string& valueUnit = "", int valueLabelWidth = 0, const string& valueUnit = "",
int valueLabelGap = 4); int valueLabelGap = DEF_LBL_GAP, bool forceLabelSign = false);
virtual ~SliderWidget() = default; virtual ~SliderWidget() = default;
void setValue(int value); void setValue(int value);
@ -363,6 +366,7 @@ class SliderWidget : public ButtonWidget
string _valueUnit; string _valueUnit;
int _valueLabelGap{0}; int _valueLabelGap{0};
int _valueLabelWidth{0}; int _valueLabelWidth{0};
bool _forceLabelSign{false};
int _numIntervals{0}; int _numIntervals{0};
private: private: