From d62153451127bbb4d7013b540f03cbe19413a647 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Thu, 21 Oct 2021 12:29:36 +0200 Subject: [PATCH] LibGUI: Move GUI::FocusPolicy to its own header & add explainer comment --- Userland/Libraries/LibGUI/FocusPolicy.h | 28 +++++++++++++++++++++++++ Userland/Libraries/LibGUI/Widget.h | 10 +-------- 2 files changed, 29 insertions(+), 9 deletions(-) create mode 100644 Userland/Libraries/LibGUI/FocusPolicy.h diff --git a/Userland/Libraries/LibGUI/FocusPolicy.h b/Userland/Libraries/LibGUI/FocusPolicy.h new file mode 100644 index 0000000000..20fa101d76 --- /dev/null +++ b/Userland/Libraries/LibGUI/FocusPolicy.h @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2020-2021, Andreas Kling + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#pragma once + +#include + +namespace GUI { + +// FocusPolicy determines how GUI widgets gain focus. +// +// - NoFocus: The widget is not focusable. +// - TabFocus: The widget can gain focus by cycling through focusable widgets with the Tab key. +// - ClickFocus: The widget gains focus when clicked. +// - StrongFocus: The widget can gain focus both via Tab, and by clicking on it. +enum class FocusPolicy { + NoFocus = 0, + TabFocus = 0x1, + ClickFocus = 0x2, + StrongFocus = TabFocus | ClickFocus, +}; + +AK_ENUM_BITWISE_OPERATORS(FocusPolicy) + +} diff --git a/Userland/Libraries/LibGUI/Widget.h b/Userland/Libraries/LibGUI/Widget.h index b4d97b515c..d8de4d6ff5 100644 --- a/Userland/Libraries/LibGUI/Widget.h +++ b/Userland/Libraries/LibGUI/Widget.h @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -45,15 +46,6 @@ enum class VerticalDirection { Down }; -enum class FocusPolicy { - NoFocus = 0, - TabFocus = 0x1, - ClickFocus = 0x2, - StrongFocus = TabFocus | ClickFocus, -}; - -AK_ENUM_BITWISE_OPERATORS(FocusPolicy) - enum class AllowCallback { No, Yes