LibGUI: Add a helper for VerticalDirection

The function converts Key_[Up, Down] to the corresponding
VerticalDirection.
This commit is contained in:
Lucas CHOLLET 2022-06-07 22:43:08 +02:00 committed by Andreas Kling
parent 0bcfbdb072
commit 4d93fb4789

View file

@ -52,6 +52,15 @@ enum class VerticalDirection {
Down
};
constexpr VerticalDirection key_code_to_vertical_direction(KeyCode const& key)
{
if (key == Key_Up)
return VerticalDirection::Up;
if (key == Key_Down)
return VerticalDirection::Down;
VERIFY_NOT_REACHED();
}
enum class AllowCallback {
No,
Yes