bwidgets/inc/basic_widgets/w/feat/focus_handler.hpp

34 lines
824 B
C++
Raw Normal View History

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