Open3D (C++ API)  0.18.0+252c867
Combobox.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - Open3D: www.open3d.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2023 www.open3d.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
8 #pragma once
9 
10 #include <functional>
11 
13 
14 namespace open3d {
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 open3d
ImGuiContext * context
Definition: Window.cpp:76
Definition: Combobox.h:18
Combobox()
Definition: Combobox.cpp:39
~Combobox() override
Definition: Combobox.cpp:49
DrawResult Draw(const DrawContext &context) override
Definition: Combobox.cpp:148
int AddItem(const char *name)
Definition: Combobox.cpp:56
void RemoveItem(const char *name)
Removes the first item matching the given text.
Definition: Combobox.cpp:74
void ClearItems()
Definition: Combobox.cpp:51
void ChangeItem(int index, const char *name)
Definition: Combobox.cpp:61
const char * GetSelectedValue() const
Returns the text of the selected value, or "" if nothing is selected.
Definition: Combobox.cpp:102
const char * GetItem(int index) const
Definition: Combobox.cpp:96
Size CalcPreferredSize(const LayoutContext &context, const Constraints &constraints) const override
Definition: Combobox.cpp:133
bool SetSelectedValue(const char *value)
Definition: Combobox.cpp:117
void SetSelectedIndex(int index)
Definition: Combobox.cpp:111
int GetSelectedIndex() const
Definition: Combobox.cpp:100
void SetOnValueChanged(std::function< void(const char *, int)> on_value_changed)
Definition: Combobox.cpp:128
int GetNumberOfItems() const
Definition: Combobox.cpp:92
Definition: Widget.h:49
DrawResult
Definition: Widget.h:95
std::string name
Definition: FilePCD.cpp:39
Definition: PinholeCameraIntrinsic.cpp:16