MGL(Win32)
読み取り中…
検索中…
一致する文字列を見つけられません
mgl_ui_input_scope.h
[詳解]
1// SPDX-License-Identifier: Zlib
2/* ------------------------------------------------------------------------- */
9/* ------------------------------------------------------------------------- */
10
11#ifndef INCGUARD_MGL_UI_INPUT_SCOPE_H_1698499179
12#define INCGUARD_MGL_UI_INPUT_SCOPE_H_1698499179
13
15
16namespace MGL::UI
17{
19enum class ScopeOutBehavior : uint8_t
20{
21 Unfocus,
22 Keep
23};
24
27{
28public:
29 /* ------------------------------------------------------------------------- */
33 /* ------------------------------------------------------------------------- */
34 constexpr InputScope() noexcept = default;
35
36 /* ------------------------------------------------------------------------- */
42 /* ------------------------------------------------------------------------- */
43 constexpr InputScope(const Rectangle &scope,
44 ScopeOutBehavior behavior = ScopeOutBehavior::Unfocus) noexcept
45 : _isValid(scope.width <= 0.0f || scope.height <= 0.0f)
46 , _scope(scope)
47 , _behavior(behavior)
48 {
49 }
50
51 /* ------------------------------------------------------------------------- */
56 /* ------------------------------------------------------------------------- */
57 constexpr void SetScope(const Rectangle &scope) noexcept
58 {
59 _scope = scope;
60 _isValid = (scope.width <= 0.0f || scope.height <= 0.0f);
61 }
62
63 /* ------------------------------------------------------------------------- */
68 /* ------------------------------------------------------------------------- */
69 constexpr void SetBehavior(ScopeOutBehavior behavior) noexcept
70 {
71 _behavior = behavior;
72 }
73
74 /* ------------------------------------------------------------------------- */
79 /* ------------------------------------------------------------------------- */
80 [[nodiscard]] constexpr ScopeOutBehavior GetBehavior() const noexcept
81 {
82 return _behavior;
83 }
84
85 /* ------------------------------------------------------------------------- */
92 /* ------------------------------------------------------------------------- */
93 [[nodiscard]] bool IsEnclosed(const Vector2 &position) const noexcept
94 {
95 return _scope.IsEnclosed(position);
96 }
97
98 /* ------------------------------------------------------------------------- */
104 /* ------------------------------------------------------------------------- */
105 [[nodiscard]] constexpr bool IsValid() const noexcept
106 {
107 return _isValid;
108 }
109
110private:
111 bool _isValid{false};
112 Rectangle _scope;
113 ScopeOutBehavior _behavior{ScopeOutBehavior::Unfocus};
114};
115
116} // namespace MGL::UI
117
118#endif // INCGUARD_MGL_UI_INPUT_SCOPE_H_1698499179
119
120// vim: et ts=4 sw=4 sts=4
入力の有効範囲
Definition mgl_ui_input_scope.h:27
constexpr ScopeOutBehavior GetBehavior() const noexcept
入力範囲外に出た際の挙動を取得
Definition mgl_ui_input_scope.h:80
constexpr void SetBehavior(ScopeOutBehavior behavior) noexcept
入力範囲外に出た際の挙動を設定
Definition mgl_ui_input_scope.h:69
constexpr bool IsValid() const noexcept
有効な入力範囲が設定されているかを取得
Definition mgl_ui_input_scope.h:105
bool IsEnclosed(const Vector2 &position) const noexcept
指定した座標が入力範囲内に入っているかを取得
Definition mgl_ui_input_scope.h:93
constexpr void SetScope(const Rectangle &scope) noexcept
有効範囲を設定
Definition mgl_ui_input_scope.h:57
constexpr InputScope() noexcept=default
コンストラクタ
MGL 矩形
@ Unfocus
フォーカス解除
ScopeOutBehavior
有効範囲外に出た際の挙動
Definition mgl_ui_input_scope.h:20
@ Keep
フォーカス状態を保持
矩形
Definition mgl_rectangle.h:20
constexpr bool IsEnclosed(const Vector2 &point) const noexcept
指定した位置が矩形の内側にあるかを取得
Definition mgl_rectangle.h:148
2Dベクトル
Definition mgl_vector2.h:23