ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
Combobox.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - CloudViewer: www.cloudViewer.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2024 www.cloudViewer.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
8 #pragma once
9 
10 #include <functional>
11 
13 
14 namespace cloudViewer {
15 namespace visualization {
16 namespace gui {
17 
18 class Combobox : public Widget {
19 public:
20  Combobox();
21  explicit Combobox(const std::vector<const char*>& items);
22  ~Combobox() override;
23 
24  void ClearItems();
28  int AddItem(const char* name);
29 
32  void ChangeItem(int index, const char* name);
35  void ChangeItem(const char* orig_name, const char* new_name);
36 
38  void RemoveItem(const char* name);
40  void RemoveItem(int index);
41 
42  int GetNumberOfItems() const;
43 
46  const char* GetItem(int index) const;
47 
48  int GetSelectedIndex() const;
50  const char* GetSelectedValue() const;
53  void SetSelectedIndex(int index);
56  bool SetSelectedValue(const char* value);
57 
59  const Constraints& constraints) const override;
60 
61  DrawResult Draw(const DrawContext& context) override;
62 
65  void SetOnValueChanged(
66  std::function<void(const char*, int)> on_value_changed);
67 
68 private:
69  struct Impl;
70  std::unique_ptr<Impl> impl_;
71 };
72 
73 } // namespace gui
74 } // namespace visualization
75 } // namespace cloudViewer
std::string name
void RemoveItem(const char *name)
Removes the first item matching the given text.
Definition: Combobox.cpp:74
const char * GetSelectedValue() const
Returns the text of the selected value, or "" if nothing is selected.
Definition: Combobox.cpp:102
Size CalcPreferredSize(const LayoutContext &context, const Constraints &constraints) const override
Definition: Combobox.cpp:133
DrawResult Draw(const DrawContext &context) override
Definition: Combobox.cpp:148
bool SetSelectedValue(const char *value)
Definition: Combobox.cpp:117
void ChangeItem(int index, const char *name)
Definition: Combobox.cpp:61
const char * GetItem(int index) const
Definition: Combobox.cpp:96
void SetOnValueChanged(std::function< void(const char *, int)> on_value_changed)
Definition: Combobox.cpp:128
ImGuiContext * context
Definition: Window.cpp:76
Generic file read and write utility for python interface.