ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
cloudViewer::visualization::gui::Combobox Class Reference

#include <Combobox.h>

Inheritance diagram for cloudViewer::visualization::gui::Combobox:
Collaboration diagram for cloudViewer::visualization::gui::Combobox:

Classes

struct  Impl
 

Public Member Functions

 Combobox ()
 
 Combobox (const std::vector< const char * > &items)
 
 ~Combobox () override
 
void ClearItems ()
 
int AddItem (const char *name)
 
void ChangeItem (int index, const char *name)
 
void ChangeItem (const char *orig_name, const char *new_name)
 
void RemoveItem (const char *name)
 Removes the first item matching the given text. More...
 
void RemoveItem (int index)
 Removes the item at index. More...
 
int GetNumberOfItems () const
 
const char * GetItem (int index) const
 
int GetSelectedIndex () const
 
const char * GetSelectedValue () const
 Returns the text of the selected value, or "" if nothing is selected. More...
 
void SetSelectedIndex (int index)
 
bool SetSelectedValue (const char *value)
 
Size CalcPreferredSize (const LayoutContext &context, const Constraints &constraints) const override
 
DrawResult Draw (const DrawContext &context) override
 
void SetOnValueChanged (std::function< void(const char *, int)> on_value_changed)
 
- Public Member Functions inherited from cloudViewer::visualization::gui::Widget
 Widget ()
 
 Widget (const std::vector< std::shared_ptr< Widget >> &children)
 
virtual ~Widget ()
 
virtual void AddChild (std::shared_ptr< Widget > child)
 
virtual const std::vector< std::shared_ptr< Widget > > GetChildren () const
 
virtual const RectGetFrame () const
 Returns the frame size in pixels. More...
 
virtual void SetFrame (const Rect &f)
 
virtual const ColorGetBackgroundColor () const
 
virtual bool IsDefaultBackgroundColor () const
 
virtual void SetBackgroundColor (const Color &color)
 
virtual bool IsVisible () const
 
virtual void SetVisible (bool vis)
 
virtual bool IsEnabled () const
 
virtual void SetEnabled (bool enabled)
 
virtual void SetTooltip (const char *text)
 
virtual const char * GetTooltip () const
 
virtual Size CalcMinimumSize (const LayoutContext &context) const
 
virtual void Layout (const LayoutContext &context)
 
virtual EventResult Mouse (const MouseEvent &e)
 
virtual EventResult Key (const KeyEvent &e)
 
virtual DrawResult Tick (const TickEvent &e)
 

Additional Inherited Members

- Public Types inherited from cloudViewer::visualization::gui::Widget
enum class  DrawResult { NONE , REDRAW , RELAYOUT }
 
enum class  EventResult { IGNORED , CONSUMED , DISCARD }
 
- Static Public Attributes inherited from cloudViewer::visualization::gui::Widget
static constexpr int DIM_GROW = 10000
 
- Protected Member Functions inherited from cloudViewer::visualization::gui::Widget
void DrawImGuiPushEnabledState ()
 
void DrawImGuiPopEnabledState ()
 
void DrawImGuiTooltip ()
 

Detailed Description

Definition at line 18 of file Combobox.h.

Constructor & Destructor Documentation

◆ Combobox() [1/2]

cloudViewer::visualization::gui::Combobox::Combobox ( )

Definition at line 39 of file Combobox.cpp.

References patch::to_string().

◆ Combobox() [2/2]

cloudViewer::visualization::gui::Combobox::Combobox ( const std::vector< const char * > &  items)
explicit

Definition at line 43 of file Combobox.cpp.

References AddItem().

◆ ~Combobox()

cloudViewer::visualization::gui::Combobox::~Combobox ( )
override

Definition at line 49 of file Combobox.cpp.

Member Function Documentation

◆ AddItem()

int cloudViewer::visualization::gui::Combobox::AddItem ( const char *  name)

Adds an item to the combobox. Its index is the order in which it is added, so the first item's index is 0, the second is 1, etc. Returns the index of the new item.

Definition at line 56 of file Combobox.cpp.

References name.

Referenced by Combobox(), and cloudViewer::visualization::gui::pybind_gui_classes().

◆ CalcPreferredSize()

Size cloudViewer::visualization::gui::Combobox::CalcPreferredSize ( const LayoutContext context,
const Constraints constraints 
) const
overridevirtual

◆ ChangeItem() [1/2]

void cloudViewer::visualization::gui::Combobox::ChangeItem ( const char *  orig_name,
const char *  new_name 
)

If an item exists with orig_name, it will be changed to new_name.

Definition at line 65 of file Combobox.cpp.

◆ ChangeItem() [2/2]

void cloudViewer::visualization::gui::Combobox::ChangeItem ( int  index,
const char *  name 
)

Changes the item's text. index must be valid, otherwise nothing will happen.

Definition at line 61 of file Combobox.cpp.

Referenced by cloudViewer::visualization::gui::pybind_gui_classes().

◆ ClearItems()

void cloudViewer::visualization::gui::Combobox::ClearItems ( )

Definition at line 51 of file Combobox.cpp.

Referenced by cloudViewer::visualization::gui::pybind_gui_classes().

◆ Draw()

Combobox::DrawResult cloudViewer::visualization::gui::Combobox::Draw ( const DrawContext context)
overridevirtual

Draws the widget. If this is a Dear ImGUI widget, this is where the actual event processing happens. Return NONE if no action needs to be taken, REDRAW if the widget needs to be redrawn (e.g. its value changed), and RELAYOUT if the widget wishes to change size.

Reimplemented from cloudViewer::visualization::gui::Widget.

Definition at line 148 of file Combobox.cpp.

References cloudViewer::visualization::gui::colorToImgui(), context, cloudViewer::visualization::gui::Widget::DrawImGuiPopEnabledState(), cloudViewer::visualization::gui::Widget::DrawImGuiPushEnabledState(), frame, cloudViewer::visualization::gui::Widget::GetFrame(), GetSelectedValue(), cloudViewer::visualization::gui::Widget::NONE, and cloudViewer::visualization::gui::Widget::REDRAW.

◆ GetItem()

const char * cloudViewer::visualization::gui::Combobox::GetItem ( int  index) const

Returns the text of the item at index. index must be valid.

Definition at line 96 of file Combobox.cpp.

Referenced by cloudViewer::visualization::gui::pybind_gui_classes().

◆ GetNumberOfItems()

int cloudViewer::visualization::gui::Combobox::GetNumberOfItems ( ) const

Definition at line 92 of file Combobox.cpp.

Referenced by cloudViewer::visualization::gui::pybind_gui_classes().

◆ GetSelectedIndex()

int cloudViewer::visualization::gui::Combobox::GetSelectedIndex ( ) const

Definition at line 100 of file Combobox.cpp.

Referenced by cloudViewer::visualization::gui::pybind_gui_classes().

◆ GetSelectedValue()

const char * cloudViewer::visualization::gui::Combobox::GetSelectedValue ( ) const

Returns the text of the selected value, or "" if nothing is selected.

Definition at line 102 of file Combobox.cpp.

Referenced by Draw(), and cloudViewer::visualization::gui::pybind_gui_classes().

◆ RemoveItem() [1/2]

void cloudViewer::visualization::gui::Combobox::RemoveItem ( const char *  name)

Removes the first item matching the given text.

Definition at line 74 of file Combobox.cpp.

References name.

Referenced by cloudViewer::visualization::gui::pybind_gui_classes().

◆ RemoveItem() [2/2]

void cloudViewer::visualization::gui::Combobox::RemoveItem ( int  index)

Removes the item at index.

Definition at line 83 of file Combobox.cpp.

◆ SetOnValueChanged()

void cloudViewer::visualization::gui::Combobox::SetOnValueChanged ( std::function< void(const char *, int)>  on_value_changed)

Specifies a callback function which will be called when the value changes as a result of user action.

Definition at line 128 of file Combobox.cpp.

Referenced by cloudViewer::visualization::gui::pybind_gui_classes().

◆ SetSelectedIndex()

void cloudViewer::visualization::gui::Combobox::SetSelectedIndex ( int  index)

Sets the selected item by index. Does not call the onValueChanged callback.

Definition at line 111 of file Combobox.cpp.

Referenced by cloudViewer::visualization::gui::pybind_gui_classes(), and SetSelectedValue().

◆ SetSelectedValue()

bool cloudViewer::visualization::gui::Combobox::SetSelectedValue ( const char *  value)

Sets the selected item by value. Does nothing if value is not an item, but will return false. Does not call the onValueChanged callback

Definition at line 117 of file Combobox.cpp.

References SetSelectedIndex().

Referenced by cloudViewer::visualization::gui::pybind_gui_classes().


The documentation for this class was generated from the following files: