Loading [MathJax]/extensions/TeX/AMSsymbols.js
Open3D (C++ API)  0.14.1
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Combobox.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - Open3D: www.open3d.org -
3 // ----------------------------------------------------------------------------
4 // The MIT License (MIT)
5 //
6 // Copyright (c) 2018-2021 www.open3d.org
7 //
8 // Permission is hereby granted, free of charge, to any person obtaining a copy
9 // of this software and associated documentation files (the "Software"), to deal
10 // in the Software without restriction, including without limitation the rights
11 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 // copies of the Software, and to permit persons to whom the Software is
13 // furnished to do so, subject to the following conditions:
14 //
15 // The above copyright notice and this permission notice shall be included in
16 // all copies or substantial portions of the Software.
17 //
18 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 // IN THE SOFTWARE.
25 // ----------------------------------------------------------------------------
26 
27 #pragma once
28 
29 #include <functional>
30 
32 
33 namespace open3d {
34 namespace visualization {
35 namespace gui {
36 
37 class Combobox : public Widget {
38 public:
39  Combobox();
40  explicit Combobox(const std::vector<const char*>& items);
41  ~Combobox() override;
42 
43  void ClearItems();
47  int AddItem(const char* name);
48 
51  void ChangeItem(int index, const char* name);
54  void ChangeItem(const char* orig_name, const char* new_name);
55 
57  void RemoveItem(const char* name);
59  void RemoveItem(int index);
60 
61  int GetNumberOfItems() const;
62 
65  const char* GetItem(int index) const;
66 
67  int GetSelectedIndex() const;
69  const char* GetSelectedValue() const;
72  void SetSelectedIndex(int index);
75  bool SetSelectedValue(const char* value);
76 
78  const Constraints& constraints) const override;
79 
80  DrawResult Draw(const DrawContext& context) override;
81 
84  void SetOnValueChanged(
85  std::function<void(const char*, int)> on_value_changed);
86 
87 private:
88  struct Impl;
89  std::unique_ptr<Impl> impl_;
90 };
91 
92 } // namespace gui
93 } // namespace visualization
94 } // namespace open3d
const char * GetItem(int index) const
Definition: Combobox.cpp:115
Definition: Widget.h:68
int GetNumberOfItems() const
Definition: Combobox.cpp:111
ImGuiContext * context
Definition: Window.cpp:95
DrawResult Draw(const DrawContext &context) override
Definition: Combobox.cpp:167
const char * GetSelectedValue() const
Returns the text of the selected value, or "" if nothing is selected.
Definition: Combobox.cpp:121
void SetOnValueChanged(std::function< void(const char *, int)> on_value_changed)
Definition: Combobox.cpp:147
void RemoveItem(const char *name)
Removes the first item matching the given text.
Definition: Combobox.cpp:93
int AddItem(const char *name)
Definition: Combobox.cpp:75
void ChangeItem(int index, const char *name)
Definition: Combobox.cpp:80
Combobox()
Definition: Combobox.cpp:58
void ClearItems()
Definition: Combobox.cpp:70
~Combobox() override
Definition: Combobox.cpp:68
bool SetSelectedValue(const char *value)
Definition: Combobox.cpp:136
Definition: PinholeCameraIntrinsic.cpp:35
Definition: Combobox.h:37
Size CalcPreferredSize(const LayoutContext &context, const Constraints &constraints) const override
Definition: Combobox.cpp:152
int GetSelectedIndex() const
Definition: Combobox.cpp:119
DrawResult
Definition: Widget.h:114
void SetSelectedIndex(int index)
Definition: Combobox.cpp:130
std::string name
Definition: FilePCD.cpp:58