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)
* 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
be re-entered again.
@ -99,6 +99,9 @@
* 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
the first character entered. Entering characters in lowercase still
selects files, as before.

View File

@ -136,8 +136,9 @@ GameInfoDialog::GameInfoDialog(
ypos += lineHeight + VGAP;
t = new StaticTextWidget(myTab, font, HBORDER, ypos + 1, "V-Center ");
myVCenter = new SliderWidget(myTab, font, t->getRight() + 2, ypos,
"", 0, kVCenterChanged, 7 * fontWidth, "px");
myVCenter = new SliderWidget(myTab, font, t->getRight() + 2, ypos, "",
0, kVCenterChanged, 7 * fontWidth, "px",
SliderWidget::DEF_LBL_GAP, true);
myVCenter->setMinValue(TIAConstants::minVcenter);
myVCenter->setMaxValue(TIAConstants::maxVcenter);

View File

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

View File

@ -621,12 +621,14 @@ void CheckboxWidget::drawWidget(bool hilite)
SliderWidget::SliderWidget(GuiObject* boss, const GUI::Font& font,
int x, int y, int w, int h,
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),
_labelWidth(labelWidth),
_valueUnit(valueUnit),
_valueLabelGap(valueLabelGap),
_valueLabelWidth(valueLabelWidth)
_valueLabelWidth(valueLabelWidth),
_forceLabelSign(forceLabelSign)
{
_flags = Widget::FLAG_ENABLED | Widget::FLAG_TRACK_MOUSE;
_bgcolor = kDlgColor;
@ -645,9 +647,11 @@ SliderWidget::SliderWidget(GuiObject* boss, const GUI::Font& font,
SliderWidget::SliderWidget(GuiObject* boss, const GUI::Font& font,
int x, int y,
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(),
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)
{
_valueLabel = std::to_string(value);
_valueLabel = (_forceLabelSign && value > 0 ? "+" : "") + std::to_string(value);
setDirty();
}

View File

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