1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071(* Claude Code
*
* Copyright (C) 2026 Yoann Padioleau
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public License
* (LGPL) as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*)(* See Widget.mli *)(*****************************************************************************)(* Types *)(*****************************************************************************)typebox={x:float;y:float;w:float;h:float}letleft(b:box)=b.x-.(b.w/.2.)letright(b:box)=b.x+.(b.w/.2.)letbottom(b:box)=b.y-.(b.h/.2.)lettop(b:box)=b.y+.(b.h/.2.)letcontains(b:box)pxpy=px>=leftb&&px<=rightb&&py>=bottomb&&py<=topbtypeid=float*floatletid(b:box):id=(b.x,b.y)letinsetd(b:box)={bwithw=max0.(b.w-.(2.*.d));h=max0.(b.h-.(2.*.d))}typeinput={mx:float;my:float;mdown:bool;mclick:bool;mrdown:bool;typed:string;wheel:float;keys:stringlist;}letno_input={mx=0.;my=0.;mdown=false;mclick=false;mrdown=false;typed="";wheel=0.;keys=[]}typecanvas_event=Hoverof(float*float)|Pressof(float*float)|Right_pressof(float*float)(*****************************************************************************)(* What a widget draws *)(*****************************************************************************)typepaint=|FillofColor.t*box|TextofColor.t*box*string|DiscofColor.t*float*float*float|SegmentofColor.t*float*float*float*float*floatletframecolorthickness(b:box)=lett=minthickness(min(b.w/.2.)(b.h/.2.))in[Fill(color,{bwithy=topb-.(t/.2.);h=t});Fill(color,{bwithy=bottomb+.(t/.2.);h=t});(* claude: the sides stop at the bars above, so no pixel is filled
* twice -- it would show through a translucent color *)Fill(color,{bwithx=leftb+.(t/.2.);w=t;h=b.h-.(2.*.t)});Fill(color,{bwithx=rightb-.(t/.2.);w=t;h=b.h-.(2.*.t)});]lettext_width~sizes=0.6*.size*.float_of_int(String.lengths)