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 ByteArray = std::vector<uInt8>;
using ShortArray = std::vector<uInt16>; using ShortArray = std::vector<uInt16>;
using StringList = std::vector<std::string>; 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 // We use KB a lot; let's make a literal for it
constexpr uInt32 operator "" _KB(unsigned long long size) constexpr uInt32 operator "" _KB(unsigned long long size)

View File

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

View File

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

View File

@ -221,6 +221,9 @@ void CommandDialog::handleCommand(CommandSender* sender, int cmd,
instance().eventHandler().leaveMenuMode(); instance().eventHandler().leaveMenuMode();
instance().reloadConsole(); instance().reloadConsole();
break; break;
default:
return;
} }
// Console commands should be performed right away, after leaving the menu // 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() void ContextMenu::drawDialog()
{ {
static constexpr uInt32 up_arrow[8] = { static constexpr std::array<uInt32, 8> up_arrow = {
0b00011000, 0b00011000,
0b00011000, 0b00011000,
0b00111100, 0b00111100,
@ -531,7 +531,7 @@ void ContextMenu::drawDialog()
0b11111111, 0b11111111,
0b11111111 0b11111111
}; };
static constexpr uInt32 down_arrow[8] = { static constexpr std::array<uInt32, 8> down_arrow = {
0b11111111, 0b11111111,
0b11111111, 0b11111111,
0b01111110, 0b01111110,
@ -559,7 +559,7 @@ void ContextMenu::drawDialog()
if(_showScroll) if(_showScroll)
{ {
s.hLine(x, y+_rowHeight-1, w+2, kColor); 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; y += _rowHeight;
offset--; offset--;
} }
@ -577,7 +577,7 @@ void ContextMenu::drawDialog()
if(_showScroll) if(_showScroll)
{ {
s.hLine(x, y, w+2, kColor); 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(); setDirty();