Skip to content

Commit

Permalink
Switch to C++20 and utilize std::erase_if (broken)
Browse files Browse the repository at this point in the history
  • Loading branch information
martonmiklos committed Jan 11, 2025
1 parent 328a4ca commit 9780ab9
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 26 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ juce_add_gui_app(
DESCRIPTION
"An ISO11783-6 Server")

set_target_properties(AgISOVirtualTerminal PROPERTIES CXX_STANDARD 17)
set_target_properties(AgISOVirtualTerminal PROPERTIES CXX_STANDARD 20)

target_compile_definitions(AgISOVirtualTerminal PRIVATE JUCE_USE_CURL=0
JUCE_WEB_BROWSER=0)
Expand Down
42 changes: 18 additions & 24 deletions src/ServerMainComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1174,30 +1174,24 @@ void ServerMainComponent::handle_softkey_release_if_mask_changed()
{
// If a Key object .... is erased from the screen ... while it is activated, the VT shall send a Soft Key Activation message
// ... indicating released to the erased object on its parent Data Mask.

for (auto button = heldButtons.begin(); button != heldButtons.end();)
{
if (button->softKeyMaskObjectID != activeWorkingSetSoftkeyMaskObjectID)
{
if (button->isSoftKey)
{
send_soft_key_activation_message(isobus::VirtualTerminalBase::KeyActivationCode::ButtonUnlatchedOrReleased,
button->buttonObjectID,
button->softKeyMaskObjectID,
button->buttonKeyCode,
get_active_working_set()->get_control_function());
// In the case if a currently pressed softkey is being replaced with a new one during a softkey mask change
// the mouseUp event on the newly added key will not be called, however the mouseRelease will.
// To prevent sending the unneeded mouse release events in this scenario we cache the softkey positions of the pressed and replaced keys.
softKeyPositionReleasedByMaskChange = button->keyPosition;
button = heldButtons.erase(button);
}
}
else
{
button++;
}
}
std::erase_if(heldButtons,
[this] (const HeldButtonData button)
{
if ((button.softKeyMaskObjectID != activeWorkingSetSoftkeyMaskObjectID) && button.isSoftKey)
{
send_soft_key_activation_message(isobus::VirtualTerminalBase::KeyActivationCode::ButtonUnlatchedOrReleased,
button.buttonObjectID,
button.softKeyMaskObjectID,
button.buttonKeyCode,
get_active_working_set()->get_control_function());
// In the case if a currently pressed softkey is being replaced with a new one during a softkey mask change
// the mouseUp event on the newly added key will not be called, however the mouseRelease will.
// To prevent sending the unneeded mouse release events in this scenario we cache the softkey positions of the pressed and replaced keys.
softKeyPositionReleasedByMaskChange = button.keyPosition;
return true;
}
return false;
});
}

void ServerMainComponent::repaint_on_next_update()
Expand Down
2 changes: 1 addition & 1 deletion src/SoftKeyMaskComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ void SoftKeyMaskComponent::on_content_changed(bool initial)

if (isobus::VirtualTerminalObjectType::ObjectPointer == child->get_object_type())
{
childComponents.back()->setSize(softKeyWidth, softKeyHeight);
childComponents.back()->setSize(dimensionInfo.keyHeight, dimensionInfo.keyWidth);
auto keyReference = get_object_by_id(std::static_pointer_cast<ObjectPointerComponent>(childComponents.back())->get_value(), parentWorkingSet->get_object_tree());
if (nullptr != keyReference && isobus::VirtualTerminalObjectType::Key == child->get_object_type())
{
Expand Down

0 comments on commit 9780ab9

Please sign in to comment.