From c85906af87ec6cc8c447a09a6dacad0988e0501b Mon Sep 17 00:00:00 2001 From: Michael Natterer Date: Wed, 13 Oct 2004 12:58:51 +0000 Subject: [PATCH] app/actions/image-actions.c added menu branch "/Image/Guides". 2004-10-13 Michael Natterer * app/actions/image-actions.c * menus/image-menu.xml.in: added menu branch "/Image/Guides". * plug-ins/script-fu/scripts/Makefile.am * plug-ins/script-fu/scripts/guides-from-selection.scm * plug-ins/script-fu/scripts/guides-new-percent.scm * plug-ins/script-fu/scripts/guides-new.scm * plug-ins/script-fu/scripts/guides-remove-all.scm: added new scripts from Alan Horkan. Fixes bug #119667. --- ChangeLog | 12 ++++++ app/actions/image-actions.c | 1 + menus/image-menu.xml.in | 3 ++ plug-ins/script-fu/scripts/Makefile.am | 4 ++ .../scripts/guides-from-selection.scm | 34 +++++++++++++++++ .../script-fu/scripts/guides-new-percent.scm | 37 +++++++++++++++++++ plug-ins/script-fu/scripts/guides-new.scm | 34 +++++++++++++++++ .../script-fu/scripts/guides-remove-all.scm | 24 ++++++++++++ 8 files changed, 149 insertions(+) create mode 100644 plug-ins/script-fu/scripts/guides-from-selection.scm create mode 100644 plug-ins/script-fu/scripts/guides-new-percent.scm create mode 100644 plug-ins/script-fu/scripts/guides-new.scm create mode 100644 plug-ins/script-fu/scripts/guides-remove-all.scm diff --git a/ChangeLog b/ChangeLog index 4edbfbd30b..edfff9d437 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2004-10-13 Michael Natterer + + * app/actions/image-actions.c + * menus/image-menu.xml.in: added menu branch "/Image/Guides". + + * plug-ins/script-fu/scripts/Makefile.am + * plug-ins/script-fu/scripts/guides-from-selection.scm + * plug-ins/script-fu/scripts/guides-new-percent.scm + * plug-ins/script-fu/scripts/guides-new.scm + * plug-ins/script-fu/scripts/guides-remove-all.scm: added new + scripts from Alan Horkan. Fixes bug #119667. + 2004-10-13 Michael Natterer * plug-ins/common/flarefx.c: cleaned up and simplified the diff --git a/app/actions/image-actions.c b/app/actions/image-actions.c index e98da8579d..1ab2296802 100644 --- a/app/actions/image-actions.c +++ b/app/actions/image-actions.c @@ -56,6 +56,7 @@ static GimpActionEntry image_actions[] = { "image-menu", NULL, N_("_Image") }, { "image-mode-menu", NULL, N_("_Mode") }, { "image-transform-menu", NULL, N_("_Transform") }, + { "image-guides-menu", NULL, N_("_Guides") }, { "image-new", GTK_STOCK_NEW, N_("_New..."), "N", NULL, diff --git a/menus/image-menu.xml.in b/menus/image-menu.xml.in index 7b16aa4d42..a0a50a5c80 100644 --- a/menus/image-menu.xml.in +++ b/menus/image-menu.xml.in @@ -288,6 +288,8 @@ + + @@ -508,6 +510,7 @@ + diff --git a/plug-ins/script-fu/scripts/Makefile.am b/plug-ins/script-fu/scripts/Makefile.am index cd646310aa..cf1dd7dcdc 100644 --- a/plug-ins/script-fu/scripts/Makefile.am +++ b/plug-ins/script-fu/scripts/Makefile.am @@ -57,6 +57,10 @@ scriptdata_DATA = \ gradient-bevel-logo.scm \ gradient-example.scm \ grid-system.scm \ + guides-from-selection.scm \ + guides-new.scm \ + guides-new-percent.scm \ + guides-remove-all.scm \ hsv-graph.scm \ i26-gunya2.scm \ image-structure.scm \ diff --git a/plug-ins/script-fu/scripts/guides-from-selection.scm b/plug-ins/script-fu/scripts/guides-from-selection.scm new file mode 100644 index 0000000000..54e4ed41d8 --- /dev/null +++ b/plug-ins/script-fu/scripts/guides-from-selection.scm @@ -0,0 +1,34 @@ +;; -*-scheme-*- + +(define (script-fu-guides-from-selection image + drawable) + (let* ((boundries (gimp-selection-bounds image)) + ;; non-empty INT32 TRUE if there is a selection + (selection (car boundries)) + (x1 (cadr boundries)) + (y1 (caddr boundries)) + (x2 (cadr (cddr boundries))) + (y2 (caddr (cddr boundries)))) + + ;; need to check for a selection or we get guides right at edges of the image + (if (= selection TRUE) + (begin + (gimp-image-undo-group-start image) + + (gimp-image-add-vguide image x1) + (gimp-image-add-hguide image y1) + (gimp-image-add-vguide image x2) + (gimp-image-add-hguide image y2) + + (gimp-image-undo-group-end image) + (gimp-displays-flush))))) + +(script-fu-register "script-fu-guides-from-selection" + _"/Image/Guides/New Guides from _Selection" + _"Creates four Guides around the bounding box of the current selection." + "Alan Horkan" + "Alan Horkan, 2004. Public Domain." + "2004-08-13" + "" + SF-IMAGE "Image" 0 + SF-DRAWABLE "Drawable" 0) diff --git a/plug-ins/script-fu/scripts/guides-new-percent.scm b/plug-ins/script-fu/scripts/guides-new-percent.scm new file mode 100644 index 0000000000..42b9f778fa --- /dev/null +++ b/plug-ins/script-fu/scripts/guides-new-percent.scm @@ -0,0 +1,37 @@ +;; -*-scheme-*- + +;; Alan Horkan 2004. Copyright. +;; I'll fix it and license it differntly later if anyone cares to ask + +(define (script-fu-guide-new-percent image + drawable + direction + position) + (let* ((width (car (gimp-drawable-width drawable))) + (height (car (gimp-drawable-height drawable)))) + (gimp-image-undo-group-start image) + + (if (= direction 0) + (set! position (/ (* height position) 100)) + (set! position (/ (* width position) 100))) + + (if (= direction 0) + ;; convert position to pixel + (if (< position height) (gimp-image-add-hguide image position)) + (if (< position width) (gimp-image-add-vguide image position))) + + (gimp-image-undo-group-end image) + (gimp-displays-flush))) + +(script-fu-register "script-fu-guide-new-percent" + _"/Image/Guides/New Guide (by _Percent)..." + "Add a single Line Guide with the specified postion. Position specified as a percent of the image size." + "Alan Horkan" + "Alan Horkan, 2004" + "April 2004" + "" + SF-IMAGE "Input Image" 0 + SF-DRAWABLE "Input Drawable" 0 + SF-OPTION _"Direction" '(_"Horizontal" + _"Vertical") + SF-ADJUSTMENT _"Position (in %)" '(50 0 100 1 10 0 1)) diff --git a/plug-ins/script-fu/scripts/guides-new.scm b/plug-ins/script-fu/scripts/guides-new.scm new file mode 100644 index 0000000000..7c236021b8 --- /dev/null +++ b/plug-ins/script-fu/scripts/guides-new.scm @@ -0,0 +1,34 @@ +;; -*-scheme-*- + +;; Alan Horkan 2004. Public Domain. +;; so long as remove this block of comments from your script +;; feel free to use it for whatever you like. + +(define (script-fu-guide-new image + drawable + direction + position) + (let* ((width (car (gimp-drawable-width drawable))) + (height (car (gimp-drawable-height drawable)))) + (gimp-image-undo-group-start image) + + (if (= direction 0) + ;; check position is inside the image boundaries + (if (< position height) (gimp-image-add-hguide image position)) + (if (< position width) (gimp-image-add-vguide image position))) + + (gimp-image-undo-group-end image) + (gimp-displays-flush))) + +(script-fu-register "script-fu-guide-new" + _"/Image/Guides/New _Guide..." + "Add a single Line Guide with the specified postion and orientation. Postion is specified in Pixels (px)." + "Alan Horkan" + "Alan Horkan, 2004. Public Domain." + "2004-04-02" + "" + SF-IMAGE "Image" 0 + SF-DRAWABLE "Drawable" 0 + SF-OPTION _"Direction" '(_"Horizontal" + _"Vertical") + SF-ADJUSTMENT "Position" '(0 0 1000 1 10 0 1)) diff --git a/plug-ins/script-fu/scripts/guides-remove-all.scm b/plug-ins/script-fu/scripts/guides-remove-all.scm new file mode 100644 index 0000000000..1be23f8797 --- /dev/null +++ b/plug-ins/script-fu/scripts/guides-remove-all.scm @@ -0,0 +1,24 @@ +;; -*-scheme-*- + +(define (script-fu-guides-remove image + drawable) + (let* ((guide-id 0)) + (gimp-image-undo-group-start image) + + (set! guide-id (car (gimp-image-find-next-guide image 0))) + (while (> guide-id 0) + (gimp-image-delete-guide image guide-id) + (set! guide-id (car (gimp-image-find-next-guide image 0)))) + + (gimp-image-undo-group-end image) + (gimp-displays-flush))) + +(script-fu-register "script-fu-guides-remove" + _"/Image/Guides/_Remove all Guides" + "Removes all horizontal and vertical guides." + "Alan Horkan" + "Alan Horkan, 2004. Public Domain." + "April 2004" + "" + SF-IMAGE "Image" 0 + SF-DRAWABLE "Drawable" 0)