Use UIDrawable names as tags / .find on a collection #41

Closed
opened 2024-03-09 19:35:04 +00:00 by john · 2 comments
Owner

Notes say:
58 feat: Scene's UIDrawable collection / Frame's UIDrawable collection / Grid's UIEntity collection - .find(name) - return single object or collection of them

See #39 and #40 for related functionality

returning new collections that represent "search results" could be challenging or require a new Container class -- perhaps just instantiate a UICollection with a new vector of (copied) pointers.

Notes say: 58 feat: Scene's UIDrawable collection / Frame's UIDrawable collection / Grid's UIEntity collection - .find(name) - return single object or collection of them See #39 and #40 for related functionality returning new collections that represent "search results" could be challenging or require a new Container class -- perhaps just instantiate a UICollection with a new vector of (copied) pointers.
john added the
Minor Feature
label 2024-03-09 19:35:04 +00:00
john added this to the Alpha Release Targets milestone 2024-03-13 14:49:14 +00:00
Author
Owner

implemented in d11f76ac43 - needs tests

implemented in d11f76ac43012768d5291529d3b18ecd065ab5c2 - needs tests
Author
Owner

Implementation Complete

The .find() method has been implemented on both UICollection and EntityCollection.

API

# Exact match - returns single element or None
element = ui.find("player_frame")

# Wildcard matches - returns list
elements = ui.find("player*")      # starts with
elements = ui.find("*_frame")      # ends with
elements = ui.find("*status*")     # contains
elements = ui.find("*")            # match all

# Recursive search (UICollection only) - searches Frame children
element = ui.find("deep_widget", recursive=True)

Features

  • Exact match: Returns single element or None
  • Wildcard patterns: Returns list of matches
    • prefix* - starts with
    • *suffix - ends with
    • *substring* - contains
    • * - match all
  • Recursive search: Traverse nested Frame children (UICollection only)

Files Changed

  • src/UICollection.h - Added find() declaration
  • src/UICollection.cpp - Implemented find() with wildcard and recursive support
  • src/UIGrid.h - Added find() declaration to UIEntityCollection
  • src/UIGrid.cpp - Implemented find() for EntityCollection

Test

  • tests/unit/collection_find_test.py - Comprehensive test coverage

The previous comment about implementation in d11f76ac only added the name property (#39), not the .find() method.

## Implementation Complete The `.find()` method has been implemented on both `UICollection` and `EntityCollection`. ### API ```python # Exact match - returns single element or None element = ui.find("player_frame") # Wildcard matches - returns list elements = ui.find("player*") # starts with elements = ui.find("*_frame") # ends with elements = ui.find("*status*") # contains elements = ui.find("*") # match all # Recursive search (UICollection only) - searches Frame children element = ui.find("deep_widget", recursive=True) ``` ### Features - **Exact match**: Returns single element or `None` - **Wildcard patterns**: Returns list of matches - `prefix*` - starts with - `*suffix` - ends with - `*substring*` - contains - `*` - match all - **Recursive search**: Traverse nested Frame children (UICollection only) ### Files Changed - `src/UICollection.h` - Added find() declaration - `src/UICollection.cpp` - Implemented find() with wildcard and recursive support - `src/UIGrid.h` - Added find() declaration to UIEntityCollection - `src/UIGrid.cpp` - Implemented find() for EntityCollection ### Test - `tests/unit/collection_find_test.py` - Comprehensive test coverage The previous comment about implementation in d11f76ac only added the `name` property (#39), not the `.find()` method.
john closed this issue 2025-11-26 10:23:48 +00:00
Sign in to join this conversation.
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: john/McRogueFace#41
No description provided.