You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Issue description: I recently noticed in LibreOffice that it has right-click option on its objects (like vectors, images, sound files and video). If clicked, that particular object will be opened in external application (the default one for those kind of files in your system, e.g., gimp for raster images, inkscape for vector images, ardour for sound files, etc.), so that we can edit them and save them directly into the document, not externally. Thus, it allows a workflow where the parts can be updated while they being positioned in the document. Can it be done in Synfig, for its raster images, vector images and sound files -- if they be needing editing while the project has already crossed the half-way?
Let's start by implementing this for Image Layers only.
What is expected:
New option in Preferences of Synfig Studio, which defines a path to application for opening image files ("krita" or "gimp" or similar).
User can right-click any image and choose "Edit in external application..." menu item. This should open a image file in application specified in Preferences.
@morevnaproject working on it now :)
As far as I've seen synfig did not edit the images it only let the user change its dimensions. So where is that modified state saved in the app? If that image is internally saved as the format it was previously (i.e jpeg, png etc) then the "Edit in an external app..." option can link the image with the defined path provided in preferences. What are your views on this?
So, all you need to do is to launch binary (the one specified in preferences) and pass an image path as an argument to it. I.e.:
/usr/bin/Krita /path/to/some/file.png
@morevnaproject I saw the code of LibreOffice for "Edit in external tool" they save the image temporarily somewhere and "edit" works on that local copy, not on the original one.
/usr/bin/krita /path/to/some/file.png
This will, however, change the original file which I think not all user wants
So what I am thinking now
add an option Preferred image editor in preferences
point the original image unless the user edits that using an external edit tool.
when the edit is done the local copy (not the original one) will be modified.
on subsequent edit local copy will be used.
As the local copy can be edited by external tool so it's source may not be needed by user hence will not be shown to him.
I have started working as I described. kindly let me know if I need to change something else
:)
It uses App::open_uri() function, which relies on OS file associations. It doesn't works for me when I am trying to open PNG files. Also, the OS file associations could be not a best choice when we want to edit PNG files (I usually associate PNG files with some viewer, not editor). So, let's go with an Preferred Image Editor option in preferences.
Second: it is not very convenient to expand yellow group and right-click layer inside. This is not intuitive. It would be better to have this option for yellow group itself. The problem is that yellow groups are actually can contain something else than image layer (this is because they are general-purpose switch groups). As a solution we need a special condition, which will check if yellow group has (a single) image layer inside. If yes - then "Open file ..." option is displayed.
How to achieve last requirement?
There is already similar case, which can help to understand how to implement this.
@ankit-kumar-dwivedi I need some time to think on the solution. While I am doing this (^__^) I suggest to make a PR for first part of this issue (about Preferred Image Editor option).
EDIT: I got my answer. This comment can be ignored @morevnaproject and is there a separate function that is called when I right click a yellow switch group?
As I was trying to find where the same is implemented for .pgo files as you mentioned earlier
There is already similar case, which can help to understand how to implement this.
@morevnaproject I used the group layer and accessed the canvas using layer->get_canvas() but when I tried using the function std::set<etl::handle<Layer> > get_layers_in_group(const String&group);
In return I am getting an empty set.
so i changed the following
and I am getting 0 after I wrote the following at line 1634.
int layerset = layer->get_canvas()->get_group_count();
std::cout<<std::endl<<"group count is : "<<layerset<<"\n";
I wish to know the number of layers inside the group layer which is passed to the gather_uri() function please let me know if am looking into wrong direction [^_^]
As this is the last step for achieving this feature
Activity
morevnaproject commentedon Apr 4, 2018
Sounds good!
morevnaproject commentedon Apr 4, 2018
Related to #513
morevnaproject commentedon Mar 3, 2019
Let's start by implementing this for Image Layers only.
What is expected:
ankit-kumar-dwivedi commentedon Mar 3, 2019
Thanks for referring this issue @morevnaproject have my exam on Monday so will be unresponsive for 2 days.
And yes assign this one to me 😁
morevnaproject commentedon Mar 4, 2019
Great! This issue is yours now. ^__^
ankit-kumar-dwivedi commentedon Mar 8, 2019
@morevnaproject working on it now :)
As far as I've seen synfig did not edit the images it only let the user change its dimensions. So where is that modified state saved in the app? If that image is internally saved as the format it was previously (i.e jpeg, png etc) then the "Edit in an external app..." option can link the image with the defined path provided in preferences. What are your views on this?
morevnaproject commentedon Mar 8, 2019
By default Synfig doesn't embeds images into its files. It just references them.
You can obtain image path from image layer -
So, all you need to do is to launch binary (the one specified in preferences) and pass an image path as an argument to it. I.e.:
ankit-kumar-dwivedi commentedon Mar 8, 2019
@morevnaproject will send a PR tomorrow :)
ankit-kumar-dwivedi commentedon Mar 9, 2019
@morevnaproject I saw the code of LibreOffice for "Edit in external tool" they save the image temporarily somewhere and "edit" works on that local copy, not on the original one.
This will, however, change the original file which I think not all user wants
So what I am thinking now
add an option Preferred image editor in preferences

point the original image unless the user edits that using an external edit tool.
when the edit is done the local copy (not the original one) will be modified.
on subsequent edit local copy will be used.
As the local copy can be edited by external tool so it's source may not be needed by user hence will not be shown to him.
I have started working as I described. kindly let me know if I need to change something else
:)
morevnaproject commentedon Mar 9, 2019
Still, we would expect original file to be edited. So, here I have to insist - please make edits on original file. ^__^
morevnaproject commentedon Mar 9, 2019
Also, here is what I've just found:
If you import an image, then expand a yellow group and right-click a layer inside, then you can see there is already "Open file ..." menu item exists.
The code for it can be found here:
synfig/synfig-studio/src/gui/instance.cpp
Lines 1716 to 1749 in f1244c2
The problems with current implementation:
App::open_uri()function, which relies on OS file associations. It doesn't works for me when I am trying to open PNG files. Also, the OS file associations could be not a best choice when we want to edit PNG files (I usually associate PNG files with some viewer, not editor). So, let's go with an Preferred Image Editor option in preferences.How to achieve last requirement?
There is already similar case, which can help to understand how to implement this.
Synfig has support for Papagayo lipsync files - PGO. Here is how it works - https://www.youtube.com/watch?v=-Y0Ox0cnlL4
This feature is interesting for us, because it adds "Open file ..." action to group menu, IF some of group's parameters references a filename:
See
gather_uri()functions responsible for this in https://github.com/synfig/synfig/blob/master/synfig-studio/src/gui/instance.cpp#L1597So, I think, it should be possible to add check if group has a single layer inside and this layer is image layer.
9 remaining items
ankit-kumar-dwivedi commentedon Mar 13, 2019
trying this now 😃
ankit-kumar-dwivedi commentedon Mar 13, 2019
@morevnaproject
I uncommented those lines
and added some cout to get information
I am getting 0 here
ankit-kumar-dwivedi commentedon Mar 13, 2019
Sure I will do that :)
Added Image editor preference as per synfig#516
ankit-kumar-dwivedi commentedon Mar 14, 2019
@morevnaproject please have a look at PR :)
Added Edit Image in external tool. WIP for #516.
ankit-kumar-dwivedi commentedon Apr 2, 2019
@morevnaproject I am not getting any output for ⬇️ after changing
synfig/synfig-studio/src/gui/instance.cpp
Lines 1704 to 1707 in a6476f2
to
However it is being called on line
synfig/synfig-studio/src/gui/canvasview.cpp
Line 1711 in 7180292
This is the function responsible for adding "open file.." option in group menu right?
morevnaproject commentedon Apr 3, 2019
@ankit-kumar-dwivedi The part of code you referenced is called when you right-click a layer in workarea (CanvasView).
When you select a layer in Layer Panel it calls this -
synfig/synfig-studio/src/gui/instance.cpp
Lines 1732 to 1756 in 7180292
This function is called from
synfig/synfig-studio/src/gui/actionmanagers/layeractionmanager.cpp
Lines 320 to 322 in 7180292
ankit-kumar-dwivedi commentedon Apr 3, 2019
EDIT: I got my answer. This comment can be ignored
@morevnaproject and is there a separate function that is called when I right click a yellow switch group?
As I was trying to find where the same is implemented for .pgo files as you mentioned earlier
ankit-kumar-dwivedi commentedon Apr 4, 2019
@morevnaproject I used the group layer and accessed the canvas using
layer->get_canvas() but when I tried using the function
std::set<etl::handle<Layer> > get_layers_in_group(const String&group);In return I am getting an empty set.
so i changed the following
synfig/synfig-studio/src/gui/instance.cpp
Lines 1630 to 1659 in a6476f2
I wish to know the number of layers inside the group layer which is passed to the gather_uri() function please let me know if am looking into wrong direction [^_^]
As this is the last step for achieving this feature
morevnaproject commentedon Apr 5, 2019
@ankit-kumar-dwivedi I am afraid
get_group_count()is not the right function to use, as it serves for different purpose ^__^ -synfig/synfig-core/src/synfig/canvas.h
Lines 380 to 381 in 6eafe8e
You need to look for other function of Canvas class. ^__^
Fixed part 2 of synfig#516
Fixed part 2 of synfig#516
Refactor code for synfig#516