Open3D (C++ API)  0.12.0
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 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 
77  Size CalcPreferredSize(const Theme& theme) const override;
78 
79  DrawResult Draw(const DrawContext& context) override;
80 
83  void SetOnValueChanged(
84  std::function<void(const char*, int)> on_value_changed);
85 
86 private:
87  struct Impl;
88  std::unique_ptr<Impl> impl_;
89 };
90 
91 } // namespace gui
92 } // namespace visualization
93 } // namespace open3d
Definition: Theme.h:39
const char * GetItem(int index) const
Definition: Combobox.cpp:118
Definition: Widget.h:62
int GetNumberOfItems() const
Definition: Combobox.cpp:114
DrawResult Draw(const DrawContext &context) override
Definition: Combobox.cpp:168
const char * GetSelectedValue() const
Returns the text of the selected value, or "" if nothing is selected.
Definition: Combobox.cpp:124
void SetOnValueChanged(std::function< void(const char *, int)> on_value_changed)
Definition: Combobox.cpp:150
void RemoveItem(const char *name)
Removes the first item matching the given text.
Definition: Combobox.cpp:96
int AddItem(const char *name)
Definition: Combobox.cpp:78
void ChangeItem(int index, const char *name)
Definition: Combobox.cpp:83
Combobox()
Definition: Combobox.cpp:59
void ClearItems()
Definition: Combobox.cpp:73
~Combobox() override
Definition: Combobox.cpp:71
Size CalcPreferredSize(const Theme &theme) const override
Definition: Combobox.cpp:155
bool SetSelectedValue(const char *value)
Definition: Combobox.cpp:139
Definition: PinholeCameraIntrinsic.cpp:35
std::string name
Definition: FilePCD.cpp:58
Definition: Combobox.h:37
int GetSelectedIndex() const
Definition: Combobox.cpp:122
DrawResult
Definition: Widget.h:98
void SetSelectedIndex(int index)
Definition: Combobox.cpp:133