FreeRDP
SDL3/dialogs/sdl_buttons.hpp
1 #pragma once
2 
3 #include <vector>
4 #include <cstdint>
5 
6 #include "sdl_button.hpp"
7 
8 class SdlButtonList
9 {
10  public:
11  SdlButtonList() = default;
12  SdlButtonList(const SdlButtonList& other) = delete;
13  SdlButtonList(SdlButtonList&& other) = delete;
14  virtual ~SdlButtonList();
15 
16  SdlButtonList& operator=(const SdlButtonList& other) = delete;
17  SdlButtonList& operator=(SdlButtonList&& other) = delete;
18 
19  bool populate(SDL_Renderer* renderer, const std::vector<std::string>& labels,
20  const std::vector<int>& ids, Sint32 total_width, Sint32 offsetY, Sint32 width,
21  Sint32 height);
22 
23  bool update(SDL_Renderer* renderer);
24  SdlButton* get_selected(const SDL_MouseButtonEvent& button);
25  SdlButton* get_selected(float x, float y);
26 
27  bool set_highlight_next(bool reset = false);
28  bool set_highlight(size_t index);
29  bool set_mouseover(float x, float y);
30 
31  void clear();
32 
33  private:
34  std::vector<SdlButton> _list;
35  SdlButton* _highlighted = nullptr;
36  size_t _highlight_index = 0;
37  SdlButton* _mouseover = nullptr;
38 };