FreeRDP
SDL3/dialogs/sdl_selectlist.hpp
1 #pragma once
2 
3 #include <string>
4 #include <vector>
5 
6 #include <SDL3/SDL.h>
7 
8 #include "sdl_select.hpp"
9 #include "sdl_button.hpp"
10 #include "sdl_buttons.hpp"
11 
12 class SdlSelectList
13 {
14  public:
15  SdlSelectList(const std::string& title, const std::vector<std::string>& labels);
16  SdlSelectList(const SdlSelectList& other) = delete;
17  SdlSelectList(SdlSelectList&& other) = delete;
18  virtual ~SdlSelectList();
19 
20  SdlSelectList& operator=(const SdlSelectList& other) = delete;
21  SdlSelectList& operator=(SdlSelectList&& other) = delete;
22 
23  int run();
24 
25  private:
26  enum
27  {
28  INPUT_BUTTON_ACCEPT = 0,
29  INPUT_BUTTON_CANCEL = -2
30  };
31 
32  ssize_t get_index(const SDL_MouseButtonEvent& button);
33  bool update_text();
34  void reset_mouseover();
35  void reset_highlight();
36 
37  SDL_Window* _window;
38  SDL_Renderer* _renderer;
39  std::vector<SdlSelectWidget> _list;
40  SdlButtonList _buttons;
41 };