(define (script-fu-dvdbutton-find-layer-by-name-recursive inLayerCount inLayerList inName inDepth) (let* (ourLayer 0) (ourName "") ) ( (set! ourLayer (car inLayerList) ) (set! ourName (car (gimp-drawable-get-name ourLayer)) ) (cond ((> inDepth inLayerCount) -1) ((string=? ourName inName) ourLayer) (else (script-fu-dvdbutton-find-layer-by-name-recursive inLayerCount (cdr inLayerList) inName (+ inDepth 1))) ) ) ) (define (script-fu-dvdbutton-find-layer-by-name inImage inName) (let* (ourLayerCount 0) (ourLayerList '()) ) ( (set! ourLayerList (gimp-image-get-layers inImage) ) (set! ourLayerCount (car ourLayerList) ) (set! ourLayerList (cdr ourLayerList) ) (script-fu-dvdbutton-find-layer-by-name-recursive ourLayerCount ourLayerList inName 1) ) ) (define (script-fu-add-dvdbutton inImage inDrawable inText inFont inFontSize inTextColor) (let* ( (ourTextLayer -1) (ourBorderLayer -1) (ourExtentsList '()) (ourTextboxX 0) (ourTextboxY 0) (ourLayerList '()) (ourOffsetBlurRad (/ inFontSize 10) ) ) (gimp-context-set-foreground inTextColor) (set! ourTextLayer (car (gimp-text-fontname inImage -1 10 10 inText 0 TRUE inFontSize 0 inFont)) ) (set! ourExtentsList (gimp-text-get-extents-fontname inText inFontSize 0 inFont) ) (set! ourTextboxX (car ourExtentsList) ) (set! ourTextboxY (cadr ourExtentsList) ) (set! ourLayerList (cdr (gimp-image-get-layers inImage)) ) (gimp-image-raise-layer-to-top inImage ourTextLayer) (script-fu-drop-shadow inImage ourTextLayer 10 10 10 '(0 0 0) 80 0) (gimp-rect-select inImage 7 7 ourTextboxX ourTextboxY 2 FALSE 0) (gimp-selection-border inImage 3) (set! ourBorderLayer (script-fu-dvdbutton-find-layer-by-name inImage "DVDButton_select_layer") ) (cond ((= ourBorderLayer -1) (set! ourBorderLayer (car (gimp-layer-new inImage (car (gimp-image-width inImage)) (car (gimp-image-height inImage)) 1 "DVDButton_select_layer" 0 0)) ) ) ) (gimp-image-add-layer inImage ourBorderLayer 1) (gimp-edit-bucket-fill ourBorderLayer 0 0 100 0 FALSE 0 0) (gimp-displays-flush) ) ) (script-fu-register "script-fu-add-dvdbutton" ;func name "Add DVD Button" ;menu label "Creates a text box, sized to fit\ around the user's choice of text,\ font, font size, and color." ;description "Om" ;author "copyright 2008, Om" ;copyright notice "Febuary 23, 2008" ;date created "" ;image type that the script works on SF-IMAGE "Image" 0 ;the image SF-DRAWABLE "Drawable" 0 ;reference to the active layer SF-STRING "Text:" "Button Text" ;a string variable SF-FONT "Font:" "Scaberous" ;a font variable SF-ADJUSTMENT "Font size" '(50 1 1000 1 10 0 1) ;a spin-button SF-COLOR "Color:" '(255 255 255) ;color variable ) (script-fu-menu-register "script-fu-add-dvdbutton" "/Script-Fu/DVDButton")