Class ImguiItem
Base class for all UI widgets (buttons, sliders, inputs, etc.).More...
#include <ImguiItem.h>
Inherited by the following classes: UI::Button, UI::OpaButton, UI::ParaInput, UI::Text, UI::TextureViewer
Public Attributes
| Type | Name |
|---|---|
| std::function< void(void)> | ButtonFunc = [] {}Callback function executed when button is pressed. |
| bool | fixed_size = falseWhether item size is fixed. |
| bool | is_activated = falseWhether item is currently active/focused. |
| bool | is_button_pressed Whether button is currently pressed. |
| std::string | notagname = ""Display name without tag prefix. |
| bool | show_tag_name = falseWhether to display tag name. |
| int | uitm_id = -1Unique item ID within layer. |
| std::string | uitm_name = ""Item name for display and lookup. |
| ImVec2 | uitm_size Item size in pixels. |
| ImItemType | uitm_type = NONE\_INPItem type identifier. |
| bool | using_size = falseWhether to apply custom size. |
Public Functions
| Type | Name |
|---|---|
| virtual void | CallButtonFunc () const Executes the button callback. |
| void | DisableTagName () const Disables tag name display. |
| void | EnableTagName () const Enables tag name display. |
| const char * | GetCharName () const Returns item name as C-string. |
| virtual Parameters * | GetPara () Returns pointer to parameter value. |
| std::string | GetTagName () const Returns the tag name for display. |
| ImguiItem () Default constructor. |
|
| ImguiItem (ImItemType type, const std::string & name) Constructs item with type and name. |
|
| void | Rename (const std::string & name) const Renames the item. |
| virtual void | RenderItem () const Renders the item's UI . |
| virtual void | ResetBufferID (int id) Updates texture/framebuffer ID for viewport items. |
| virtual void | ResetSize (const ImVec2 & size) Updates size for viewport items. |
| virtual void | ResetUV (const ImVec2 & min, const ImVec2 & max) Updates UV coordinates for viewport items. |
| virtual void | SetArgsList (int length, ...) const Sets variable argument list for text output items. |
| virtual void | SetArgsList (int length, float * f1) const Sets argument list from float array for text output. |
| virtual | ~ImguiItem () Virtual destructor for proper cleanup of derived classes. |
Detailed Description
ImguiItem represents a single reusable UI widget that can be added to any ImguiLayer. Items handle their own rendering via ImGui calls and provide a consistent interface for value access and callbacks.
Item Lifecycle: * Construction - Item created with type and name * Configuration - Set size, callbacks, initial values * RenderItem() - Called each frame when parent layer is visible * Destruction - Cleanup resources
Common Item Patterns: * Parameter items: Expose GetPara() for value access * Button items: Execute ButtonFunc callback on press * Viewport items: Support texture ID and UV coordinate updates
Note:
Thread-safety: Not thread-safe. Must be used from main thread only.
Note:
Ownership: Items are owned by their parent ImguiLayer via shared_ptr
Public Attributes Documentation
variable ButtonFunc
Callback function executed when button is pressed.
std::function<void(void)> ImguiItem::ButtonFunc;
Set this to a custom lambda or function for button items. Default is no-op.
variable fixed_size
Whether item size is fixed.
bool ImguiItem::fixed_size;
variable is_activated
Whether item is currently active/focused.
bool ImguiItem::is_activated;
variable is_button_pressed
Whether button is currently pressed.
bool ImguiItem::is_button_pressed;
variable notagname
Display name without tag prefix.
std::string ImguiItem::notagname;
variable show_tag_name
Whether to display tag name.
bool ImguiItem::show_tag_name;
variable uitm_id
Unique item ID within layer.
int ImguiItem::uitm_id;
variable uitm_name
Item name for display and lookup.
std::string ImguiItem::uitm_name;
variable uitm_size
Item size in pixels.
ImVec2 ImguiItem::uitm_size;
variable uitm_type
Item type identifier.
ImItemType ImguiItem::uitm_type;
variable using_size
Whether to apply custom size.
bool ImguiItem::using_size;
Public Functions Documentation
function CallButtonFunc
Executes the button callback.
inline virtual void ImguiItem::CallButtonFunc () const
Only applicable to button items. Call this when button is pressed.
Note:
Override in button classes
function DisableTagName
Disables tag name display.
void ImguiItem::DisableTagName () const
function EnableTagName
Enables tag name display.
void ImguiItem::EnableTagName () const
function GetCharName
Returns item name as C-string.
inline const char * ImguiItem::GetCharName () const
Returns:
C-string pointer for ImGui functions
function GetPara
Returns pointer to parameter value.
inline virtual Parameters * ImguiItem::GetPara ()
Only applicable to parameter input items (sliders, text inputs, etc.).
Returns:
Pointer to Parameters, or nullptr if item is not a parameter input
Note:
Override in parameter input classes
function GetTagName
Returns the tag name for display.
std::string ImguiItem::GetTagName () const
Returns:
Tag name string (includes type prefix if enabled)
function ImguiItem [1/2]
Default constructor.
ImguiItem::ImguiItem ()
Note:
Item must be configured before use
function ImguiItem [2/2]
Constructs item with type and name.
ImguiItem::ImguiItem (
ImItemType type,
const std::string & name
)
Parameters:
typeItem type identifiernameUnique item name for lookup and display
function Rename
Renames the item.
void ImguiItem::Rename (
const std::string & name
) const
Parameters:
nameNew item name
function RenderItem
Renders the item's UI .
inline virtual void ImguiItem::RenderItem () const
Override this to implement item-specific rendering logic using ImGui calls. Called every frame when parent layer is visible.
Note:
Default implementation logs error. All derived classes must override.
function ResetBufferID
Updates texture/framebuffer ID for viewport items.
inline virtual void ImguiItem::ResetBufferID (
int id
)
Parameters:
idOpenGL texture/framebuffer ID to display
Note:
Override in viewport classes
function ResetSize
Updates size for viewport items.
inline virtual void ImguiItem::ResetSize (
const ImVec2 & size
)
Parameters:
sizeNew viewport size in pixels
Note:
Override in viewport classes
function ResetUV
Updates UV coordinates for viewport items.
inline virtual void ImguiItem::ResetUV (
const ImVec2 & min,
const ImVec2 & max
)
Used by viewport items to specify texture sampling region.
Parameters:
minMinimum UV coordinate (bottom-left)maxMaximum UV coordinate (top-right)
Note:
Override in viewport classes
function SetArgsList [1/2]
Sets variable argument list for text output items.
inline virtual void ImguiItem::SetArgsList (
int length,
...
) const
Used by text output items to support formatted string display.
Parameters:
lengthNumber of arguments...Variable arguments for formatting
Note:
Override in text output classes
function SetArgsList [2/2]
Sets argument list from float array for text output.
inline virtual void ImguiItem::SetArgsList (
int length,
float * f1
) const
Parameters:
lengthArray lengthf1Float array pointer
Note:
Override in text output classes
function ~ImguiItem
Virtual destructor for proper cleanup of derived classes.
virtual ImguiItem::~ImguiItem ()
The documentation for this class was generated from the following file src/UI/ImguiItem.h