Open3D (C++ API)  0.16.0
Button.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
30
31#include <functional>
32
34
35namespace open3d {
36namespace visualization {
37namespace gui {
38
39class Button : public Widget {
40public:
41 explicit Button(const char* title);
42 explicit Button(std::shared_ptr<UIImage> image);
43 ~Button();
44
47 const char* GetText() const;
49 void SetText(const char* text);
50
52 float GetHorizontalPaddingEm() const;
53 float GetVerticalPaddingEm() const;
60 void SetPaddingEm(float horiz_ems, float vert_ems);
61
62 bool GetIsToggleable() const;
63 void SetToggleable(bool toggles);
64
65 bool GetIsOn() const;
66 void SetOn(bool is_on);
67
69 const Constraints& constraints) const override;
70
71 DrawResult Draw(const DrawContext& context) override;
72
73 void SetOnClicked(std::function<void()> on_clicked);
74
75private:
76 struct Impl;
77 std::unique_ptr<Impl> impl_;
78};
79
80} // namespace gui
81} // namespace visualization
82} // namespace open3d
std::shared_ptr< core::Tensor > image
Definition: FilamentRenderer.cpp:202
ImGuiContext * context
Definition: Window.cpp:95
Definition: Button.h:39
void SetPaddingEm(float horiz_ems, float vert_ems)
Definition: Button.cpp:79
void SetToggleable(bool toggles)
Definition: Button.cpp:86
~Button()
Definition: Button.cpp:65
void SetOnClicked(std::function< void()> on_clicked)
Definition: Button.cpp:96
float GetHorizontalPaddingEm() const
Returns the padding, in units of ems.
Definition: Button.cpp:71
DrawResult Draw(const DrawContext &context) override
Definition: Button.cpp:134
Button(const char *title)
Definition: Button.cpp:56
Size CalcPreferredSize(const LayoutContext &context, const Constraints &constraints) const override
Definition: Button.cpp:100
bool GetIsOn() const
Definition: Button.cpp:88
float GetVerticalPaddingEm() const
Definition: Button.cpp:75
void SetOn(bool is_on)
Definition: Button.cpp:90
void SetText(const char *text)
Sets the text of the button. Do not call if this is an image button.
Definition: Button.cpp:69
bool GetIsToggleable() const
Definition: Button.cpp:84
const char * GetText() const
Definition: Button.cpp:67
Definition: Widget.h:68
DrawResult
Definition: Widget.h:114
Definition: PinholeCameraIntrinsic.cpp:35