A few more cleanups from clang-tidy.

This commit is contained in:
Stephen Anthony 2019-12-26 11:55:25 -03:30
parent 1c37618426
commit df4748417d
5 changed files with 23 additions and 28 deletions

View File

@ -83,7 +83,7 @@ using BoolArray = std::vector<bool>;
using ByteArray = std::vector<uInt8>;
using ShortArray = std::vector<uInt16>;
using StringList = std::vector<std::string>;
using ByteBuffer = std::unique_ptr<uInt8[]>;
using ByteBuffer = std::unique_ptr<uInt8[]>; // NOLINT
// We use KB a lot; let's make a literal for it
constexpr uInt32 operator "" _KB(unsigned long long size)

View File

@ -50,7 +50,7 @@ class DelayQueue : public Serializable
bool load(Serializer& in) override;
private:
DelayQueueMember<capacity> myMembers[length];
std::array<DelayQueueMember<capacity>, length> myMembers;
uInt8 myIndex;
std::array<uInt8, 0xFF> myIndices;

View File

@ -168,37 +168,29 @@ bool CheckListWidget::getState(int line)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CheckListWidget::handleEvent(Event::Type e)
{
switch(e)
if(e == Event::UISelect)
{
case Event::UISelect:
// Simulate a mouse button click
_checkList[ListWidget::getSelected()]->handleMouseUp(0, 0, MouseButton::LEFT, 0);
return true;
default:
return ListWidget::handleEvent(e);
// Simulate a mouse button click
_checkList[ListWidget::getSelected()]->handleMouseUp(0, 0, MouseButton::LEFT, 0);
return true;
}
else
return ListWidget::handleEvent(e);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CheckListWidget::handleCommand(CommandSender* sender, int cmd,
int data, int id)
{
switch(cmd)
if(cmd == CheckboxWidget::kCheckActionCmd)
{
case CheckboxWidget::kCheckActionCmd:
{
// Figure out which line has been checked
int line = _currentPos + id;
_stateList[line] = bool(data);
// Figure out which line has been checked
int line = _currentPos + id;
_stateList[line] = bool(data);
// Let the boss know about it
sendCommand(CheckListWidget::kListItemChecked, line, _id);
break;
}
default:
ListWidget::handleCommand(sender, cmd, data, id);
break;
// Let the boss know about it
sendCommand(CheckListWidget::kListItemChecked, line, _id);
}
else
ListWidget::handleCommand(sender, cmd, data, id);
}

View File

@ -221,6 +221,9 @@ void CommandDialog::handleCommand(CommandSender* sender, int cmd,
instance().eventHandler().leaveMenuMode();
instance().reloadConsole();
break;
default:
return;
}
// Console commands should be performed right away, after leaving the menu

View File

@ -521,7 +521,7 @@ void ContextMenu::scrollDown(int distance)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void ContextMenu::drawDialog()
{
static constexpr uInt32 up_arrow[8] = {
static constexpr std::array<uInt32, 8> up_arrow = {
0b00011000,
0b00011000,
0b00111100,
@ -531,7 +531,7 @@ void ContextMenu::drawDialog()
0b11111111,
0b11111111
};
static constexpr uInt32 down_arrow[8] = {
static constexpr std::array<uInt32, 8> down_arrow = {
0b11111111,
0b11111111,
0b01111110,
@ -559,7 +559,7 @@ void ContextMenu::drawDialog()
if(_showScroll)
{
s.hLine(x, y+_rowHeight-1, w+2, kColor);
s.drawBitmap(up_arrow, ((_w-_x)>>1)-4, (_rowHeight>>1)+y-4, _scrollUpColor, 8);
s.drawBitmap(up_arrow.data(), ((_w-_x)>>1)-4, (_rowHeight>>1)+y-4, _scrollUpColor, 8);
y += _rowHeight;
offset--;
}
@ -577,7 +577,7 @@ void ContextMenu::drawDialog()
if(_showScroll)
{
s.hLine(x, y, w+2, kColor);
s.drawBitmap(down_arrow, ((_w-_x)>>1)-4, (_rowHeight>>1)+y-4, _scrollDnColor, 8);
s.drawBitmap(down_arrow.data(), ((_w-_x)>>1)-4, (_rowHeight>>1)+y-4, _scrollDnColor, 8);
}
setDirty();