Setter first, then getter.

This commit is contained in:
Jari Vetoniemi 2014-04-10 20:11:41 +03:00
parent 702d808b28
commit 9525c77f55
2 changed files with 81 additions and 82 deletions

View File

@ -218,15 +218,6 @@ int bmMenuRemoveItemAt(bmMenu *menu, unsigned int index);
*/
int bmMenuRemoveItem(bmMenu *menu, bmItem *item);
/**
* Get highlighted item from bmMenu instance.
*
* @param menu bmMenu instance from where to get highlighted item.
* @return Selected bmItem instance, **NULL** if none highlighted.
*/
bmItem* bmMenuGetHighlightedItem(const bmMenu *menu);
/**
* Highlight item in menu by index.
*
@ -245,13 +236,12 @@ int bmMenuSetHighlightedIndex(bmMenu *menu, unsigned int index);
int bmMenuSetHighlighted(bmMenu *menu, bmItem *item);
/**
* Get selected items from bmMenu instance.
* Get highlighted item from bmMenu instance.
*
* @param menu bmMenu instance from where to get selected items.
* @param outNmemb Reference to unsigned int where total count of returned items will be stored.
* @return Pointer to array of bmItem pointers.
* @param menu bmMenu instance from where to get highlighted item.
* @return Selected bmItem instance, **NULL** if none highlighted.
*/
bmItem** bmMenuGetSelectedItems(const bmMenu *menu, unsigned int *outNmemb);
bmItem* bmMenuGetHighlightedItem(const bmMenu *menu);
/**
* Set selected items to bmMenu instance.
@ -266,27 +256,13 @@ bmItem** bmMenuGetSelectedItems(const bmMenu *menu, unsigned int *outNmemb);
int bmMenuSetSelectedItems(bmMenu *menu, bmItem **items, unsigned int nmemb);
/**
* Get filtered (displayed) items from bmMenu instance.
* Get selected items from bmMenu instance.
*
* @warning The pointer returned by this function _will_ be invalid when menu internally filters its list again.
* Do not store this pointer.
*
* @param menu bmMenu instance from where to get filtered items.
* @param menu bmMenu instance from where to get selected items.
* @param outNmemb Reference to unsigned int where total count of returned items will be stored.
* @return Pointer to array of bmItem pointers.
*/
bmItem** bmMenuGetFilteredItems(const bmMenu *menu, unsigned int *outNmemb);
/**
* Get items from bmMenu instance.
*
* @warning The pointer returned by this function may be invalid after removing or adding new items.
*
* @param menu bmMenu instance from where to get items.
* @param outNmemb Reference to unsigned int where total count of returned items will be stored.
* @return Pointer to array of bmItem pointers.
*/
bmItem** bmMenuGetItems(const bmMenu *menu, unsigned int *outNmemb);
bmItem** bmMenuGetSelectedItems(const bmMenu *menu, unsigned int *outNmemb);
/**
* Set items to bmMenu instance.
@ -301,6 +277,29 @@ bmItem** bmMenuGetItems(const bmMenu *menu, unsigned int *outNmemb);
*/
int bmMenuSetItems(bmMenu *menu, const bmItem **items, unsigned int nmemb);
/**
* Get items from bmMenu instance.
*
* @warning The pointer returned by this function may be invalid after removing or adding new items.
*
* @param menu bmMenu instance from where to get items.
* @param outNmemb Reference to unsigned int where total count of returned items will be stored.
* @return Pointer to array of bmItem pointers.
*/
bmItem** bmMenuGetItems(const bmMenu *menu, unsigned int *outNmemb);
/**
* Get filtered (displayed) items from bmMenu instance.
*
* @warning The pointer returned by this function _will_ be invalid when menu internally filters its list again.
* Do not store this pointer.
*
* @param menu bmMenu instance from where to get filtered items.
* @param outNmemb Reference to unsigned int where total count of returned items will be stored.
* @return Pointer to array of bmItem pointers.
*/
bmItem** bmMenuGetFilteredItems(const bmMenu *menu, unsigned int *outNmemb);
/** @} Menu Items */
/**

View File

@ -265,25 +265,6 @@ int bmMenuRemoveItem(bmMenu *menu, bmItem *item)
return ret;
}
/**
* Get highlighted item from bmMenu instance.
*
* @param menu bmMenu instance from where to get highlighted item.
* @return Selected bmItem instance, **NULL** if none highlighted.
*/
bmItem* bmMenuGetHighlightedItem(const bmMenu *menu)
{
assert(menu);
unsigned int count;
bmItem **items = bmMenuGetFilteredItems(menu, &count);
if (!items || count <= menu->index)
return NULL;
return items[menu->index];
}
/**
* Highlight item in menu by index.
*
@ -323,16 +304,22 @@ int bmMenuSetHighlighted(bmMenu *menu, bmItem *item)
}
/**
* Get selected items from bmMenu instance.
* Get highlighted item from bmMenu instance.
*
* @param menu bmMenu instance from where to get selected items.
* @param outNmemb Reference to unsigned int where total count of returned items will be stored.
* @return Pointer to array of bmItem pointers.
* @param menu bmMenu instance from where to get highlighted item.
* @return Selected bmItem instance, **NULL** if none highlighted.
*/
bmItem** bmMenuGetSelectedItems(const bmMenu *menu, unsigned int *outNmemb)
bmItem* bmMenuGetHighlightedItem(const bmMenu *menu)
{
assert(menu);
return _bmItemListGetItems(&menu->selection, outNmemb);
unsigned int count;
bmItem **items = bmMenuGetFilteredItems(menu, &count);
if (!items || count <= menu->index)
return NULL;
return items[menu->index];
}
/**
@ -352,38 +339,16 @@ int bmMenuSetSelectedItems(bmMenu *menu, bmItem **items, unsigned int nmemb)
}
/**
* Get filtered (displayed) items from bmMenu instance.
* Get selected items from bmMenu instance.
*
* @warning The pointer returned by this function _will_ be invalid when menu internally filters its list again.
* Do not store this pointer.
*
* @param menu bmMenu instance from where to get filtered items.
* @param menu bmMenu instance from where to get selected items.
* @param outNmemb Reference to unsigned int where total count of returned items will be stored.
* @return Pointer to array of bmItem pointers.
*/
bmItem** bmMenuGetFilteredItems(const bmMenu *menu, unsigned int *outNmemb)
bmItem** bmMenuGetSelectedItems(const bmMenu *menu, unsigned int *outNmemb)
{
assert(menu);
if (menu->filtered.list)
return _bmItemListGetItems(&menu->filtered, outNmemb);
return _bmItemListGetItems(&menu->items, outNmemb);
}
/**
* Get items from bmMenu instance.
*
* @warning The pointer returned by this function may be invalid after removing or adding new items.
*
* @param menu bmMenu instance from where to get items.
* @param outNmemb Reference to unsigned int where total count of returned items will be stored.
* @return Pointer to array of bmItem pointers.
*/
bmItem** bmMenuGetItems(const bmMenu *menu, unsigned int *outNmemb)
{
assert(menu);
return _bmItemListGetItems(&menu->items, outNmemb);
return _bmItemListGetItems(&menu->selection, outNmemb);
}
/**
@ -411,6 +376,41 @@ int bmMenuSetItems(bmMenu *menu, const bmItem **items, unsigned int nmemb)
return ret;
}
/**
* Get items from bmMenu instance.
*
* @warning The pointer returned by this function may be invalid after removing or adding new items.
*
* @param menu bmMenu instance from where to get items.
* @param outNmemb Reference to unsigned int where total count of returned items will be stored.
* @return Pointer to array of bmItem pointers.
*/
bmItem** bmMenuGetItems(const bmMenu *menu, unsigned int *outNmemb)
{
assert(menu);
return _bmItemListGetItems(&menu->items, outNmemb);
}
/**
* Get filtered (displayed) items from bmMenu instance.
*
* @warning The pointer returned by this function _will_ be invalid when menu internally filters its list again.
* Do not store this pointer.
*
* @param menu bmMenu instance from where to get filtered items.
* @param outNmemb Reference to unsigned int where total count of returned items will be stored.
* @return Pointer to array of bmItem pointers.
*/
bmItem** bmMenuGetFilteredItems(const bmMenu *menu, unsigned int *outNmemb)
{
assert(menu);
if (menu->filtered.list)
return _bmItemListGetItems(&menu->filtered, outNmemb);
return _bmItemListGetItems(&menu->items, outNmemb);
}
/**
* Render bmMenu instance using chosen draw method.
*