TBC Macros and Extensions

 View Only
Expand all | Collapse all

replace/reload macro icons - best software to create icons

  • 1.  replace/reload macro icons - best software to create icons

    Posted 07-13-2021 20:19
    Hi,
    I've got a hard time to update macro icons once TBC had loaded one already. Restarting, resetting Ribbon Tabs and restarting doesn't work.
    Sometimes it works with moving the macros somewhere else, restarting TBC, resetting tabs, restarting, resetting tabs ..., but I haven't found out the exact order yet.
    There must be an easier way.

    Or does it fall back to an old version if it doesn't like the new one? Are there any specifics for the PNG format, transparency to look out for? I figured that the icon shouldn't be bigger than 38x38 pixel.

    What software are you guys using to create icons?

    ------------------------------
    Ronny Schneider
    ------------------------------


  • 2.  RE: replace/reload macro icons - best software to create icons

    Posted 07-13-2021 20:43

    Hey Ronny,

    The CmdData object that is passed into your setup has an ImageSmall and an ImageLarge property (both bitmap objects).

    ImageSmall be 16x16 and ImageLarge should be 32x32.

    Here is some example code for loading a Bitmap in Python:

    To define location on Ribbon set the following properties on CmdData object:
    - DefaultTabKey
    - DefaultTabGroupKey
    - InsertAfterMenuToolKey

    A lot of questions there... hope I'm answering the relevant ones!



    ------------------------------
    Dylan Towler
    www.tbcanz.com/anz-toolbox/
    ------------------------------



  • 3.  RE: replace/reload macro icons - best software to create icons

    Posted 07-13-2021 21:02
    Hi Dylan,
    that's the same code as in all the sample macros, and I haven't changed that one. Weird is that most of the sample macros use 38x38 icons.
    And when it is 38x38 or 32x32, the large version,  why would you assign the image to "cmdData.ImageSmall"?

    I tried now 32x32 and that seems to work. Wasn't there a thread on the TBC forum about macro icons not updating after installing a new version? Maybe that's connected to the sample macros using too large icons.

    Thanks
    Ronny

    ------------------------------
    Ronny Schneider
    ------------------------------



  • 4.  RE: replace/reload macro icons - best software to create icons

    Posted 07-13-2021 21:10
    Not sure on any of that mate. I just had a quick peek at the C# code behind the macro bootstrapping.  Glad the 32x32 icons work.

    ------------------------------
    Dylan Towler
    www.tbcanz.com/anz-toolbox/
    ------------------------------



  • 5.  RE: replace/reload macro icons - best software to create icons

    Posted 07-13-2021 21:38
    It doesn't seem to be the 32x32 pixel icon only.
    For that test I had rescaled the icon and saved as "...32x32.png"

    I had changed the macro code to 
    b = Bitmap (macroFileFolder + "\\" + cmdData.Key + "32x32.png")
    cmdData.ImageSmall = b

    After a restart it still showed the old icon, but after another tab reset it would show the new one.

    I did another test and my suspicion was confirmed, TBC doesn't reload the icon from the disk if the path it has somewhere in memory hasn't changed.
    By altering the icon name and the macro code I had forced a new path onto TBC and only then it is reloading the icon during a tab reset.
    That is utterly stupid and actually worth a bug report. Could you please see to that.

    They most likely aren't going to do anything about it. So, the best workaround is probably to include a revision number in the icon name and reference to it in the macro code.


    ------------------------------
    Ronny Schneider
    ------------------------------



  • 6.  RE: replace/reload macro icons - best software to create icons

    Posted 07-14-2021 07:51
    Just use the "Reset to Defaults" option in the "Set Ribbon Tabs" command (on the support tab). This will reset the ribbon and set all command icons to the current value. Any user modifications to the ribbon would be lost.

    Any new ribbon tabs defined by the commands (using the DefaultTabKey property) would be turned off by default. So after pressing the "Reset to Defaults" button, check if there are some tabs you want to turn on.

    ------------------------------
    Gary Lantaff
    ------------------------------



  • 7.  RE: replace/reload macro icons - best software to create icons

    Posted 07-14-2021 14:17
    Hi Garry,
    that's exactly what I tried, but that doesn't load the new image if the name/path is the same as it was before. Only if the image name/path is different it will be updated during the "reset to defaults".

    ------------------------------
    Ronny Schneider
    ------------------------------



  • 8.  RE: replace/reload macro icons - best software to create icons

    Posted 07-14-2021 14:25
    I have the same issues and sometimes, the only thing that helps is deleting the .user file which contains the ribbons etc settings.

    Not sure where it is now as I don't have my laptop with me, but under the \35\ folder depending on the TBC version either 33, 34, 35....

    If you order the files by newer, the file appears on the top

    There are 2 files withe the same name, but not sure now if it's the .user one or the other one

    ------------------------------
    Fernando Calvo
    calvo@calvo-geospatial.com
    ------------------------------



  • 9.  RE: replace/reload macro icons - best software to create icons

    Posted 07-14-2021 11:06
    When are TML icons loaded?

    At TBC startup, the MacroManager command looks for new or updated TMLs (.py or .pydll files with newer timestamps than previously loaded) and adds them or updates them in the TML dictionary (.dict file in the TML folder, .dict2 file in TBC v5.50+)

    Part of the loading process includes adding/updating a "tool" in the ribbon layout for each TML.

    I am not sure if updating your .png file (only that file) will cause the TML dictionary to update - I'm guessing it does NOT.

    Reload all TMLs in a folder:
    Delete the .dict/.dict2 file

    Reload an individual TML:
    Modify the .py/.pydll file and re-save, so the modified date is newer than previously loaded.

    NOTE: Updating a TML in the dictionary will NOT automatically update the ribbon. It "should" update the icon for the ribbon "tool" in the ribbon layout (ie the "default" icon), but it won't update the "current" ribbon. You'll need to "reset to default" the icon for the ribbon items to get the updated "tool" icon.

    "Set Ribbon Tabs" command

    Using the "Reset to Defaults" button will reset the currently loaded ribbon "tab layout" to it's default tabs, tab contents (and icons), and tab visibility, but I do NOT think it reloads the TML dictionary.

    NOTE: While it sets the ribbon values to match the default values, if you go into the Customize Ribbon command (Customize the Ribbon dialog), you'll see that the ribbon editor considers many (all?) of the values to now be "custom". I think the end result is the same, but if you then go to Customize Ribbon, it looks like everything has been customized.

    "Customize Ribbon" command
    ("Customize the Ribbon" dialog)

    Here, you can actually reset customizations to the actual ribbon

    Reset everything via "Reset" > Reset All Customizations

    You can select individual items and reset their image too

    Note: these will reset the image to the "tool" image - it won't reload the TML dictionary

    PNG file guidelines

    Transparency - use the PNG feature for transparency (alpha channel). Partial transparency of colors is supported. So you can have a dark blue fade to transparent, vs. always fading to white.

    PNG image sizes

    TBC commands (including TMLs) use two sizes: 19x19 (small) and 38x38 (large)

    These match the specific icon sizes supported by the ribbon.

    There are many other TBC features (like the icon at the top of the Command Pane, icons in the Command List, icons in window title bars, etc.) that use the original 16x16 icon size, and so your 19x19 icons will get resized (blurred), but that's an issue that all commands (not just TMLs) are stuck with.

    The original sizes were 16x16 and 32x32, but when the ribbon was added, they changed to 19x19 and 38x38.

    TML CmdData icon properties

    In TBC v5.0, CmdData released with:

    ImageSmall - Used for both large and small icons. The guidance was to use 38x38 icons so the large image looks good and the small image gets resized (good enough). ImageSmall is used for traditional, light and dark themes.

    In TBC v5.2, they added:

    ImageLight - Used for the light theme. If null, fallback to ImageSmall
    ImageDark - Used for the dark theme. If null, fallback to ImageSmall

    In TBC v5.5, they added

    ImageLarge - Used for large icon, all themes. If null, fallback to ImageSmall
    ImageLightLarge - Used for large icon, light theme. If null, I'm guessing fallback to ImageLight. Guessing fallback to ImageLarge if no ImageLight.
    ImageDarkLarge - Used for large icon, dark theme. If null, I'm guessing fallback to ImageDark. Guessing fallbck to ImageLarge if no ImageDark

    PNG editors

    I've used the free app Paint.NET (https://www.getpaint.net/) for basic image editing since 2006 - was introduced to it by one of the other TBC devs.

    At the time one bonus over MS Paint, was it supported transparency.  So you could do gradient transparency.

    Paint.NET has support for layers if you want to create icon components (like a plus sign for create, pencil for edit, etc.) and combine them together (linestring icon + plus sign = create linestring!). Many a TBC command mock-up icon was created with Paint.NET - and many later deemed "good enough" and included in the product (not my decision ;-)

    I'm sure there are better (even free) tools for icon creation/management, but I haven't looked into it yet.

    Hope those answers help!  (It's on the list to someday publish docs/tips around these topics :)

    ------------------------------
    Quan Mueller
    Revenant Solutions - TML Development
    ------------------------------



  • 10.  RE: replace/reload macro icons - best software to create icons

    Posted 07-14-2021 11:17
    And yes, if you're wondering... I really poked Gary to add support for large icons (separate from small ones) before retirement (whenever that comes!)  As a UI guy, it has bugged me since day 1 that TMLs were second-class citizens in the icon department and had these blurry small icons!

    ------------------------------
    Quan Mueller
    Revenant Solutions - TML Development
    ------------------------------



  • 11.  RE: replace/reload macro icons - best software to create icons

    Posted 07-14-2021 14:36
    Hi Quan,
    thanks for all the info. I'm using MS Paint and GIMP, but I also have Photoshop. I was just wondering if somebody has a favorite program with icon library instead of pixel editing from scratch like '95.

    As I figured out yesterday, if you just replace the content of an icon file, it will not be updated during a "reset to defaults". Only if the name/path is different. So, to make it easy for me, I just added a revision number to the icon name and reference to it in the macro. That way I can be sure that the icon is reloaded during the "reset to default".

    The "reset to default" is something I have to deal with after every update anyway, to get my real custom tab with selected built-in functions back.
    1 - start TBC
    2 - restore a backup in customize ribbon
    3 - close TBC
    only now will my custom tab be available in step 6 in "all tabs"

    4 - start TBC
    5 - reset ribbon to defaults
    6 - customize ribbon and move my custom tab from "all tabs" on the left side back to the right
    7 - export as new backup
    8 - close TBC - only now it updates the ribbon settings file
    9 - start TBC


    Cheers
    Ronny

    ------------------------------
    Ronny Schneider
    ------------------------------



  • 12.  RE: replace/reload macro icons - best software to create icons

    Posted 07-14-2021 15:21
    Hi Ronny,

    The reason your renaming of the icon file causes a CmdData update is because you're having to update your .py file with the file path - and thus, the .py modified date/time is newer than what was previously loaded.

    I believe the MacroManager only looks at .py/.pydll files when deciding whether to update the CmdData for a TML.  The CmdData is the only thing stored in the TML dictionary - the MacroManager has no idea how you populated the CmdData.

    Rather than modifying the icon file name and the path within your .py, you could just increment the CmdData.Version - which is kind of appropriate, you're saying that version 1.01 has a newer icon than 1.00 for example.

    You could also make a change to the file, like adding a blank line, then save it. (and if you don't want that line, delete it, and save it again).

    ------------------------------
    Quan Mueller
    Revenant Solutions - TML Development
    ------------------------------



  • 13.  RE: replace/reload macro icons - best software to create icons

    Posted 07-14-2021 20:16
    Hi Quan,
    you are right. Just slightly editing the macro and saving it again does update the icon during the tab reset. I didn't test this before.

    I admit I'm lazy in terms of updating the revision number in the macro. I was hoping to find a tool that would increment it automatically whenever I save it.
    For compiled C#, C++ projects Visual Studio can do it, but I haven't found a convenient way for python code yet.

    ------------------------------
    Ronny Schneider
    ------------------------------



  • 14.  RE: replace/reload macro icons - best software to create icons

    Posted 07-16-2021 09:38
    The version number is mainly useful if you are distributing your TMLs to others and you're trying to troubleshoot something. (What version of the TML do you have? Have you updated to the latest version? ,etc.)  In that case, you only need to update the version when you share a new version.

    One trick might be to put a variable at the top of the .py file with the version number - and you just get into a habit of scrolling to the top and incrementing it when you're happy with something you've changed.

    ------------------------------
    Quan Mueller
    Revenant Solutions - TML Development
    ------------------------------