58 lines
1.6 KiB
C++
58 lines
1.6 KiB
C++
#pragma once
|
|
|
|
#include <XCEngine/UI/DrawData.h>
|
|
|
|
#include <cstddef>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
namespace XCEngine::Components {
|
|
class GameObject;
|
|
}
|
|
|
|
namespace XCEngine::UI::Editor::App {
|
|
|
|
class EditorContext;
|
|
|
|
struct AddComponentPanelHostContext {
|
|
bool mounted = false;
|
|
::XCEngine::UI::UIRect bounds = {};
|
|
bool focused = false;
|
|
bool focusGained = false;
|
|
bool focusLost = false;
|
|
};
|
|
|
|
class AddComponentPanel {
|
|
public:
|
|
void ResetInteractionState();
|
|
void Update(
|
|
EditorContext& context,
|
|
const AddComponentPanelHostContext& hostContext,
|
|
const std::vector<::XCEngine::UI::UIInputEvent>& inputEvents);
|
|
void Append(::XCEngine::UI::UIDrawList& drawList) const;
|
|
|
|
private:
|
|
struct EntryPresentation {
|
|
std::string componentTypeName = {};
|
|
std::string displayName = {};
|
|
std::string disabledReason = {};
|
|
::XCEngine::UI::UIRect rect = {};
|
|
bool enabled = false;
|
|
};
|
|
|
|
void ResetPanelState();
|
|
void RebuildEntries(const ::XCEngine::Components::GameObject* gameObject);
|
|
bool TryActivateEntry(EditorContext& context, std::size_t entryIndex);
|
|
std::size_t HitTestEntry(const ::XCEngine::UI::UIPoint& point) const;
|
|
|
|
bool m_visible = false;
|
|
bool m_hasTarget = false;
|
|
::XCEngine::UI::UIRect m_bounds = {};
|
|
std::string m_targetDisplayName = {};
|
|
std::vector<EntryPresentation> m_entries = {};
|
|
std::size_t m_hoveredEntryIndex = static_cast<std::size_t>(-1);
|
|
std::size_t m_pressedEntryIndex = static_cast<std::size_t>(-1);
|
|
};
|
|
|
|
} // namespace XCEngine::UI::Editor::App
|