123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138(* This file is part of BOGUE *)(* Style is used to describe background, border, shadow in an immutable way. Box
uses this, Layout uses this in addition to a Box field for caching the
computation. *)moduleDraw=B_drawmoduleImage=B_imagemoduleRGBA=B_rgbamoduleTheme=B_themeopenB_utilstypeline_style=|Solid|Dottedof(int*int)(* TODO implement "line_with_label" ----------like this----------- *)typeline={color:Draw.color;width:int;style:line_style(* TODO implement this *)}(* TODO implement those fantastic old-style boxes with pattern lines ;) *)typeborder={up:line;down:line;left:line;right:line;radius:intoption(* int should be enough since 0 means None *)}typegradient={colors:Draw.colorlist;angle:float}typebackground=|ImageofImage.t(* pattern image *)|SolidofDraw.color|Gradientofgradienttypeshadow={size:int;(* should the shadow be larger than the box? *)offset:int*int;radius:intoption;(* corner radius *)width:int(* the width of the gradient *)}typet={background:backgroundoption;border:borderoption;shadow:shadowoption}letcreate?background?border?shadow()={background;border;shadow}letof_bgbackground=create~background()letof_borderborder=create~border()letof_shadowshadow=create~shadow()letempty=create()letwith_bgbackgroundt={twithbackground=Somebackground}letwith_shadowshadowt={twithshadow=Someshadow}letwith_borderbordert={twithborder=Someborder}letwithout_bgt={twithbackground=None}letwithout_shadowt={twithshadow=None}letwithout_bordert={twithborder=None}letget_bgt=t.backgroundletget_bordert=t.borderletget_shadowt=t.shadowletunloadt=do_optiont.background@@function|Imageimg->Image.unloadimg|Solid_->()|Gradient_->()letimage_bgimage=Imageimageletcolor_bgcolor=Solidcolorletopaque_bgrgb=color_bg(Draw.opaquergb)lettheme_bg=color_bgRGBA.bg_colorletget_color=function|Solidc->c|_->printddebug_error"Cannot get color from non Solid background";RGBA.noneletgradient?(angle=0.)colors=Gradient{colors;angle}lethgradientcolors=Gradient{colors;angle=180.}letvgradientcolors=Gradient{colors;angle=0.}letmk_line?(color=RGBA.black)?(width=1)?(style:line_style=Solid)()={color;width;style}letmk_radiusradius=ifradius=Some0thenNoneelseradiusletmk_border?radiusline={up=line;down=line;left=line;right=line;radius=mk_radiusradius}letmk_shadow?(offset=(1,3))?(size=3)?(width=6)?radius():shadow={size;offset;radius=mk_radiusradius;width}