2008-04-20

Showing and Hiding Gadgets

The existing show/hide methods within Woopsi are designed to allow hidden gadgets to be moved out of the gadget hierarchy entirely. When a gadget is hidden, it gets moved into a separate array within its parent where it is totally ignored until it is shown again. This means that hidden gadgets do not cause any performance loss at all; in fact, other than their memory requirements, hidden gadgets use the same resources as non-existent gadgets.

This can be problematic, though, as John discovered. Hidden gadgets that get re-shown are pushed onto the end of the gadget array, thus losing their original z-index. There’s no point in remembering the original z-index as the gadget order may have changed.

To work around this, I’ve renamed the current hide/show system to “shelve” and “unshelve”. If you want to remove a gadget from the system but don’t want to recreate it later, you can shelve() it. If you want to bring it back, you can unshelve() it. I have added new show() and hide() functions that just make a gadget invisible and non-interactive. However, unlike shelved gadgets Woopsi will attempt (fruitlessly) to interact with hidden gadgets.

There are a couple of other changes. There’s a new Gadget::isEnabled() method that will check that a gadget is enabled by recursing through its ancestors. I’ve replaced the majority of _flags.enabled checks (in Gadget::click(), for example) with calls to this function instead.

The closeChild() and shelveChild() methods weren’t reassigning focus correctly if the child being closed was the only child. This should now be sorted.

It is possible that the changes will introduce bugs, so if you spot anything strange happening when hiding gadgets let me know.

Comments

ant on 2008-04-21 at 09:23 said:

Must have missed that one the first time I compiled, and since then I’ve been making instead of clean making. Fixed!

ant on 2008-04-21 at 09:31 said:

OK, ROM icon moved to a new location, and I’ve dropped the wifi logo completely. I’ve updated the makefiles to match.

Jeff on 2008-04-21 at 10:19 said:

Compiling skinnedwindow.cpp /projects/Woopsi/woopsi/skinnedwindow.cpp: In member function ‘virtual bool SkinnedWindow::handleEvent(const EventArgs&)’: /projects/Woopsi/woopsi/skinnedwindow.cpp:341: warning: enumeration value ‘CLOSE_TYPE_SHELVE’ not handled in switch Updating library member skinnedwindow.o

Jeff on 2008-04-21 at 10:22 said:

Oh, one other thing I keep forgetting to say. You have the logo.bmp file in the data directory which means it gets incorporated into your binary as an image, as well as being used as the .nds icon

And the wifi-logo.bmp is the same, though from what I’ve read, it would be better to ditch it altogether since it does no good, and some actual harm (it goofs up compatibility with some loaders, apparently)