2021-08-06 14:22:56 +02:00
|
|
|
#ifndef BWIDGETS_FOCUS_HANDLER_HPP
|
|
|
|
#define BWIDGETS_FOCUS_HANDLER_HPP
|
2021-07-18 18:26:12 +02:00
|
|
|
|
|
|
|
struct SDL_Rect;
|
|
|
|
|
2021-08-06 14:22:56 +02:00
|
|
|
namespace bwidgets
|
2021-07-18 18:26:12 +02:00
|
|
|
{
|
|
|
|
class FocusHandler
|
|
|
|
{
|
2021-07-29 16:06:03 +02:00
|
|
|
protected:
|
|
|
|
const SDL_Rect* _focus_area = nullptr;
|
|
|
|
bool _has_focus = false;
|
2021-07-18 18:26:12 +02:00
|
|
|
|
2021-07-29 16:06:03 +02:00
|
|
|
virtual void _handle_focus_change(bool) = 0;
|
2021-07-18 18:26:12 +02:00
|
|
|
|
2021-07-29 16:06:03 +02:00
|
|
|
public:
|
2021-08-12 16:10:49 +02:00
|
|
|
FocusHandler() = default;
|
2021-08-12 15:29:25 +02:00
|
|
|
FocusHandler(const FocusHandler&) = delete;
|
2021-08-12 16:10:49 +02:00
|
|
|
FocusHandler(FocusHandler&&) = delete;
|
|
|
|
virtual ~FocusHandler() = default;
|
2021-07-18 18:26:12 +02:00
|
|
|
|
2021-08-12 15:29:25 +02:00
|
|
|
auto operator=(FocusHandler&&) -> FocusHandler& = delete;
|
|
|
|
auto operator=(const FocusHandler&) -> FocusHandler& = delete;
|
|
|
|
|
2021-07-29 16:06:03 +02:00
|
|
|
virtual inline void focus(bool focus) final
|
|
|
|
{
|
|
|
|
_handle_focus_change(focus);
|
|
|
|
_has_focus = focus;
|
|
|
|
}
|
2021-07-18 18:26:12 +02:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|