10
10
; All calls to gimp-text-* have been converted to use the *-fontname form.
11
11
; The corresponding parameters have been replaced by an SF-FONT parameter.
12
12
; ************************************************************************
14
14
; This program is free software; you can redistribute it and/or modify
15
15
; it under the terms of the GNU General Public License as published by
16
16
; the Free Software Foundation; either version 2 of the License, or
17
17
; (at your option) any later version.
19
19
; This program is distributed in the hope that it will be useful,
20
20
; but WITHOUT ANY WARRANTY; without even the implied warranty of
21
21
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22
22
; GNU General Public License for more details.
24
24
; You should have received a copy of the GNU General Public License
25
25
; along with this program; if not, write to the Free Software
26
26
; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28
(define (text-width extents)
31
(define (text-height extents)
34
(define (text-ascent extents)
37
(define (text-descent extents)
38
(cadr (cddr extents)))
40
(define (round-select img
46
(let* ((diameter (* ratio height)))
47
(gimp-ellipse-select img x y diameter height CHANNEL-OP-ADD FALSE 0 0)
48
(gimp-ellipse-select img (+ x (- width diameter)) y
49
diameter height CHANNEL-OP-ADD FALSE 0 0)
50
(gimp-rect-select img (+ x (/ diameter 2)) y
51
(- width diameter) height CHANNEL-OP-ADD FALSE 0)))
53
28
(define (script-fu-round-button text
70
45
(cond ((eqv? notpressed TRUE)
71
(do-pupibutton text size font ul-color lr-color
72
text-color xpadding ypadding bevel ratio 0)))
46
(do-pupibutton text size font ul-color lr-color
47
text-color xpadding ypadding bevel ratio 0)))
73
48
(cond ((eqv? notpressed-active TRUE)
74
(do-pupibutton text size font ul-color-high lr-color-high
75
hlight-color xpadding ypadding bevel ratio 0)))
49
(do-pupibutton text size font ul-color-high lr-color-high
50
hlight-color xpadding ypadding bevel ratio 0)))
76
51
(cond ((eqv? pressed TRUE)
77
(do-pupibutton text size font ul-color-high lr-color-high
78
hlight-color xpadding ypadding bevel ratio 1))))
52
(do-pupibutton text size font ul-color-high lr-color-high
53
hlight-color xpadding ypadding bevel ratio 1))))
80
55
(define (do-pupibutton text
92
(let* ((text-extents (gimp-text-get-extents-fontname text
96
(ascent (text-ascent text-extents))
97
(descent (text-descent text-extents))
99
(height (+ (* 2 (+ ypadding bevel))
102
(radius (/ (* ratio height) 4))
104
(width (+ (* 2 (+ radius xpadding))
106
(text-width text-extents)))
108
(img (car (gimp-image-new width height RGB)))
110
(bumpmap (car (gimp-layer-new img width height
111
RGBA-IMAGE "Bumpmap" 100 NORMAL-MODE)))
112
(gradient (car (gimp-layer-new img width height
113
RGBA-IMAGE "Button" 100 NORMAL-MODE))))
67
(define (text-width extents)
70
(define (text-height extents)
73
(define (text-ascent extents)
76
(define (text-descent extents)
77
(cadr (cddr extents)))
79
(define (round-select img
85
(let* ((diameter (* ratio height)))
86
(gimp-ellipse-select img x y diameter height CHANNEL-OP-ADD FALSE 0 0)
87
(gimp-ellipse-select img (+ x (- width diameter)) y
88
diameter height CHANNEL-OP-ADD FALSE 0 0)
89
(gimp-rect-select img (+ x (/ diameter 2)) y
90
(- width diameter) height CHANNEL-OP-ADD FALSE 0)))
93
(text-extents (gimp-text-get-extents-fontname text
97
(ascent (text-ascent text-extents))
98
(descent (text-descent text-extents))
100
(height (+ (* 2 (+ ypadding bevel))
103
(radius (/ (* ratio height) 4))
105
(width (+ (* 2 (+ radius xpadding))
107
(text-width text-extents)))
109
(img (car (gimp-image-new width height RGB)))
111
(bumpmap (car (gimp-layer-new img width height
112
RGBA-IMAGE "Bumpmap" 100 NORMAL-MODE)))
113
(gradient (car (gimp-layer-new img width height
114
RGBA-IMAGE "Button" 100 NORMAL-MODE)))
115
117
(gimp-context-push)
117
119
(gimp-image-undo-disable img)
119
121
; Create bumpmap layer
121
123
(gimp-image-add-layer img bumpmap -1)
122
124
(gimp-selection-none img)
123
125
(gimp-context-set-background '(0 0 0))
124
126
(gimp-edit-fill bumpmap BACKGROUND-FILL)
126
128
(round-select img (/ bevel 2) (/ bevel 2)
127
(- width bevel) (- height bevel) ratio)
129
(- width bevel) (- height bevel) ratio)
128
130
(gimp-context-set-background '(255 255 255))
129
131
(gimp-edit-fill bumpmap BACKGROUND-FILL)
177
179
(gimp-image-undo-enable img)
178
180
(gimp-display-new img)
182
186
(script-fu-register "script-fu-round-button"
185
"Arturo Espinosa (stolen from quartic's beveled button)"
186
"Arturo Espinosa & Federico Mena Quintero"
189
SF-STRING _"Text" "The GIMP"
190
SF-ADJUSTMENT _"Font size (pixels)" '(16 2 100 1 1 0 1)
191
SF-FONT _"Font" "Sans"
192
SF-COLOR _"Upper color" '(192 192 0)
193
SF-COLOR _"Lower color" '(128 108 0)
194
SF-COLOR _"Text color" '(0 0 0)
195
SF-COLOR _"Upper color (active)" '(255 255 0)
196
SF-COLOR _"Lower color (active)" '(128 108 0)
197
SF-COLOR _"Text color (active)" '(0 0 192)
198
SF-ADJUSTMENT _"Padding X" '(4 0 100 1 10 0 1)
199
SF-ADJUSTMENT _"Padding Y" '(4 0 100 1 10 0 1)
200
SF-ADJUSTMENT _"Bevel width" '(2 0 100 1 10 0 1)
201
SF-ADJUSTMENT _"Round ratio" '(1 0.05 20 0.05 1 2 1)
202
SF-TOGGLE _"Not pressed" TRUE
203
SF-TOGGLE _"Not pressed (active)" TRUE
204
SF-TOGGLE _"Pressed" TRUE)
188
_"Create images, each containing an oval button graphic"
189
"Arturo Espinosa (stolen from quartic's beveled button)"
190
"Arturo Espinosa & Federico Mena Quintero"
193
SF-STRING _"Text" "GIMP"
194
SF-ADJUSTMENT _"Font size (pixels)" '(16 2 100 1 1 0 1)
195
SF-FONT _"Font" "Sans"
196
SF-COLOR _"Upper color" '(192 192 0)
197
SF-COLOR _"Lower color" '(128 108 0)
198
SF-COLOR _"Text color" "black"
199
SF-COLOR _"Upper color (active)" '(255 255 0)
200
SF-COLOR _"Lower color (active)" '(128 108 0)
201
SF-COLOR _"Text color (active)" '(0 0 192)
202
SF-ADJUSTMENT _"Padding X" '(4 0 100 1 10 0 1)
203
SF-ADJUSTMENT _"Padding Y" '(4 0 100 1 10 0 1)
204
SF-ADJUSTMENT _"Bevel width" '(2 0 100 1 10 0 1)
205
SF-ADJUSTMENT _"Round ratio" '(1 0.05 20 0.05 1 2 1)
206
SF-TOGGLE _"Not pressed" TRUE
207
SF-TOGGLE _"Not pressed (active)" TRUE
208
SF-TOGGLE _"Pressed" TRUE
206
211
(script-fu-menu-register "script-fu-round-button"
207
_"<Toolbox>/Xtns/Script-Fu/Buttons")
212
"<Toolbox>/Xtns/Buttons")