My GUI uses callbacks to deal with widgets being clicked or otherwise handled, which ultimately ends up in functions like this:
void ButtonsTest::butnCancel_onClick(GUI::Event&) { exit(); }
My inventory has a list of items, and I am thinking of using the MVC architecture, so the callbacks would be to a view which would then call operations on a controller. The question is, how do I associate items in the inventory with GUI widgets?
The other issue is that the number of items in the inventory will change frequently, so how should I represent each item? Should I create a new ImageBox whenever a new item is added? Or should I pool them?
I've also considered not using a widget per item at all, but rather, having a single widget for each item list. This widget could internally manage its list of items, and allow drag / drop. Here is an image of what the inventory screen currently looks like:
Click to view in full
The idea is that I want to drag an item from the item list (e.g. item 1) into a weapon slot (if its a weapon), and the radio buttons are used to filter down to specific item types.
The area at the bottom right is context sensitive, with different buttons appearing when a user clicks at item in the list.