mirror of
https://github.com/XITRIX/NXKit.git
synced 2026-05-30 11:46:52 +00:00
45 lines
1.0 KiB
C++
45 lines
1.0 KiB
C++
//
|
|
// UIFocusSystem.hpp
|
|
// SDLTest
|
|
//
|
|
// Created by Даниил Виноградов on 02.04.2023.
|
|
//
|
|
|
|
#pragma once
|
|
|
|
#include <UIFocus.h>
|
|
#include <UIEvent.h>
|
|
|
|
namespace NXKit {
|
|
|
|
class UIView;
|
|
class UIWindow;
|
|
class UIPressesEvent;
|
|
class UIFocusSystem {
|
|
public:
|
|
UIFocusSystem();
|
|
|
|
// Return nullptr if FocusSystem is not active
|
|
std::weak_ptr<UIFocusItem> focusedItem() { return _isActive ? _focusedItem : std::weak_ptr<UIFocusItem>(); }
|
|
private:
|
|
void setActive(bool active);
|
|
bool _isActive = true;
|
|
|
|
std::weak_ptr<UIFocusItem> _selectedFocusedItem;
|
|
std::weak_ptr<UIFocusItem> _focusedItem;
|
|
std::weak_ptr<UIWindow> _rootWindow;
|
|
|
|
void updateFocus();
|
|
void sendEvent(const std::shared_ptr<UIEvent>& event);
|
|
|
|
std::shared_ptr<UIFocusItem> findItemToFocus();
|
|
void applyFocusToItem(const std::shared_ptr<UIFocusItem>& item, UIFocusUpdateContext context);
|
|
|
|
static UIFocusHeading makeFocusHeadingFromEvent(const std::shared_ptr<UIPressesEvent>& event);
|
|
|
|
friend class UIWindow;
|
|
friend class UIControl;
|
|
};
|
|
|
|
}
|