Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A Bit of Feedback #1

Open
tin2tin opened this issue Aug 16, 2019 · 43 comments
Open

A Bit of Feedback #1

tin2tin opened this issue Aug 16, 2019 · 43 comments

Comments

@tin2tin
Copy link

tin2tin commented Aug 16, 2019

Now I finally got around to test your add-on. Scrolling through all your snippets, I'm really impressed with all the work you put into this.

I just have a few comments:
In Blender UI the frist letter of each word is in caps, like this: Open Library Folder
Save snippet could be a + icon.
(should there also be a remove function(- icon)?
Insert could be a paste icon, or a check mark, but I couldn't find any.
Maybe all of the icons is that self explanatory that you could add all of the icons to the right with the arrows?
Maybe Open Folder could go into the add-on properties? (If you got + and - you properly wouldn't have to open the folder?)

One really useful function would be to search inside the snippets by the name of a function and all the files containing that string would be visible among the snippets. That's properly very hard to implement, I guess? The hard part with an add on like this is to find what you're looking for. And a function-search operator would help.

@Pullusb
Copy link
Owner

Pullusb commented Aug 20, 2019

Thank you for the feedback.

In Blender UI the frist letter of each word is in caps, like this: Open Library Folder

I know that button label should be titled, but I often forget to do it. Tx for the reminder, I'll do that.

Save snippet could be a + icon.

Agree

(should there also be a remove function(- icon)?
Maybe Open Folder could go into the add-on properties? (If you got + and - you properly wouldn't have to open the folder?)

I will think about that. But I have to admit that I prefer doing operation of renaming/deleting/moving snippets direclty with the texts files.
I chose this system (over my original json oriented approach) because I wanted it super EZ for people to do action on each snippets. like editing and sharing.
That's why I did'nt want to add a delete button in the first place. Wanted to keep it simple and "OS explorer oriented".

In the same spirit I'll let "Open Folder" in the UI. I use it really often so I dont want to push it back to the prefs .
For exemple usually when I add a snippets I open to sort it in the way I want.
I know that since I use prefixes that can be automated, but maybe some other people would want to do otherwise.

Insert could be a paste icon, or a check mark, but I couldn't find any.

Yeah its not the best one. But could not find a better one and I'm used to it now ^^

Maybe all of the icons is that self explanatory that you could add all of the icons to the right with the arrows?

If you mean on the right side of the ui_list it's sounds good, I'll see what I can do.

One really useful function would be to search inside the snippets by the name of a function and all the files containing that string would be visible among the snippets. That's properly very hard to implement, I guess? The hard part with an add on like this is to find what you're looking for. And a function-search operator would help.

I totally agree with you about this. Thats why I try to make the titles of my own snips as explicit as I can, so I can use the built-in UI list search bar efficiently.
I already thought about some way to have an inside-snippet'search but as you said it's kind of hard to do. With my current knowledge of searching techniques it would surely be slow and clumsy.
Maybe by manually generating an index file of the functions with an additional button, but I'm not sure I can do a user friendly UX/UI with this method...
so for now thats a standby for this feature.

One thing I want to implement first is the ability to filter by specific categories/types/user-defined-filter with a tag system.
For example now more than ever we need to be able to filter snippet by blender version compatibility.
I have a somewhat clear idea of how to achieve this but again, I'm afraid that it may add too much complexity both to UI and UX.
And it will alterate the simplicity of the text files themselves that I like, since the best way I found is by adding a dic at the start of each snippets to gather these information and make it readable/editable both by python and by the user...
But I'll definitely do this to at least avoid version conflict, that's starting to bother me.

Another thing I would really like to achieve is to make it easier to share ! Like having an online shared snippet repository where the addon can read/write so it can be fed realtime by the dev community !
That's on a whole other level but would be so awesome...

Once I go back from holidays I'll see to all of this. (when times allow that is.) ;)

@tin2tin
Copy link
Author

tin2tin commented Aug 21, 2019

I played around with the idea of a text preview of the template header, maybe you'll find that interesting?

https://blenderartists.org/uploads/default/original/4X/7/8/9/78952dba5b95b4f582b376fb2feadb17fde09373.gif

For me the biggest problem with using templates is that the titles doesn't describe what I need to know. Ex. if I'm looking for a UI solution, a template(the build in ones) might actually use it, but is actually showcasing something else, and therefore I'll not be able to find it by looking at their names. Also with the removal of the left tools sidebar most template UIs are not easy to find for newcomers, so having a text preview, the location could be exposed.

@Pullusb
Copy link
Owner

Pullusb commented Aug 21, 2019

Interesting indeed. Thats a nice way to do it !
Not so long ago I thinked about running a modal operator to display an openGL preview overlay over the text area (this way you dont have to extend the compressed toolbar to see clearly the preview). But running a modal for just the text editor snippets seemed a bit overkill to me (though I still want to try it some days)...

Feel free to pull request some change if you already did the code.
Or send me a template snippet of your template preview so I can add it later ! 😉

@Pullusb
Copy link
Owner

Pullusb commented Aug 29, 2019

Ok there is a new version for you to try ! Mostly cosmetic change but that's a big improvement on the UI side thanks to your feedback. 👍
Now I'm thinking of a tag system to filter the snippets.

For the header preview can you send me your testing code so I can save some time ?

@tin2tin
Copy link
Author

tin2tin commented Aug 29, 2019

Currently it doesn't seem to install properly(it doesn't show up among the installed add ons?).
In the bl_info there is a whitespace line, and that gives an error, but still when removing that, it doesn't work here?

It was just a mock up with a label pr. line(copy + pasted) and a .box added to the column.

@Pullusb
Copy link
Owner

Pullusb commented Aug 29, 2019

Ok ! sorry for that, I commited the wrong file. I just started using vscode's blender dev plugin from Jacque. L. I understand how it works now.
Strange though... I corrected that single line and its working good for me. Can you try redownload it ?

Ok for the preview, I didn't understand that it was a mockup. thx

@tin2tin
Copy link
Author

tin2tin commented Aug 29, 2019

Yes, now it opens. I had to refresh the list to get entries in the list on first run, maybe it should do this automatic?

Maybe you could consider making a new text block when adding a snippet to the Text Editor, and call it the name of the snippet. Currently it is overwriting whatever is in the text block called 'Text'. Users may loose work this way.

I asked for adding a checkmark to the Blender icon set, if this is added, it might be a better icon than the arrow.

I really like the search function, if possible maybe to could be open on default?

@tin2tin
Copy link
Author

tin2tin commented Aug 29, 2019

Ah, next update there will be a checkmark included: https://devtalk.blender.org/t/new-icons-for-blender-2-8x/4651/716

@Pullusb
Copy link
Owner

Pullusb commented Aug 29, 2019

Yes, now it opens. I had to refresh the list to get entries in the list on first run, maybe it should do this automatic?

I tried to do this just now. I added a call of the reload function in the register. But the problem is that when you hit the checkbox to enable the addon it's in the context of the preferences (I can't access bpy.context.scene). So it give an error...
I'll check if there is a workaround later.

Maybe you could consider making a new text block when adding a snippet to the Text Editor, and call it the name of the snippet. Currently it is overwriting whatever is in the text block called 'Text'. Users may loose work this way.

It supposed to work the way you say. It's the case for me...
it's never overwriting an existing text block. maybe we are not talking about the same thing or I misunderstood. Can you send an exemple ?

Since the last two published version, if no text block is loaded, it will create a new one with the name of the snippet (just as you just asked ) ! This is the only moment when the script is really "creating" a text datablock.

I asked for adding a checkmark to the Blender icon set, if this is added, it might be a better icon than the arrow.
Ah, next update there will be a checkmark included

Cool ! Do you know if in the code I can check if an icon exists ? (to avoid error and replacing with old icon for people who haven't update blender)

I really like the search function, if possible maybe to could be open on default?

Totally agree, I use this search all the time. looking a bit on the web it's possible with self.use_filter_show = True, (found here) It will be in the next version.

@Pullusb
Copy link
Owner

Pullusb commented Aug 29, 2019

Ok preview is live ! \o/

But the spacing gap between line label is too big. I dont know how setup something better (not so good in UI tweaking code...)
I did as follow:

if bpy.context.scene.sniptool_preview:
    # box.prop(scn, 'sniptool_preview', text='')# '\n' not recognised, split in multiple labels
    box = layout.box()
    for l in bpy.context.scene.sniptool_preview.split('\n'):
        box.label(text=l)

@tin2tin Tell me If you know a better way

@tin2tin
Copy link
Author

tin2tin commented Aug 29, 2019

Maybe placing something like this before the loop will do the trick:
box = box(align=True)

Maybe using box also may add additional spacing?

Not at computer right now, so I can't check.

@tin2tin
Copy link
Author

tin2tin commented Aug 29, 2019

This is as tight as possible(without box):

            if bpy.context.scene.sniptool_preview:
                # box.prop(scn, 'sniptool_preview', text='')# '\n' not recognised, split in multiple labels
                col = layout.column(align=True)
                for l in bpy.context.scene.sniptool_preview.split('\n'):
                    col.label(text=l)

But that's without the box.

Do you know about this snippet collection?
https://github.com/zeffii/BlenderPythonRecipes/wiki

The build in templates are called like this:
bpy.utils.script_paths("templates_py"),
So maybe templates_py a predefined path, so maybe you can grab them too?

@tin2tin
Copy link
Author

tin2tin commented Aug 29, 2019

Maybe there should be two insert functions one in a new document and one pasting into the current document(paste icon)?

On the new icon, maybe a try and catch could be used?

@Pullusb
Copy link
Owner

Pullusb commented Aug 29, 2019

This is as tight as possible(without box)

I think I'll let the box for now and see later how can I do better (at least the UI is nice that way).

Maybe there should be two insert functions one in a new document and one pasting into the current document(paste icon)?

I'm not sure about having two buttons. it's fairly simple to make a new block with a clic or alt+N and from the beginning the snippets aimed at being tiny piece of code that you insert in your scripts, not really there to load full-fledged scripts/addons so I'll stick with only the insert.

On the new icon, maybe a try and catch could be used?

Yeah right, I wondered if existed som specific 'get' method but a good'old try block will be fine.

The build in templates are called like this [...]so maybe you can grab them too ?

I thought of integrating the build-in template (just to be able to reach them with the search really) but I in the end it would be redundant to have them at both location. It's kind of good to have your own snippets (or community) separated from the shipped ones.

Do you know about this snippet collection?

I knew of zeffi x_templates and once a sort of tag/category filters is up I might add these. Before adding snippets that aren't mine I need to find a good way to sort all of this and mixing everything is difficult.

But be wary, I'm sort of a slow developer... This might take a while.
And thus today was dedicated to the snippetLib, I have a lot of other project to work on ^^. (as anyone 😄 )

Thanks for all the proposals. Keeped me motivated.

@tin2tin
Copy link
Author

tin2tin commented Aug 29, 2019

The Templates implementation is pretty bad as it is now(that mega long menu), so maybe your add-on could replace it? Or be included in Blender as a much more comprehensive snippet lib.?

@Pullusb
Copy link
Owner

Pullusb commented Aug 29, 2019

You think it can go in ?
I always think I use too many hacky tricks in my code to be ever included.

@Pullusb
Copy link
Owner

Pullusb commented Aug 29, 2019

The next I wanted to do is modify the snippets themselves by adding versions/tag/description/stuff with a dic at the header of each one. This header would be evaluated in python during the scan, and generated with the add popup when you create a new one.
Something pretty much like this :

info = {
    'icon' : 'OUTLINER_OB_EMPTY', #optionally the user can choose an icon instead of the default one
    'description' : 'Add empty at object location', #description (displayed like a tooltip)
    'tags' : ['object', 'translation', '2.8+',] #every new tag would add a checkbox in another UI list dedicated to filtering snippets of the first UI list.
    'version' : '2.80' #merged in the tags ? it's kind of one...
}
Here is were the real snippets starts
blablabla...

(Do you have comment about this btw)

BUT, replacing the current Template system or going alongside it means I'll certainly will have to stick with plain snippets (like it is now) since template_py are also plain.
So the categorization filter would be only folder based (like zeffii did with his menu/submenus)...
The build-in template are only few but with a lot of snippets I dont know if this filter only will be ok.
:s

Here goes the dilemmas

@tin2tin
Copy link
Author

tin2tin commented Aug 31, 2019

To be able to search the contents and functions of the snippets could be very useful, but it'll complicate things and may be a lot of work.

The preview idea was mainly for reading a commented text block at the start of a script(which would have to be added to each snippet), but if you add info headers maybe the preview is not needed, because the exposing the info would be sufficient preview?

The build in templates could also be updated to comply to whatever styles you find right, but of course the Blender Devs would have to be convinced first.

I think the optimal snippet solution would be to connect the API docs with snippets showcasing all the functions, so if you want to add info, maybe the api functions could be harvested from the snippet and added to the info, so snippets somehow could be linked to the api documentation. I don't know how to do that, but I this it could be a great way for people learn coding Blender Python.

@Pullusb
Copy link
Owner

Pullusb commented Aug 31, 2019

To be able to search the contents and functions of the snippets could be very useful, but it'll complicate things and may be a lot of work.

I see a rather simple way to make it, but it will be a somewhat slow search (but not too slow either) that will rely on scanning every snippets at each search call.
So that mean a lot of read on disk... But heh ! if the user find his stuff, no cost too great !
Will run some test and if it seems ok I'll add it

The preview idea was mainly for reading a commented text block at the start of a script(which would have to be added to each snippet), but if you add info headers maybe the preview is not needed, because the exposing the info would be sufficient preview?

After thinking hard (5 long minutes 😲 ) I decided to stay with plain snippets, if only for the sake of
simplicity. And for the limited time I can spare working on this addon.

The build in templates could also be updated to comply to whatever styles you find right, but of course the Blender Devs would have to be convinced first.

About this, it might be better to stick with plain text too, I dont think the devs will be convinced by a script that evaluate string to python execution from an external file for security reason (but maybe I'm wrong)

I think the optimal snippet solution would be to connect the API docs with snippets showcasing all the functions, so if you want to add info, maybe the api functions could be harvested from the snippet and added to the info, so snippets somehow could be linked to the api documentation. I don't know how to do that, but I this it could be a great way for people learn coding Blender Python.

Sound too complex for me to handle 😅

By the way there was a new version yesterday evening. I think you'll like the new feature. The preview now display the definition/classes (if any) in another box below.

I wanted also to scan the build-in snippet (as you proposed) while adding a checkbox on preferences to disable this source. BUT it's incompatible with my current design that is made for specifically targetting one library folder only.

If I make the library multi-folder it add a level of complexity (and not only on the code level). For exemple when you add a new snippets you will have to choose where to send it. Same when you open lib folder, does-it open all folder ?(a bit messy) or again a choice popup ?... + certainly other problems I didnt think about (like handling file conflict for example).

So again it kind of break the simplicity of the plugin that I like...
The built-in template can just be moved to the snippets lib folder and it will work perfectly fine.

Since it can be really usefull to have multiple source anyway, I just put the idea on standby for later.

@tin2tin
Copy link
Author

tin2tin commented Aug 31, 2019

Cool with the classes/defs extracts.

If the snippets are always pasted into the current document, maybe the paste icon should be used instead of the arrow?

@Pullusb
Copy link
Owner

Pullusb commented Aug 31, 2019

Big new update. You will certainly like it !

Here is the changelog of this v0.2.0 (always updated on the readme btw):

  • New feature : Search in content (search in content and filename). act like reload with a filtering when populating the list
  • New snippet standalone add mode (instead of inserting in current text, create a new text block)
  • New option in user preferences : Choose max line number for preview (default 10)
  • New option in user preferences : When auto-creating a new textblock choose wich text editor option to toggle on.
  • Better tooltips

@tin2tin
Copy link
Author

tin2tin commented Aug 31, 2019

Wow that's super cool!

A couple of small things I noticed:
In the Preferences, in 2.81 everything is right aligned and starting with a capital letter(eg. Show). 'Preview line number' should maybe be 'Preview number of lines'.

Insert in new document, maybe use the New File icon eg. document with +?
(Using the copy icon in the text editor header is a bug)

Maybe the new search function could suggest selected text in the search field when opening the popup?

I'm not sure about this, but maybe it is easier for users to navigate the snippets if ex. bpy_ is added to the end of the filenames instead of the beginning - so you could still use them for searching, but the actual function would be the first you'll read?

Maybe you could ask on https://blender.chat/channel/python if there is a solution which will load the files in the list at start up?

@Pullusb
Copy link
Owner

Pullusb commented Aug 31, 2019

A couple of small things I noticed:
In the Preferences, in 2.81 everything is right aligned and starting with a capital letter(eg. Show). 'Preview line number' should maybe be 'Preview number of lines'.

Done. I didn't know of this new layout.use_property_split = True
The labels staying on the left side feels slightly odd but this is definitely better.

Insert in new document, maybe use the New File icon eg. document with +?
(Using the copy icon in the text editor header is a bug)

Done. Didn't realised it was weird ahah (the duplicate made sense too in a way)

Maybe the new search function could suggest selected text in the search field when opening the popup?

Wow ! I super like this idea 👍 ! Done. (only if the selection does not go over one line)

I'm not sure about this, but maybe it is easier for users to navigate the snippets if ex. bpy_ is added to the end of the filenames instead of the beginning - so you could still use them for searching, but the actual function would be the first you'll read?

About that, I dont really want to change it since it's just sort of a naming rule I made for myself.
I only did this to have a quick idea of the "type" but also to sort them (both in OS and in the UI list), going with a suffix will disable this sorting in both.
But that's fine, other users can name otherwise as they like (and definitely will).
And ultimately, it may just be useless to have this. I may just drop it to stay simple and avoid inconsistency with other users snippets.

Maybe you could ask on https://blender.chat/channel/python if there is a solution which will load the files in the list at start up?

Since this is not super important, this is where my lazyness come in ! 😸
I start feeling like an hermit working on this ahah. maybe later.

@tin2tin
Copy link
Author

tin2tin commented Aug 31, 2019

Cool! I can't come up with anything more, except you could run a pep8 check. If vscode doesn't have it, maybe you could use this one: http://pep8online.com/

@tin2tin
Copy link
Author

tin2tin commented Sep 3, 2019

Looking at it again. You're right, it is better to left align the preferences.

Maybe the list widget should have a default height which fits the height of the icons?

Opening the Sidebar:
image

Refreshing the list:
image

Having the Preview button selected, it is pretty dominant, maybe it could just be an icon button below the folder open button?

Maybe double clicking a list item should paste it into the current text?

Renaming, by double clicking snippet name, makes the file unreachable.

@Pullusb
Copy link
Owner

Pullusb commented Sep 3, 2019

Ahah ! I knew you were going to go back with some other changes in mind.

Looking at it again. You're right, it is better to left align the preferences.

All right, I take your word for it, dont mind it being left or right.

Maybe the list widget should have a default height which fits the height of the icons?

True, but I dont know how to do that ^^. Will see if its possible

Having the Preview button selected, it is pretty dominant, maybe it could just be an icon button below the folder open button?

Though I agree it may be currently a bit too big, I like the way it serve as a clear separator/indicator.
I tried a few different things for this part of the UI already, but did not test putting it in the side-icons... I'll give it a shot.

Maybe double clicking a list item should paste it into the current text?

I want that too. Not sure if it's possible to trigger it with a double clic (I think the rename action is part of the UIlist core design). I'll check this anyway but my hope aren't that high...

Already tried something towards this idea of quick insert. At some point I got it working so just single clic on it would paste (but it wasn't relying on clicking event, and it's not something we want now with the preview).

Renaming, by double clicking snippet name, makes the file unreachable.

Yeah, if you want to rename you need to go in the folder library and rename the file itself then hit the reload.
From the start it's up with this OS-based approach. I know it's not perfect but it greatly simplify things.
Nevertheless, I wondered if I should sync the rename on list with the actual file on disk, But it's complicated (maybe not even possible without super tricky hacks...) so I prefer not to.

In the end the double clic to insert would definitely be a good thing, it will be a new cool feature that fix a bad UX in one shot !


I wasn't sleepy while you were blending stuff and gathering toughts ! There is a new feature prepared over the weekend, Check the changelog ;)

One sad thing though : after a lot of trial and sweat yesterday, I failed miserably trying to implement a TabTrigger system in Blender when inserting snippet. Placing/moving the cursor with the API is just an absolute pain ! I'm not sure to add this feature in the end... Already lost way too much time just for this that I consider a bonus.
But I think it's cool that we can now write the syntax in the snippets and enjoy it after conversion on external editor.
Btw what editor do you use ? where are you from ? what is your main use of blender ? so many question all of a sudden 😄.

@tin2tin
Copy link
Author

tin2tin commented Sep 4, 2019

I'm not using any external editor(only Notepad++ once in a while). I know I should, but I'm mostly doing Blender UI work, and it is so much faster to do this from within Blender Text Editor. (I know some people using Emacs and Vim for coding Blender add-ons too)

Generally I just think that the Text Editor has been falling far behind, and do need a lot of love to reach the level of the rest of Blender and therefore I did this thread on Blenderartists to gain some traction for the Text Editor: https://blenderartists.org/t/how-would-you-show-some-love-for-the-blender-text-editor/

The better and more friendly the Text Editor seems, the more add-on devs will start coding for Blender(and eventually they'll move to other IDEs), which is a good thing imo. And therefore I think a good snippets/templates system is crucial.

@Pullusb
Copy link
Owner

Pullusb commented Sep 5, 2019

Here is the new version. I made all the change except for the double-click-insert on item, did not found a way to do it... But as a fix I disabled the rename on double click (just had to make items labels instead of props)

The UI is better now than ever before ;)

Also added a 'Todo' and 'ideas considered' in the readme.
Here is the change log.

v0.2.3 2019-09-05:

  • Converting a snippets without prefix now use containing folder name as trigger keyword. (instead of "bsnip")
    thinking about making it the default in the future...
  • UI fix : The list as now a default minimum size that match the right icons space.
  • UI fix : List item are no longer renamable with double click does nothing, this avoid bad UX and losing track of the snippets file
  • UI new : Preview toggle button is now part of the right side buttons.

@tin2tin
Copy link
Author

tin2tin commented Sep 6, 2019

Excellent! Maybe it deserves a tab with the "Snippets" name, now it uses the full tab?

Maybe you can make a post about it here(so people will know that there still are good things going on with the Text Editor)? https://blenderartists.org/t/how-would-you-show-some-love-for-the-blender-text-editor/1163857/89

I can post about it on Twitter, if you're not on Twitter?

@Pullusb
Copy link
Owner

Pullusb commented Sep 6, 2019

Since it's for coding purpose the dev tab seemed like the right choice. But with the preview and all taking that much space I agree its a good idea to have a dedicated tab. Will do it in the next update ;)

About sharing it, I had planned to post it on the BA thread you mentionned (and eventually on my twitter). But before I want to do 2 things :

  • The number one of my todo : Changing the code so I does not affect user's paperclip.
    I already knew that was considered sort of a bad hack (even before Campbell mentionned it) and at the same time it is so much simple to use this rather than the rest of the API... but there is no way it will ever be included in blender as it is and tempering with clipboard is clearly no good.
    So I will try to make it work clean.

  • Second : I want to make numerous changes on my personal library that is shipped with it.
    Since these snippets are already there, they should be an exemple of good naming convention for the user to make their own snippet.
    But now that I made the converter and used some snippets in vscode and sublime, it's clear that some of my prefix name aren't that clear and my folder structure is not used as its best.

There is more to it on this second todo. I dont know if I completely drop the idea of a prefix and use instead the name of the folder there are being stored in.
This way you have a clean file name (compatible with old templates, good point) and not think that much about "categorizing" when adding a new snippets. Changing the category afterward would be as simple as moving the snippet into another folder. The addon is still able to detect something to be use as a prefix with the folder structure alone. And not classifying it would automatically fall in the "snippets" category (or maybe bpy by defaut).

The other way is keeping things as they are. Which does not rely on folder structure.
Actually now it use both. If no prefix is given, the folder name is used when using the converter. Not so bad all things considered.
The one thing I super like about this current method is that you can have a same "category" (prefix) within different folders. That means you can have your own snippets or specific project snippets in another folder but not mixed (lost) within "standard" library or any other people snippets. In other words it lets you organise the library with more flexibility. Moreover for multiple user working with the same source folder on network where the can create a User folder and still categorize it properly inside...

I think there is a choice to make bout this (I'm not so good with choices ... doubt being a dear friend of mine ^^)

In any cases I think about going with more detailed name. For exemple I used sometimes def_ as prefix just to say these were containing methods, not interesting infos on the snippet itself...

My current categories are :
bpy : blender python (this is kind of an all or uncategorized category but not completely though)
py : pure pyhon operation that work out of the blender scope
def : will delete this one, with time passing i added def on many other prefixed snippets
dev : directly related with developpement, like getting addon preferences etc.
regex : this category is relevant, will keep it as it is
rig : rigging stuff, good category event if its kind off
and thats about it.

I won't go too detailed either. Because with trigger words in IDE you'll have to remenber as many keywords as there are category...
Always trying to keep name short to avoid taking screen space when displayed in UI list and used as trigger keyword.

Maybe something relative to the areas (or scope of action) like :
bpy, py, regex, rig : still good
mat or shader : for scripting related to shader/material...
node : node-tree things
obj : whenever the snippets affect objects in the 3D viewport
mesh : when using bmesh module and other edit mode stuff
ui : panel template and such
gp : grease pencil python (will do this one anyway)
_ops or operator ? : Considering the default templates, there would be an operator exemples category
batch ? : batching stuff. This is tricky, since it can be in many other category (for exemple batch export object can be in obj etc... this is why I wanted to add a tag system but it will overcomplexify things so let be only one tag.
...

This might already be to much category to memorize triggers. Maybe grouping all viewport related stuff under bpy is still good... I think a lot with the converter in mind because I see a lot of potential with this. Sadly you can have only one keyword trigger in those IDEs and only vscode let you "elastic search" in the result after tapping the trigger (that is super cool btw).

I want your opinion. What do you think of all this ? what organisation would you prefer to use ? folder or name prefix like now ?
I suppose you used it a bit already, how have you entered and categorized your own new snippets ?
have you got any category or sorting in mind ?

Of course the user can decide himself for his own method of sorting and will add more category anyway (still more flexible for him if folder are not used as tag).

Also maybe I'm overthinking things... that will not be a first 😄.

Will think about it while fixing the clipboard.

@tin2tin
Copy link
Author

tin2tin commented Sep 6, 2019

On your first thing on the to-do, didn't dfilinto give you a get selection operator, which can be used instead of the clipboard?

On the 2. I do not use sublime or vscode, so I don't know that much about how snippets would work within them, but for me is your search-within-files function that powerful, that it could replace the file name search, and thereby not use the filenames to categorise, but the used or tagged(in commented lines(ex. #gp #mesh) words inside the snippets. Maybe there could be presets search for your catagories, like a drop down, when selecting the category is the auto inserted in the search field, and a search is executed. A way to think of the categories is maybe as bookmarks.

I think the main thing is that this way finding the right snippets aren't dependant on how the files are named, but the contents of the files.

But I do not know how that would work, and maybe you have already found a better way to solve it?

@Pullusb
Copy link
Owner

Pullusb commented Sep 6, 2019

For the clipboard stuff, It's ok for the text get but not for the text insertion. But should totally be doable, I'll implement it soon.

About organisation, those are very interesting thoughts. 👍
I realise that, since the search function is here, I already added some keywords in comments on my new snippets with the purpose of using them as tag to find. Exactly like you mentionned.
More generally I also put more often a comment as first line that act as a description (for the preview but may also be used for the IDEs snippet's description field in the future).
Plus that description line usually contain the needed tags/keywords already.

I'll think about this idea of bookmark tagsearch !

As for now I really dont have any better idea since I decided to stay with a plain file not adding a dic on top like I mentionned before.
About this info-dic stuff, the cool thing is that it would have been compatible with custom shelves. It's a super powerfull addon (2.79 for now) made by a friend to quickly load UI for code instantly from single files whithout restarting blender or adding further addon.
It work in a very similar way as snippets library but it's dynamically drawing operator button interface from individual files and loading/executing code. So if I had taken this dic-info model, any standalone working snippets could have been turn in an instant in a button in the interface with "custom shelves", and any custom shelves addon would have been used as snippets instead of executing.

But I'm just mentionning this so you know his addon exists ^^ I made up my mind to stay with plain-text snippets.

Back to the snippet Lib folder structure, with what you just brought up I'm starting to feel that the prefix is effectively not that important. Simply sorting things in the folder can be best for the user and more logical... and I can still display the parent folder name as a prefix in the UIlist if I still want to use the file-name-search !
I'll think a bit more... Thanks for the quick feedback.

@Pullusb
Copy link
Owner

Pullusb commented Sep 7, 2019

New big version. took me the whole day ! 😅

I chose to rely on folder to stay simple, no prefix anymore.
Also cleaned up and sorted my current library.
A lot of old snippets were not compatible with 2.80, it took me a hell lot of time !! 😵

Here are the changes
v0.3.0 2019-09-07:

  • Library Clean : All shipped personnal snippets have been corrected to work in 2.8 (mentionned otherwise in the header for a few). Filenames are now with spaces and without prefix
  • Changed shipped snippets folder organisation.
  • UX change : The library use now plain filename without prefix. For IDE conversion it uses now the containing folder name as trigger.
  • New conversion feature : Convert auto-description, during conversion to external editors format, use the top comment (if any) of the snippets as description (else use the snippet name.)
  • Add overwrite alert : Confirmation/options popup when creating snippets with the same name as an already existing one
  • Clean text-get: Change the methods of getting selection so it doesn't mess with user clipboard.
  • Clean save : Saving a new snippet has now a lot of error/sanity check with help messages in case of obvious problems.
  • New addon pref : You can choose if you want snippets to be saved as .txt file or .py by default.
    This choice is also shown at the moment of saving (if an extension is manually added it will override the settings)
    considering .py format for all snippets in the future...

@Pullusb
Copy link
Owner

Pullusb commented Sep 8, 2019

I'm close to sharing it now. But need to make some slight adjust here and there.
It sure is better now, the system folder is good. But I slightly miss the prefix showing up in the list (maybe it's just because of the habits).
Maybe I will add an option to display the folder name in the list as a side column...

Another thing. I will surely define .py as the only snippet format to save to in next version... At first it was only saved to .txt because I thought it would be easier for the user to open and modify snippets (double clic open a text editor with a .txt, but try to execute the python with a .py extension).
In last version I added the option to choose between py and txt, and added this comment in the readme :

The default format can be changed in the addon preference. It's completely up to you. Preferably use '.py' when the code can run as a standalone script

But it's overkill since it absolutely does not change the use of the lib and the purpose of this lib it to handle python snippets anyway. at least when you open the snippet with an IDE you have syntax color right away.


Some stuff I may try in the future :
I demoed the addon and discussed it with a friend ('custom shelves' author) and he gave me some ideas to improve. The most interesting one was using the search bar as a "search in content" already. He taught me that you can adapt this search field to call other updates. This would be nice. I'll try in the future. Right now I'm a bit bored working only on this addon to be honest ^^.

@tin2tin
Copy link
Author

tin2tin commented Sep 8, 2019

We're having birthday parties all weekend. My son is turning 6, so I don't have much time, but I noticed after uninstalling and installing the new version the preview was on, but didn't change when changing snippet, until I ran a refresh. Overall this has now a really cool pro feeling. Great job!

I don't know if it is possible to add a drop down to the search area in the 'Search inside snippets' so you can both enter a new entry or select between pre-defined ones like your categories?

If you want to add some more templates, there is a very nice UI template here: https://gist.github.com/AzureDVBB/0b3d941a719e88574533da45d4970492
And some more here:
https://github.com/zeffii/x_templates

Is is strange that adding labels to a box that the line distance goes up, so I think I'll try to ask Harleya if he can help us with that.

@tin2tin
Copy link
Author

tin2tin commented Sep 12, 2019

In a thread on BlenderArtists I came across this way to allow users to select between folders(the enum on the top of the UI):
image
If you want/need separation of your categories, maybe this could be a way too?

@Pullusb
Copy link
Owner

Pullusb commented Sep 12, 2019

It can be a simple and elegant way to filter folders, but just an enum has the drawback of letting the user only choose one tag or all. No multiple category possible at once.
I was thinking of the approach of having a popup containing the list of folders with a checkbox to toggle wich ones to scan.

But maybe a filter by tag is not necessary at all.
As you said, a well made search option and the user will find his way to the right snippets.

Btw I continued working on the addon this week as I have way more free time than usual.
There is a big update coming (probably today) ;)

@Pullusb
Copy link
Owner

Pullusb commented Sep 12, 2019

Here it is ! I let you check the changelog.

Next I'll try to focus on UIlist's search options (currently its case sensitive only) and filter option (for example alphabetical re-order is broken so I removed the button).

That said, I'm pretty happy about how it is now already.

@tin2tin
Copy link
Author

tin2tin commented Sep 14, 2019

Very cool!

A small thing I noticed when using osl templates, which apparently uses tabs for indentation, labels can't print tabs properly:
image

Is there a way to search for ex. osl files only?

@Pullusb
Copy link
Owner

Pullusb commented Sep 14, 2019

Fixed the tab display in preview.

There is no way to filter by file extension.
I do not plan to add this filter. Adding a filter-by-folder can solve this problem I think. Plus there is only py and osl format).

I'll see what I can do for these filtering ideas. Later end of next week though, work has caught up on me.

@tin2tin
Copy link
Author

tin2tin commented Sep 17, 2019

If you want to ease the readability maybe you can use Titel Case for the entries in the list?
text=text.title()
(It's a built-in Python function)

It's very nice that you can add you own path, so you can add your scripts folder, and search in the contents in all of your scripts, if there is something you know you coded at one time, but forgot in what script it is. :-)

@tin2tin
Copy link
Author

tin2tin commented Nov 25, 2019

If you add the column with align=True after adding a box() to layout, the text inside the box will have an aligned leading(line distance), which may allow for more visible lines in your add-on.

Demonstration:

import bpy


class HelloWorldPanel(bpy.types.Panel):
    """Creates a Panel in the Object properties window"""
    bl_label = "Hello World Panel"
    bl_idname = "OBJECT_PT_hello"
    bl_space_type = 'PROPERTIES'
    bl_region_type = 'WINDOW'
    bl_context = "object"

    def draw(self, context):
        layout = self.layout

        layout = layout
        layout = layout.box() #comment this to see align=True not overwritten. 
        col = layout.column(align=True)
        col.label(text="Lorem ipsum dolor sit amet, consectetur adipiscing elit.")
        col.label(text="Integer nec mi imperdiet, sodales metus a, gravida enim.")
        col.label(text="Aliquam pulvinar, neque quis scelerisque molestie, quam arcu volutpat odio")
        col.label(text="a lobortis nisl nulla id orci. ")
        

def register():
    bpy.utils.register_class(HelloWorldPanel)


def unregister():
    bpy.utils.unregister_class(HelloWorldPanel)


if __name__ == "__main__":
    register()

@Pullusb
Copy link
Owner

Pullusb commented Nov 26, 2019

Nice ! I remember we talked about this "too wide line spacing problem".
The solution was real close ! (Maybe you already mentionned it actually, I did not re-read the whole discussion ^^).
I just added the align=True. As you suggested, Thats better, Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants