Air-Trap 1.0.0
A multiplayer R-Type clone game engine built with C++23 and ECS architecture
Loading...
Searching...
No Matches
Dropdown.hpp
Go to the documentation of this file.
1/*
2** EPITECH PROJECT, 2025
3** Air-Trap
4** File description:
5** Dropdown - UI component for selection from list
6*/
7
8#pragma once
9
10#include <functional>
11#include <vector>
12#include <string>
13#include "RType/Math/Vec2.hpp"
14
16
21struct Dropdown {
23 Vec2f size{200.0f, 40.0f};
24 std::vector<std::string> options;
26 std::function<void(int)> onSelect;
28 // Visual properties
29 uint8_t bgColor[3]{100, 100, 100};
30 uint8_t hoverColor[3]{120, 120, 120};
31 uint8_t textColor[3]{255, 255, 255};
33 bool isOpen{false};
34 int hoveredIndex{-1};
35 int zIndex{10};
40 std::string getSelected() const {
41 if (selectedIndex >= 0 && selectedIndex < static_cast<int>(options.size())) {
42 return options[selectedIndex];
43 }
44 return "";
45 }
46};
47
48} // namespace rtp::ecs::components::ui
Declaration of the 2-dimensional vector class.
File : SpritePreview.hpp License: MIT Author : GitHub Copilot Date : 14/01/2026.
Definition Button.hpp:14
Component for dropdown menu selection.
Definition Dropdown.hpp:21
int selectedIndex
Currently selected option.
Definition Dropdown.hpp:25
Vec2f position
Position of the dropdown.
Definition Dropdown.hpp:22
std::function< void(int)> onSelect
Callback when option selected.
Definition Dropdown.hpp:26
bool isOpen
Is dropdown menu open.
Definition Dropdown.hpp:33
std::vector< std::string > options
Available options.
Definition Dropdown.hpp:24
uint8_t hoverColor[3]
RGB hover color.
Definition Dropdown.hpp:30
Vec2f size
Size of the dropdown button.
Definition Dropdown.hpp:23
int hoveredIndex
Currently hovered option.
Definition Dropdown.hpp:34
std::string getSelected() const
Get currently selected option text.
Definition Dropdown.hpp:40
uint8_t textColor[3]
RGB text color.
Definition Dropdown.hpp:31
uint8_t bgColor[3]
RGB background color.
Definition Dropdown.hpp:29