Open3D (C++ API)  0.16.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-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
33namespace open3d {
34namespace visualization {
35namespace gui {
36
37class Combobox : public Widget {
38public:
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
85 std::function<void(const char*, int)> on_value_changed);
86
87private:
88 struct Impl;
89 std::unique_ptr<Impl> impl_;
90};
91
92} // namespace gui
93} // namespace visualization
94} // namespace open3d
ImGuiContext * context
Definition: Window.cpp:95
Definition: Combobox.h:37
Combobox()
Definition: Combobox.cpp:58
~Combobox() override
Definition: Combobox.cpp:68
DrawResult Draw(const DrawContext &context) override
Definition: Combobox.cpp:167
int AddItem(const char *name)
Definition: Combobox.cpp:75
void RemoveItem(const char *name)
Removes the first item matching the given text.
Definition: Combobox.cpp:93
void ClearItems()
Definition: Combobox.cpp:70
void ChangeItem(int index, const char *name)
Definition: Combobox.cpp:80
const char * GetSelectedValue() const
Returns the text of the selected value, or "" if nothing is selected.
Definition: Combobox.cpp:121
const char * GetItem(int index) const
Definition: Combobox.cpp:115
Size CalcPreferredSize(const LayoutContext &context, const Constraints &constraints) const override
Definition: Combobox.cpp:152
bool SetSelectedValue(const char *value)
Definition: Combobox.cpp:136
void SetSelectedIndex(int index)
Definition: Combobox.cpp:130
int GetSelectedIndex() const
Definition: Combobox.cpp:119
void SetOnValueChanged(std::function< void(const char *, int)> on_value_changed)
Definition: Combobox.cpp:147
int GetNumberOfItems() const
Definition: Combobox.cpp:111
Definition: Widget.h:68
DrawResult
Definition: Widget.h:114
std::string name
Definition: FilePCD.cpp:58
Definition: PinholeCameraIntrinsic.cpp:35