More fixes for warnings from clang-tidy.

Mostly converting C-style arrays to C++.
This commit is contained in:
Stephen Anthony 2019-12-25 20:40:01 -03:30
parent e09634cb56
commit 4c8c08639a
33 changed files with 123 additions and 109 deletions

View File

@ -55,12 +55,10 @@ class FpsMeter
float myFps;
private:
FpsMeter(const FpsMeter&) = delete;
FpsMeter(FpsMeter&&) = delete;
FpsMeter& operator=(const FpsMeter&) = delete;
FpsMeter& operator=(FpsMeter&&) = delete;
};
#endif // FPS_METER_HXX

View File

@ -36,7 +36,6 @@ struct Point
Int32 y; //!< The vertical part of the point
Point() : x(0), y(0) { }
Point(const Point& p) : x(p.x), y(p.y) { }
explicit Point(Int32 x1, Int32 y1) : x(x1), y(y1) { }
explicit Point(const string& p) : x(0), y(0) {
char c = '\0';
@ -45,7 +44,6 @@ struct Point
if(c != 'x')
x = y = 0;
}
Point& operator=(const Point & p) { x = p.x; y = p.y; return *this; }
bool operator==(const Point & p) const { return x == p.x && y == p.y; }
bool operator!=(const Point & p) const { return x != p.x || y != p.y; }
@ -61,7 +59,6 @@ struct Size
uInt32 h; //!< The height part of the size
Size() : w(0), h(0) { }
Size(const Size& s) : w(s.w), h(s.h) { }
explicit Size(uInt32 w1, uInt32 h1) : w(w1), h(h1) { }
explicit Size(const string& s) : w(0), h(0) {
char c = '\0';
@ -72,7 +69,6 @@ struct Size
}
bool valid() const { return w > 0 && h > 0; }
Size& operator=(const Size& s) { w = s.w; h = s.h; return *this; }
bool operator==(const Size& s) const { return w == s.w && h == s.h; }
bool operator!=(const Size& s) const { return w != s.w || h != s.h; }
bool operator<(const Size& s) const { return w < s.w && h < s.h; }
@ -111,9 +107,7 @@ struct Rect
public:
Rect() : top(0), left(0), bottom(0), right(0) { assert(valid()); }
Rect(const Rect& s) : top(s.top), left(s.left), bottom(s.bottom), right(s.right) { assert(valid()); }
explicit Rect(const Size& s) : top(0), left(0), bottom(s.h), right(s.w) { assert(valid()); }
Rect& operator=(const Rect&) = default;
Rect(uInt32 w, uInt32 h) : top(0), left(0), bottom(h), right(w) { assert(valid()); }
Rect(const Point& p, uInt32 w, uInt32 h) : top(p.y), left(p.x), bottom(h), right(w) { assert(valid()); }
Rect(uInt32 x1, uInt32 y1, uInt32 x2, uInt32 y2) : top(y1), left(x1), bottom(y2), right(x2) { assert(valid()); }

View File

@ -82,7 +82,7 @@ class SoundNull : public Sound
@return The previous (old) mute state
*/
bool toggleMute() override { }
bool toggleMute() override { return true; }
/**
Sets the volume of the sound device to the specified level. The

View File

@ -42,7 +42,7 @@ class Variant
}
public:
Variant() { }
Variant() = default;
Variant(const string& s) : data(s) { }
Variant(const char* s) : data(s) { }

View File

@ -1444,13 +1444,13 @@ void CartDebug::disasmTypeAsString(ostream& buf, uInt8 flags) const
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const char* const CartDebug::ourTIAMnemonicR[16] = {
std::array<const char*, 16> CartDebug::ourTIAMnemonicR = {
"CXM0P", "CXM1P", "CXP0FB", "CXP1FB", "CXM0FB", "CXM1FB", "CXBLPF", "CXPPMM",
"INPT0", "INPT1", "INPT2", "INPT3", "INPT4", "INPT5", "$1e", "$1f"
};
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const char* const CartDebug::ourTIAMnemonicW[64] = {
std::array<const char*, 64> CartDebug::ourTIAMnemonicW = {
"VSYNC", "VBLANK", "WSYNC", "RSYNC", "NUSIZ0", "NUSIZ1", "COLUP0", "COLUP1",
"COLUPF", "COLUBK", "CTRLPF", "REFP0", "REFP1", "PF0", "PF1", "PF2",
"RESP0", "RESP1", "RESM0", "RESM1", "RESBL", "AUDC0", "AUDC1", "AUDF0",
@ -1462,7 +1462,7 @@ const char* const CartDebug::ourTIAMnemonicW[64] = {
};
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const char* const CartDebug::ourIOMnemonic[24] = {
std::array<const char*, 24> CartDebug::ourIOMnemonic = {
"SWCHA", "SWACNT", "SWCHB", "SWBCNT", "INTIM", "TIMINT",
"$286", "$287", "$288", "$289", "$28a", "$28b", "$28c",
"$28d", "$28e", "$28f", "$290", "$291", "$292", "$293",
@ -1470,7 +1470,7 @@ const char* const CartDebug::ourIOMnemonic[24] = {
};
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const char* const CartDebug::ourZPMnemonic[128] = {
std::array<const char*, 128> CartDebug::ourZPMnemonic = {
"ram_80", "ram_81", "ram_82", "ram_83", "ram_84", "ram_85", "ram_86", "ram_87",
"ram_88", "ram_89", "ram_8A", "ram_8B", "ram_8C", "ram_8D", "ram_8E", "ram_8F",
"ram_90", "ram_91", "ram_92", "ram_93", "ram_94", "ram_95", "ram_96", "ram_97",

View File

@ -352,10 +352,10 @@ class CartDebug : public DebuggerSystem
string myListFile, mySymbolFile, myCfgFile, myDisasmFile, myRomFile;
/// Table of instruction mnemonics
static const char* const ourTIAMnemonicR[16]; // read mode
static const char* const ourTIAMnemonicW[64]; // write mode
static const char* const ourIOMnemonic[24];
static const char* const ourZPMnemonic[128];
static std::array<const char*, 16> ourTIAMnemonicR; // read mode
static std::array<const char*, 64> ourTIAMnemonicW; // write mode
static std::array<const char*, 24> ourIOMnemonic;
static std::array<const char*, 128> ourZPMnemonic;
private:
// Following constructors and assignment operators not supported

View File

@ -433,7 +433,7 @@ bool TIADebug::collision(CollisionBit id, bool toggle) const
case CollisionBit::M1P1:
if(toggle)
myTIA.toggleCollP1M1();
return myTIA.collCXM1P() & 0x40;
return myTIA.collCXM1P() & 0x40;
case CollisionBit::P0PF:
if(toggle)

View File

@ -159,6 +159,9 @@ void RomWidget::handleCommand(CommandSender* sender, int cmd, int data, int id)
DiStella::settings.rFlag);
invalidate();
break;
default:
break;
}
}

View File

@ -161,6 +161,9 @@ void TiaOutputWidget::handleCommand(CommandSender* sender, int cmd, int data, in
}
break;
}
default:
break;
}
}
@ -186,7 +189,7 @@ void TiaOutputWidget::drawWidget(bool hilite)
for(uInt32 y = 0, i = 0; y < height; ++y)
{
uInt32* line_ptr = myLineBuffer;
uInt32* line_ptr = myLineBuffer.data();
for(uInt32 x = 0; x < width; ++x, ++i)
{
uInt8 shift = i >= scanoffset ? 1 : 0;
@ -194,10 +197,10 @@ void TiaOutputWidget::drawWidget(bool hilite)
*line_ptr++ = pixel;
*line_ptr++ = pixel;
}
s.drawPixels(myLineBuffer, _x + 1, _y + 1 + y, width << 1);
s.drawPixels(myLineBuffer.data(), _x + 1, _y + 1 + y, width << 1);
}
// Show electron beam position
if(visible && scanx < width && scany+2u < height)
if(visible && scanx < width && scany+2U < height)
s.fillRect(_x + 1 + (scanx<<1), _y + 1 + scany, 3, 3, kColorInfo);
}

View File

@ -55,7 +55,7 @@ class TiaOutputWidget : public Widget, public CommandSender
// Create this buffer once, instead of allocating it each time the
// TIA image is redrawn
uInt32 myLineBuffer[320];
std::array<uInt32, 320> myLineBuffer;
private:
void handleMouseDown(int x, int y, MouseButton b, int clickCount) override;

View File

@ -819,6 +819,9 @@ void TiaWidget::handleCommand(CommandSender* sender, int cmd, int data, int id)
case kPF2ID:
tia.pf2(myPF[2]->getIntState());
break;
default:
break;
}
break;
@ -922,8 +925,14 @@ void TiaWidget::handleCommand(CommandSender* sender, int cmd, int data, int id)
case kPriorityPFID:
tia.priorityPF(myPriorityPF->getState() ? 1 : 0);
break;
default:
break;
}
break;
default:
break;
}
}

View File

@ -47,7 +47,7 @@ class TiaWidget : public Widget, public CommandSender
ColorWidget* myCOLUBKColor;
CheckboxWidget* myFixedEnabled;
ColorWidget* myFixedColors[8];
std::array<ColorWidget*, 8> myFixedColors;
TogglePixelWidget* myGRP0;
TogglePixelWidget* myGRP0Old;
@ -89,9 +89,9 @@ class TiaWidget : public Widget, public CommandSender
CheckboxWidget* myResMP1;
/** Collision register bits */
CheckboxWidget* myCollision[15];
std::array<CheckboxWidget*, 15> myCollision;
TogglePixelWidget* myPF[3];
std::array<TogglePixelWidget*, 3> myPF;
CheckboxWidget* myRefPF;
CheckboxWidget* myScorePF;
CheckboxWidget* myPriorityPF;

View File

@ -15,6 +15,8 @@
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//============================================================================
#include <cmath>
#include "OSystem.hxx"
#include "Console.hxx"
#include "Debugger.hxx"
@ -25,8 +27,6 @@
#include "Widget.hxx"
#include "GuiObject.hxx"
#include "ContextMenu.hxx"
#include <math.h>
#include "TiaZoomWidget.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -245,42 +245,38 @@ bool TiaZoomWidget::handleEvent(Event::Type event)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void TiaZoomWidget::handleCommand(CommandSender* sender, int cmd, int data, int id)
{
switch(cmd)
if(cmd == ContextMenu::kItemSelectedCmd)
{
case ContextMenu::kItemSelectedCmd:
uInt32 startLine = instance().console().tia().startLine();
const string& rmb = myMenu->getSelectedTag().toString();
if(rmb == "scanline")
{
uInt32 startLine = instance().console().tia().startLine();
const string& rmb = myMenu->getSelectedTag().toString();
ostringstream command;
int lines = myClickY / myZoomLevel + myOffY + startLine - instance().console().tia().scanlines();
if(rmb == "scanline")
if (lines < 0)
lines += instance().console().tia().scanlinesLastFrame();
if(lines > 0)
{
ostringstream command;
int lines = myClickY / myZoomLevel + myOffY + startLine - instance().console().tia().scanlines();
if (lines < 0)
lines += instance().console().tia().scanlinesLastFrame();
if(lines > 0)
{
command << "scanline #" << lines;
string message = instance().debugger().parser().run(command.str());
instance().frameBuffer().showMessage(message);
}
}
else if(rmb == "bp")
{
ostringstream command;
int scanline = myClickY / myZoomLevel + myOffY + startLine;
command << "breakif _scan==#" << scanline;
command << "scanline #" << lines;
string message = instance().debugger().parser().run(command.str());
instance().frameBuffer().showMessage(message);
}
else
{
int level = myMenu->getSelectedTag().toInt();
if(level > 0)
zoom(level);
}
break;
}
else if(rmb == "bp")
{
ostringstream command;
int scanline = myClickY / myZoomLevel + myOffY + startLine;
command << "breakif _scan==#" << scanline;
string message = instance().debugger().parser().run(command.str());
instance().frameBuffer().showMessage(message);
}
else
{
int level = myMenu->getSelectedTag().toInt();
if(level > 0)
zoom(level);
}
}
}

View File

@ -171,8 +171,7 @@ class Event
{
std::lock_guard<std::mutex> lock(myMutex);
for(Int32 i = 0; i < LastType; ++i)
myValues[i] = Event::NoType;
myValues.fill(Event::NoType);
}
/**
@ -194,7 +193,7 @@ class Event
private:
// Array of values associated with each event type
Int32 myValues[LastType];
std::array<Int32, LastType> myValues;
mutable std::mutex myMutex;

View File

@ -227,14 +227,14 @@ void FBSurface::drawChar(const GUI::Font& font, uInt8 chr,
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FBSurface::drawBitmap(uInt32* bitmap, uInt32 tx, uInt32 ty,
void FBSurface::drawBitmap(const uInt32* bitmap, uInt32 tx, uInt32 ty,
ColorId color, uInt32 h)
{
drawBitmap(bitmap, tx, ty, color, h, h);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FBSurface::drawBitmap(uInt32* bitmap, uInt32 tx, uInt32 ty,
void FBSurface::drawBitmap(const uInt32* bitmap, uInt32 tx, uInt32 ty,
ColorId color, uInt32 w, uInt32 h)
{
if(!checkBounds(tx, ty) || !checkBounds(tx + w - 1, ty + h - 1))
@ -254,7 +254,7 @@ void FBSurface::drawBitmap(uInt32* bitmap, uInt32 tx, uInt32 ty,
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FBSurface::drawPixels(uInt32* data, uInt32 tx, uInt32 ty, uInt32 numpixels)
void FBSurface::drawPixels(const uInt32* data, uInt32 tx, uInt32 ty, uInt32 numpixels)
{
if(!checkBounds(tx, ty) || !checkBounds(tx + numpixels - 1, ty))
return;

View File

@ -148,7 +148,7 @@ class FBSurface
@param color The color of the bitmap
@param h The height of the data image
*/
virtual void drawBitmap(uInt32* bitmap, uInt32 x, uInt32 y, ColorId color,
virtual void drawBitmap(const uInt32* bitmap, uInt32 x, uInt32 y, ColorId color,
uInt32 h = 8);
/**
@ -161,7 +161,7 @@ class FBSurface
@param w The width of the data image
@param h The height of the data image
*/
virtual void drawBitmap(uInt32* bitmap, uInt32 x, uInt32 y, ColorId color,
virtual void drawBitmap(const uInt32* bitmap, uInt32 x, uInt32 y, ColorId color,
uInt32 w, uInt32 h);
/**
@ -174,7 +174,7 @@ class FBSurface
@param y The destination y-location to start drawing pixels
@param numpixels The number of pixels to draw
*/
virtual void drawPixels(uInt32* data, uInt32 x, uInt32 y, uInt32 numpixels);
virtual void drawPixels(const uInt32* data, uInt32 x, uInt32 y, uInt32 numpixels);
/**
This method should be called to draw a rectangular box with sides

View File

@ -35,8 +35,8 @@ Properties::Properties(const Properties& properties)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Properties::set(PropType key, const string& value)
{
uInt8 pos = static_cast<uInt8>(key);
if(pos < static_cast<uInt8>(PropType::NumTypes))
size_t pos = static_cast<size_t>(key);
if(pos < myProperties.size())
{
myProperties[pos] = value;
if(BSPF::equalsIgnoreCase(myProperties[pos], "AUTO-DETECT"))
@ -115,7 +115,7 @@ ostream& operator<<(ostream& os, const Properties& p)
{
// Write out each of the key and value pairs
bool changed = false;
for(uInt8 i = 0; i < static_cast<uInt8>(PropType::NumTypes); ++i)
for(size_t i = 0; i < static_cast<size_t>(PropType::NumTypes); ++i)
{
// Try to save some space by only saving the items that differ from default
if(p.myProperties[i] != Properties::ourDefaultProperties[i])
@ -192,7 +192,7 @@ void Properties::writeQuotedString(ostream& out, const string& s)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Properties::operator==(const Properties& properties) const
{
for(uInt8 i = 0; i < static_cast<uInt8>(PropType::NumTypes); ++i)
for(size_t i = 0; i < myProperties.size(); ++i)
if(myProperties[i] != properties.myProperties[i])
return false;
@ -221,14 +221,14 @@ Properties& Properties::operator=(const Properties& properties)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Properties::setDefault(PropType key, const string& value)
{
ourDefaultProperties[static_cast<uInt8>(key)] = value;
ourDefaultProperties[static_cast<size_t>(key)] = value;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Properties::copy(const Properties& properties)
{
// Now, copy each property from properties
for(uInt8 i = 0; i < static_cast<uInt8>(PropType::NumTypes); ++i)
for(size_t i = 0; i < myProperties.size(); ++i)
myProperties[i] = properties.myProperties[i];
}
@ -262,16 +262,16 @@ void Properties::print() const
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Properties::setDefaults()
{
for(uInt8 i = 0; i < static_cast<uInt8>(PropType::NumTypes); ++i)
for(size_t i = 0; i < myProperties.size(); ++i)
myProperties[i] = ourDefaultProperties[i];
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PropType Properties::getPropType(const string& name)
{
for(uInt8 i = 0; i < static_cast<uInt8>(PropType::NumTypes); ++i)
for(size_t i = 0; i < NUM_PROPS; ++i)
if(ourPropertyNames[i] == name)
return PropType(i);
return static_cast<PropType>(i);
// Otherwise, indicate that the item wasn't found
return PropType::NumTypes;
@ -305,7 +305,7 @@ void Properties::printHeader()
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string Properties::ourDefaultProperties[static_cast<uInt8>(PropType::NumTypes)] =
std::array<string, Properties::NUM_PROPS> Properties::ourDefaultProperties =
{
"", // Cart.MD5
"", // Cart.Manufacturer
@ -331,7 +331,7 @@ string Properties::ourDefaultProperties[static_cast<uInt8>(PropType::NumTypes)]
};
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const char* const Properties::ourPropertyNames[static_cast<uInt8>(PropType::NumTypes)] =
std::array<string, Properties::NUM_PROPS> Properties::ourPropertyNames =
{
"Cart.MD5",
"Cart.Manufacturer",

View File

@ -188,14 +188,16 @@ class Properties
static void printHeader();
private:
static constexpr size_t NUM_PROPS = static_cast<size_t>(PropType::NumTypes);
// The array of properties
string myProperties[static_cast<uInt8>(PropType::NumTypes)];
std::array<string, NUM_PROPS> myProperties;
// List of default properties to use when none have been provided
static string ourDefaultProperties[static_cast<uInt8>(PropType::NumTypes)];
static std::array<string, NUM_PROPS> ourDefaultProperties;
// The text strings associated with each property type
static const char* const ourPropertyNames[static_cast<uInt8>(PropType::NumTypes)];
static std::array<string, NUM_PROPS> ourPropertyNames;
};
#endif

View File

@ -56,8 +56,8 @@ class Audio : public Serializable
AudioChannel myChannel0;
AudioChannel myChannel1;
Int16 myMixingTableSum[0x1e + 1];
Int16 myMixingTableIndividual[0x0f + 1];
std::array<Int16, 0x1e + 1> myMixingTableSum;
std::array<Int16, 0x0f + 1> myMixingTableIndividual;
Int16* myCurrentFragment;
uInt32 mySampleIndex;

View File

@ -25,7 +25,7 @@
class DelayQueueIterator
{
public:
virtual ~DelayQueueIterator() {}
virtual ~DelayQueueIterator() = default;
public:
virtual bool isValid() const = 0;

View File

@ -49,7 +49,7 @@ class DelayQueueMember : public Serializable {
bool load(Serializer& in) override;
public:
Entry myEntries[capacity];
std::array<Entry, capacity> myEntries;
uInt8 mySize;
private:

View File

@ -123,7 +123,7 @@ class TIA : public Device
/**
Configure the frame manager.
*/
void setFrameManager(AbstractFrameManager *frameManager);
void setFrameManager(AbstractFrameManager* frameManager);
/**
Set the audio queue. This needs to be dynamic as the queue is created after
@ -540,7 +540,7 @@ class TIA : public Device
*/
enum FixedObject { P0, M0, P1, M1, PF, BL, BK };
FixedColor myFixedColorPalette[3][7];
string myFixedColorNames[7];
std::array<string, 7> myFixedColorNames;
private:
/**

View File

@ -73,7 +73,7 @@ AboutDialog::AboutDialog(OSystem& osystem, DialogContainer& parent,
{
myDesc.push_back(new StaticTextWidget(this, font, xpos, ypos, _w - xpos * 2,
fontHeight, "", TextAlign::Left));
myDescStr.push_back("");
myDescStr.emplace_back("");
ypos += fontHeight;
}
@ -152,6 +152,9 @@ void AboutDialog::updateStrings(int page, int lines, string& title)
ADD_ATEXT("\\L\\c0""VCS team for giving us the magic, and to the");
ADD_ATEXT("\\L\\c0""homebrew developers for keeping the magic alive.");
break;
default:
return;
}
while(i < lines)

View File

@ -49,6 +49,7 @@ ComboDialog::ComboDialog(GuiObject* boss, const GUI::Font& font,
ypos = 10 + _th;
// Add event popup for 8 events
myEvents.fill(nullptr);
auto ADD_EVENT_POPUP = [&](int idx, const string& label)
{
myEvents[idx] = new PopUpWidget(this, font, xpos, ypos,
@ -56,15 +57,14 @@ ComboDialog::ComboDialog(GuiObject* boss, const GUI::Font& font,
wid.push_back(myEvents[idx]);
ypos += lineHeight + 4;
};
myEvents[0] = nullptr; ADD_EVENT_POPUP(0, "Event 1 ");
myEvents[1] = nullptr; ADD_EVENT_POPUP(1, "Event 2 ");
myEvents[2] = nullptr; ADD_EVENT_POPUP(2, "Event 3 ");
myEvents[3] = nullptr; ADD_EVENT_POPUP(3, "Event 4 ");
myEvents[4] = nullptr; ADD_EVENT_POPUP(4, "Event 5 ");
myEvents[5] = nullptr; ADD_EVENT_POPUP(5, "Event 6 ");
myEvents[6] = nullptr; ADD_EVENT_POPUP(6, "Event 7 ");
myEvents[7] = nullptr; ADD_EVENT_POPUP(7, "Event 8 ");
ADD_EVENT_POPUP(0, "Event 1 ");
ADD_EVENT_POPUP(1, "Event 2 ");
ADD_EVENT_POPUP(2, "Event 3 ");
ADD_EVENT_POPUP(3, "Event 4 ");
ADD_EVENT_POPUP(4, "Event 5 ");
ADD_EVENT_POPUP(5, "Event 6 ");
ADD_EVENT_POPUP(6, "Event 7 ");
ADD_EVENT_POPUP(7, "Event 8 ");
// Add Defaults, OK and Cancel buttons
addDefaultsOKCancelBGroup(wid, font);
@ -91,7 +91,7 @@ void ComboDialog::loadConfig()
{
StringList events = instance().eventHandler().getComboListForEvent(myComboEvent);
uInt32 size = std::min(uInt32(events.size()), 8u);
uInt32 size = std::min<uInt32>(events.size(), 8);
for(uInt32 i = 0; i < size; ++i)
myEvents[i]->setSelected("", events[i]);

View File

@ -44,8 +44,7 @@ class ComboDialog : public Dialog
private:
Event::Type myComboEvent;
PopUpWidget* myEvents[8];
std::array<PopUpWidget*, 8> myEvents;
private:
// Following constructors and assignment operators not supported

View File

@ -102,7 +102,7 @@ void ContextMenu::recalc(const Common::Rect& image)
{
// Now is the time to adjust the height
// If it's higher than the screen, we need to scroll through
uInt32 maxentries = std::min(18u, (image.h() - 2) / _rowHeight);
uInt32 maxentries = std::min<uInt32>(18, (image.h() - 2) / _rowHeight);
if(_entries.size() > maxentries)
{
// We show two less than the max, so we have room for two scroll buttons
@ -521,7 +521,7 @@ void ContextMenu::scrollDown(int distance)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void ContextMenu::drawDialog()
{
static uInt32 up_arrow[8] = {
static constexpr uInt32 up_arrow[8] = {
0b00011000,
0b00011000,
0b00111100,
@ -531,7 +531,7 @@ void ContextMenu::drawDialog()
0b11111111,
0b11111111
};
static uInt32 down_arrow[8] = {
static constexpr uInt32 down_arrow[8] = {
0b11111111,
0b11111111,
0b01111110,

View File

@ -759,6 +759,9 @@ void Dialog::handleCommand(CommandSender* sender, int cmd, int data, int id)
case GuiObject::kCloseCmd:
close();
break;
default:
break;
}
}

View File

@ -126,7 +126,7 @@ class Dialog : public GuiObject
bool shouldResize(uInt32& w, uInt32& h) const;
protected:
virtual void draw() override { }
void draw() override { }
void releaseFocus() override;
virtual void handleText(char text);
@ -141,7 +141,7 @@ class Dialog : public GuiObject
virtual void handleJoyUp(int stick, int button);
virtual void handleJoyAxis(int stick, JoyAxis axis, JoyDir adir, int button = JOY_CTRL_NONE);
virtual bool handleJoyHat(int stick, int hat, JoyHatDir hdir, int button = JOY_CTRL_NONE);
virtual void handleCommand(CommandSender* sender, int cmd, int data, int id) override;
void handleCommand(CommandSender* sender, int cmd, int data, int id) override;
virtual Event::Type getJoyAxisEvent(int stick, JoyAxis axis, JoyDir adir, int button);
Widget* findWidget(int x, int y) const; // Find the widget at pos x,y if any

View File

@ -74,7 +74,7 @@ class FileListWidget : public StringListWidget
/** Gets current node(s) */
const FilesystemNode& selected() {
_selected = BSPF::clamp(_selected, 0u, uInt32(_fileList.size()-1));
_selected = BSPF::clamp(_selected, 0U, uInt32(_fileList.size()-1));
return _fileList[_selected];
}
const FilesystemNode& currentDir() const { return _node; }

View File

@ -213,7 +213,7 @@ void PopUpWidget::drawWidget(bool hilite)
s.fillRect(x + w - 15, _y + 2, 13, _h - 4, onTop ? isEnabled() && hilite ? kWidColor : kBGColorHi : kBGColorLo);
// Draw an arrow pointing down at the right end to signal this is a dropdown/popup
s.drawBitmap(down_arrow, x + w - 13, _y + myArrowsY + 1,
!(isEnabled() && onTop) ? kColor : kTextColor, 9u, 8u);
!(isEnabled() && onTop) ? kColor : kTextColor, 9U, 8U);
// Draw the selected entry, if any
const string& name = myMenu->getSelectedName();

View File

@ -420,7 +420,7 @@ void TimeMachineDialog::initBar()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string TimeMachineDialog::getTimeString(uInt64 cycles)
{
const Int32 scanlines = std::max(instance().console().tia().scanlinesLastFrame(), 240u);
const Int32 scanlines = std::max<Int32>(instance().console().tia().scanlinesLastFrame(), 240);
const bool isNTSC = scanlines <= 287;
const Int32 NTSC_FREQ = 1193182; // ~76*262*60
const Int32 PAL_FREQ = 1182298; // ~76*312*50

View File

@ -16,6 +16,7 @@
//============================================================================
#include "bspf.hxx"
#include "DialogContainer.hxx"
#include "BrowserDialog.hxx"
#include "Dialog.hxx"
#include "OSystem.hxx"
@ -438,8 +439,8 @@ void UIDialog::setDefaults()
{
FilesystemNode node("~");
myRomPath->setText(node.getShortPath());
uInt32 w = std::min(instance().frameBuffer().desktopSize().w, 900u);
uInt32 h = std::min(instance().frameBuffer().desktopSize().h, 600u);
uInt32 w = std::min<uInt32>(instance().frameBuffer().desktopSize().w, 900);
uInt32 h = std::min<uInt32>(instance().frameBuffer().desktopSize().h, 600);
myLauncherWidthSlider->setValue(w);
myLauncherHeightSlider->setValue(h);
myLauncherFontPopup->setSelected("medium", "");

View File

@ -188,6 +188,7 @@ class StaticTextWidget : public Widget
int x, int y,
const string& text = "", TextAlign align = TextAlign::Left,
ColorId shadowColor = kNone);
virtual ~StaticTextWidget() = default;
void setValue(int value);
void setLabel(const string& label);
void setAlign(TextAlign align) { _align = align; setDirty(); }
@ -228,6 +229,7 @@ class ButtonWidget : public StaticTextWidget, public CommandSender
int x, int y, int dw, int dh,
uInt32* bitmap, int bmw, int bmh,
int cmd = 0, bool repeat = false);
virtual ~ButtonWidget() = default;
void setCmd(int cmd) { _cmd = cmd; }
int getCmd() const { return _cmd; }
@ -270,6 +272,7 @@ class CheckboxWidget : public ButtonWidget
public:
CheckboxWidget(GuiObject* boss, const GUI::Font& font, int x, int y,
const string& label, int cmd = 0);
virtual ~CheckboxWidget() = default;
void setEditable(bool editable);
void setFill(FillType type);
@ -319,6 +322,7 @@ class SliderWidget : public ButtonWidget
int x, int y,
const string& label = "", int labelWidth = 0, int cmd = 0,
int valueLabelWidth = 0, const string& valueUnit = "", int valueLabelGap = 4);
virtual ~SliderWidget() = default;
void setValue(int value);
int getValue() const { return _value; }