Fancy icon labels on your desktop

So it was kind of bugging me. I kept hearing how DesktopX couldn't do fancy icon labels. DesktopX certainly was capable of it. We just hadn't built in the feature into DesktopX.  So I decided I would make it so that people could have big friendly icons on their desktop with fancy labels.

So here's how I did it:

First: I realized that I would need 3 objects:

    Object 1: The pretty icon.
    Object 2: The pretty label background
    Object 3: The label text itself.

Secondly, since the goal was to make is to that other users could just right click on something and clone it to have more, I couldn't refer to specific object names. I would have to deal with them through parents. So I made the label background the parent of the label text but the child of the fancy icon.  That way I could have the label text communicate with its parent and its parent's parent (got that?).

In DesktopX, you get to an object's parent's object info like this: object.parent.object.  If you think that's a bit strange looking, imagine getting to the parent objects's parent: object.parent.object.parent.object.  Woha.  But that's how it's done.

So for the label background I made a single .PNG image in Corel Photopaint. Basically it was a square with two circle masks but I got my fancy image going that looked close to screenshots I've seen of other fancy labels on the Mac and elsewhere.

Then for the label text I wrote this code:

'Called when the script is executed
Sub Object_OnScriptEnter
   If Object.PersistStorage("Label") = "" Then Object.Text = "Label"
   Object.State = "labelchangel"
End Sub

Function Object_OnLButtonDown(x, y)
   szLabel = Inputbox("Enter Label", szText)
   Object.Text = szLabel
   Object_OnLButtonDown = False
   Object.state = "labelchange"
End Function

Sub Object_OnStateChange(state)
   If state = "labelchange" Then
       Object.Parent.Object.Width = Object.Width + 12
       Object.Parent.Object.Left = (Object.Parent.Object.Parent.Object.Left +
          Object.Parent.Object.Parent.Object.Width/2 - Object.Parent.Object.Width/2)
       Object.Left = Object.Parent.Object.Left + 6
       Object.Parent.Object.Top = Object.Parent.Object.Parent.Object.Bottom + 6
       Object.Top = Object.Parent.Object.Top + 2

       Object.PersistStorage("Label") = Object.Text

    End If

End Sub

 

Very straight forward. I used the documentation at: https://www.stardock.com/products/desktopx/Docs/22/ScriptingGuide.htm to figure out how to do this.

So basically the way I made it work is that I used "persistent storage" so that it will remember the label I type in.  Then, when I click on the actual label have it bring up a message box to change the text.  I found a "bug" in DesktopX in that I need to actually change the state for it to recognize that the size has changed.  So I created a "labelchange" state in the labeltext object and change the state to that. Then in there I do some work to size the background and move it so that it is positioned correctly under the parent object.  Plus I wanted to make sure that if I make my icon really big or small it'll still center right.

I can also change the color of the labels just by right clicking on the label background and going to the appearance tab on the state page and changing the hue.  And if I want more, I just right click and choose clone.

The whole thing took about 5 minutes (took longer to create this little report).

Download it now: https://www.wincustomize.com/skins.asp?library=3&SkinID=3609

Makes sure you have DesktopX 2.2 or later installed.

2,708 views 4 replies
Reply #1 Top
These are pretty cool. You should probably make a default entry, even if it's only 1 blank character, because if you don't enter label text when asked, you lose the ability to do so.



Powered by SkinBrowser!
Reply #2 Top
Frogboy, that is beautiful. But, I always hide my desktop icons, because they tend to clutter stuff up so fast. Maybe, I should rethink this. Beautiful. Really. Well done!!



Powered by SkinBrowser!
Reply #3 Top
This is nice but I would like if it would be a feature in IconX. Another good feature is a sublabel that shows file count for folders or image info for files. Oh yeah for the hard drives could you put a sublabel that hows free and total hard drive space like:

28.64GB, 20.14GB free
[Message Edited]
Reply #4 Top
I agree. IconX needs this feature too.