Olympe Engine 2.0
2D Game Engine with ECS Architecture
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
Olympe::PresetDropdownHelper Class Reference

ImGui dropdown widget for selecting a ConditionPreset from the registry. More...

#include <PresetDropdownHelper.h>

+ Collaboration diagram for Olympe::PresetDropdownHelper:

Public Member Functions

 PresetDropdownHelper (ConditionPresetRegistry &registry)
 Constructs the dropdown helper bound to the preset registry.
 
 ~PresetDropdownHelper ()=default
 
void SetLabel (const std::string &label)
 Sets the label displayed next to the dropdown.
 
void SetFilter (const std::string &filter)
 Sets optional filter — only presets matching this substring are shown in the dropdown.
 
void ClearFilter ()
 Clears any active filter.
 
bool Render (std::string &selectedPresetID)
 Renders the dropdown widget and handles selection.
 
size_t GetVisiblePresetCount () const
 Returns the number of presets visible after filtering.
 
std::string GetPresetDisplayName (const std::string &presetID) const
 Returns the display name of a preset, or empty if not found.
 

Private Attributes

ConditionPresetRegistrym_registry
 
std::string m_label
 
std::string m_filter
 
bool m_isOpen = false
 
int m_hoveredIndex = -1
 

Detailed Description

ImGui dropdown widget for selecting a ConditionPreset from the registry.

Definition at line 38 of file PresetDropdownHelper.h.

Constructor & Destructor Documentation

◆ PresetDropdownHelper()

Olympe::PresetDropdownHelper::PresetDropdownHelper ( ConditionPresetRegistry registry)
explicit

Constructs the dropdown helper bound to the preset registry.

Parameters
registryGlobal ConditionPresetRegistry (must outlive this helper).

Definition at line 25 of file PresetDropdownHelper.cpp.

◆ ~PresetDropdownHelper()

Olympe::PresetDropdownHelper::~PresetDropdownHelper ( )
default

Member Function Documentation

◆ ClearFilter()

void Olympe::PresetDropdownHelper::ClearFilter ( )
inline

Clears any active filter.

Definition at line 69 of file PresetDropdownHelper.h.

References m_filter.

◆ GetPresetDisplayName()

std::string Olympe::PresetDropdownHelper::GetPresetDisplayName ( const std::string &  presetID) const

Returns the display name of a preset, or empty if not found.

Definition at line 122 of file PresetDropdownHelper.cpp.

References GetComponentTypeID_Static(), Olympe::ConditionPresetRegistry::GetPreset(), m_registry, and Olympe::ConditionPreset::name.

+ Here is the call graph for this function:

◆ GetVisiblePresetCount()

size_t Olympe::PresetDropdownHelper::GetVisiblePresetCount ( ) const

Returns the number of presets visible after filtering.

Definition at line 116 of file PresetDropdownHelper.cpp.

References GetComponentTypeID_Static(), Olympe::ConditionPresetRegistry::GetFilteredPresets(), m_filter, and m_registry.

+ Here is the call graph for this function:

◆ Render()

bool Olympe::PresetDropdownHelper::Render ( std::string &  selectedPresetID)

Renders the dropdown widget and handles selection.

Must be called once per frame inside the ImGui render loop.

Parameters
[in,out]selectedPresetIDCurrent selection; updated on user change. Pass empty string for "no selection".
Returns
true if the user made a new selection in this frame.

The dropdown displays presets filtered by m_filter and the registry's internal search state. Clicking a preset updates selectedPresetID and returns true.

Definition at line 35 of file PresetDropdownHelper.cpp.

References GetComponentTypeID_Static(), Olympe::ConditionPresetRegistry::GetFilteredPresets(), Olympe::ConditionPresetRegistry::GetPreset(), m_filter, m_label, m_registry, and Olympe::ConditionPreset::name.

+ Here is the call graph for this function:

◆ SetFilter()

void Olympe::PresetDropdownHelper::SetFilter ( const std::string &  filter)
inline

Sets optional filter — only presets matching this substring are shown in the dropdown.

Parameters
filterFilter string (empty = no filter).

Definition at line 64 of file PresetDropdownHelper.h.

References GetComponentTypeID_Static(), and m_filter.

+ Here is the call graph for this function:

◆ SetLabel()

void Olympe::PresetDropdownHelper::SetLabel ( const std::string &  label)
inline

Sets the label displayed next to the dropdown.

Parameters
labelDisplay label (e.g. "Select Condition").

Definition at line 57 of file PresetDropdownHelper.h.

References m_label.

Member Data Documentation

◆ m_filter

std::string Olympe::PresetDropdownHelper::m_filter
private

Definition at line 109 of file PresetDropdownHelper.h.

Referenced by ClearFilter(), GetVisiblePresetCount(), Render(), and SetFilter().

◆ m_hoveredIndex

int Olympe::PresetDropdownHelper::m_hoveredIndex = -1
private

Definition at line 111 of file PresetDropdownHelper.h.

◆ m_isOpen

bool Olympe::PresetDropdownHelper::m_isOpen = false
private

Definition at line 110 of file PresetDropdownHelper.h.

◆ m_label

std::string Olympe::PresetDropdownHelper::m_label
private

Definition at line 108 of file PresetDropdownHelper.h.

Referenced by Render(), and SetLabel().

◆ m_registry

ConditionPresetRegistry& Olympe::PresetDropdownHelper::m_registry
private

Definition at line 107 of file PresetDropdownHelper.h.

Referenced by GetPresetDisplayName(), GetVisiblePresetCount(), and Render().


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