/* Filter Editor - may.98 - by Sylvain Huet */ /* Oct. '98 - by Marc Barilley */ struct FEd= [chFEd:Chn,winFEd:ObjWin, colcheckFEd:ObjCheck,colwinFEd:ObjWin,colcolFEd:I,colrateFEd:ObjSlider, rotcheckFEd:ObjCheck,rotangFEd:ObjSlider, satcheckFEd:ObjCheck,satvalFEd:ObjSlider,satrateFEd:ObjSlider, attcheckFEd:ObjCheck,attwinFEd:ObjWin,attcolFEd:I,attdistFEd:ObjSlider, okFEd:ObjButton,cancelFEd:ObjButton, endFEd:fun[S] I,updateFEd:fun[S] I,oldFEd:S ]mkFEd;; fun extend(s,i)= if (strlen s)=strlen s then 0 else let nth_char s i ->c in if c=='C then (set b.colcolFEd=htoi substr s i+1 6; _SETsliderLeft b.colrateFEd itof htoi substr s i+7 2; _SETcheck b.colcheckFEd 1; parseFilter b s i+9) else if c=='R then (_SETsliderLeft b.rotangFEd itof ((htoi substr s i+1 4)*360/65536); _SETcheck b.rotcheckFEd 1; parseFilter b s i+5) else if c=='S then (_SETsliderLeft b.satvalFEd itof ((htoi substr s i+1 4)/256); _SETsliderLeft b.satrateFEd itof htoi substr s i+5 2; _SETcheck b.satcheckFEd 1; parseFilter b s i+7) else if c=='A then (set b.attcolFEd=htoi substr s i+1 6; _SETsliderLeft b.attdistFEd itof htoi substr s i+7 2; _SETcheck b.attcheckFEd 1; parseFilter b s i+9) else parseFilter b s i+1;; fun setFilter(b,s)=parseFilter b s 0;; fun updateFilter(b)= exec b.updateFEd with [getFilter b];; fun _paintcol(x,b)= _PAINTrectangle b.colwinFEd 0 0 200 200 DRAW_SOLID 1 b.colcolFEd DRAW_SOLID b.colcolFEd; 0;; fun endcol(c,b)= if c==nil then nil else (set b.colcolFEd=c; _paintcol nil b; updateFilter b);; fun _clickcol(a,b,x,y,c)= _CRcolorMap b.chFEd b.winFEd 0 0 "Color" mknode @endcol b b.colcolFEd;; fun _paintatt(x,b)= _PAINTrectangle b.attwinFEd 0 0 200 200 DRAW_SOLID 1 b.attcolFEd DRAW_SOLID b.attcolFEd; 0;; fun endatt(c,b)= if c==nil then nil else (set b.attcolFEd=c; _paintatt nil b; updateFilter b);; fun _clickatt(a,b,x,y,c)= _CRcolorMap b.chFEd b.winFEd 0 0 "Color" mknode @endatt b b.attcolFEd;; fun _ok(x,b)= let getFilter b-> s in (_DSwindow b.winFEd; exec b.endFEd with [s]);; fun _cancel(x,b)= exec b.updateFEd with [b.oldFEd]; _DSwindow b.winFEd; exec b.endFEd with [nil];; fun _destroy(x,b)= _DSslider b.colrateFEd; _DSslider b.rotangFEd; _DSslider b.satvalFEd; _DSslider b.satrateFEd; exec b.endFEd with [nil];; fun chkcol(w,b,i)= updateFilter b;; fun retcol (s, new1, new2, b)= updateFilter b;; fun iniFilterEdit(ch,father,title,filter,end,update)= let [300 340]->[w h] in let _CRwindow ch father 270 0 w h WN_MENU|WN_MINBOX title -> win in let _CRtext ch win 5 5 w-10 20 ET_BORDER title -> banner in let _CRcheck ch win 5 h-310 w-10 15 0 "Color Filter" -> colcheck in let _CRtext ch win 10 h-290 35 15 ET_ALIGN_LEFT "Color:" -> coltxt1 in let _CRwindow ch win 10 h-270 35 20 WN_CHILDINSIDE|WN_NOCAPTION|WN_DOWN "" -> colwin in let _CRtext ch win 50 h-290 35 15 ET_ALIGN_LEFT "Rate:" -> coltxt2 in let _CRcheck ch win 5 h-240 w-10 15 0 "Rotation Filter" -> rotcheck in let _CRtext ch win 10 h-220 50 15 ET_ALIGN_LEFT "Angular:" -> rottxt1 in let _CRcheck ch win 5 h-170 w-10 15 0 "Saturation Filter" -> satcheck in let _CRtext ch win 10 h-150 40 15 ET_ALIGN_RIGHT "Value:" -> sattxt1 in let _CRtext ch win 155 h-150 40 15 0 "Rate:" -> sattxt2 in let _CRcheck ch win 5 h-100 w-10 15 0 "Attraction Filter" -> attcheck in let _CRtext ch win 10 h-80 35 15 ET_ALIGN_LEFT "Color:" -> atttxt1 in let _CRtext ch win 50 h-80 60 15 ET_ALIGN_LEFT "Distance:" -> atttxt2 in let _CRwindow ch win 10 h-60 35 20 WN_CHILDINSIDE|WN_NOCAPTION|WN_DOWN "" -> attwin in let _CRbutton ch win 5 h-25 60 20 0 "Ok" -> ok in let _CRbutton ch win 70 h-25 60 20 0 "Cancel" -> cancel in let mkFEd [ch win colcheck colwin 0 nil rotcheck nil satcheck nil nil attcheck attwin 0 nil ok cancel end update filter] -> b in (_CBwinDestroy win @_destroy b; _CBcheck colcheck @chkcol b; _CBwinPaint colwin @_paintcol b; _CBwinClick colwin @_clickcol b; set b.colrateFEd= _CRslider ch win nil 50 h-275 240 24 0xff0000 (itof 0) (itof 255) (itof 0) (itof 0) mkfun4 @retcol b SLIDER_INTER_FIXED|SLIDER_DRAW_VALUE|SLIDER_BUTTON; _SETsliderPrecisionStep b.colrateFEd itof 1; _SETsliderPrecisionMark b.colrateFEd 0; _CBcheck rotcheck @chkcol b; set b.rotangFEd= _CRslider ch win nil 10 h-205 280 24 0xff0000 (itof 0) (itof 360) (itof 0) (itof 0) mkfun4 @retcol b SLIDER_INTER_FIXED|SLIDER_DRAW_VALUE|SLIDER_BUTTON; _SETsliderPrecisionStep b.rotangFEd itof 1; _SETsliderPrecisionMark b.rotangFEd 0; _CBcheck satcheck @chkcol b; set b.satvalFEd= _CRslider ch win nil 10 h-135 135 24 0xff0000 (itof 0) (itof 255) (itof 0) (itof 0) mkfun4 @retcol b SLIDER_INTER_FIXED|SLIDER_DRAW_VALUE|SLIDER_BUTTON; _SETsliderPrecisionStep b.satvalFEd itof 1; _SETsliderPrecisionMark b.satvalFEd 0; set b.satrateFEd= _CRslider ch win nil 155 h-135 135 24 0xff0000 (itof 0) (itof 255) (itof 0) (itof 0) mkfun4 @retcol b SLIDER_INTER_FIXED|SLIDER_DRAW_VALUE|SLIDER_BUTTON; _SETsliderPrecisionStep b.satrateFEd itof 1; _SETsliderPrecisionMark b.satrateFEd 0; _CBcheck attcheck @chkcol b; _CBwinPaint attwin @_paintatt b; _CBwinClick attwin @_clickatt b; set b.attdistFEd= _CRslider ch win nil 50 h-65 240 24 0xff0000 (itof 0) (itof 255) (itof 0) (itof 0) mkfun4 @retcol b SLIDER_INTER_FIXED|SLIDER_DRAW_VALUE|SLIDER_BUTTON; _SETsliderPrecisionStep b.attdistFEd itof 1; _SETsliderPrecisionMark b.attdistFEd 0; _CBbutton ok @_ok b; _CBbutton cancel @_cancel b; setFilter b filter; _paintcol nil b; _paintatt nil b; b );;