Open3D (C++ API)  0.17.0
MenuBase.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - Open3D: www.open3d.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2023 www.open3d.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
8 #pragma once
9 
10 #include <memory>
11 
13 
14 namespace open3d {
15 namespace visualization {
16 namespace gui {
17 
18 struct DrawContext;
19 struct Theme;
20 
26 class MenuBase {
27 public:
28  using ItemId = int;
29  static constexpr ItemId NO_ITEM = -1;
30 
31  MenuBase() {}
32  virtual ~MenuBase() {}
33 
34  virtual void AddItem(const char* name,
35  ItemId item_id = NO_ITEM,
36  KeyName key = KEY_NONE) = 0;
37  virtual void AddMenu(const char* name,
38  std::shared_ptr<MenuBase> submenu) = 0;
39  virtual void AddSeparator() = 0;
40 
41  virtual void InsertItem(int index,
42  const char* name,
43  ItemId item_id = NO_ITEM,
44  KeyName key = KEY_NONE) = 0;
45  virtual void InsertMenu(int index,
46  const char* name,
47  std::shared_ptr<MenuBase> submenu) = 0;
48  virtual void InsertSeparator(int index) = 0;
49 
50  virtual int GetNumberOfItems() const = 0;
51 
54  virtual bool IsEnabled(ItemId item_id) const = 0;
57  virtual void SetEnabled(ItemId item_id, bool enabled) = 0;
58 
59  virtual bool IsChecked(ItemId item_id) const = 0;
60  virtual void SetChecked(ItemId item_id, bool checked) = 0;
61 
62  virtual int CalcHeight(const Theme& theme) const = 0;
63 
65  virtual bool CheckVisibilityChange() const = 0;
66 
67  virtual ItemId DrawMenuBar(const DrawContext& context, bool is_enabled) = 0;
68  virtual ItemId Draw(const DrawContext& context,
69  const char* name,
70  bool is_enabled) = 0;
71 
72  virtual void* GetNativePointer() = 0; // nullptr if not using native menus
73 };
74 
75 } // namespace gui
76 } // namespace visualization
77 } // namespace open3d
ImGuiContext * context
Definition: Window.cpp:76
const Theme * theme
Definition: Window.cpp:74
Definition: MenuBase.h:26
virtual void InsertSeparator(int index)=0
static constexpr ItemId NO_ITEM
Definition: MenuBase.h:29
virtual bool IsEnabled(ItemId item_id) const =0
virtual ItemId DrawMenuBar(const DrawContext &context, bool is_enabled)=0
virtual void InsertItem(int index, const char *name, ItemId item_id=NO_ITEM, KeyName key=KEY_NONE)=0
virtual void AddItem(const char *name, ItemId item_id=NO_ITEM, KeyName key=KEY_NONE)=0
virtual int GetNumberOfItems() const =0
virtual void AddMenu(const char *name, std::shared_ptr< MenuBase > submenu)=0
int ItemId
Definition: MenuBase.h:28
virtual void InsertMenu(int index, const char *name, std::shared_ptr< MenuBase > submenu)=0
virtual ItemId Draw(const DrawContext &context, const char *name, bool is_enabled)=0
virtual bool IsChecked(ItemId item_id) const =0
virtual int CalcHeight(const Theme &theme) const =0
virtual void SetEnabled(ItemId item_id, bool enabled)=0
virtual ~MenuBase()
Definition: MenuBase.h:32
virtual bool CheckVisibilityChange() const =0
Returns true if submenu visibility changed on last call to DrawMenuBar.
MenuBase()
Definition: MenuBase.h:31
virtual void SetChecked(ItemId item_id, bool checked)=0
std::string name
Definition: FilePCD.cpp:39
const char const char value recording_handle imu_sample recording_handle uint8_t size_t data_size k4a_record_configuration_t config target_format k4a_capture_t capture_handle k4a_imu_sample_t imu_sample playback_handle k4a_logging_message_cb_t void min_level device_handle k4a_imu_sample_t timeout_in_ms capture_handle capture_handle capture_handle image_handle temperature_c int
Definition: K4aPlugin.cpp:474
KeyName
Definition: Events.h:96
@ KEY_NONE
Definition: Events.h:97
Definition: PinholeCameraIntrinsic.cpp:16
Definition: Theme.h:20