ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
Button.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - CloudViewer: www.cloudViewer.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2024 www.cloudViewer.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
8 #pragma once
9 
12 
13 #include <functional>
14 
15 namespace cloudViewer {
16 namespace visualization {
17 namespace gui {
18 
19 class Button : public Widget {
20 public:
21  explicit Button(const char* title);
22  explicit Button(std::shared_ptr<UIImage> image);
23  ~Button();
24 
27  const char* GetText() const;
29  void SetText(const char* text);
30 
32  float GetHorizontalPaddingEm() const;
33  float GetVerticalPaddingEm() const;
40  void SetPaddingEm(float horiz_ems, float vert_ems);
41 
42  bool GetIsToggleable() const;
43  void SetToggleable(bool toggles);
44 
45  bool GetIsOn() const;
46  void SetOn(bool is_on);
47 
49  const Constraints& constraints) const override;
50 
51  DrawResult Draw(const DrawContext& context) override;
52 
53  void SetOnClicked(std::function<void()> on_clicked);
54 
55 private:
56  struct Impl;
57  std::unique_ptr<Impl> impl_;
58 };
59 
60 } // namespace gui
61 } // namespace visualization
62 } // namespace cloudViewer
std::shared_ptr< core::Tensor > image
void SetOnClicked(std::function< void()> on_clicked)
Definition: Button.cpp:77
void SetText(const char *text)
Sets the text of the button. Do not call if this is an image button.
Definition: Button.cpp:50
float GetHorizontalPaddingEm() const
Returns the padding, in units of ems.
Definition: Button.cpp:52
Size CalcPreferredSize(const LayoutContext &context, const Constraints &constraints) const override
Definition: Button.cpp:81
void SetPaddingEm(float horiz_ems, float vert_ems)
Definition: Button.cpp:60
DrawResult Draw(const DrawContext &context) override
Definition: Button.cpp:115
ImGuiContext * context
Definition: Window.cpp:76
Generic file read and write utility for python interface.