001package polaris.sdk.ui; 002/** Neutral glass: state is a material tint change, never a colored covering rectangle. */ 003public final class Theme { 004 public int text=0xfff0f0f0,muted=0xffbcbcbc,accent=0xffe6e6e6,accentText=0xff171717, 005 surface=0xff171717,field=0x38777777,hover=0x24ffffff,border=0x247c7c7c, 006 selected=0x8ae0e0e0,danger=0xffe6e6e6,success=0xffe6e6e6,shade=0x3d000000; 007 /** Ordinary controls are softly squared; panels have their own larger radius. */ 008 public float radius=9,panelRadius=18,fontSize=14,rowHeight=34,blur=.98f,sigma=18, 009 refraction=10,shine=.82f,dispersion=.85f; 010 /** The backdrop itself supplies transparency; alpha=1 avoids sharp-scene leakage. */ 011 public float tint=.20f,surfaceOpacity=1,hoverTint=.025f,pressTint=.060f,selectedTint=.18f; 012 public boolean dark=true,reducedMotion=Boolean.getBoolean("liquidglass.reducedMotion"); 013 /** Global UI rendering, not a post-process over the host scene. */ 014 public Antialiasing antialiasing=Antialiasing.HIGH; 015 public TextMode textMode=TextMode.AUTO; 016 public boolean textPixelSnap=true,bezierCorners=true; 017 public float textContrast=1.05f,letterSpacing=0,cornerSmoothing=.55f; 018 /** Empty families select an installed system fallback. Font files are never bundled. */ 019 public String fontFamily="",cjkFontFamily=""; 020 public int background=0xff151515,backgroundAccent=0xff434343,highlight=0xffffffff,shadow=0xff000000, 021 disabledText=0xff858585,warning=0xffe6e6e6; 022 /** Gaussian standard deviation in physical framebuffer pixels (0 disables the blur pass). */ 023 public Theme sigma(float pixels){sigma=bounded("sigma",pixels,0,32);return this;} 024 /** Blend between sharp and Gaussian-blurred backdrop, independently of Gaussian sigma. */ 025 public Theme blur(float amount){blur=unit(amount);return this;} 026 /** Screen-space refraction strength (0..30), NOT a physical index of refraction. */ 027 public Theme refraction(float strength){refraction=bounded("refraction",strength,0,30);return this;} 028 /** Contour reflection intensity (0..1.5); 0 disables highlight, sheen and optical edge shadow. */ 029 public Theme shine(float strength){shine=bounded("shine",strength,0,1.5f);return this;} 030 /** Single red/blue-channel offset at the contour, in logical UI units (0..2). 031 * Uses sharp-source chromatic differences independently of Gaussian background blur. 032 * 0 disables dispersion; uniform backgrounds do not acquire an artificial rainbow. */ 033 public Theme dispersion(float amount){dispersion=bounded("dispersion",amount,0,2);return this;} 034 /** Surface composite opacity; unlike blur(), low values reveal the sharp scene below. */ 035 public Theme opacity(float amount){surfaceOpacity=unit(amount);return this;} 036 private static float bounded(String name,float value,float min,float max){if(!Float.isFinite(value)||value<min||value>max)throw new IllegalArgumentException(name+" must be "+min+".."+max);return value;} 037 public Theme antialiasing(Antialiasing a){if(a==null)throw new NullPointerException("antialiasing");antialiasing=a;return this;} 038 public Theme textMode(TextMode mode){if(mode==null)throw new NullPointerException("text mode");textMode=mode;return this;} 039 public Theme pixelSnap(boolean enabled){textPixelSnap=enabled;return this;} 040 public Theme textContrast(float c){if(!Float.isFinite(c)||c<.5f||c>2)throw new IllegalArgumentException("textContrast 0.5..2");textContrast=c;return this;} 041 public Theme letterSpacing(float spacing){if(!Float.isFinite(spacing)||spacing< -2||spacing>12)throw new IllegalArgumentException("letterSpacing -2..12");letterSpacing=spacing;return this;} 042 public Theme fonts(String latin,String cjk){fontFamily=latin==null?"":latin;cjkFontFamily=cjk==null?"":cjk;return this;} 043 public Theme cornerSmoothing(float smooth){if(!Float.isFinite(smooth)||smooth<0||smooth>1)throw new IllegalArgumentException("corner smoothing 0..1");cornerSmoothing=smooth;return this;} 044 public Theme cubicCorners(boolean value){bezierCorners=value;return this;} 045 public Theme background(int color){background=color;return this;} 046 public Theme backgroundAccent(int color){backgroundAccent=color;return this;} 047 public Theme surface(int color){surface=color;return this;} 048 /** Set the glass tint color; tint(float) adjusts its amount. */ 049 public Theme tint(int color){surface=color;return this;} 050 public Theme tint(float amount){tint=unit(amount);return this;} 051 public Theme text(int color){text=color;return this;} 052 public Theme muted(int color){muted=color;return this;} 053 public Theme accent(int color){accent=color;return this;} 054 public Theme accentText(int color){accentText=color;return this;} 055 public Theme highlight(int color){highlight=color;return this;} 056 public Theme shadow(int color){shadow=color;return this;} 057 public Theme border(int color){border=color;return this;} 058 public Theme field(int color){field=color;return this;} 059 public Theme selected(int color){selected=color;return this;} 060 public Theme disabledText(int color){disabledText=color;return this;} 061 public Theme danger(int color){danger=color;return this;} 062 public Theme success(int color){success=color;return this;} 063 public Theme warning(int color){warning=color;return this;} 064 public Theme hoverTint(float amount){hoverTint=unit(amount);return this;} 065 public Theme pressTint(float amount){pressTint=unit(amount);return this;} 066 public Theme selectedTint(float amount){selectedTint=unit(amount);return this;} 067 private static float unit(float v){if(!Float.isFinite(v)||v<0||v>1)throw new IllegalArgumentException("amount must be 0..1");return v;} 068 public static Theme dark(){return new Theme();} 069 public static Theme light(){Theme t=new Theme();t.dark=false;t.text=0xff202020;t.muted=0xff606060; 070 t.accent=0xff222222;t.accentText=0xfff4f4f4;t.surface=0xfffafafa;t.tint=.26f; 071 t.field=0x28777777;t.hover=0x16000000;t.border=0x264b4b4b;t.selected=0x99383838; 072 t.danger=0xff333333;t.success=0xff333333;t.shade=0x26000000;t.background=0xffdddddd;t.backgroundAccent=0xfffafafa;t.disabledText=0xff888888;t.warning=0xff333333;return t;} 073 public Theme copy(){Theme t=new Theme();t.text=text;t.muted=muted;t.accent=accent;t.accentText=accentText; 074 t.surface=surface;t.field=field;t.hover=hover;t.border=border;t.selected=selected;t.danger=danger; 075 t.success=success;t.shade=shade;t.radius=radius;t.panelRadius=panelRadius;t.fontSize=fontSize; 076 t.rowHeight=rowHeight;t.blur=blur;t.sigma=sigma;t.refraction=refraction;t.shine=shine;t.dispersion=dispersion; 077 t.tint=tint;t.surfaceOpacity=surfaceOpacity;t.hoverTint=hoverTint;t.pressTint=pressTint; 078 t.selectedTint=selectedTint;t.antialiasing=antialiasing;t.textMode=textMode;t.textPixelSnap=textPixelSnap;t.bezierCorners=bezierCorners; 079 t.textContrast=textContrast;t.letterSpacing=letterSpacing;t.cornerSmoothing=cornerSmoothing;t.fontFamily=fontFamily;t.cjkFontFamily=cjkFontFamily; 080 t.background=background;t.backgroundAccent=backgroundAccent;t.highlight=highlight;t.shadow=shadow;t.disabledText=disabledText;t.warning=warning;t.dark=dark;t.reducedMotion=reducedMotion;return t;} 081 public static int alpha(int argb,float a){return (Math.round((argb>>>24)*Math.max(0,Math.min(1,a)))<<24)|(argb&0xffffff);} 082 public static int mix(int a,int b,float amount){float f=MotionValue.clamp(amount);int out=0;for(int shift=0;shift<=24;shift+=8)out|=Math.round(((a>>>shift)&255)*(1-f)+((b>>>shift)&255)*f)<<shift;return out;} 083}