GNOME Bugzilla – Bug 147437
proposed replacement for align-visible-layers plug-in
Last modified: 2006-02-16 16:58:51 UTC
I am attaching below the code for a plug-in that allows users to interactively align and arrange layers in an image -- similar to align-visible-layers but hopefully more usable. It will mainly be useful for arranging text, I think. The version attached here can be installed using gimptool-2.1. Instructions for using it can be accessed using the "View Instructions" button; this will be removed if/when the plug-in becomes part of the distribution and proper help is available.
Created attachment 29474 [details] source code for plug-in, align.c Install using "gimptool-2.1 --install align.c"; adds "Align Layers" entry to Layer menu.
I'd rather see bug #143163 fixed than a new plug-in being added that implements what should actually be part of the layer properties dialog.
Is there a layer properties dialog? Anyway, jimmac's design is undoubtedly more elegant, but I'm not sure it provides sufficient flexibility for all the things one might want to do when arranging layers with respect to one another. Here are a couple of suggestions you made while discussing this in IRC (placed here so we won't forget): 1) Something like this should live in libgimpwidgets instead of in a plug-in. 2) It would be better to use stock icons (such as the gravity symbols) rather than creating custom symbols. 3) It would be better to use gdk-pixbuf-csource than to insert xpm's in the source code.
No, there is no layer properties dialog now but it clearly is on our TODO. The layer positioning doesn't absolutely need to be integrated with other layer properties, it could probably also live in a plug-in. What exactly is Jimmac's mockup missing? It certainly has the advantage that it is simple enough to be understood w/o much further explanation. I have only looked at the GUI of your plug-in shortly but I failed to understand how it is supposed to be used. What I displike most about it is the clickable image area at the top. This is a user-interface element that should be avoided and it shouldn't be needed in order to align layers. I suggest we merge the two bug reports and discuss the details of a dialog to position layers before we go into implementation details.
This plug-in is mainly intended for a specific, but commonly occurring and quite important, usage case: you have a set of text layers, and you want to arrange them in a certain way -- align the vertical centers, or align the baselines and create a specified space between the right edge of one and the left edge of another, etc. Unless I am missing something, Jimmac's prototype is not sufficiently flexible to do this, because it only allows you to pick an alignment point on the layer that is moved, not on the layer it is aligned against.
I still suggest we move the two bug reports and use bug #143163 to discuss how a useful UI for layer positioning would look like.
Created attachment 29532 [details] revised align.c Well, in any case it won't be possible to have a reasonable discussion of the pros and cons if you don't understand how the current plug-in works, so I have tried to modify the layout to make it more helpful (at the cost of some additional clutter). You will find it easiest to understand if you start by creating a few randomly scattered text layers to work with. You are right that the use of a preview to pick which layers to use is less than optimal. Ultimately, I think, this should become a tool (the "Alignment Tool"), and the layer selection should be done on the image itself. Obviously that's not possible in a plug-in version, though.
Okay, I have now converted the plug-in into a tool, while at the same time greatly simplifying the ui. Basic usage: activate tool, ctrl-click on a layer to make it the "reference" layer, click on another layer to make it the "target" layer, then press a button on the dialog to cause the target layer to be aligned with the reference layer. Seems to work well on layers, including floating selections; also works on vector items but not quite correctly yet. I would like to extend it to handle guides and selections, but this seems like a good point to present the code. (I am attaching a diff against current cvs HEAD below.) Note that the stock symbols on the buttons are less than optimal at this point because I wanted to avoid creating any new ones.
Created attachment 37850 [details] [review] diff againt cvs HEAD 02-23-05 diff creating new files gimpaligntool.[ch], gimpalignoptions.[ch] in app/tools, and changing tools/gimp-tools.c, core/core-enums.[ch] and core/gimpitem.[ch]
I would like to move ahead with this if possible. I find this an essential tool for creating complex figures -- I use the plug-in version very commonly -- and several people have asked for this functionality on #gimp and been reasonably satisfied when I pointed them to the plug-in. What do I need to add or change to make it commitable? Concerning the comments from Sven, the general answer is that it is absolutely essential to be able to align layers with respect to *other layers*, not just with respect to the image as a whole. That's why the dialogs etc mentioned in the comments are not viable alternatives.
Okay, after discussion with Sven, first version committed to HEAD. 2005-06-03 Bill Skaggs <weskaggs@primate.ucdavis.edu> * gimp/app/tools/Makefile.am * gimp/app/tools/gimp-tools.c * gimp/app/tools/gimpalignoptions.c * gimp/app/tools/gimpalignoptions.h * gimp/app/tools/gimpaligntool.c * gimp/app/tools/gimpaligntool.h: Add new tool for aligning layers etc, as described in bug #147437. * gimp/app/core/gimpitem.c * gimp/app/core/gimpitem.h (gimp_item_align): add function required by new tool. * gimp/app/core/core-enums.c * gimp/app/core/core-enums.h: add enum for alignment types. * gimp/themes/Default/images/stock-hcenter-24.png * gimp/themes/Default/images/stock-vcenter-24.png * gimp/libgimpwidgets/gimpstock.c * gimp/libgimpwidgets/gimpstock.h * gimp/themes/Default/images/Makefile.am * gimp/themes/Default/images/makefile.msc: add two stock symbols, modeled on the gravity symbols.
Should this bug be kept open? And what is the status of the diff attached to it?
*** Bug 331252 has been marked as a duplicate of this bug. ***
IMO this is implemented in 2.3 and can be closed as fixed. Any issues should be filed as new bugs. Seems like the diff was applied as well, if this didn't happen, please change its status accordingly.
Sorry, but IMO the current implementation in 2.3 is completely unusable and either needs to undergo a serious overhaul or will be backed out for the next stable release. I do very much prefer the suggestion that was made in bug #331252 and I think we should reopen that bug report.
Not sure this is the best place to follow up, but I will anyway. It seems to me that a tool for aligning things has three essential requirements: 1) A way to specify what item should be aligned. 2) A way to specify what that item should be aligned with. 3) A way to specify the type of alignment (i.e., horizontal center, left edge, etc). In the alignment tool, I tried to come up with the simplest possible way of doing each of these things: 1) Click on the item. 2) Ctrl-click on the item. 3) Press one of the six buttons in the tool options. However I am completely open to suggestions for better ways of doing it. Simplicity can't come at the cost of making the tool non-functional, though. The suggestion in bug #331252 does not handle requirement (2) at all, and it does not handle requirement (3) in a sufficiently flexible way.