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

include "add object" menu for canvas' right click popup #1917

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

porres
Copy link
Contributor

@porres porres commented Mar 14, 2023

This adds an object menu for inserting Vanilla objects into the patch when right clicking anywhere on the patch (either in edit or run mode). The object is then inserted at the very same position where the right click occured.

See screenshot. For reference

sreecnshot

the screenshot is from an experimental tcl/tk plugin prototype. For the code, I have simplified it and inserted a single file and called it just like 'deken' is called.

The older plugin works for Pd 0.53-2 but not in the current master. This Pull Request has been adapted to the current code but does not work in previous versions.

For reference for the older experimental prototype implementation, see https://github.com/porres/object-browser-test-plugin

The change for the current code is that we can't modify the .popup menu at loadtime anymore, since now each menu has its own popup.

I understand that there are other ways to do this by including this into the core so we can discuss implementation details. For now I chose this less intrusive form.

I also understand we can discuss gathering object information from somewhere else instead of this hard coded list. This could be reference .md files, for instance. But since nothing like that is present yet, I believe this can be included as is and further changes be made later when we have the framework for it.

The organization of object categories is a bit different than what we currently have in the current help-intro.pd file, but I am using revision changes that are proposed in my documentation branch PR, see #1897

Cheers

@umlaeute
Copy link
Contributor

I also understand we can discuss gathering object information from somewhere else instead of this hard coded list. This could be reference .md files, for instance.

i don't see any .md files in the Pd repository (and I'm not overly enthusiastic about duplicating documentation in multiple files).
I do see quite a lot of -help.pd files though, which would be a prime target for getting information about an object.

umlaeute

This comment was marked as resolved.

@porres

This comment was marked as resolved.

@umlaeute

This comment was marked as resolved.

@porres
Copy link
Contributor Author

porres commented Mar 15, 2023

i don't see any .md files in the Pd repository

I meant those we're planning to use for an online reference at https://pd.iem.sh/objects/

but I get it's part of this repo, and maybe it should be kept that way, right?

@umlaeute
Copy link
Contributor

but I get it's part of this repo, and maybe it should be kept that way, right?

my idea was mainly to parse the section information at runtime from within Pd.

for this to work, the information ought to be available when Pd is running, so it should be included in the Pd-distribution (and therefore in the main Pd-repository).
also, i think that parsing Pd-files for such information is much simpler than parsing markdown files (ideally we need to extract the front-matter from the .md files, determine whether it's TOML or YAML and then parse that structured data; in practice we might get away with just a simple grep for ^pdcategory, but still...).

@porres
Copy link
Contributor Author

porres commented Mar 15, 2023

my idea was mainly to parse the section information at runtime from within Pd.

for this to work, the information ought to be available when Pd is running, so it should be included in the Pd-distribution (and therefore in the main Pd-repository).
also, i think that parsing Pd-files for such information is much simpler than parsing markdown files (ideally we need to extract the front-matter from the .md files, determine whether it's TOML or YAML and then parse that structured data; in practice we might get away with just a simple grep for ^pdcategory, but still...).

Ok, have information about listed objects and their category. The problem with doing this for the help files is that we have multiple objects calling the same help file, so I don't know. In the case of [array] and [file], a single help file also branch up to multiple help files and reference subpatches, so it seems a bit complicated.

So, I'm thinking about it and got the idea to use [help-intro.pd] for such a thing, since now it is actually the only place where the category is explicitly given right now and it's the file that needs to be edited when new objects get in or get deprecated.

But I still don't really know what is the best thing and what needs to be done or how one can parse such information. It just seems like a good place to do it. What do you think?

@porres
Copy link
Contributor Author

porres commented Mar 15, 2023

Here's a rough idea, add a [pd meta] under each category. Does this make sense?

Screen Shot 2023-03-15 at 15 37 57

@sebshader
Copy link
Contributor

sebshader commented Mar 15, 2023

imo at that point it's just as good to have a yaml or json or xml file or something.
I like the idea of the objects in the menu being stored in some files, that way they could be more easily customized/extended by the user.
Also how would category information for a class be determined at runtime? Imo using some object format makes more sense (maybe even tcl arrays in .tcl files)

@umlaeute
Copy link
Contributor

imo at that point it's just as good to have a yaml or json or xml file or something.

until you start parsing yaml/json/xml in Tcl.

Also how would category information for a class be determined at runtime? Imo using some object format makes more sense (maybe even tcl arrays in .tcl files)

???
well, the search-plugin parses the -*.help.pd files for [pd META] (at least in theory), and therein looks for the KEYWORDS identifer, which is just a comment like so:

KEYWORDS control filesystem

it then adds that help-file to the given categories (control and filesystem), and you can get the patch by selecting the filesystem category in the search-browser.

what would the advantage be of putting the category data into a separate file?

@umlaeute
Copy link
Contributor

@porres wrote

Here's a rough idea, add a [pd meta] under each category. Does this make sense?

in practice i think this would complicate things.
suddenly you have to take care of multiple subpatches containing similar data. so you really have to properly handle the subpatches (IIRC the search-plugin actually just ignores the [pd META] and does a search for "KEYWORDS" regardless of actual location for simplicity...)

(I'm aware that I have quite specific ideas how this might work, and I'm talking all other ideas down; sorry for that; feel free to come up with more ideas and implementations...)

@umlaeute umlaeute marked this pull request as draft March 15, 2023 21:38
@pure-data pure-data deleted a comment from porres Mar 15, 2023
@porres
Copy link
Contributor Author

porres commented Jul 5, 2023

(I'm aware that I have quite specific ideas how this might work, and I'm talking all other ideas down; sorry for that; feel free to come up with more ideas and implementations...)

I don't really have any ideas and I'm actually pretty fine in manually handling this, the work load is pretty minimal and is already a reality for me when handling documentation issues. Having to add a new object or method to an object is kinda rare and I already have to update it manually by including it into the 'help-intro.pd" file. And I've been the one who'd been keeping track of changes for 'help-intro.pd" for quite a while now...

By the way, I just had to update it and include the new [file] methods to that file, see this last commit 01c56fa

I then did the same revision and added them here as well, see c36c9a2

by the way, I noticed I missed including the tcl file to "Makefile.am" (not 'makefilename', hahaha), so this PR is really ready to go and tested with the source updated to the newly released Pd 0.54!

I don't think it makes sense to keep this as a "draft", please consider making this ready for consideration and we can keep discussing if it's ok for me to just handle thing like I'm already doing.

pinging @millerpuckette

cheers

@porres porres marked this pull request as ready for review July 5, 2023 00:16
@danomatika
Copy link
Contributor

danomatika commented Jul 5, 2023

I'd say that:

IOhannes is right in that a runtime option would be nicer and probably better in the long run...however this solution works fine, even if it's less flexible.

My 2 cents would be a hybrid solution: a script to generate the object list when building Pd into the plugin tcl, an object meta info tcl or separate txt, etc file. Since the object list is focused on built-in objects so far then this would probably be fine for now.

Then extending to a run-time solution (which could be optional... who knows it might be slow on some platforms, people don't want it, etc) could be done later.

@danomatika
Copy link
Contributor

Ah, I see your original plugin works this way -> object browser is a separate file.

@porres
Copy link
Contributor Author

porres commented Jul 5, 2023

I updated my original plugin here https://github.com/porres/object-browser-test-plugin/releases/tag/v0.0.1-aplha

I haven't uploaded to deken, I think it is sufficient to have it here for now or attached as a zip file right here.

object-browser-test-plugin-0.0.1-aplha.zip

It is now a single tcl file.

@porres
Copy link
Contributor Author

porres commented Jul 6, 2023

so I accidentally made some undesired commits that were supposed to go to my doc branch, and that I reverted and for me to delete them from history it involves me doing some 'git rebase' and force push that I just can't do as it requires some incredible bureaucracy with creating 'tokens' and passwords and I've hit this wall before... I can reboot the PR or someone can just delete them maybe?

@Spacechild1
Copy link
Contributor

and for me to delete them from history it involves me doing some 'git rebase'

To roll back the last two commits: git reset --hard HEAD~2.

NOTE: this will throw away all local changes!! If you have any uncomitted changes that you want to keep, you first need to stash them.

Then you can force push with git push -f

I just can't do as it requires some incredible bureaucracy with creating 'tokens' and passwords and I've hit this wall before...

??? If you have write access to your branch, you can also force push. This shouldn't require any "bureaucracy". What exactly is your problem?

@porres

This comment was marked as off-topic.

@umlaeute

This comment was marked as off-topic.

@danomatika
Copy link
Contributor

danomatika commented Jul 6, 2023 via email

@Spacechild1
Copy link
Contributor

Was going to suggest the same thing as @danomatika: use SSH!

@porres porres added the feature suggestion for an enhancement label Jan 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature suggestion for an enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants