giuspen / cherrytree

cherrytree
https://www.giuspen.net/cherrytree/
Other
3.37k stars 459 forks source link

[Feature Request] Custom Node Icons in the Tree #1231

Open crogonint opened 3 years ago

crogonint commented 3 years ago

I found a couple of similar requests for this from a while back, but the idea appears to have fizzled out. https://github.com/giuspen/cherrytree/issues/291 https://github.com/giuspen/cherrytree/issues/146

For my own use, I just want to be able to use specific icons to help call out different root level categories that I intend to use. I've been pondering this for a few days, and here's what I picture:

1) [Optional] Add the ability to define a default template (document) that will load the users custom icons for a 'new' document. 2) Add a button to the 'New Node Properties' and 'Node Properties' popups to 'Add a Custom Node Icon'. 2a) [Optional] Add ability to add a set of colored icons to replace the colored cherries. (I note that there are already a set of four colored balls that could be a start of a second set.) This feature could be added in to the settings next to the 'Use different Cherries per Level' option. 3) Custom Node icons are saved in the document database/xml file. 4) It should go without saying, but of course the custom icons will need to be added in to the 'Select Node Icon' popup.

I fully intend to over-use this feature for categorizing different types of things in different documents, and would be more than happy to donate Node Icons to Cherrytree as I create them. I've got half a mind to create a full set of colored balls right now. :)

crogonint commented 3 years ago

TA-DA!

ct_circle-icons.zip

crogonint commented 3 years ago

It has occurred to me that you might want to put Custom Node Icons, Header Font settings and etc. in to a 'Document Properties' menu, and then have those configurable in a Template Document.

Not real sure if that would be easier or more work in the long run though. It makes sense to me as a Document Properties sort of thing, but I dunno if that works for all of the other stuff you've got going on.

crogonint commented 3 years ago

One more thought on this mess.. Custom fonts have been a mess since about Win3.1. It would be a really awesome idea to embed custom fonts in to the document as well.

pvelas commented 3 years ago

As a workaround I was able to add my custom icons following way in cherrytree v0.99.21. Add svg icons files into cherrytree/icons/ folder. Mine was named ct_one.svg and ct_two.svg . Run script cherrytree/scripts/gresource_to_c.py .

Add your icons into list in file src/ct/ct_const.h ... 240 const inline static std::array<const gchar*, 51> NODE_CUSTOM_ICONS { ... 288 "ct_c", // 47 289 "ct_cpp", // 48 290 "ct_one", // 49 291 "ct_two", // 50

Compile as usual and you should see your new node icons in the list. select_node

pvelas commented 3 years ago

Maybe one warning before you modify your cherrytree notebook with custom icons that you wouldn't be able to open your notebooks with unmodified version cause it fails to find your custom icon.

txe commented 3 years ago

@crogonint , you can change/customize build-in icons, read more in https://github.com/giuspen/cherrytree/issues/1179#issuecomment-704495346

(maybe we need add more default "empty" icons like 1 2 3, so users can change them)

pvelas commented 3 years ago

@txe - solution that you refer to is more about customizing/overriding existing icons. Unfortunately it wouldn't pick up new icons from this folder. I like your idea of premade (empty) custom icons that can be replaced instead of overriding existing usable icons. That way we will keep default icons backward compatible.