Vista Sidebar Gadgets
Friday 20th April, 2007 01:37 Comments: 1
The more I look into it the more frustrating it gets. My first complaint is how slow it is (you can do a few tricks to potentially help speed things up very slightly, but nothing major). My second complaint is the poor alpha-transparency support* (see #6) (Microsoft introduced the graphics API so you can add text to an image without it going all weird/purple, but it looks like it might cause memory leaks and makes it very difficult/occasionally impossible to use stylesheet settings). My third complaint is the seemingly slow writing to the registry.
The code I've written isn't particularly inefficient, but I'm struggling to find ways to make it leaner/make the gadget more responsive. My first thought was to stop writing the volume to the registry every time it's changed, but there doesn't appear to be an event to detect when the gadget is closed, or at least nothing like the one that exists for settings. That means if someone shuts down the sidebar and starts it up again, it'll load the gadget and read the settings in the registry. Which is fine, unless that person had the volume set at 100%, lowered it to 0%, and then restarted Windows - once Windows starts it'll start the sidebar.exe process, and the gadget will be using 100% again instead of 0% like it was previously using. I'd like to save the old setting as the gadget closes, and there appears to be a way of capturing an event when the gadget is closed, but I think that's when the gadget is effectively removed from the sidebar. The documentation isn't very clear, so I'm going to have to write something to catch the event, save the value into the registry, and hope that it works.
Next on the list is to teach myself the best way of storing station data - in a separate file (requires VBScript and permissions) or the registry (allegedly has a maximum length)? I've noticed that as of RC1, you can share information between the gadget and the settings, so I might look into using that to access the hidden drop down list in the gadget to populate the settings drop down list, and then do the reverse once they click OK. I'm also wondering what the best way is to edit/reset the contents of the drop down list. I think I'll end up having to create a separate list for each version of the gadget, and hosting it on my server, as the station data also holds the filename for the station graphic, which are files that are stored locally. I could solve the problem by rewriting the gadget to load the graphics from my server, but that'd really increase the bandwidth, and would take longer to appear/probably slow down the gadget.
I have quite a few good ideas rattling around my head, but not enough time to implement them. Sadly, the storing and editing of the stations probably needs to be done together, so I think the 1.2.9 release will have more stations, perhaps the ability to add custom stations, and definitely an improved volume control that brings in mousewheel support. And then, probably a long time after that, 1.3.0 will introduce the improved handling of stations. With that release, I hope the gadget will be nearly complete. The only things that might be added are additional popular stations, updated code that offers performance improvements, bug fixes, and perhaps some updated/new themes. And I'll eventually sort out the flyout information for the top 5 stations. Perhaps I'll sort out 1.2.9 over the weekend as I create my new RAID arrays.
* Microsoft specifically say: The gadget platform allows for transparency around the edges of a gadget. Any PNG file with a transparent region set to 100% can be used if it is specified as the background on the BODY tag. It is not possible to have a transparent region in the middle of your gadget. It is also not possible to have partially transparent regions, such as a shadow, on the edge or in the middle of a gadget. Attempting this will lead to a poor appearance in many cases.
The code I've written isn't particularly inefficient, but I'm struggling to find ways to make it leaner/make the gadget more responsive. My first thought was to stop writing the volume to the registry every time it's changed, but there doesn't appear to be an event to detect when the gadget is closed, or at least nothing like the one that exists for settings. That means if someone shuts down the sidebar and starts it up again, it'll load the gadget and read the settings in the registry. Which is fine, unless that person had the volume set at 100%, lowered it to 0%, and then restarted Windows - once Windows starts it'll start the sidebar.exe process, and the gadget will be using 100% again instead of 0% like it was previously using. I'd like to save the old setting as the gadget closes, and there appears to be a way of capturing an event when the gadget is closed, but I think that's when the gadget is effectively removed from the sidebar. The documentation isn't very clear, so I'm going to have to write something to catch the event, save the value into the registry, and hope that it works.
Next on the list is to teach myself the best way of storing station data - in a separate file (requires VBScript and permissions) or the registry (allegedly has a maximum length)? I've noticed that as of RC1, you can share information between the gadget and the settings, so I might look into using that to access the hidden drop down list in the gadget to populate the settings drop down list, and then do the reverse once they click OK. I'm also wondering what the best way is to edit/reset the contents of the drop down list. I think I'll end up having to create a separate list for each version of the gadget, and hosting it on my server, as the station data also holds the filename for the station graphic, which are files that are stored locally. I could solve the problem by rewriting the gadget to load the graphics from my server, but that'd really increase the bandwidth, and would take longer to appear/probably slow down the gadget.
I have quite a few good ideas rattling around my head, but not enough time to implement them. Sadly, the storing and editing of the stations probably needs to be done together, so I think the 1.2.9 release will have more stations, perhaps the ability to add custom stations, and definitely an improved volume control that brings in mousewheel support. And then, probably a long time after that, 1.3.0 will introduce the improved handling of stations. With that release, I hope the gadget will be nearly complete. The only things that might be added are additional popular stations, updated code that offers performance improvements, bug fixes, and perhaps some updated/new themes. And I'll eventually sort out the flyout information for the top 5 stations. Perhaps I'll sort out 1.2.9 over the weekend as I create my new RAID arrays.
* Microsoft specifically say: The gadget platform allows for transparency around the edges of a gadget. Any PNG file with a transparent region set to 100% can be used if it is specified as the background on the BODY tag. It is not possible to have a transparent region in the middle of your gadget. It is also not possible to have partially transparent regions, such as a shadow, on the edge or in the middle of a gadget. Attempting this will lead to a poor appearance in many cases.
Yamahito - Friday 20th April, 2007 14:44
Unfortunately, I lack the knowledge to draw the inevitable (sp?) dashboard comparison. I can say that dashboard is also pretty slow, though. And I think that looking at the binary clock widget, for instance, you can get mid-region tranparency.